Skip to content

Instantly share code, notes, and snippets.

View wonderbeyond's full-sized avatar
🎯
Focusing

Wonder wonderbeyond

🎯
Focusing
View GitHub Profile
#!/bin/bash
#使用vim打开文件时, 可以简单指定Vim服务器
VIM=gvim
server=${s-GVIM}
args="--servername ${server}"
[[ "$#" != 0 && `$VIM --serverlist` == *${server^^}* ]] && \
args="$args --remote-tab"
@wonderbeyond
wonderbeyond / arale-validator-addRule-integer.js
Last active August 29, 2015 14:07
arale/validator addRule for integer check
MyValidator.addRule('integer', function(options){
var v = Number(options.element.val());
if(v && Math.floor(v) === v){
return true;
}
return false;
}, '{{display}}必须为整数');
@wonderbeyond
wonderbeyond / clearfix.less
Last active August 29, 2015 14:07
clearfix mixin of less supports IE6/7
// Refer:
// - http://nicolasgallagher.com/micro-clearfix-hack/
// - http://nicolasgallagher.com/better-float-containment-in-ie/
// - http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified/
.clearfix() {
&:before,
&:after {
content: " "; // 1
display: table; // 2
@wonderbeyond
wonderbeyond / ie-fake-console.js
Last active June 7, 2023 14:11
Fake console.log for IE
window.console = window.console || {log: function(){return false;}};
@wonderbeyond
wonderbeyond / update-dom-with-tick-data.js
Last active August 29, 2015 14:08
Get tick data via jsonp api and update DOM at intervals
/**
* Demo code snip:
* Get tick data via jsonp api and update DOM at intervals
*
* `#market` is the DOM element to update;
* `https://example.com/data.json` is the url to fetch tick data;
* `1000*5` is the time interval for tick.
*/
$('#market').on('_init _tick', function(event) {
@wonderbeyond
wonderbeyond / get-ip-via-nslookup.sh
Created February 28, 2015 07:39
Get only-ip address via nslookup
nslookup www.example.com | awk '{if($1=="Name:") {ptr_set=1}; if(ptr_set==1 && $1=="Address:"){print $2; exit}}'
@wonderbeyond
wonderbeyond / pagecache-ngx-lua-redis.nginx
Last active October 17, 2015 06:40
基于 Nginx+Lua+Redis(http://openresty.org/) 的页面缓存配置案例
server {
listen 80;
server_name localhost;
location ~ ^/update(/.*)$ {
proxy_pass http://127.0.0.1:8000$1$is_args$args;
}
location /api/ {
# set expire timeout, in seconds
@wonderbeyond
wonderbeyond / nginx-proxy_cache.nginx
Last active August 29, 2015 14:20
nginx proxy_cache configuration sample, with url-based-update support
http {
# ... ...
proxy_cache_path /var/cache/nginx/ levels=1:2 keys_zone=api_cache:100m;
server {
listen 80;
server_name localhost;
add_header X-Upstream-Cache-Status $upstream_cache_status;
@wonderbeyond
wonderbeyond / nginx_cors.conf
Last active August 29, 2015 14:21
add CORS header with nginx
server {
# ...
# support some sub domains
# `add_header` is not allowed in `server`, so I did the hack.
if ($http_origin ~* "^https?://[\w\-]+\.example\.com$") {
set $allowed_origin $http_origin;
}
add_header "Access-Control-Allow-Origin" $allowed_origin;
@wonderbeyond
wonderbeyond / meets.conf
Last active February 21, 2017 06:15
[obsolete]uwsgi+upstart conf sample
description "Meets uwsgi instance"
#start on socket PROTO=inet PORT=3031
start on runlevel [2345]
stop on runlevel [06]
respawn
setuid mama
setgid mama