Skip to content

Instantly share code, notes, and snippets.

@xli
xli / go-stage-job-count-stats.js
Created January 28, 2016 00:12
Go server stage job count stats
var pipelines = $H({});
var stats = {
pipelineCount: 0,
stageCount: 0,
stageHasOneJobCount: 0,
stageHasMultipleJobCount: 0
}
$j.ajax({url: "/go/cctray.xml", dataType: "xml"}).done(function(data) {
$j(data).find("Project").each(function(i, e) {
var job = $j(e).attr("name").split(" :: ");
@xli
xli / gist:1592604
Created January 11, 2012 02:25
git repo info in termial for pair machine
PS1='\u@\h \W$(__git_ps1 "(%s)[$(git config --get user.name)]")\$ '
PS1='\h \W$(__git_ps1 "($(git config --get user.name)@%s)")\$ '
@xli
xli / platform_config.rb
Created January 9, 2012 02:18
Load a config.yml file to setup global variables
require 'fileutils'
require 'yaml'
require 'erb'
module PlatformConfig
def load(config_yml)
unless File.exists?(config_yml)
FileUtils.cp("#{config_yml}.example", config_yml)
end
if platform_config = YAML.load(ERB.new(File.read(config_yml)).result)[RUBY_PLATFORM]
@xli
xli / autoload_threadsafe.rb
Created April 24, 2011 06:53
autoload threadsafe
# Load this file before load anything.
# JRuby-Rack will load rack before load rails, so should load this file when JRuby runtime initialized.
# Call AutoloadThreadsafe.eager_load_all! at the end of rails environment rb
module AutoloadThreadsafe
module Recorder
def self.included(base)
base.class_eval do
alias :unsafe_autoload :autoload
def autoload(m, filename)
import static org.jruby.javasupport.JavaEmbedUtils.invokeMethod;
import org.jruby.Ruby;
import org.jruby.runtime.builtin.IRubyObject;
public class JRubyObject {
public static JRubyObject load(Ruby runtime, String dump) {
return new JRubyObject(((IRubyObject) marshalClass(runtime).send("load", dump)));
}
//find out caller's class name (found from log5j)
public static void xxx() {
String name = new Exception().getStackTrace()[1].getClassName();
....
}
// or
String name = Thread.currentThread().getStackTrace()[3].getClassName()
@xli
xli / gist:77242
Created March 11, 2009 01:20 — forked from chad/gist:76951
# How to find out where a method comes from.
# Learned this from Dave Thomas while teaching Advanced Ruby Studio
# Makes the case for separating method definitions into
# modules, especially when enhancing built-in classes.
module Perpetrator
def crime
end
end
class Fixnum
class YourModule::Parser
options no_result_var
...
@xli
xli / gist:65352c95199e5b51c94f
Last active August 29, 2015 14:22
eb_deployer-environments-config-example.yml
common:
phoenix_mode: true #default to false
environments:
dev:
phoenix_mode: false # turn off for dev env for faster deployment
strategy: inplace-update # default strategy: blue-green
option_settings:
- namespace: aws:elb:loadbalancer
option_name: SSLCertificateId
@xli
xli / gist:a930b41e5058b9076837
Last active August 29, 2015 14:22
eb_deployer-components-example.yml
components:
- name: bg
strategy: inplace-update
option_settings:
- namespace: aws:autoscaling:asg
option_name: MinSize
value: "1"
- namespace: aws:autoscaling:asg
option_name: MaxSize
value: "1"