Skip to content

Instantly share code, notes, and snippets.

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

davylin DavyLin

💭
I may be slow to respond.
View GitHub Profile
@nilcolor
nilcolor / Node.js CORS
Created February 8, 2011 15:28
Node.js cross-origin POST. You should response for OPTIONS request first. Something like this.
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
@mklabs
mklabs / bootstrap-plugins.txt
Created December 2, 2011 11:23
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js
@tj
tj / app.js
Created December 17, 2011 23:15
express 3.x cookie session middleware example
var express = require('express')
, cookieSessions = require('./cookie-sessions');
var app = express();
app.use(express.cookieParser('manny is cool'));
app.use(cookieSessions('sid'));
app.get('/', function(req, res){
req.session.count = req.session.count || 0;
;; ummels's solution to Palindromic Numbers
;; https://4clojure.com/problem/150
(fn [n]
(letfn [(decode [n] (if (< n 10) [n] (conj (decode (quot n 10)) (rem n 10))))
(encode [x] (reduce #(+ (* % 10) %2) 0 x))
(next-pal [n]
(let [N (decode n)
l (count N)
d (quot l 2)
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

@killme2008
killme2008 / solr_monitor.rb
Last active December 18, 2015 07:37
A nagios plugin ruby script to monitor solr cloud cluster
####
# Description:a nagios plugin script to monitor solr cloud cluster
# Requirements: zookeeper
# sudo gem install zookeeper
# sudo gem install rsolr
#
#####
require 'rubygems'
require 'zookeeper'
require 'rsolr'
@antonellopasella
antonellopasella / Applescript to send new iMessage
Last active February 20, 2019 19:09
How to send a new iMessage throug Applescript. For retrieve the contactname select your contact from list then SHIFT+CMD+I
tell application "Messages"
set isAppRunning to false
tell application "System Events"
if (exists process "Messages") then
set isAppRunning to true
end if
end tell
if isAppRunning is false then
@killme2008
killme2008 / gen_docset_for_dash.rb
Last active December 15, 2015 14:39
A ruby script to generate docset for dash from your public gists.
#!/usr/bin/ruby
## Author : dennis (killme2008@gmail.com)
## Description : A ruby script to generate docset for dash from your public gists.Test on ruby-2.0.0-p0.
## Dependencies : sudo gem install sqlite3
## Useage : Type command : ruby gen_docset_for_dash.rb [docset_name] [github_account]
## Then it will create a folder named '[docset_name].docset' in current folder,you can add the generated
## docset to dash in dash Preferences menu.
require 'rubygems'
require 'fileutils'
@n8henrie
n8henrie / Send with Messages.applescript
Last active July 10, 2022 14:54
Send an iMessage to a buddy with Quicksilver. First pane: pick buddy and arrow in to select the correct phone number. Second pane: choose this action. Third pane: Enter text to send.
property appleID : "yourAppleID"
(*
See post at: http://n8henrie.com/2013/04/send-imessage-messages-with-quicksilver
Send an iMessage to a buddy with Quicksilver.
Install by placing in ~/Library/Application Support/Quicksilver/Actions and restarting Quicksilver
First pane: pick buddy from contacts and right arrow in to select the correct phone number (or just type the phone number as text)
Second pane: choose this action.
Third pane: Enter text to send.
@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