Skip to content

Instantly share code, notes, and snippets.

View yorkie's full-sized avatar
🎯
Focusing

Yorkie yorkie

🎯
Focusing
View GitHub Profile
@yorkie
yorkie / sort.js
Last active December 31, 2015 08:19
// sort and no using any `var` statement
function sort_(list) {
return list.map(function(item, i){
return (function(min_val, sum) {
return list.filter(function(o, j) {
return (o < min_val) && (min_val = o || true);
}).slice(-1).map(function(o, j) {
list[list.indexOf(o)] = sum;
return o;
@yorkie
yorkie / check_sorted.js
Last active May 18, 2022 06:07
Check if an array is sorted in Javascript...
/*
* check the array is sorted
* return: if positive -> 1
* if negative -> -1
* not sorted -> 0
*/
Array.prototype.isSorted = function() {
return (function(direction) {
return this.reduce(function(prev, next, i, arr) {
@yorkie
yorkie / main.js
Last active December 31, 2015 22:09
simple multi-pipe test case
var fs = require('fs');
var util = require('util');
var Writable = require('stream').Writable;
function MyWriteStream() {
Writable.call(this);
}
util.inherits(MyWriteStream, Writable);
MyWriteStream.prototype._write = function(chunk, encoding, callback) {
@yorkie
yorkie / github-downloader.sh
Created December 20, 2013 15:55
download github folder and project without cloning...
#####################################################
# Download Specific folders from Github using SVN
#
# Author: Declan Cook
# Licence: MIT
#####################################################
GHDOMAIN="https://github.com/"
IN=$1
IN=${IN##$GHDOMAIN}
BRANCH="trunk"
@yorkie
yorkie / Readable.js
Last active January 1, 2016 00:19
nodejs的Readable分析
Readable.prototype.pipe = function(dest, pipeOpts) {
var src = this;
var state = this._readableState;
switch (state.pipesCount) {
case 0:
state.pipes = dest;
break;
case 1:
state.pipes = [state.pipes, dest];
@yorkie
yorkie / node-acg.js
Last active January 1, 2016 16:39
node acg
var request = require('request');
var async = require('async');
var path = require('path');
var fs = require('fs');
var baseURL = 'http://acg.sugdream.com/_uploadfiles/iphone5/300/';
function checkRootDir() {
var reg = /[0-9]+\.jpg/g;
request(baseURL, function(er, res, body) {
@yorkie
yorkie / random-timer.js
Created January 29, 2014 03:43
random timer
function startTimer(fn) {
var interval = Math.random()*100;
console.log('interval:',interval);
var timer = setTimeout(function() {
fn();
startTimer(fn);
}, interval);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>杭州绿尚室内家居环保有限责任公司</title>
<!-- TemplateEndEditable -->
<!--<meta name="keywords" content="环保 检测 家居 绿尚 绿色 室内" />
<meta name="description" content=" 我公司主导产品定位为室内家居环保一体化服务。一体化服务是指集咨询、检测、环保产品销售、上门污染治理等独立服务为一体的新服务模式。可根据顾客不同的定位需求来设计个性化方案,挑选合适的产品来为顾客改善家居环境。为顾客解决环保问题省去了原本繁冗复杂的过程。" />
#include <math.c>
int
computeDigit(int num) {
return 1+(int)log10((float)num);
}
@yorkie
yorkie / chap1.txt
Created March 2, 2014 09:17
bash references
beginning-of-line (C-a)
Move to the start of the current line.
end-of-line (C-e)
Move to the end of the line.
forward-char (C-f)
Move forward a character.
backward-char (C-b)