Skip to content

Instantly share code, notes, and snippets.

View mattash's full-sized avatar

Fr. Mesrop Ash mattash

View GitHub Profile
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
alias grb='git rb'
@mattash
mattash / convert.rb
Created February 21, 2010 07:16 — forked from look/convert.rb
# Convert a Gemfile to Heroku's .gems file plus config.gem statements for Rails 2.3
herokuconfig = ""
railsconfig = ""
gemfile = File.new("Gemfile")
gemfile.readlines.each do |line|
if line =~ /gem ['"](\w+)['"](?:, ['"](.+?)['"]){0,1}(?:, :require => ['"](.+?)['"]){0,1}/
herokuconfig << "#{$1}" + ($2 ? %Q( --version "#{$2}") : '') + "\n"
railsconfig << "config.gem '#{$1}'" + ($2 ? ", :version => '#{$2}'" : '') + ($3 ? ", :lib => '#{$3}'" : '') + "\n"
db = Connection.new(ENV['DATABASE_URL']).db(db_name)
if ENV['DATABASE_USER'] && ENV['DATABASE_PASSWORD']
auth = db.authenticate(ENV['DATABASE_USER'], ENV['DATABASE_PASSWORD'])
end
<h4> Բառարան </h4>
<dl>
<dt>XHTML / HTML</dt>
<dd>գերտեքստային նշման լեզու</dd>
<dt>Tags</dt>
<dd>HTML-ի հիմունքներ.</dd>
</dl>
<h4>HTML Տեղեկագրություն</h4>
<dl>
@mattash
mattash / projects.bash
Created December 10, 2010 14:03
A bash script to interact with project directory structure
# Changes into the project's directory. All of my projects are stored in
# $PROJECTDIR/. Some of them are still on subversion, thus the need for all
# of the checks on "trunk". They often have one or more of the following
# subdirectories: application, prototype, mockups, artwork, or website.
# The command takes to parameters: the name of the project and the sub-
# directory. The application subdirectory is assumed if nothing is passed.
PROJECTDIR=/Volumes/MEDIA/projects
@mattash
mattash / passages.gawk
Created January 7, 2011 18:37
A gawk script to process a text file of Armenian Church Lectionary dates
BEGIN { print "days:" }
/ ([a-zA-Z]*)/ {
monthtext = $2;
m["January"] = 1;
m["February"] = 2;
m["March"] = 3;
m["April"] = 4;
m["May"] = 5;
m["June"] = 6;
m["July"] = 7;
@mattash
mattash / gist:863821
Created March 10, 2011 09:36
A snippet which uses jQuery to load www.oratsouyts.com info on a page.
$.getJSON('http://www.oratsouyts.com/day.js?callback=?', function(data) {
var readings = []
if(data.length > 0) {
$.each(data[0].readings, function(key,val) {
readings.push('<li><a href="http://www.oratsouyts.com/day/'+ data[0].date +'/passage/show/'+data[0].readings[key].passage+'">' + data[0].readings[key].title + '</a></li>');
})
$("<h4 />", {html: "Today is the <strong><a href='http://www.oratsouyts.com/day/"+data[0].date+"'>"+data[0].title+"</a></strong>"}).appendTo("#HomePage_Today");
$("<ul/>", { html: readings.join('') }).appendTo("#HomePage_Today");
} else {
$("<h4 />", {html: "No readings found for today"}).appendTo("#HomePage_Today");
@mattash
mattash / Console Log
Created April 6, 2011 09:54
A MongoMapper Model, the LocalizedString custom data type, and the Console Log.
>> f = Foo.new({:title => "Title"})
NoMethodError: undefined method `translations' for "Title":String
from /Volumes/MEDIA/projects/oratsouyts/lib/LocalizedString.rb:19:in `to_mongo'
from /Library/Ruby/Gems/1.8/bundler/gems/mongomapper-b3ab248dd907/lib/mongo_mapper/plugins/keys/key.rb:51:in `set'
from /Library/Ruby/Gems/1.8/bundler/gems/mongomapper-b3ab248dd907/lib/mongo_mapper/plugins/keys.rb:310:in `write_key'
from /Library/Ruby/Gems/1.8/bundler/gems/mongomapper-b3ab248dd907/lib/mongo_mapper/plugins/dirty.rb:59:in `write_key'
from (eval):10:in `title='
from /Library/Ruby/Gems/1.8/bundler/gems/mongomapper-b3ab248dd907/lib/mongo_mapper/plugins/keys.rb:183:in `send'
from /Library/Ruby/Gems/1.8/bundler/gems/mongomapper-b3ab248dd907/lib/mongo_mapper/plugins/keys.rb:183:in `attributes='
from /Library/Ruby/Gems/1.8/bundler/gems/mongomapper-b3ab248dd907/lib/mongo_mapper/plugins/keys.rb:181:in `each_pair'
class LocalizedString < HashWithIndifferentAccess
def self.from_mongo(value)
value.is_a?(String) ? value : LocalizedString.new(value || {})
end
def available_locales
symbolize_keys.keys
end
def to_s