Skip to content

Instantly share code, notes, and snippets.

View MrHuxu's full-sized avatar

xhu MrHuxu

View GitHub Profile
@MrHuxu
MrHuxu / Sublime - Key Bindings - User
Last active April 4, 2018 02:38
[sublime text] #configuration
[
{ "keys": ["ctrl+shift+v"], "command": "paste" },
{ "keys": ["ctrl+v"], "command": "paste_and_indent" },
{ "keys": ["ctrl+t"], "command": "rebuild_tags"},
{ "keys": ["ctrl+i"], "command": "hide_overlay"},
//让sidebar和group的操作更符合vim的快捷键,这算是下策了
{ "keys": ["ctrl+h"], "command": "focus_side_bar"},
{ "keys": ["ctrl+l"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["ctrl+l", "ctrl+l"], "command": "focus_group", "args": { "group": 1 } },
//Simple Rails Navigator的快捷键
@MrHuxu
MrHuxu / nginx
Last active April 4, 2018 02:38
[register nginx] register nginx as a service in centos #configuration
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@MrHuxu
MrHuxu / main.go
Last active April 4, 2018 02:40
[receive exit message in go] show message when exit go app #demo
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@MrHuxu
MrHuxu / node-github-test.js
Last active April 4, 2018 02:40
[node.js & github] #demo
var GitHubApi = require('github');
var github = new GitHubApi({
version: '3.0.0',
debug: false,
protocol: 'https',
host: 'api.github.com', // should be api.github.com for GitHub
timeout: 5000,
headers: {
'user-agent': 'MrHuxu-GitHub-APP'
@MrHuxu
MrHuxu / bit-map.js
Last active April 4, 2018 02:40
[bit-map] a demo of bit map #snippet
const BitMap = function () {
this.data = [];
};
BitMap.prototype.getIdx = num => parseInt(num / 32);
BitMap.prototype.getPos = num => num % 32;
BitMap.prototype.add = function (num) {
const index = this.getIdx(num);
const pos = this.getPos(num);
@MrHuxu
MrHuxu / priority-queue.js
Last active April 4, 2018 02:40
[priority-queue] a demo of priority queue #snippet
const PriorityQueue = function () {
this.data = [];
};
PriorityQueue.prototype.isEmpty = function() {
return 0 === this.data.length;
};
PriorityQueue.prototype.less = function(i, j) {
return this.data[i] < this.data[j];
@MrHuxu
MrHuxu / colorize.go
Created April 4, 2018 05:57
[color in console] print text with color in console #demo
package main
import (
"fmt"
)
var colors = map[string]string{
"black": "0;30",
"red": "0;31",
"green": "0;32",
@MrHuxu
MrHuxu / launch.sh
Created April 4, 2018 16:15
[on ubuntu restart] scripts needed to run when restart ubuntu on vultr #scripts
# expose the 22 port for ssh login
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
# launch ss server and export port
ssserver -d start -c /etc/shadowsocks.json
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8398 -j ACCEPT
# launch nginx
sudo nginx
@MrHuxu
MrHuxu / config.fish
Last active April 5, 2018 11:16
[fish] fish configuration #configuration
set Path /usr/local/bin $PATH
nvm use --delete-prefix v8.6.0 > /usr/local/etc/dev
rvm use 2.3.4 > /usr/local/etc/dev
gvm use go1.9.1 > /usr/local/etc/dev
set -x PATH $PATH $GOPATH/bin
set GOPATH $GOPATH:/Users/xhu/workspace/ui/ui-common/src/go
@MrHuxu
MrHuxu / .zpreztorc
Last active April 5, 2018 11:17
[prezto] prezto configuration #configuration
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#