Skip to content

Instantly share code, notes, and snippets.

View killme2008's full-sized avatar
🎯
Focusing

dennis zhuang killme2008

🎯
Focusing
View GitHub Profile
@killme2008
killme2008 / query_queue_length.rb
Created March 17, 2013 06:59
Query queue length in metaq.
####
# Description:a ruby script to monitor metaq queue size
# Requirements: zookeeper
# sudo gem install zookeeper
#
#####
require 'rubygems'
require 'zookeeper'
require 'socket'

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 / environ.rb
Last active December 15, 2015 05:39
A ruby script to scan all environment variables using environ lib and print the result in bash format.Environ is a Clojure library for managing environment settings from a number of different sources.https://github.com/weavejester/environ
#!/bin/ruby
if __FILE__ == $0
vars = {}
Dir.glob("**/*") do |name|
if File.file? name and name =~ /\.clj$/
File.open(name,"r") do |f|
content = f.read
if content =~ /environ.core/
content.scan(/\(env :([a-zA-Z\-]+) ("([^\)]+)")?\)/).each do |matches|
@killme2008
killme2008 / lru.clj
Created March 30, 2013 05:57
A LRU cache for core.cache that supports evict handler.
(ns cache.lru
(:use [clojure.core.cache :only [CacheProtocol defcache]]))
(defn- build-leastness-queue
[base limit start-at]
(merge
(into {} (take (- limit (count base)) (for [k (range (- limit) 0)] [k k])))
(into {} (for [[k _] base] [k start-at]))))
(defcache LRUCache [cache lru tick limit evict-handler]
@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'
var fs = require('fs');
var file = __dirname + '/test.json';
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.log('Error: ' + err);
return;
}
data = JSON.parse(data);
@killme2008
killme2008 / tw_test.clj
Last active August 29, 2015 14:00
ThoughtWorks的代码题 https://www.jinshuju.net/f/EGQL3D
;;Code for https://www.jinshuju.net/f/EGQL3D
(defn- read-n-numbers [n]
(repeatedly n #(let [x (read-line)]
(Integer/valueOf x))))
(defn- say-what [inputs words n]
(let [[x y z] inputs
rs (filter #(zero? (rem n %)) inputs)]
(cond
;;rule 5
/* *******************************************
// LICENSE INFORMATION
// The code, "Detecting Smartphones Using PHP"
// by Anthony Hand, is licensed under a Creative Commons
// Attribution 3.0 United States License.
//
// Updated 01 March 2010 by Bryan J Swift
// - Remove un-needed if statements instead just returning the boolean
// inside the if clause
//
/* *******************************************
// LICENSE INFORMATION
// The code, "Detecting Smartphones Using PHP"
// by Anthony Hand, is licensed under a Creative Commons
// Attribution 3.0 United States License.
//
// Updated 01 March 2010 by Bryan J Swift
// - Remove un-needed if statements instead just returning the boolean
// inside the if clause
//
@killme2008
killme2008 / fizz_buzz.clj
Created September 19, 2015 14:54
《计算的本质》第 6 章使用 clojure 基于 lambda 演算实现 FizzBuzz 程序。
(ns fizz-buzz
"《计算的本质》第 6 章使用 clojure 基于 lambda 演算实现 FizzBuzz 程序。")
(def zero (fn [p] (fn [x] x)))
(def one (fn [p] (fn [x] (p x))))
(def two (fn [p] (fn [x] (p (p x)))))
(def three (fn [p] (fn [x] (p (p (p x))))))
(def four (fn [p] (fn [x] (p (p (p (p x)))))))
(def five (fn [p] (fn [x] (p (p (p (p (p x))))))))