Rumah > Artikel > pembangunan bahagian belakang > 开发拾遗
s = 'u6d4bu8bd5u957fu5ea6' s = s.replace('u', '/u') print s.decode('unicode-escape')
$bin = bindec('110011'); $bin = 0b110011;
$arr = [ [1, 2], [3, 4],];foreach ($arr as list($a, $b)) { echo $a.$b/n";}
var_dump(md5('240610708') == md5('QNKCDZO'));// true 两个字符串恰好以0e 的科学记数法开头,字符串被隐式转换为浮点数,也就等效于0×10^0var_dump(sha1('aaroZmOk') == sha1('aaK1STfY'));// truevar_dump('0x1234Ab' == '1193131');// true 0x1234Ab转为16进制,php7无此bugvar_dump( 0 == "a" );// truevar_dump( "0" == "a" );// true
// 如果 $name 值为 0,那么它会满足任何一条 caseswitch ($name) {// 使用switch (strval($name)) { case "danny": break; case "eve": break;}$needle = '1abc'; $haystack = array(1,2,3); var_dump(in_array($needle, $haystack);// true
// chrome同时支持’-‘和’/’分割日期的时间字符串;safari不支持’-‘分割日期的时间字符串
var arr = "2010-03-15 10:30:00".split(/[- / :]/), date = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);
function keys(obj){ var a = []; for(a[a.length] in obj); return a;}
function dedupe(array){ return Array.from(new Set(array));}dedupe([1,1,2,3]) //[1,2,3]
// 命令行提示tldr npm install -g tldr
octotree是一款可为 GitHub 和 GitLab 添加侧边栏文件导航的 Chrome 和 Opera 插件
python下载视频工具// Package Control:Install Package,输入Chinese,选择ChineseLocalization
arr = [1,2,3,4,5] arr.reduce(function(a,b){ return a*10+b; });//12345var result = [1, 2, 3, 4, 5].reduce(function(prev, curr, index, array){debugger; prev.push(curr * 2); return prev;}, []);console.log(result);//[2, 4, 6, 8, 10]//求最大值var max = arr.reduce(function(pre,cur,inde,arr){return pre>cur?pre:cur;});var arr = [ {name: 'brick1'}, {name: 'brick2'}, {name: 'brick3'} ]function carryBricks(arr){ return arr.reduce(function(prev, current, index, array){ if (index === 0){ return current.name; } else if (index === array.length - 1){ return prev + ' & ' + current.name; } else { return prev + ', ' + current.name; } }, ''); }//brick11, brick12 & brick13//去重var arr = [1, 3, 1, 'x', 'zz', 'x', false, false];var result = arr.reduce(function(prev, curr, i, array) { var flag = prev.every(function(value) { return value !== curr; }); flag && prev.push(curr); return prev;}, []);console.log(result);
输入提示自动完成插件 tokeninput
tablesorter表格排序
Date.js执行日期/时间的计算
图片裁剪
日期选择插件pickadate.js
javascript刻度条插件Math.round( (.1+.2)*100)/100; //0.3
select * from teacher join school on teacher.id = school.idjoin course on teacher.id = course.idwhere course.name= 'english' 分解后 select * from course where name = 'english'select * from school where course_id = 1select * from teacher where school_id in (1,2,3)
var temp = {}; 'abcdaabc'.replace(/(/w{1})/g,function($1){ temp[$1] ? temp[$1]+=1 : temp[$1] = 1; }) console.log(temp) // {a: 3, b: 2, c: 2, d: 1}
PHP HTTP请求套件
实现 Laravel 模型的无限极分类$arr = ['a', 'b', 'c', 'd'];$child = array();$res = [];while($v = array_pop($arr)) { $res = [$v => $child]; $child = $res;}
a = "1000111000"b = "1000000001"c = int(a, 2) | int(b, 2)print('{0:b}'.format(c))#1000111001
def fib(max): n, a, b = 0, 0, 1 while n < max: print(b) a, b = b, a + b n = n + 1 return 'done'
$str="{a:1,b:2,c:3}"; preg_match_all('/(/w+):(/d+)/', $str, $matches); $arr = array_combine($matches[1], $matches[2]);#['a'=>1,'b'=>2,'c'=>3]
max(ceil(-0.5), 0) # -0.0max(0, ceil(-0.5)) # 0
_.isNaN = function(obj){ return _.isNumber(obj) && obj !==+obj;};
update tableA as ca inner join tableB as cb set ca.thumbs=cb.thumbs where cb.courseid=1;24.php后期静态绑定
class A { public static function get_self() { return new self(); } public static function get_static() { return new static(); } } class B extends A {} get_class(B::get_self());//A get_class(B::get_static()) //B get_class(A::get_static());//A
$images = array( 'myself.png' , 'friends.png' , 'colleagues.png' ); $js_code = 'var images = ' . json_encode($images); echo $js_code; // var images = ["myself.png","friends.png","colleagues.png"]
var regex_num_set = /&#(/d+);/g;var str = "Here is some text: 每日一色|蓝白~"str2 = str.replace(regex_num_set, function(_, $1) { return String.fromCharCode($1);});//"Here is some text: 每日一色|蓝白~"