Skip to content

Instantly share code, notes, and snippets.

@z5h
z5h / ycombinator.clj
Created March 6, 2013 20:25
Applicative-Order Y Combinator (Clojure Version)
; Stumbling towards Y (Clojure Version)
;
; (this tutorial can be cut & pasted into your IDE / editor)
;
; The applicative-order Y combinator is a function that allows one to create a
; recursive function without using define.
; This may seem strange, because usually a recursive function has to call
; itself, and thus relies on itself having been defined.
;
; Regardless, here we will stumble towards the implementation of the Y combinator.
@solos
solos / offline_evernote.py
Created February 23, 2013 07:03
Offline evernote on android - solos's or diaosi's way to evernote pro.
#!/usr/bin/python
#coding=utf-8
import sqlite3
import os
from lxml import etree
def get_notes(ever_enex):
'''extract notes from .enex file'''
content = open(ever_enex, 'r').read()
@rkirsling
rkirsling / LICENSE
Last active September 22, 2024 23:23
Directed Graph Editor
Copyright (c) 2013 Ross Kirsling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@neekey
neekey / gist-blog-browser-js-error-catch-summary.md
Last active July 31, 2020 10:14
浏览器错误捕捉总结

捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。

window.onerror 讲接收3个参数:

  • msg:错误描述,比如:a is not defined
  • url:出错脚本所在的url
  • lineNumber:出错脚本的行数

本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。

@JacksonTian
JacksonTian / api.js
Last active June 28, 2016 01:40
Go语言的actor并发模式更容易,一点都不绕,比如要实现一个API,API内部有两个http接口A,B并发调用,如果都在200ms内返回,则合并结果输出,如果B比A慢,且B耗时超过200ms,则丢弃B调用只返回A结果;用Go很容易实现这个逻辑,50行 - 牛,学到了,但看逻辑是不是A和B如果都超过200ms了就无结果输出?这种情况下需要等A返回了再返回 - 逻辑还可以再完善一下,如果ab都在200ms内返回应该在慢的那个返回时就触发,而不是等到200ms - 接着上面的需求,如果B之后还要根据B的结果来判断是否要调用C,然后B和C的结果和A join后再进入下一个阶段 用我自己的EventProxy库做了下重构 https://gist.github.com/4364823 加注释50行。
var callA = function (callback) {
setTimeout(function () {
callback({name: "a", data: "I am result A"});
}, Math.round(Math.random() * 300));
};
var callB = function (callback) {
setTimeout(function () {
callback({name: "b", data: Math.round(Math.random() * 300)) % 2 === 0});
}, Math.round(Math.random() * 300));
@bang590
bang590 / stepEngine.js
Created October 22, 2012 09:29
stepEngine - simplify everyauth asynchronous resolution
var fs = require('fs'),
http = require('http');
var Promise = function(values) {
this._callbacks = [];
this._errbacks = [];
if (arguments.length > 0) {
this.fulfill.apply(this, values);
}
}
@wintercn
wintercn / h5g
Last active May 19, 2017 06:50
HTML5 Canvas Game Template
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<!--允许全屏-->
<meta content="yes" name="apple-mobile-web-app-capable"/>
<meta content="yes" name="apple-touch-fullscreen"/>
<!--禁止电话号码和邮箱识别-->
@zythum
zythum / gist:2848881
Created June 1, 2012 04:50
google收录的敏感词
@igrigorik
igrigorik / load.rb
Created April 20, 2012 06:34
load githubarchive data into sqlite3 database
#
# $> ruby load.rb http://data.githubarchive.org/2012-04-01-15.json.gz
#
require 'yajl'
require 'zlib'
require 'sqlite3'
require 'open-uri'
input = ARGV.shift