Skip to content

Instantly share code, notes, and snippets.

View youxiachai's full-sized avatar

youxiachai youxiachai

View GitHub Profile
@youxiachai
youxiachai / maimeng.js
Created April 11, 2014 02:34
js 卖萌代码..
var Z = function () {
}
Z.prototype.s = function () {
console.log('hi s')
}
var S = function () {
@youxiachai
youxiachai / array.js
Created May 29, 2014 10:24
js 数组练习
var newArray = ['1','2','3','4'].map(function (item){
return item
}).reduce(function (x, y){
if(Array.isArray(x)){
return x.concat(y)
}else{
var arr = [];
arr.push(x)
return arr;
}
@youxiachai
youxiachai / array2.js
Created June 1, 2014 08:51
不用循环构建任意初始值数组
var a = Array.apply(null, {length : 10}).map(function () {
return 'a'
})
var b = new Array(10).join(',').split(',').map(function(){return 'b'});
@youxiachai
youxiachai / megesort.js
Last active August 29, 2015 14:02
归并排序
Array.prototype.mergeSort=function(){
var merge=function(left,right){
var final=[];
while (left.length && right.length) {
final.push(left[0] <= right[0] ? left.shift() : right.shift() );
}
return final.concat(left.concat(right));
}
// 递归结束
if (this.length < 2) {
@youxiachai
youxiachai / jsarray.js
Created June 9, 2014 06:29
js 数组练习 2
/**
* Created by youxiachai on 14-6-9.
*/
var totalPoint = 0;
var action = ''
//rule
@youxiachai
youxiachai / specic.txt
Created June 9, 2014 07:15
搞怪泰文
( ̄(工) ̄) 凸ส้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้
@youxiachai
youxiachai / jsistrue.js
Last active August 29, 2015 14:02
js 真值练习
console.log(undefined >= 0); // false
console.log(null === 0); // false
console.log(null == 0); // false
console.log(0 >= 0); // true
//坑来了.. 对了js只有恒等 只有 !==, === 可没有恒比较 >== 的写法.
// 直觉上 null >= 0 应该跟 null == 0 或者 undefined >= 0 的效果一样的啊..但是事实不是这样的..
console.log(null >= 0); //true
@youxiachai
youxiachai / retrunasync.js
Created June 17, 2014 08:45
嵌套async练习
var async = require('async');
async.eachSeries(['2m内容'], function (item, callback) {
async.parallel([
function (subcallback) {
//1
},
function (subcallback){
//2
@youxiachai
youxiachai / express.js
Created July 8, 2014 06:29
express 中间件匹配用法..,注意位置!
app.use('/fsck', function (req, res, next){
console.log('fsck');
res.header("How-Old-Are-You", "Iamfinethinkyou");
next();
})
app.get('/fsck/fsck', function (res, res){
console.log('fsck');
res.send('ok')
@youxiachai
youxiachai / gist:4ba917796f972ca06526
Created March 25, 2015 02:06
获得viewpage 当前fragment 实例
FragmentManager fm = getSupportFragmentManager();
Class<FragmentStatePagerAdapter> viewPageAdpater = FragmentStatePagerAdapter.class;
try {
Field field = viewPageAdpater.getDeclaredField("mCurrentPrimaryItem");
field.setAccessible(true);
Fragment value = (FgmMyGameCircleList) field.get(FragmentStatePagerAdapter(实例));