Skip to content

Instantly share code, notes, and snippets.

View jnstq's full-sized avatar

Jon Stenqvist jnstq

  • Equipe AB
  • Helsingborg, Sweden
View GitHub Profile
# remote
cd /var/git
mkdir app_name
cd app_name
git init
# local
git init
git remote add origin git@server.com:/var/git/app_name
git push origin master
class User
def initialize()
@context = Context.new
end
def state
@context.state
end
end
class Context
require "enumerator"
[10,20,30].enum_for(:each_with_index).map { |value, index| puts "Value: #{value} Index: #{index}" }
[1,2,3].each_cons(2) do |l, r|
puts "left: #{l}"
puts "right: #{r}"
end
require 'rubygems'
require 'benchmark'
gem = ARGV.shift.strip rescue ''
if gem == ''
STDERR.puts "usage: #{$0} [gem]"
exit 1
end
`free`
sudo apt-get install imagemagick
sudo apt-get install libmagick9-dev
sudo gem install rmagick
sudo /opt/ruby-enterprise-1.8.6-20090421/bin/ruby /opt/ruby-enterprise-1.8.6-20090421/bin/gem install rmagick
it "should mark order as paid when completed" do
@payment_notification = Factory.build(:payment_notification, :status => "Completed")
@payment_notification.save!
@payment_notification.order.should be_paid
end
For some time here at EdgeCase we've had a bit of a standard for organization of model files in a Rails app. In the body of our model classes, we try to keep things in the following order:
1. Module includes
2. Class level constants
3. acts_as_whatever calls or similar extending method calls, for example attachment_fu's has_attachment
4. Associations, ex: has_many and belongs_to
5. Callbacks*
6. Validations
7. Named scopes
8. Class methods
require 'rubygems'
require 'pathname'
dirname = Pathname.new("/Users/jon/Dropbox/Equipe Windows Server/trans")
File.open("/Users/jon/tmp/kvitto-0224-0303.txt", "w") do |output|
%w(4548 4550 4551 4552 4555 4556 4557 4558 4559 4560 4562 4565 4566 4567 4568 4569 4570 4572 4573 4574 4575 4576 4579 4580 4581 4583 4584 4585 4587 4588).each do |tran_id|
if dirname.join("#{tran_id}.txt").exist?
output.puts File.open(dirname.join("#{tran_id}.txt")).read if dirname.join("#{tran_id}.txt").exist?
require 'rubygems'
require 'activerecord'
require 'activesupport'
require "spec/autorun"
require "spec/mocks"
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
ActiveRecord::Migration.verbose = false
ActiveRecord::Migration.suppress_messages do
require 'rubygems'
require 'rbench'
require 'activesupport'
strings = %w(jon stefan carl sofie)
numbers = [1, 3, 5, 7]
RBench.run(10_000) do
column :one