Skip to content

Instantly share code, notes, and snippets.

View itamar's full-sized avatar

Itamar Yunger itamar

View GitHub Profile
@itamar
itamar / gist:5755943
Created June 11, 2013 10:37
Fix "Too many open files" error - Rails / paperclip / Too many open files - identify -format ..
def download_remote_image
if io = do_download_remote_image
self.image = io
self.image_remote_url = image_url
io.close # Already copied to a Tempfile.
end
end
@itamar
itamar / sticky
Created June 2, 2013 18:28
Sticky sidebar
# Sticky Sidebar
$(document).ready () ->
if (!!$('.sticky').offset())
stickyTop = $('.sticky').offset().top
$(window).scroll () ->
windowTop = $(window).scrollTop()
if (stickyTop < windowTop)
$('.sticky').css({ position: 'fixed', top: 0 });
else
@itamar
itamar / artists_releases_spec.rb
Created December 17, 2012 22:20 — forked from stuliston/artists_releases_spec.rb
Testing HABTM with rspec and factory girl
require 'spec_helper'
describe "Artists to releases relationship" do
before(:all) do
@kanye = FactoryGirl.create(:artist, :name => 'Kanye West')
@jz = FactoryGirl.create(:artist, :name => 'Jay Z')
@watch_the_throne = FactoryGirl.create(:release, :name => 'Watch the Throne')
@dropout = FactoryGirl.create(:release, :name => 'The College Dropout')
end
@itamar
itamar / rspec-syntax-cheat-sheet.rb
Created November 11, 2012 09:43 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@itamar
itamar / gist:3859921
Created October 9, 2012 16:34
using OLE32 thing for word export
Re: Rails and MS Word
Posted by Paul Corcoran (Guest)
on 2006-12-29 18:24
(Received via mailing list)
Here is an example of creating a Word and Excel file from a Ruby
application. Win32ole is bundled with Ruby 1.8 and above so no need to
install it if your current on Ruby.
-Paul
@itamar
itamar / gist:3818058
Created October 2, 2012 10:26
Test Routes in Rails Console
include ActionController::UrlWriter
users_path
users_url
@itamar
itamar / mymodel.rb
Created August 29, 2012 12:02 — forked from aliang/mymodel.rb
render from model in Rails 3
# yes, sometimes you need to do this. you get pilloried in a forum if you
# ask about it, though!
# this code taken from
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/
class MyModel < ActiveRecord::Base
# Use the my_models/_my_model.txt.erb view to render this object as a string
def to_s
ActionView::Base.new(Rails.configuration.paths.app.views.first).render(
@itamar
itamar / wkhtmltopdf install
Created June 19, 2012 15:53
install WKHTMLTOPDF
WKHTMLTOPDF : HTML to PDF
Linux:
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
sudo mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
OSX:
@itamar
itamar / install-ruby-debug-ubuntu-ruby-1.9.3
Created May 10, 2012 07:30 — forked from boriscy/install-ruby-debug-ubuntu-ruby-1.9.3
ruby-debug for rails 3 in ruby-1.9.3 and Mac OS x
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
@itamar
itamar / chef_solo_bootstrap.sh
Created May 3, 2012 13:31 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install