Skip to content

Instantly share code, notes, and snippets.

View fanzeyi's full-sized avatar

Zeyi (Rice) Fan fanzeyi

View GitHub Profile
@tonyseek
tonyseek / conrotine_task_manager.py
Created April 26, 2012 05:39
The demo of a corotine task manager.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from Queue import Queue
# ---------------------
# Corotine Task Manager
# ---------------------
@CMGS
CMGS / websocket.py
Created May 2, 2012 03:41
websocket hybi3 support with gunicorn and gevent
import collections
import errno
import re
from hashlib import md5, sha1
import base64
from base64 import b64encode, b64decode
import socket
import struct
import logging
@chuangbo
chuangbo / cidr.py
Created August 13, 2012 09:45
Check if ip in cidr
#-*- coding:utf-8 -*-
# Author: @chuangbo
# For: @likexian
import socket
import struct
class CIDR:
'''Check if ip in cidr
@jirutka
jirutka / rules-both.iptables
Created September 18, 2012 12:42
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@fanzeyi
fanzeyi / .vimrc
Last active December 21, 2015 15:19
" Zeray Rice's New Vimrc
" Created: Augest 24, 2013
" ===============
" Vundle
" ===============
set nocompatible
filetype off
@felixrabe
felixrabe / string-utils.coffee
Last active September 29, 2023 16:39
CoffeeScript: String.startsWith() and String.endsWith()
# http://stackoverflow.com/a/646643
String::startsWith ?= (s) -> @slice(0, s.length) == s
String::endsWith ?= (s) -> s == '' or @slice(-s.length) == s
@gnarmis
gnarmis / gist:0d08ad5603014efea52f
Last active August 29, 2015 14:02
Swift on the Command Line
So, this is where swift lives, after you've installed XCode 6 Beta:
/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
Also, there's a directory named swift which has various libraries:
/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
To start playing in a terminal:
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()
@danielrw7
danielrw7 / replify
Last active October 24, 2023 12:03
replify - Create a REPL for any command
#!/bin/sh
command="${*}"
printf "Initialized REPL for `%s`\n" "$command"
printf "%s> " "$command"
read -r input
while [ "$input" != "" ];
do
eval "$command $input"
printf "%s> " "$command"
@mdo
mdo / 00-intro.md
Last active March 24, 2024 08:04
Instructions for how to affix an Ikea Gerton table top to the Ikea Bekant sit-stand desk frame.

Ikea Bekant standing desk with Gerton table top