Skip to content

Instantly share code, notes, and snippets.

View JoshuaChi's full-sized avatar

Joshua Chi JoshuaChi

View GitHub Profile
@JoshuaChi
JoshuaChi / erlang_gc
Last active August 29, 2015 14:00
Manually GC
[erlang:garbage_collect(Pid) || Pid <- processes()].
#!/bin/sh
#
# Usage: ./redis-delkeys.sh [-h host] [-p port] [-n db] pattern
#
# Matches keys with the KEYS command matching pattern
# and deletes them from the specified Redis DB.
set -e
HOST="localhost"
# set up flags for Numpy C extentions compiling
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export CC=gcc-4.2
export CXX="g++ -arch i386 -arch x86_64"
pip install numpy
# success!
@JoshuaChi
JoshuaChi / system_monitor
Created August 21, 2014 01:59
get_busy_dist_port
%% Copyright (c) 2011 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% Description: A simple FSM for a code lock with three states
%% based on an example from the OTP system documentation
-module(code_lock_fsm).
-behaviour(gen_fsm).
%% public API functions
-export([start_link/1, stop/0, button/1, reset/0, get_state/0]).
%% state names
-export([locked/2, locked/3, open/2, open/3]).
@JoshuaChi
JoshuaChi / CAS spin lock
Created December 11, 2014 02:12
CAS spin lock
https://github.com/cloudwu/skynet/pull/208/files
diff --git a/skynet-src/skynet_mq.c b/skynet-src/skynet_mq.c
index 8cc8f9d..51f47ef 100644
--- a/skynet-src/skynet_mq.c
+++ b/skynet-src/skynet_mq.c
@@ -32,12 +32,9 @@ struct message_queue {
};
struct global_queue {

Steps to install PIL

$ sudo apt-get install python-imaging
$ sudo apt-get install libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

$ pip install PIL

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@JoshuaChi
JoshuaChi / default.conf
Last active August 29, 2015 14:14 — forked from cbmd/default.conf
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";
@JoshuaChi
JoshuaChi / GetCsvDataFromYahoo.java
Created March 19, 2015 14:25
GetCsvDataFromYahoo
package finance.datainit.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.SocketException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;