Skip to content

Instantly share code, notes, and snippets.

@redraiment
redraiment / Y Combinator 简介
Last active December 23, 2020 07:44
Y Combinator (Fixed-point Combinator) 不动点组合子
Y组合子是Lambda演算的一部分,也是函数式编程的理论基础。
它是一种方法/技巧,在没有赋值语句的前提下定义递归的匿名函数。
即仅仅通过Lambda表达式这个最基本的“原子”实现循环/迭代。
颇有道生一、一生二、二生三、三生万物的感觉。
虽然Y组合子在理论上很优美,但在实际开发中并不会真的用到。
想要了解Y组合子是什么,请参见维基百科:http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator
或者知乎上的回答:http://www.zhihu.com/question/20115649
(defn debounce
([c ms] (debounce (chan) c ms))
([c' c ms]
(go
(loop [start nil loc (<! c)]
(if (nil? start)
(do
(>! c' loc)
(recur (js/Date.) nil))
(let [loc (<! c)]
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'
@williscool
williscool / post-commit
Created January 26, 2013 20:43
Git lab references post commit hook
#!/bin/sh
PRIVATE_TOKEN="YOU_SECRET_TOKEN"
GITLAB_URL="http://gitlab.example.com/"
URL=`git config --get remote.origin.url`
PROJECT=`basename ${URL} .git | cut -d':' -f2`
COMMIT_MSG="git log -1 HEAD"
COMMIT_HASH_MSG=`git log -1 HEAD | head -1`
@allenhuang
allenhuang / proxychains4_formula.rb
Created September 27, 2012 06:33
Unofficial brew formula for proxychains 4
# Unofficial brew formula for proxychains 4
# Instruction:
# $ git clone git://gist.github.com/3792521.git gist-3792521
# $ brew install --HEAD gist-3792521/proxychains4_formula.rb
#
# The default config file will be located in /usr/local/etc/proxychains.conf
#
require 'formula'
class Proxychains < Formula
@arosh
arosh / nginx.conf
Last active December 17, 2023 15:23
redmine on nginx + unicorn
# This is example contains the bare mininum to get nginx going with
# Unicorn or Rainbows! servers. Generally these configuration settings
# are applicable to other HTTP application servers (and not just Ruby
# ones), so if you have one working well for proxying another app
# server, feel free to continue using it.
#
# The only setting we feel strongly about is the fail_timeout=0
# directive in the "upstream" block. max_fails=0 also has the same
# effect as fail_timeout=0 for current versions of nginx and may be
# used in its place.
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 5, 2024 13:30
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@moklett
moklett / openconnect.md
Created July 24, 2012 15:21
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@sjoerdvisscher
sjoerdvisscher / curry.html
Created July 9, 2012 20:37
Curry and uncurry in JavaScript
<script>
function curry(f)
{
if (typeof f != "function" || f.length < 2)
return f;
return mkHelper(f, []);
}
function mkHelper(f, args)
@jonathantneal
jonathantneal / Demo
Created April 18, 2012 17:13
addEventListener for IE8
http://jsfiddle.net/GuQaV/show/