This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
class World | |
attr_reader :continents | |
def initialize(world_xml="cia-1996.xml") | |
@continents = [] | |
if File.exists?(world_xml) | |
@noko = Nokogiri::XML(File.open world_xml ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Importer | |
attr_accessor :db | |
def initialize(db="#{Rails.root}/db/base-5-7-2011.sqlite3") | |
self.db = SQLite3::Database.new(db) | |
end | |
def import_articles | |
articles = @db.execute(" | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Note that scopes defined with scope will be evaluated when they are defined, rather than when they are used. For example, the following would be INCORRECT!!!: | |
scope :published, | |
where(:published => 1) | |
.where(:hidden => 0) | |
.where("publish_date <= ?", Time.now) | |
The example above would be "frozen" to the Time.now value when the model class was defined, and so the resultant SQL query would always be the same. The correct way to do this would be via a lambda, which will re-evaluate the scope each time it is called: | |
scope :published, -> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Playing with blocks :) | |
class Integer | |
def times(&block) | |
(0...self).each do |i| | |
block.call i | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "nokogiri" | |
require "pathname" | |
require "date" | |
gpx_root_folder = "/"+["Users", ENV["USER"], "mainnav-tracklogs"].join("/") | |
if ARGV[0].nil? or ARGV[1].nil? | |
puts "Missing dates!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run: test | |
./test | |
test: | |
clang -ansi test.c -o test | |
clean: | |
rm -rf test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@font-face { | |
font-family: 'HPBold'; | |
src: url("<%= ('http://myproductionhostorsomething.com/font/HPSimplifiedW04-Bold.eot') %>"); | |
font-weight: normal; | |
font-style: normal; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By Oto Brglez - <oto.brglez@opalab.com> | |
require 'httparty' | |
class PeerIndex | |
include HTTParty | |
format :json | |
base_uri "http://api.peerindex.net/v2" | |
def get(handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard 'livereload', :apply_css_live => false, :apply_js_live => false do | |
watch(%r{app/.+\.(erb|haml|js|css|scss)}) | |
watch(%r{app/helpers/.+\.rb}) | |
watch(%r{(public/|app/assets).+\.(css|js|erb|html)}) | |
watch(%r{(app/assets/.+\.css)\.s[ac]ss}) { |m| m[1] } | |
watch(%r{(app/assets/.+\.js)\.coffee}) { |m| m[1] } | |
watch(%r{(app/assets/.+\.js)\.erb}) { |m| m[1] } | |
watch(%r{config/locales/.+\.yml}) | |
end |