This file contains 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
def folder_exists!(folder) | |
folder = File.expand_path(folder) | |
target = "" | |
folder.split(File::SEPARATOR).each{ |path| | |
target = "/" if target.empty? && path.empty? #Unix environment | |
target = File.join(target, path).to_s | |
create_folder(target) if path.empty? | |
} | |
target | |
end |
This file contains 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/python | |
# Equivalent of "tail -f" as a webpage using websocket | |
# Usage: webtail.py PORT FILENAME | |
# Tested with tornado 2.1 | |
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket | |
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/ | |
import tornado.httpserver |
This file contains 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
# via http://tagaholic.me/2009/05/29/exploring-how-to-configure-irb.html#echo | |
def irb_verbosity_toggle | |
irb_context.echo ? irb_context.echo = false : irb_context.echo = true | |
end |
This file contains 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 'net/http' | |
require 'json' | |
YOUR_API_KEY="INPUT YOUR ADMIN PRIVATE_KEY HERE" | |
YOUR_SERVER_HOST="YOUR HOST" | |
response = Net::HTTP.get_response(YOUR_SERVER_HOST, "/api/v3/users?private_token=${YOUR_API_KEY}") | |
users = JSON.parse response.body | |
puts users.map{|user| user["email"] + ";"} |
This file contains 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
#!/bin/sh | |
BASEURL=http://git | |
USERNAME=DOMAIN_USER | |
USERPASS=DOMAIN_PASSWORD | |
RAW_FILE=RAW_FILE_URI | |
# login | |
curl -s -c cookies.txt -d "username=$USERNAME&password=$USERPASS" $BASEURL/users/auth/ldap/callback -o /dev/null | |
curl -s -c cookies.txt -b cookies.txt $BASEURL$RAW_FILE |
This file contains 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
commit 458580f297fbda26dc4b0f49cf18b231d1010597 | |
Author: Gene Wu <genewoo_AT_gmail.com> | |
Date: Sun Apr 28 02:03:42 2013 -0700 | |
Enable user to access public project | |
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb | |
index 32b1246..89ab816 100644 | |
--- a/app/controllers/application_controller.rb | |
+++ b/app/controllers/application_controller.rb |
This file contains 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
#!/bin/bash | |
# watchdo "rake" .rb | |
command="$1" | |
shift | |
fileSpec="$@" | |
sentinel=/tmp/t.$$ | |
touch -t197001010000 $sentinel |
This file contains 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
class APIProfiler | |
def initialize(app, config = {}) | |
@app = app | |
# default print out log to STDOUT, otherwise you can inject rails logger | |
@config = config | |
@config[:logger] = Logger.new(STDOUT) unless config[:logger] | |
@config[:log_level] = :info unless config[:logger_level] | |
@config[:filter] = lambda { false } unless config[:filter] #turn off by default | |
end | |
=begin |
This file contains 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
class BSTree | |
attr_accessor :left, :right, :parent, :value | |
def initialize(value, parent = nil) | |
@value = value | |
@parent = parent | |
end | |
def self.build_by_array(array, parent = nil) | |
return nil unless array |
This file contains 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
[repositories] | |
local | |
oschina: http://maven.oschina.net/content/groups/public/ | |
oschina-ivy: http://maven.oschina.net/content/groups/public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] | |
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly | |
#sonatype-oss-releases | |
#maven-central | |
#sonatype-oss-snapshots |
OlderNewer