Skip to content

Instantly share code, notes, and snippets.

View knightq's full-sized avatar

Andrea Salicetti knightq

View GitHub Profile
@knightq
knightq / hudson.xml
Created September 23, 2011 13:39
Script to update jenkins to the latest version
hudson_home: /home/cruisecontrol/apache-tomcat-6.0.16/webapps/hudson
hudson_ftp: ftp.osuosl.org
hudson_ftp_base_dir: pub/jenkins/war/
@knightq
knightq / quarter_utils.js
Created May 2, 2017 14:18
Javascript - Quarter begin and quarter end
var now = new Date();
var quarter = Math.floor((now.getMonth() / 3));
var firstDate = new Date(now.getFullYear(), quarter * 3, 1);
var endDate = new Date(firstDate.getFullYear(), firstDate.getMonth() + 3, 0);
@knightq
knightq / rbenv
Created May 7, 2013 09:02
rbenv ruby version installation
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
@knightq
knightq / rbenv
Created May 7, 2013 09:46
rbenv new version install
CC=/usr/local/bin/gcc-4.2 rbenv install ree-1.8.7-2012.02
@knightq
knightq / Postgres array_agg
Created April 24, 2013 13:39
Using array_agg in Postgres – powerful and flexible. Further explanation on http://craigkerstiens.com/2013/04/17/array-agg/?utm_source=postgresweekly&utm_medium=email
select array_to_string(array_agg(projects.name), ',')) as projects ...
@knightq
knightq / Benchmark
Created February 27, 2013 15:27
Benchmarking Ruby
# Got from here: http://www.skorks.com/2010/03/timing-ruby-code-it-is-easy-with-benchmark/
require "benchmark"
Benchmark.bm(7) do |x|
x.report("first:") { (1..10000).each { |i| i } }
x.report("second:") { (1..10000).each { |i| i }}
x.report("third:") { (1..10000).each { |i| i }}
end
brew install memcached libmemcached
env ARCHFLAGS="-arch x86_64" gem install memcached --no-ri --no-rdoc -- --with-libmemcached-dir=/opt/local
@knightq
knightq / Rails log from console
Created January 17, 2013 15:05
How to enable Rails 2.3 logs from script/console.
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
@knightq
knightq / Disable Rails console colors
Created January 9, 2013 13:52
Config to put in config/development.rb to disable console ANSI colors.
config.active_record.colorize_logging = false
@knightq
knightq / gist:3077181
Created July 9, 2012 15:30
Repair MongoDB on Ubuntu
# see: http://stackoverflow.com/questions/4837427/mongo-ruby-connection-problem
sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo start mongodb
sudo status mongodb