Skip to content

Instantly share code, notes, and snippets.

View hqman's full-sized avatar
🏊‍♂️
Focusing

Kai Wang hqman

🏊‍♂️
Focusing
View GitHub Profile
@hqman
hqman / gunicorn_lighttpd.conf
Created January 11, 2012 03:03 — forked from thomasbilk/gunicorn_lighttpd.conf
gunicorn lighttpd conf file
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_extforward",
"mod_rewrite",
#"mod_fastcgi",
"mod_proxy",
"mod_redirect" )
try:
from recaptcha.client import captcha
from pylons import request, config
class RecaptchaValidator(Schema):
'''
Validates ReCAPTCHA against their web service
'''
@hqman
hqman / gist:3074740
Created July 9, 2012 07:08 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@hqman
hqman / webkit_inspector_font_size.sh
Created August 6, 2012 14:05 — forked from cowboy/webkit_inspector_font_size.sh
Increase WebKit Inspector's font size (probably will need to re-run after updates)
#!/bin/bash
sudo find '/Applications/Google Chrome.app' \
\( -name inspector.css -or -name devTools.css \) \
-exec sh -c 'cat >> $1 <<WAT
/* Added on `date` */
#drawer .monospace,
#drawer .source-code {
font-size: 18px !important;
@hqman
hqman / example.html
Created November 18, 2012 01:08 — forked from kylebarrow/example.html
Prevent links in standalone web apps opening Mobile Safari
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
var down = "touchup" in window ? "touchup" : "click";
var abstractView = Backbone.View.extend({
// we don't want both click and touch handlers
// delegated on touch-enabled devices
events: function () {
"click .toggler" : "foo",
"touchup .toggler" : "bar"
},
initialize: function () {
// reset scaling on iPads on orientation change. author: @axolx
if (navigator.userAgent.match(/iPad/i)) {
$(window).bind('orientationchange', function(event) {
if (window.orientation == 90 || window.orientation == -90 || window.orientation == 270) {
$('meta[name="viewport"]').attr('content', 'height=device-width,width=device-height,initial-scale=1.0,maximum-scale=1.0');
$(window).resize();
} else {
$('meta[name="viewport"]').attr('content', 'height=device-height,width=device-width,initial-scale=0.8,maximum-scale=0.8');
$(window).resize();
}
# If you don't have Homebrew installed, you should. Do this.
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
# Install DNSMasq from Homebrew
brew install dnsmasq
# Create a directory for virtual hosts files
mkdir -p /usr/local/etc/dnsmasq.d
# Create a config for DNSMasq
@hqman
hqman / Y Combinator 简介
Created February 3, 2016 08:41 — forked from redraiment/Y Combinator 简介
Y Combinator (Fixed-point Combinator) 不动点组合子
Y组合子是Lambda演算的一部分,也是函数式编程的理论基础。
它是一种方法/技巧,在没有赋值语句的前提下定义递归的匿名函数。
即仅仅通过Lambda表达式这个最基本的“原子”实现循环/迭代。
颇有道生一、一生二、二生三、三生万物的感觉。
虽然Y组合子在理论上很优美,但在实际开发中并不会真的用到。
想要了解Y组合子是什么,请参见维基百科:http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator
或者知乎上的回答:http://www.zhihu.com/question/20115649
@hqman
hqman / fix.wkhtmltopdf.odoo.snippetbucket.erp.open.source.seo.sh
Created July 1, 2017 08:30 — forked from tejastank/fix.wkhtmltopdf.odoo.snippetbucket.erp.open.source.seo.sh
Wkhtmltopdf failed (error code: -6). Message: The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display.
How to Fix it:
1. Remove wkhtmltopdf and related package
$ sudo apt-get remove libqt4-dev qt4-dev-tools wkhtmltopdf
$ sudo apt-get autoremove
2. Install requirement package for compiling
$ sudo apt-get install openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y