Skip to content

Instantly share code, notes, and snippets.

View mckelvin's full-sized avatar

GitHubLeakedPAN, GitHubLeakedMyautsai mckelvin

View GitHub Profile
@pointcom
pointcom / nginx.conf
Created January 15, 2009 17:42
Patch for Nginx 0.6.34 : Added instruction "post_to_static" (HTTP 405 error when serving static file after a POST request)
server {
listen 80;
server_name my.host.com;
location / {
root /path/to/your/root;
post_to_static on; # You allow static file after a POST request
}
}
inoremap ( <c-r>=OpenPair('(')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap { <c-r>=OpenPair('{')<CR>
inoremap } <c-r>=ClosePair('}')<CR>
inoremap [ <c-r>=OpenPair('[')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
" just for xml document, but need not for now.
"inoremap < <c-r>=OpenPair('<')<CR>
"inoremap > <c-r>=ClosePair('>')<CR>
function! OpenPair(char)
@EnigmaCurry
EnigmaCurry / ipython_virtualenv.py
Created February 9, 2011 01:52
Setup ipython to work in a virtualenv
#Call this inside ~/.ipython/ipy_user_conf.py main()
import sys
import subprocess
from os import environ
if 'VIRTUAL_ENV' in environ:
#This is kludgy but it works; grab the right sys.path from the virtualenv python install:
path = subprocess.Popen(['python', '-c','import sys;print(repr(sys.path))'],
stdout=subprocess.PIPE).communicate()[0]
anonymous
anonymous / adhoc
Created July 31, 2011 17:38
Linux Ad-hoc shell script
#!/bin/bash
#####################################
#Author: Leon Lee #
#email: lendylongli@gmail.com #
#QQ: 730395591 #
#Version: 1.0 #
#Note: If you have some good ideas #
# or advice, please mail me^^ #
#####################################
@traeblain
traeblain / batman.m
Created August 1, 2011 22:21
Batman Equation
clf; clear; syms x y
eq1 = ((x/7)^2*sqrt(abs(abs(x)-3)/(abs(x)-3))+(y/3)^2*sqrt(abs(y+3/7*sqrt(33))/(y+3/7*sqrt(33)))-1);
eq2 = (abs(x/2)-((3*sqrt(33)-7)/112)*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2)-y);
eq3 = (9*sqrt(abs((abs(x)-1)*(abs(x)-.75))/((1-abs(x))*(abs(x)-.75)))-8*abs(x)-y);
eq4 = (3*abs(x)+.75*sqrt(abs((abs(x)-.75)*(abs(x)-.5))/((.75-abs(x))*(abs(x)-.5)))-y);
eq5 = (2.25*sqrt(abs((x-.5)*(x+.5))/((.5-x)*(.5+x)))-y);
eq6 = (6*sqrt(10)/7+(1.5-.5*abs(x))*sqrt(abs(abs(x)-1)/(abs(x)-1))-(6*sqrt(10)/14)*sqrt(4-(abs(x)-1)^2)-y);
eqf = '((x/7)^2*sqrt(abs(abs(x)-3)/(abs(x)-3))+(y/3)^2*sqrt(abs(y+(3*sqrt(33))/7)/(y+(3*sqrt(33))/7))-1)*(abs(x/2)-((3*sqrt(33)-7)/112)*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2)-y)*(9*sqrt(abs((abs(x)-1)*(abs(x)-3/4))/((1-abs(x))*(abs(x)-3/4)))-8*abs(x)-y)*(3*abs(x)+3/4*sqrt(abs((abs(x)-3/4)*(abs(x)-1/2))/((3/4-abs(x))*(abs(x)-1/2)))-y)*(9/4*sqrt(abs((x-1/2)*(x + 1/2))/((1/2-x)*(1/2+x)))-y)*((6*sqrt(10))/7+(3/2-abs(x)/2)*sqrt(abs(abs(x)-1)/(abs(x)-1))-(6*sqrt(10))/14*sqrt(4-(abs(x)-1)^2)-y)=0'
@soemarko
soemarko / theme.html
Created November 26, 2011 16:18
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@mckelvin
mckelvin / .gitignore
Last active October 4, 2015 01:58
One Day One Phrase since March 30,2012
config.py
*.pyc
*.swp
@frsyuki
frsyuki / my_thoughts_on_msgpack.md
Created June 11, 2012 02:36
My thoughts on MessagePack

My thoughts on MessagePack

Hi. My name is Sadayuki "Sada" Furuhashi. I am the author of the MessagePack serialization format as well as its implementation in C/C++/Ruby.

Recently, MessagePack made it to the front page of Hacker News with this blog entry by Olaf, the creator of the Facebook game ZeroPilot. In the comment thread, there were several criticisms for the blog post as well as MessagePack itself, and I thought this was a good opportunity for me to address the questions and share my thoughts.

My high-level response to the comments

To the best of my understanding, roughly speaking, the criticisms fell into the following two categories.

@liuyu81
liuyu81 / c_extension_module.c
Created August 26, 2012 02:54
call Python callback from a non-python thread in a C extension module (in response to zed's demo, https://gist.github.com/3471699, and this question http://stackoverflow.com/questions/12116390/python-code-calls-c-library)
#include "Python.h" // should be before any standard headers
#include <errno.h>
#include <pthread.h>
static void*
non_python_thread(void *python_callback) {
//XXX without PyEval_InitThreads() it produces:
// Fatal Python error: PyEval_SaveThread: NULL tstate
//XXX with PyEval_InitThreads() it deadlocks!!
//XXX without PyGILState_*() (with/without PyEval_InitThreads()) it produces:
@zhasm
zhasm / ccc.sh
Last active December 10, 2015 06:28
像脚本语言一样运行 c 程序文件。放在 .bashrc / .bash_profile 环境中。
ccc ()
{
if [[ "$#" -lt 1 ]]; then
echo "Usage: $FUNCNAME <script.c> [optional_args]";
return;
else
file=$1;
shift;
args=$*;
out=`mktemp`;