Skip to content

Instantly share code, notes, and snippets.

parse_git_branch() {
raw_git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git::\1)/'
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk -F / '{print "(svn::"$1 "/" $2 ")"}'
}
parse_svn_url() {
svn info 2>/dev/null | grep -e '^URL*' | sed -e 's#^URL: *\(.*\)#\1#g '
}
parse_svn_repository_root() {
comment.request = stub(Object.new) do |request|
request.remote_ip {'ip'}
request.env {{ 'HTTP_USER_AGENT' => 'agent', 'HTTP_REFERER' => 'referrer' }}
end
class Erector::Inline
def method_missing(method_name, *args, &block)
if method_name.to_s =~ /!$/ && parent.respond_to?(method_name.to_s.gsub(/!$/, ""))
return_value = parent.send(method_name.to_s.gsub(/!$/, ""), *args, &block)
text!(return_value) if return_value.is_a?(String)
return_value
else
parent.send(method_name, *args, &block)
end
end
var someHost = http.createClient(80, "somehost.com");
var request = someHost.request(method, path, params);
var response;
request.addListener('response', function () {
response = arguments[0]
response.body = ""
response.addListener("data", function (chunk) {
response.body += chunk;
});
response.addListener('end', function () {
require 'benchmark'
Benchmark.bm do |x|
x.report("baseline") {}
x.report("require rubygems") {require 'rubygems'}
x.report("require bundler") {require 'bundler'}
x.report("Bundler.require(:benchmark)") {Bundler.require}
end
@btakita
btakita / tc-user.thrift
Created May 18, 2011 19:52
user service architecture meeting
namespace rb TcUser.Thrift
namespace py userservice
exception UserGetError {
1: string reason
}
exception UserCreateError {
1: map<string,list<string>> errors
}
describe UserService do
attr_reader :client_iprot, :client_iprot_transport, :client_oprot, :client_oprot_transport, :server_iprot, :server_iprot_transport, :server_oprot, :server_oprot_transport, :client, :server_handler, :server_processor
before do
@client_iprot_transport = ::Thrift::MemoryBufferTransport.new
@client_iprot = ::Thrift::BinaryProtocol.new(client_iprot_transport)
@client_oprot_transport = ::Thrift::MemoryBufferTransport.new
@client_oprot = ::Thrift::BinaryProtocol.new(client_iprot_transport)
@client = UserService::Client.new(client_iprot, client_oprot)
@server_iprot_transport = ::Thrift::MemoryBufferTransport.new
@btakita
btakita / foo_spec.js
Created May 27, 2012 08:46
Monkey-patch to add prototypes in describes to allow helper method overriding and mixins in specs
var MyMixin = {
bar: function() {
return "MyMixin bar";
}
};
describe("First Level", function() {
var variableFn = function() {
return "First Level variableFn";
};
echo
null
id
25818655
import_id
25818655
@btakita
btakita / bundle.build.js
Last active January 11, 2016 03:19
browserify,babelify,riotify,uglify,gzip-size build script
#!/usr/bin/env babel-node
var fs = require('fs')
, path = require('path')
, browserify = require('browserify')
, babelify = require('babelify')
, riotify = require('riotify')
, uglify = require('uglify-js2')
, watchify = require('watchify')
, gzipSize = require('gzip-size')
, source = require('vinyl-source-stream')