This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Make sure you have nginx sub module compiled in | |
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module' | |
# 2. add two directives below at HTTP level | |
# nginx.conf | |
http { | |
# ...... | |
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
//helpers | |
function _(){ | |
console.log.apply(console,arguments); | |
} | |
function timing(msg,callback){ | |
var t1 = new Date(); | |
_(msg); | |
return callback(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Identity function, returns its argument unmodified. | |
* | |
* This is useful almost exclusively as a workaround to an oddity in the PHP | |
* grammar -- this is a syntax error: | |
* | |
* COUNTEREXAMPLE | |
* new Thing()->doStuff(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $format(template, data) { | |
return template.replace(/\{(\w+)\}/g, function (_, key) { | |
var value = data[key]; | |
return typeof value == 'undefined' ? _ : value; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kaixin001.jiecao.common; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
public class Delegator implements java.lang.reflect.InvocationHandler { | |
private Object obj; | |
private Method method; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 将一个函数调分拆成多个函数调用,使形式上像是英文描述 | |
* var $hi = englishfy('callMe.later',function(who,when){console.log(who+' will call me ' + when)}); | |
* $hi('tom').callMe('1 hour').later(); | |
* @param names | |
* @param done | |
* @param ctx | |
* @return {Function} | |
*/ | |
function $englishfy(names,done,ctx){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# MIT License - (c) 2011 John Mettraux | |
# | |
require 'rubygems' | |
require 'parslet' # gem install parslet | |
module MyJson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#gem install rkelly-remix | |
require 'rkelly' | |
parser = RKelly::Parser.new | |
matches = parser.parse(open("sample.js")).pointcut(RKelly::Nodes::DotAccessorNode).matches | |
matches.each do |match| | |
resolve_node = matches.value | |
if resolve_node.value == 'window' | |
pos = resolve_node.range.from | |
$stderr.puts "found access of window at: line #{pos.line}, char #{pos.char}" | |
end |