Skip to content

Instantly share code, notes, and snippets.

View batasrki's full-sized avatar

Srdjan Pejic batasrki

  • S-Squared Design & Development
  • Toronto, ON
View GitHub Profile
@batasrki
batasrki / gist:1670983
Created January 24, 2012 16:30 — forked from wmoxam/gist:1569088
Ubuntu Way of managing Rubies
# Installs Ruby, makes 1.9.2 the default.
sudo aptitude install ruby rubygems ri ruby1.9.1 ri1.9.1 jruby
sudo update-alternatives --remove-all gem
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.8 300 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.8.1.gz \
@batasrki
batasrki / Gemfile
Created January 1, 2012 09:22 — forked from bkerley/1.txt
source :rubygems
path '/Users/bkerley/Documents/ripple' do
gem 'riak-client'
gem 'ripple'
end
###
# This is a JSON building library. It allows you to build data structures
# to dump as JSON. Here is a sample of how to use it:
#
# def person_hash(person)
# {
# 'name' => person.name,
# 'age' => person.age,
# 'friends' => person.friends.map { |x| person_hash x }
# }
var z="http://gist.github.com/",y=document.write,x=$("body"),w=$("p.gist").map(function(b,a){a=$(a);var c=$("a",a),u=c.attr("href");if(c.length&&u.indexOf(z)==0)return{p:a,id:u.substring(z.length)}}).get(),v=function(){if(w.length==0)document.write=y;else{var b=w.shift();document.write=function(){document.write=function(a){b.p.replaceWith(a);v()}};x.append('<scr'+'ipt src="'+z+b.id+'.js"></scr'+'ipt>')}};v();
@batasrki
batasrki / debugger.markdown
Created July 20, 2011 20:32 — forked from jcasimir/debugger.markdown
Ruby Debugger

Ruby Debugger

Most of the time simple output statements using warn, raise, or a logger will help you find your issue. But sometimes you need the big guns, and that means ruby-debug.

Ruby-Debug

The ruby-debug package has had some rocky times during the transition from Ruby 1.8.7 to 1.9.2 and beyond. But now, finally, the debugger is reliable and usable.

Installation

Currently the RubyGems index is stored as a Gzip file that is a marshalled array. Whenever Bundler needs to install a gem that is not yet installed it downloads the index, gunzips it and unmarshals it. It then looks for dependencies that are described in another file that is also a gzipped and marshalled file. There are several issues that arise from this setup:

  • The full index must be downloaded and parsed, but does not contain dependency data, which must then be downloaded and parsed. This is a relatively time consuming process.
  • The index must be centralized.

Additionally the gems themselves are currently centralized since there is nothing in the meta data that indicates where the gem should be downloaded from. However in order to allow this it is important to find ways of keeping the index from being poisoned (is this an issue in the centralized system?)

Dependency Resolution

class EngineVariant
def api_representation
{ engine: engine, locale: locale }
end
end
#!/usr/bin/env ruby
require 'nokogiri'
path = ARGV.shift || File.join(ENV['HOME'], "Music/iTunes/iTunes Music Library.xml")
doc = Nokogiri.XML File.open(path)
tracks = []
doc.xpath('/plist/dict/dict/dict').each do |node|
children = node.children.map(&:text).reject { |x| x.strip.empty? }
@batasrki
batasrki / backup.rb
Created May 5, 2011 15:07 — forked from jschoolcraft/backup.rb
bit of my astrails-safe file, showing mysql command line batch execution
mysqldump do
options "-ceKq --single-transaction --create-options"
username = "some"
pass = "thing"
user username
password pass
socket "/var/run/mysqld/mysqld.sock"
require "stateful"
class Folder < ActiveRecord::Base
include Stateful
# ...
stateful do
state :active
state :inactive