Skip to content

Instantly share code, notes, and snippets.

View atupal's full-sized avatar

kangle yu atupal

View GitHub Profile
@atupal
atupal / github.css
Created November 15, 2013 17:25 — forked from theconektd/github.css
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
(function (window) {
// This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6.
// iOS6 suffers from a bug that kills timers that are created while a page is scrolling.
// This library fixes that problem by recreating timers after scrolling finishes (with interval correction).
// This code is free to use by anyone (MIT, blabla).
// Author: [email protected]
var timeouts = {};
var intervals = {};
@atupal
atupal / new_gist_file
Created September 5, 2013 02:06
thrift server generate sh
ls | sed 's/hbase-\(.*\)\.cfg/\1/p' -n | awk -v cnt=9091 '{printf("(%s|localhost:%s),", $1, cnt); cnt++;}'
@atupal
atupal / README.md
Created August 19, 2013 06:31 — forked from rkirsling/LICENSE

Click in the open space to add a node, drag from one node to another to add an edge.
Ctrl-drag a node to move the graph layout.
Click a node or an edge to select it.

When a node is selected: R toggles reflexivity, Delete removes the node.
When an edge is selected: L(eft), R(ight), B(oth) change direction, Delete removes the edge.

To see this example as part of a larger project, check out Modal Logic Playground!

@atupal
atupal / linux_dump_text_to_hex
Created July 14, 2013 14:02
linux下将文件转化为16进制。
linux中有多种方式可以将文件dump成16进制显示,也可以将16进制值再反向成文件。
$ hexdump test.txt
0000000 524f 2d41 3030 3036 0a30 524f 2d41 3030
0000010 3630 0a30
0000014
$ od -x test.txt
0000000 524f 2d41 3030 3036 0a30 524f 2d41 3030
0000020 3630 0a30
0000024
@atupal
atupal / bashrc
Created July 9, 2013 12:51
my bashrc config file
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@atupal
atupal / flask-socketio-demo.py
Created July 6, 2013 18:35
flask-socketio-demo
from flask import Flask, request, send_file
from werkzeug.wsgi import SharedDataMiddleware
from gevent import monkey; monkey.patch_all()
from socketio import socketio_manage
from socketio.server import SocketIOServer
from socketio.namespace import BaseNamespace
from socketio.mixins import BroadcastMixin, RoomsMixin
import os
@atupal
atupal / python_long_socket.py
Created July 5, 2013 18:03
python 长链接
#coding=utf-8
'''''
socket 给百度发送http请求
连接成功后,发送http的get请求,所搜索功能
'''
import socket
import sys
import time
@atupal
atupal / use_mount_bind
Created July 4, 2013 13:36
How to get git to follow symlinks
what i did to add to get the files within a symlink into git (i didn't use a symlink but):
sudo mount --bind SOURCEDIRECTORY TARGETDIRECTORY
do this command in the git managed directory. TARGETDIRECTORY has to be created before the SOURCEDIRECTORY is mounted into it.
works fine! that trick helped me with subversion too. i use it to include files from an Dropbox account, where a webdesigner does his stuff.
#!/usr/bin/env python
"""
Define a Timer context manager, allowing to measure the
wall time of the code block it contains.
Example:
>>> with Timer() as timer:
... for i in xrange(10000000):
... pass
...