Skip to content

Instantly share code, notes, and snippets.


Flaviu Simihaian FlaviuSim

View GitHub Profile
FlaviuSim / iframe-position.html
Created Apr 4, 2011
Positioning an iframe's content
View iframe-position.html
width : 534px;
height : 850px;
overflow : hidden;
position : relative;
FlaviuSim / gist:903001
Created Apr 5, 2011
bash script to convert directory structure to xml - by @sente
View gist:903001
function indent() {
spacer=${2:" "}
for ((i=0;i<$depth;i++)); do
echo -ne " ";
function recurse() {
local name=$1
FlaviuSim / watch
Created May 4, 2011
Python watch for modified files and run tests
View watch
#!/usr/bin/env python
-Thanks to Shawn Milochik for this - saved for future reference
Run unit test suite every time a Python file
is modified.
Requires pyinotify:
View gist:994244
def isAnagramOf(attempt, original):
# all the same case
attempt = attempt.strip()
if len(attempt) < 1: # only actual words
return False
attempt, original = attempt.lower(), original.lower()
for character in attempt:
position = original.find(character)
if (position == -1):
return False
FlaviuSim / gist:1224087
Created Sep 17, 2011
factory_girl association recursion
View gist:1224087
# Question model - question.rb
class Question < ActiveRecord::Base
attr_accessible :text, :survey_id
belongs_to :survey
validates_presence_of :text, :survey
#Survey model - survey.rb
View gist:1224293
after_build do |q|
2.times { }
View gist:1224294
survey { Survey.create(:name => "Survey Answer") }
FlaviuSim / spec_helper.rb
Created Sep 25, 2011
Spec helper with spork
View spec_helper.rb
require 'rubygems'
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
FlaviuSim / Gemfile
Created Sep 25, 2011
testing part of the gem file
View Gemfile
group :test, :development do
gem 'sqlite3'
gem 'rspec-rails', '~> 2.6.1'
#capybara > webrat:
gem "capybara", "~> 1.0.0"
#headless js testing that hopefully is faster than selenium
gem "capybara-webkit", "~> 0.6.1"
#supposedly you need this for Mac OS X file system scanning, though it's worked fine so far
gem "rb-fsevent", "~>"
# gem 'guard-rspec'
View Guardfile
# A sample Guardfile
# More info at
guard 'rspec', :version => 2, :cli => "--drb" do
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec/" }
# Rails example