This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// go get github.com/lib/pq | |
// | |
package main | |
import ( | |
_ "github.com/lib/pq" | |
"database/sql" | |
"fmt" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"strings" | |
"github.com/garyburd/redigo/redis" | |
"github.com/ant0ine/go-json-rest/rest" | |
"log" | |
"net/http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Implement Trie in Python. | |
References: | |
http://www.geeksforgeeks.org/trie-delete/ | |
""" | |
def make_trie(*args): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <map> | |
#include <vector> | |
using namespace std; | |
struct Node { | |
char ch; | |
map<char, Node*> children; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> /* printf() */ | |
#include <stdlib.h> /* exit(), malloc(), free() */ | |
#include <sys/types.h> /* key_t, sem_t, pid_t */ | |
#include <sys/shm.h> /* shmat(), IPC_RMID */ | |
#include <errno.h> /* errno, ECHILD */ | |
#include <semaphore.h> /* sem_open(), sem_destroy(), sem_wait().. */ | |
#include <fcntl.h> /* O_CREAT, O_EXEC */ | |
int main (int argc, char **argv){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <sys/epoll.h> | |
#include <errno.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg install python | |
pkg install git | |
pkg install wget | |
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python | |
easy_install pip | |
pip install ipython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use C-a, since it's on the home row and easier to hit than C-b | |
set-option -g prefix C-a | |
unbind-key C-a | |
bind-key C-a send-prefix | |
set -g base-index 1 | |
# vi is good | |
setw -g mode-keys vi | |
# mouse behavior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Slideshare link: http://www.slideshare.net/ChaoGao1/write-a-redis-client | |
import socket | |
tcp_host = '127.0.0.1' | |
tcp_port = 6379 | |
tcp_timeout = 10000 | |
buffer_size = 1024 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |