Skip to content

Instantly share code, notes, and snippets.

@kourge
kourge / gist:38c1d3a07a5dee9407c0
Created June 4, 2014 21:19
Fun with double arrow / hash rocket in Swift
operator infix => { associativity left }
func => <K : Hashable, V>(key: K, value: V) -> (K, V) {
return (key, value)
}
let pairs: (String, Int)[] = [
"e" => 10,
"t" => 7,
"i" => 2
]
operator infix => { associativity left }
func => <K : Hashable, V>(key: K, value: V) -> (K, V) {
return (key, value)
}
let pairs: (String, Int)[] = [
"e" => 10,
"t" => 7,
"i" => 2
]
@lengarvey
lengarvey / assets_location_nginx.conf
Created September 25, 2012 01:14
Access control allow origin header for nginx
location /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}
class Pipe(object):
def __init__(self, func):
self.func = func
def __ror__(self, other):
def generator():
for obj in other:
if obj is not None:
yield self.func(obj)
return generator()
@viko16
viko16 / formatTime.js
Created August 20, 2014 17:45
人性化时间处理 #javascript
/**
* 格式化时间戳为人性化的时间
* @param {String} publishTime 时间戳
* @return {String} 人性化时间
*/
function formatTime(publishTime) {
var d_minutes, d_hours, d_days;
var timeNow = parseInt(new Date().getTime() / 1000, 10);
var d;

海盗哥talks about vim

  1. visual 模式下面能用o来切换选中上下

  2. repeat: .,用来重复上一次对字符串的操作

  3. visual模式下可以这样用:

        :'<,'>g/text_feature/vimcommand

:'<,'>g/text_feature/s/this/that

@Breefield
Breefield / phantom.js
Created September 9, 2012 03:40
PhantomJS Custom Headers
var page = require('webpage').create();
// User-Agent is supported through page.settings
page.settings.userAgent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
// This is how you set other header variables
page.customHeaders = {'Referer': 'localhost'};
@ravageralpha
ravageralpha / fetchsub.sh
Created October 27, 2012 16:53
shell script get subtitle from shooter.cn
#!/bin/sh
# Author: RA <ravageralpha@gmail.com>
USAGE(){
echo "Usage:$(basename $0) [eng] files..."
}
[ $# -eq 0 ] && USAGE && exit 0
ERROR(){
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
---
# Python 简介
@su27 and @menghan
---

What is Python?

Python: 优雅而健壮的编程语言

  • 高级

  • 易学易读易维护