Skip to content

Instantly share code, notes, and snippets.

require 'spec_helper'
describe 'Fabricators' do
Fabrication::Support.find_definitions if Fabrication.schematics.empty?
Fabrication.schematics.schematics.keys.each do |fabrication|
it "The #{fabrication} fabrication is valid" do
f = Fabricate.build(fabrication)
f.should be_valid if f.respond_to?(:valid?)
end
@sumskyi
sumskyi / Gemfile
Created April 18, 2012 16:10
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@sumskyi
sumskyi / iwlist.log
Created April 10, 2012 19:03
iwlist: neighbours channels
-> # iwlist wlan0 scanning | ruby -ne "readlines.each{|l| puts l if l =~ /(?:Cell|ESSID|Channel)/ }"
Cell 01 - Address: 00:1A:70:9E:98:60
Channel:1
Frequency:2.412 GHz (Channel 1)
ESSID:"Uncle Zhora"
Cell 02 - Address: 00:22:6B:86:F6:C8
Channel:1
Frequency:2.412 GHz (Channel 1)
ESSID:"sabaka2"
Cell 03 - Address: 00:15:E9:62:A7:44
@sumskyi
sumskyi / condition.rb
Created December 3, 2011 08:15
hash driven conditional statements
#!/usr/bin/env ruby
class A
CONDITION = {
nil => :a,
false => :b,
true => :c
}
def abc(val)
@sumskyi
sumskyi / initializer_qu.rb
Created November 24, 2011 15:02
immediately performing Qu backend
if %w(test development).include? Rails.env
Qu.backend = Qu::Backend::RightNow.new
else
@sumskyi
sumskyi / node-and-npm-in-30-seconds.sh
Created November 22, 2011 12:19 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@sumskyi
sumskyi / README.md
Last active June 7, 2022 18:49
rails STI with custom "type" field and storing there value different from ClassName

GeoEntity.last

SELECT geo_entities.* FROM geo_entities ORDER BY geo_entities.id DESC LIMIT 1

returns:

County id: 4, eid: nil, pid: nil, ename: nil, etype: 2, created_at: "2011-11-21 06:26:37", updated_at: "2011-11-21 06:26:37"

@sumskyi
sumskyi / froro.rb
Created November 9, 2011 21:26
======== и этот даун пишет мне "Please use one soft tab (2 spaces) when indenting" ========
def user_timeline(uid)
- request(:get, "/statuses/user_timeline.json", {'user_id' => uid, 'count' => 100, 'trim_user' => true})
+ request(:get, "/statuses/user_timeline.json",
+ user_id: uid,
+ count: 100,
+ trim_user: true,
+ include_rts: 1
+ )
end
/usr/bin/firefox -new-tab $1
@sumskyi
sumskyi / .pryrc.rb
Created July 22, 2011 06:22
my .pryrc
Pry.config.editor = "gvim --remote-silent"
Pry.hooks.add_hook(:after_session, :say_bye) do
puts "fuck off Gnida"
end
Pry.prompt = [Proc.new{ |obj, nest_level| "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL} (#{obj}):#{nest_level} > " },
Proc.new{ |obj, nest_level| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " } ]