Skip to content

Instantly share code, notes, and snippets.

@samuel1112
samuel1112 / get_str_charcode.js
Created January 6, 2020 10:05
get string charCode
function getStrCharCode(str){
str = `${(str||'')}`;
for(let i=0,len=str.length; i<len; i++){
console.log({idx: i, char: `${str[i]}`, charCode: `0x${str.charCodeAt(i).toString(16)}`});
}
};
# 你可以从该 URL 下载这个配置文件: http://surge.run/config-example/ios.conf
# 用编辑器编辑后,再通过 iTunes, URL, AirDrop 或者 iCloud Drive 复制回 iOS 设备
# Version 2.0
[General]
# 日志等级: warning, notify, info, verbose (默认值: notify)
loglevel = notify
# 跳过某个域名或者 IP 段,这些目标主机将不会由 Surge Proxy 处理。(在 macOS
# 版本中,如果启用了 Set as System Proxy, 那么这些值会被写入到系统网络代理
# 设置中.)
@samuel1112
samuel1112 / 0_reuse_code.js
Created September 29, 2015 04:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
// self pac for ss.
// 2015/07/29
var proxy = "__PROXY__";
var direct = 'DIRECT;';
var _rules = [
'live.com',
'google.com',
function quicksort(arr){
if(arr.length){
var x = arr.shift(),
smallersort = quicksort(arr.filter(function (item){
return item<x;
})),
biggersort = quicksort(arr.filter(function (item){
return item>=x;
}));
return smallersort.concat([x],biggersort);
@samuel1112
samuel1112 / findArrayChange
Created August 13, 2014 08:14
find elements change in array
function findArrayChange(arrayA, arrayB){
var iterator = 0, i = 0, len = 0, _r = false;
// _r 中存放的是 insert after 的元素的 _id_
// return false 就 over 啦
for (i=0,len = arrayA.length; i<len; i++){
if(arrayA[i] !== arrayB[i]){
if(arrayA[i] !== arrayB[i+1] && arrayA[i+1] === arrayB[i]){
// A(i) != B(i+1) && A(i+1) != B(i)
// 循环策略是找寻 A(i) 移动到了 B(n)
private function treeRecursion($array,$cid){
$html = '';
$hasValue = false;
if(isset($array)){
foreach ($array as $key => $value) {
# code...
// echo "<br/>";
$id = $value->get('id');
$pid = $value->get('faculty');
@samuel1112
samuel1112 / schonfinkelize
Created October 16, 2013 01:11
实现函数的 部分参数应用的功能
function schonfinkelize(fn){
var slice = Array.prototype.slice,
stored_args = slice.call(arguments, 1);
return function(){
var new_args = slice.call(arguments),
args = stored_args.concat(new_args);
return fn.apply(null,args);
};