Skip to content

Instantly share code, notes, and snippets.

View swanwish's full-sized avatar

Stephen swanwish

View GitHub Profile
@swanwish
swanwish / go.yml
Created May 26, 2022 06:24
common go.yml for github actions
name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
@swanwish
swanwish / mysql_set_loginpath.md
Created January 28, 2022 09:43
The command how to user mysql_config_editor to set the login path.
$> mysql_config_editor set --login-path=client
         --host=localhost --user=localuser --password
Enter password: enter password "localpass" here
$> mysql_config_editor set --login-path=remote
         --host=remote.example.com --user=remoteuser --password
Enter password: enter password "remotepass" here
@swanwish
swanwish / install.bash
Created November 11, 2017 12:37 — forked from nowakowski-damian/install.bash
Raspberry Pi Install PHP7 + Nginx + MySQL + PhpMyAdmin (last versions)
if [ "$(whoami)" != "root" ]; then
echo "root required!"
exit
fi
apt-get update
apt-get upgrade
apt-get dist-upgrade
@swanwish
swanwish / LC_CTYPE.txt
Created October 31, 2016 14:43 — forked from jampajeen/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
Add the following style to the div:
-webkit-user-select: text
For Mac OS, the application is located in the following folder
~/Library/Application Support/Google/Chrome/Default
The chrome app is in Extensions folder, the folder name for the application is the application id.
@swanwish
swanwish / restart_service.sh
Last active August 29, 2015 14:24
Restart service
#!/bin/bash
if [ -z "$1" ]; then
echo Please pass the service name
exit
else
SERVICE_NAME=$1
fi
if [ ! $2 ]; then
@swanwish
swanwish / parsedate.js
Last active August 29, 2015 14:24
Safari new Date('2015-07-06') invalid date
// Use moment to parse date to handle different browser
var startDate = moment('2015-07-06 08:00', 'YYYY-MM-DD HH:mm').toDate();
var timestamp = startDate.getTime();
console.log(timestamp);
// Output
// 1436140800000
// Get Unix timestamp
@swanwish
swanwish / format.js
Last active August 29, 2015 14:24
Format number in Javascript
var number = 3;
var formattedNumber = number.toFixed(2)
console.log(formattedNumber)
// Output
// 3.00
@swanwish
swanwish / log.go
Last active August 29, 2015 14:24
Log Client IP (nginx + go)
func logRequest(r *http.Request) {
ip := r.Header.Get("X-Real-IP")
if ip == "" {
ip, _, _ = net.SplitHostPort(r.RemoteAddr)
}
logs.Debugf("%s %v from ip: %s", r.Method, r.URL, ip)
}