Skip to content

Instantly share code, notes, and snippets.

View ccbikai's full-sized avatar
🍜
吃面条

面条 ccbikai

🍜
吃面条
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ccbikai on github.
  • I am ccbikai (https://keybase.io/ccbikai) on keybase.
  • I have a public key ASAayS5EUfE0yo6rmHR6YP6Q-eKmzFZlu8R0s3rW0TQ-NQo

To claim this, I am signing this object:

@ccbikai
ccbikai / promise.js
Last active February 1, 2016 08:21
数组转换成 Promise 的序列
[1,2,3].reduce(function(sequence, i) {
return sequence.then(function() {
return Promise.resolve(i);
}).then(function(j) {
console.log(j);
});
}, Promise.resolve());
// 从一个完成状态的 Promise 开始
var sequence = Promise.resolve();
@ccbikai
ccbikai / rem.js
Created December 24, 2015 06:27
rem自适应,宽度计算 1rem === 40px ;
(function(doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) {
return
};
if (clientWidth >= 640) {
@ccbikai
ccbikai / brainfuck.js
Created December 4, 2014 06:38
BrainFuck 解释器
function getMatchingBra(code) {
var stack = [];
var bra = [];
for(var i = 0; i < code.length; i++) bra.push(-1);
for(var i = 0; i < code.length; i++) {
if(code[i] === '[') {
stack.push(i);
} else if(code[i] === ']') {
bra[i] = stack.pop();
bra[bra[i]] = i;
@ccbikai
ccbikai / chinese_convert
Created November 26, 2014 01:15
网站繁体转简体
var defaultEncoding = 1; // 預設語言:1-繁體中文 | 2-简体中文
var translateDelay = 0;
var cookieDomain = window.location.protocol + "//" + window.location.host;
var msgToTraditionalChinese = "轉換爲繁體";
var msgToSimplifiedChinese = "转换为简体";
var translateButtonId = "translateLink";
var currentEncoding = defaultEncoding;
var targetEncodingCookie = "targetEncoding" + cookieDomain.replace(/\./g,"");
var targetEncoding = ( getCookie(targetEncodingCookie) == null ? defaultEncoding : getCookie(targetEncodingCookie) );
@ccbikai
ccbikai / unsplash.py
Last active December 31, 2019 12:15
unsplash 全站下载脚本
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
# unsplash 全站下载脚本
# 请先安装 requests ,BeautifulSoup
# pip install requests beautifulsoup4
# 运行 python unsplash.py
# 输入最小页数和最大页数
@ccbikai
ccbikai / m163player.php
Created July 28, 2014 06:24
WordPress快速插入网易云音乐
function wp_iframe_handler_m163( $matches, $attr, $url, $rawattr ) {
$iframe = '<iframe width="430" height="200" src="http://miantiao.jd-app.com/m163player/'. esc_attr($matches[1]) . '" allowtransparency scrolling="0" frameborder="0" ></iframe>';
return apply_filters( 'iframe_m163', $iframe, $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'm163_iframe', '#http://music.163.com/\#/song\?id=([\d]+)(.*?)#i', 'wp_iframe_handler_m163' );
@ccbikai
ccbikai / xiami.js
Created June 13, 2014 06:06
虾米外链破解JS脚本
SongUrl = (function (sLocation) {
var num = Number(sLocation.charAt(0)),
inp = sLocation.substr(1),
iLe = inp.length % num,
a = 0,
ret = '',
arr = [];
for (var i = 0; i < num; i++) {
arr[i] = (iLe > i ? 1 : 0) + (inp.length - iLe) / num;
}
@ccbikai
ccbikai / xiamiplayer.php
Last active August 29, 2015 14:02
WordPress快速插入虾米音乐代码
function wp_iframe_handler_xiami( $matches, $attr, $url, $rawattr ) {
$iframe = '<iframe width="430" height="200" src="http://miantiao.jd-app.com/xiamiplayer/'. esc_attr($matches[1]) . '" allowtransparency scrolling="0" frameborder="0" ></iframe>';
return apply_filters( 'iframe_xiami', $iframe, $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'xiami_iframe', '#http://www.xiami.com/song/([\d]+)(.*?)#i', 'wp_iframe_handler_xiami' );
@ccbikai
ccbikai / gist.php
Last active May 13, 2017 15:54
Wordpress 嵌入 Gist代码
function wp_iframe_handler_gist( $matches, $attr, $url, $rawattr ) {
$iframe = '<iframe width="100%" height="300" src="https://gist.github.com/'. esc_attr($matches[1]) .'/'. esc_attr($matches[2]) . '.pibb" frameborder=0 ></iframe>';
return apply_filters( 'iframe_gist', $iframe, $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'gist_iframe', '#https://gist.github.com/(.*?)/([\w]+)#i', 'wp_iframe_handler_gist' )