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
#!/usr/bin/env python | |
import os | |
import re | |
import md5 | |
import sys | |
import json | |
import urllib | |
import urllib2 | |
try: |
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
#!/usr/bin/env python | |
# ref. https://medium.com/on-coding/shorter-code-is-inconsiderate-41cce917b51b | |
import timeit | |
setup = ''' | |
def hamming_fp(a, b): | |
return sum(x != y for x, y in map(None, a, b)) | |
def hamming(s1, s2): | |
hamming_number = 0 |
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
// ==UserScript== | |
// @name Pocket Web Customized | |
// @description Cusotmizations/Simplifications for Pocket Web | |
// @namespace http://getpocket.com | |
// @author Shao-Chung Chen | |
// @license MIT (http://opensource.org/licenses/MIT) | |
// @version 1.9.1 | |
// @include http://getpocket.com/* | |
// @include https://getpocket.com/* | |
// |
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
// ==UserScript== | |
// @name PTT Web Auto AID Link | |
// @description 自動為 PTT 網頁版的文章代碼加上連結 | |
// @namespace https://www.ptt.cc/bbs | |
// @author Shao-Chung Chen | |
// @license MIT (http://opensource.org/licenses/MIT) | |
// @version 1.3.0 | |
// @include http://www.ptt.cc/* | |
// @include https://www.ptt.cc/* | |
// |
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
// ==UserScript== | |
// @name Bypass PTT Over-18 Checking | |
// @description 自動跳過 PTT 的分級檢查 (請謹慎使用) | |
// @namespace https://www.ptt.cc/bbs | |
// @author Shao-Chung Chen | |
// @license MIT (http://opensource.org/licenses/MIT) | |
// @version 1.1.0 | |
// @include http://www.ptt.cc/* | |
// @include https://www.ptt.cc/* | |
// |
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
#include <iostream> | |
template <typename lhs_t, typename func_t> | |
inline func_t operator > (lhs_t const &lhs, func_t rhs) { | |
return rhs; | |
} | |
template <typename rhs_t, typename func_t> | |
inline auto operator < (func_t const &lhs, rhs_t const &rhs) -> decltype(lhs()) | |
{ |
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
// clang++ hello.cpp | |
#include <iostream> | |
template <typename lhs_t, typename rhs_t> | |
inline int operator, (lhs_t lhs, rhs_t b) { | |
std::cout << "飲冰室茶集" << std::endl; | |
return 0; | |
} | |
template <typename lhs_t, typename rhs_t> |
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
#include <iostream> | |
#include <type_traits> | |
class Foo { | |
public: | |
int ToString(); | |
}; | |
class Bar { | |
public: |
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
/* bitset.js | |
* | |
* bitset = new Bitset(64); | |
* bitset.toString(); // "0000000000000000000000000000000000000000000000000000000000000000" | |
* bitset.setBit(48, 1).setBit(23, 1).setBit(52, 1); | |
* bitset.toString(); // "0000000000010001000000000000000000000000100000000000000000000000" | |
* bitset.toInt(); // 4785074612469760 | |
* | |
* bitset.fromInt(679642164705874); | |
* bitset.toString(); // "0000000000000010011010100010000110000101110011010011101001010010" |
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
#!/usr/bin/env phantom | |
var webpage = require("webpage"), | |
system = require("system"); | |
var args = system.args; | |
if (args.length < 3) { | |
system.stderr.writeLine("usage: " + args[0] + " <URL> <Filename.png> [delay] [viewWidth] [viewHeight]"); | |
phantom.exit(); | |
} |