Skip to content

Instantly share code, notes, and snippets.

View krzysztofjablonski's full-sized avatar

Krzysztof Jablonski krzysztofjablonski

  • Siepomaga.pl
  • Poznań
View GitHub Profile
@krzysztofjablonski
krzysztofjablonski / gist:1143843
Created August 13, 2011 13:17
bug in datamapper
class Transaction
include DataMapper::Resource
property :user_id, Integer
def self.u1
all(:conditions => ["user_id != 4"])
end
def self.u2
all(:conditions => ["user_id != 5"])
module Rack
module Test
module Utils # :nodoc:
private
def build_primitive_part(parameter_name, value)
unless value.is_a? Array
value = [value]
@krzysztofjablonski
krzysztofjablonski / gist:1194809
Created September 5, 2011 12:11
my sweet bash file configuration
# Git branch name
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
parse_rvm() {
~/.rvm/bin/rvm-prompt
}
@krzysztofjablonski
krzysztofjablonski / commands
Created December 23, 2011 11:39 — forked from panchicore/commands
setup postgis on Snow Leopard 64-bits
#Download and install XCode
#Install homebrew (package manager) IF INSTALLED: just update it
ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
#Install git
brew install git
#IF LION
sudo vi /etc/paths and move /usr/local/bin to the top, cuz LION comes with a specific osx restricted PG.
@krzysztofjablonski
krzysztofjablonski / cumulative_performance.patch
Created January 27, 2012 12:00 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p0 cumulative performance patch.
diff --git a/common.mk b/common.mk
index ea244cc..4f22609 100644
--- a/common.mk
+++ b/common.mk
@@ -629,7 +629,8 @@ file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
- {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h
+ {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \
@krzysztofjablonski
krzysztofjablonski / config.ru
Created March 1, 2012 15:06
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
require "rails"
@krzysztofjablonski
krzysztofjablonski / regex.irb
Created March 1, 2012 15:06 — forked from fguillen/regex.irb
Non Greedy Regex match
# By default ReGex will match the bigest occurrence:
ruby-1.9.2-p180 > "_one_ two _three_".scan(/_(.+)_/)
=> [["one_ two _three"]]
# But we can tell it to match all the smallest ones:
ruby-1.9.2-p180 > "_one_ two _three_".scan(/_(.+?)_/)
=> [["one"], ["three"]]
#!/usr/bin/env ruby
def format_commit_info timestamp, time_desc, commit_id, message, ref_name
[
"#{timestamp.strftime("%y %b %d")}, #{timestamp.strftime("%l:%M%p").downcase}",
"(#{time_desc})",
commit_id,
message,
ref_name
]
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@krzysztofjablonski
krzysztofjablonski / run.sh
Last active October 4, 2015 06:38
Chef runner
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev git-core
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xvzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0/
./configure --prefix=/usr/local
make
make install