This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function once(fn) { | |
var called = false; | |
return function() { | |
if(called) throw new Error('Callback was already called.'); | |
called = true; | |
fn.apply(null, arguments); | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable the “Are you sure you want to open this application?” dialog | |
defaults write com.apple.LaunchServices LSQuarantine -bool false | |
# Increase window resize speed for Cocoa applications | |
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001 | |
# Set a blazingly fast keyboard repeat rate | |
defaults write NSGlobalDomain KeyRepeat -int 0 | |
# Show all filename extensions in Finder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
from http://www.cnblogs.com/iamzhanglei/archive/2013/02/24/2924680.html | |
*/ | |
var Promise = function() { | |
this.thens = []; | |
}; | |
Promise.prototype = { | |
resolve: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env escript | |
%% 递归版本 | |
fib(1) -> 1; | |
fib(2) -> 1; | |
fib(N) -> fib(N-1) + fib(N-2). | |
%% 尾递归优化版本 | |
fib2(N) -> fib2_iter(1,0,N). | |
fib2_iter(A, B, N) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('angularApp') | |
.controller('TodoCtrl', function ($scope) { | |
$scope.todoLists = [ | |
{done: false, value: 'todo1'}, | |
{done: false, value: 'todo2'}, | |
{done: false, value: 'todo3'}, | |
{done: true, value: 'todo4'} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define MAXWORDLEN 10 | |
int main(int argc, const char *argv[]) | |
{ | |
int c; | |
int inspace = 0; | |
long lengtharr[MAXWORDLEN + 1]; | |
int wordlen = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
北京,101010100|北京海淀,101010200|北京朝阳,101010300|北京顺义,101010400|北京怀柔,101010500|北京通州,101010600|北京昌平,101010700|北京延庆,101010800|北京丰台,101010900|北京石景山,101011000|北京大兴,101011100|北京房山,101011200|北京密云,101011300|北京门头沟,101011400|北京平谷,101011500|上海,101020100|上海闵行,101020200|上海宝山,101020300|上海嘉定,101020500|上海南汇,101020600|上海金山,101020700|上海青浦,101020800|上海松江,101020900|上海奉贤,101021000|上海崇明,101021100|上海徐家汇,101021200|上海浦东,101021300|天津,101030100|天津武清,101030200|天津宝坻,101030300|天津东丽,101030400|天津西青,101030500|天津北辰,101030600|天津宁河,101030700|天津汉沽,101030800|天津静海,101030900|天津津南,101031000|天津塘沽,101031100|天津大港,101031200|天津蓟县,101031400|重庆,101040100|重庆永川,101040200|重庆合川,101040300|重庆南川,101040400|重庆江津,101040500|重庆万盛,101040600|重庆渝北,101040700|重庆北碚,101040800|重庆巴南,101040900|重庆长寿,101041000|重庆黔江,101041100|重庆万州,101041300|重庆涪陵,101041400|重庆开县,101041500|重庆城口,101041600|重庆云阳,101041700|重庆巫溪,101041800|重庆奉节,101041900|重庆巫山,101042000|重庆潼南,101042100|重庆垫江,101042200|重庆梁平,101042300|重庆忠县,101042400|重庆石柱,101042500|重庆大足,101042600|重庆荣昌,101042700|重庆铜梁,101042800|重庆璧山,101042900|重庆丰都,1010 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
def check | |
doc = Nokogiri::HTML(open('http://www.yyets.com/resource/11176')) | |
doc.css('.f14').each do |l| | |
if l.to_s.include?('晚上') | |
puts 'no' | |
sleep 60 * 30 | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseHTMLToText(html) { | |
if( html ){ | |
html = html.replace(/\n/g,""); | |
html = html.replace(/<br \/>|<br>|<\/p>|<\/P>|<\/li>|<\/LI>/g,"\n"); //li special | |
html = html.replace(/<[^>]+>/g,""); | |
html = html.replace(/\t+/g, ""); | |
html = html.replace(/ /g,""); | |
}else{ | |
html = ""; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
def check | |
doc = Nokogiri::HTML(open('http://www.yyets.com/resource/10733')) | |
doc.css('.f14').each do |l| | |
if l.to_s.include?('片源') | |
puts 'no' | |
sleep 60 * 10 | |
else |