Skip to content

Instantly share code, notes, and snippets.

@shrekuu
shrekuu / app.js
Created June 28, 2018 10:55
koajs + socket.io server side example
const Koa = require('koa');
const app = new Koa();
const server = require('http').createServer(app.callback());
const io = require('socket.io')(server, {path: '/remote-control-sockjs'});
const port = process.env.PORT || 8080;
@shrekuu
shrekuu / app.js
Created June 28, 2018 10:54
socket.io server side example
const server = require('http').createServer();
const io = require('socket.io')(server, {
path: '/remote-control-sockjs',
});
const port = process.env.PORT || 8080;
server.listen(port);
@shrekuu
shrekuu / .zshrc
Last active July 16, 2018 06:09
.zshrc macOS High Serria php72 mysql nginx apache
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/bond/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
@shrekuu
shrekuu / nginx-websocket-proxy.conf
Created May 21, 2018 01:45 — forked from uorat/nginx-websocket-proxy.conf
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
@shrekuu
shrekuu / nginx-socketio-ssl-reverse-proxy.conf
Created May 21, 2018 01:45 — forked from gmanau/nginx-socketio-ssl-reverse-proxy.conf
How to setup nginx as nodejs/socket.io reverse proxy over SSL
upstream upstream-apache2 {
server 127.0.0.1:8080;
}
upstream upstream-nodejs {
server 127.0.0.1:3000;
}
server {
listen 80;
@shrekuu
shrekuu / apache_cors_example
Created April 25, 2018 07:40 — forked from brianlmoon/apache_cors_example
CORS example for Apache with multiple domains
# Sets CORS headers for request from example1.com and example2.com pages
# for both SSL and non-SSL
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
Header set Access-Control-Allow-Credentials "true" env=ORIGIN
# Always set Vary: Origin when it's possible you may send CORS headers
Header merge Vary Origin
@shrekuu
shrekuu / toggle-fullscreen.js
Last active April 3, 2018 05:11
toogle fullscreen when click something
// ref: https://davidwalsh.name/fullscreen
// let's bind the event on body element
var e = document.body;
e.onclick = function() {
if (prefixed(document, "fullScreen") || prefixed(document, "isFullScreen")) {
prefixed(document, "cancelFullScreen");
} else {
@shrekuu
shrekuu / fixing-locale-error-on-ubuntu-server-14-and-16.sh
Last active July 24, 2021 11:15
fixed: manpath: can't set the locale; make sure $LC_* and $LANG are correct
# I know you've got stuck for too long ^_^Y
# Locale is not configured correct. I don't know what broke that. Maybe time did.
# I fixed it on my ubuntu 14 & 16 servers.
# Follow the steps below or run this script on your machine.
# step 1
# ensure this line in `/etc/default/locale` file and `/etc/environment` file
# LANG="en_US.UTF-8"
sudo echo '\nLANG="en_US.UTF-8"' >> /etc/default/locale && /etc/environment
@shrekuu
shrekuu / gist:01a9676d412e1b26df81e2b433a9dbb8
Created March 20, 2018 13:52 — forked from SimonSun1988/gist:2ef7db45e46b889783647d941ec15e4d
解決 Ubuntu "can’t set the locale; make sure $LC_* and $LANG are correct" 的錯誤
## 安裝語系檔
`$ sudo locale-gen "en_US.UTF-8"`
## 重新設定語系檔
`$ sudo dpkg-reconfigure locales`
## 設定檔
@shrekuu
shrekuu / cdd.sh
Last active January 13, 2018 14:21
mac command script to quickly jump between bookmarked directories or fallback to "cd" instead quickly :)
# quick jump to often used directories
# for linux check the differency mention from:
# http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
export MARKPATH=$HOME/.marks
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
pwd
}
function mark {
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"