Skip to content

Instantly share code, notes, and snippets.

View zhuangya's full-sized avatar
🧛‍♂️
only silver bullet is silver bullet.

Ya Zhuang zhuangya

🧛‍♂️
only silver bullet is silver bullet.
View GitHub Profile
@zhuangya
zhuangya / .vimrc
Created July 27, 2011 14:18 — forked from jeresig/.vimrc
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on
@zhuangya
zhuangya / index.prototype.js
Created October 31, 2011 16:20
indexOf prototype for IE 9-
/**
* Refs:
* http://nootn.com/blog/Develop/35/
* http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/#comment-57199
* http://ecma262-5.com/ELS5_HTML.htm#Section_15.4.4.14
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(el, index) {
var n = this.length >>> 0, i = ~~index;
@zhuangya
zhuangya / gist:1347480
Created November 8, 2011 10:49
md.css
::-moz-selection {
background-color: #19B8E6;
color: white;
text-shadow: none;
}
::selection {
background-color: #19B8E6;
color: white;
text-shadow: none;
@zhuangya
zhuangya / Markdown.pl
Created November 17, 2011 17:02
md conversion with highlight.js support
#!/usr/bin/perl
#
# Markdown -- A text-to-HTML conversion tool for web writers
#
# Copyright (c) 2004 John Gruber
# <http://daringfireball.net/projects/markdown/>
#
@zhuangya
zhuangya / hinter.html
Created December 6, 2011 10:05
HTML, CSS hinter.
<!DOCTYPE html>
<html>
<head>
<style>
.hinter_wrapper {
outline: 1px solid gray;
text-align: center;
width: 800px;
margin: auto;
}
HTTP/1.1 302 Found
Location: http://www.google.com/
Cache-Control: private
Content-Type: text/html; charset=UTF-8
X-Content-Type-Options: nosniff
Date: Fri, 09 Dec 2011 02:23:49 GMT
Server: sffe
Content-Length: 219
X-XSS-Protection: 1; mode=block
[ 10:44上午 ] [ nos@NosMacbookPro:~ ]
$ curl ifconfig.me
123.114.32.48 # I am in Beijing, China right now..
[ 10:45上午 ] [ nos@NosMacbookPro:~ ]
$ curl -i pubnub.com
HTTP/1.1 301 Moved Permanently
Server: nginx/0.7.67
Date: Fri, 09 Dec 2011 02:46:06 GMT
Content-Type: text/html
Content-Length: 185
function get_browser_info()
{
var ua = navigator.userAgent.toLowerCase();
var browser = '';
var version = 0;
@zhuangya
zhuangya / sort.py
Created December 28, 2011 17:05
Bubble Sort by Python.
array = [1, 1, 1, 1, 2, 2, 3, 3, 4, 1, 2, 3, 2, 1, 2, 1, 8, 4, 0, 5]
def bubblesort(array):
f = lambda x, y, _sorted: [x, y, _sorted] if x < y else [y, x, False]
for i in range(len(array) - 1):
_sorted = True
import random
import time
array = []
for i in range(1000000):
array.append(random.randint(1, 100))
def q_sort(nums):
if not nums:
return []