Skip to content

Instantly share code, notes, and snippets.

@t0d0r
t0d0r / scandoc
Created June 16, 2011 12:50
my script to use scanner in office
#!/bin/bash
date=`date +"%Y%m%d%H%M%S"`
pwd=`pwd`
pwd=~/Desktop
filename="${pwd}/scanned_${date}.tif"
echo "Finding device..."
device=$(scanimage -L | cut -d ' ' -f 2 | sed -e "s/[\`\|\']//g")
echo "got ${device}"
@t0d0r
t0d0r / Gemfile
Created December 20, 2011 13:51
Useful gems for rails 3
gem "configatron"
gem 'rest_in_place'
gem "foreman", :git => 'git://github.com/ddollar/foreman.git' # must be ~> 0.28.0 to support comments
gem "nifty-generators"
gem 'formtastic'
gem 'haml-rails'
gem "breadcrumbs_on_rails"
@t0d0r
t0d0r / gist:1505730
Created December 21, 2011 11:37
code sample for using nokogiri
require 'open-uri'
require 'nokogiri'
require 'erb'
include ERB::Util
q=url_encode("site:shipspotting.com 7224693 IMO")
doc = Nokogiri::HTML(open("http://www.google.com/search?q=#{q}"))
#link = doc.css("h3.r > a").first
/* get full dom path to the element */
var path = [];
var el = $0;
do {
path.unshift(el.nodeName + (el.className ? ' class="' + el.className + '"' : ''));
} while ((el.nodeName.toLowerCase() != 'html') && (el = el.parentNode));
console.log(path.join(" > "));
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
# require 'irb/completion'
# IRB Options
IRB.conf[:AUTO_INDENT] = true
# require 'irb/completion'
require 'open-uri'
require 'nokogiri'
require 'erb'
include ERB::Util
q=url_encode("site:shipspotting.com 7811032 IMO")
doc = Nokogiri::HTML(open("http://www.google.com/search?q=#{q}"))
link = doc.css("h3.r > a").first
snippet rip
.rest-in-place{'data-attribute' => '${1}'}
# using VestalVersions
# gem 'vestal_versions', :git => 'git://github.com/adamcooper/vestal_versions' # don't work with rails 3.1
gem 'vestal_versions', :git => 'git://github.com/jodosha/vestal_versions' # this work with 3.1
VestalVersions::Version.where(:versioned_type => "Place")
# custom generators in rails
# for example using haml instead of pure html in r g scaffold
git clone git://github.com/pjb3/rails3-generators.git lib/generators
# config/application.rb
config.generators do |g|
g.template_engine :haml
g.test_framework :rspec, :fixture => true, :views => false
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
@t0d0r
t0d0r / .hgignore
Created December 23, 2011 16:44
.hgignore
# rails hgignore
syntax: glob
*~
.bundle
.*swp
db/*.sqlite3
doc/app/*
log/*.log
tmp/**/*
.git