Skip to content

Instantly share code, notes, and snippets.

View noyobo's full-sized avatar
💭
I may be slow to respond.

noyobo noyobo

💭
I may be slow to respond.
  • Tuya
  • Hangzhou China
View GitHub Profile
@noyobo
noyobo / gist:6037876
Last active December 19, 2015 23:59
Array.shuffle 数组乱序
if (!Array.prototype.shuffle) {
Array.prototype.shuffle = function() {
for(var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x);
return this;
};
}
@noyobo
noyobo / gist:6037939
Last active December 19, 2015 23:59
Array.isArray 数组判断
if(!Array.isArray) {
Array.isArray = function (vArg) {
return Object.prototype.toString.call(vArg) === "[object Array]";
};
}
@noyobo
noyobo / gist:6038011
Created July 19, 2013 09:47
Array.indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@noyobo
noyobo / walk.js
Created June 8, 2015 02:12
node.js fs.readdir recursive directory search
var walk = function(dir) {
var results = []
var list = fs.readdirSync(dir)
list.forEach(function(file) {
file = dir + '/' + file
var stat = fs.statSync(file)
if (stat && stat.isDirectory()) results = results.concat(walk(file))
else results.push(file)
})
return results
@noyobo
noyobo / cssPrefix.js
Created June 9, 2015 02:28
get browser style Prefix
var styles = window.getComputedStyle(document.documentElement, '');
var pre = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1];
@noyobo
noyobo / upload.php
Created June 11, 2015 08:55
upload image
<?php
error_reporting(0);
//得到目录下的文件总数
function get_file_count($dir_name){
$files = 0;
if ($handle = opendir($dir_name)) {
while (false !== ($file = readdir($handle))) {
$files++;
}
closedir($handle);
@noyobo
noyobo / star.js
Created July 7, 2015 02:01
get star length
var stars = '✮✮✮✮✮✩✩✩✩✩';
var score = function(len) {
return stars.substring(5 - len, 10 - len)
}
console.log(score(1));
console.log(score(2));
console.log(score(3));
console.log(score(4));
@noyobo
noyobo / RotateKeynoteDocumentDroplet
Last active August 29, 2015 14:26 — forked from ericallam/RotateKeynoteDocumentDroplet
Rotate Keynote Document for use as an app Prototype
// Open Script Editor and Export this as an Application
//
// Then drop a keynote file on it in the Finder and it will properly resize
// and rotate everything so the Keynote file becomes usable as a prototype
// in the iPhone keynote app
// rotateDocument exported function
//
// Accepts a Keynote document and will rotate
// all the slides and elements in the slide 90 degrees
@noyobo
noyobo / background-toggle.js
Created November 24, 2015 07:20 — forked from jugglinmike/background-toggle.js
Chrome User-Agent String Modification
var listenerIsActive = true,
requestFilter = {
urls: [ "<all_urls>" ]
},
extraInfoSpec = ['requestHeaders','blocking'],
handler = function( details ) {
var headers = details.requestHeaders,
blockingResponse = {};