Skip to content

Instantly share code, notes, and snippets.

View diasjorge's full-sized avatar
🤖

Jorge Dias diasjorge

🤖
View GitHub Profile
@diasjorge
diasjorge / FirefoxEmacsHandler
Created September 11, 2009 09:29 — forked from calas/FirefoxEmacsHandler
Txmt protocol for emacs
#!/usr/bin/env ruby
# To install:
# about:config
# create a new boolean network.protocol-handler.external.txmt with value true
# create a new string network.protocol-handler.app.txmt with value path to the script
require 'rubygems'
require 'cgi'
require 'uri'
gem_cmd = "/opt/ruby-enterprise/bin/ruby /opt/ruby-enterprise/bin/gem --no-ri --no-rdoc"
a = %x(gem list)
gems = []
a.each_line do |l|
gem, *versions = l.gsub(/\(|\)|,/,"").split
versions.each do |v|
gems << "#{gem} -v #{v}"
end
end
%x(sudo #{gem_cmd} install #{gems.join(" ")})
require File.dirname(__FILE__) + '/../../../spec_helper'
describe Common::Deploy::ImportTranslations do
describe 'try' do
it 'should try' do
1.should == 1
end
f = UserFeed.find_by_name("HomeCompany")
languages = Lang.prepared
c = ActionController::Base.new
Housing.find_each(:conditions => { :rss_source_id => f.id }) do |item|
languages.each do |language|
c.expire_fragment "#{language.code}/item/#{item.class}/#{item.id}/half"
c.expire_fragment "#{language.code}/item/#{item.class}/#{item.id}/short"
c.expire_fragment "#{language.code}/item/#{item.class}/#{item.id}/full/true"
c.expire_fragment "#{language.code}/item/#{item.class}/#{item.id}/full/false"
end
trans "(use a new line for each item)","common.message.use_new_line"
trans "About me","common.about_me"
trans "Accept Invitation","common.accept_invitation"
trans "Accept this invitation","common.accept_this_invitation"
trans "Accepted friend invitations","common.accepted_friend_invitations"
trans "Account deletion is permanent and there is no way to recover any information (all messages, ads, posts, friends, etc) after you confirm this step.", "account.message.deletion_warning"
trans "Add a language...","common.add_language"
trans "Add another community","common.add_another_profile"
trans "Add sport from list", "common.add_interest_sport"
trans "Add to my discussions","common.add_to_discussions"
desc "Transform translations"
task :tt => :environment do
Translation.transaction do
require RAILS_ROOT + "/trans.rb"
end
end
def trans(st, scope_key, options={})
scope_key =~ /(.*)\.(.*)\Z/
scope = $1
(defun rinari-generate-tags()
(interactive)
(let ((my-tags-file (concat (rinari-root) "TAGS"))
(root (rinari-root)))
(message "Regenerating TAGS file: %s" my-tags-file)
(if (file-exists-p my-tags-file)
(delete-file my-tags-file))
(shell-command
(format "find %s -type f -iname \"*.rb\" | xargs ctags-exuberant -a -e -f %s"
root my-tags-file))
locales = Lang.all(:select => "code")
applications = %w(jobs housing classifieds community account)
locations = Location.all(:select => "id")
c = ActionController::Base.new
locales.each do |locale|
applications.each do |app|
locations.each do |location|
c.expire_fragment "#{locale.code}/#{app}/#{location.id}/application_tabs"
end
def gem_list(bin)
a = %x(#{bin} list)
gems = []
a.each_line do |l|
gem, *versions = l.gsub(/\(|\)|,/,"").split
versions.each do |v|
gems << "#{gem} -v #{v}"
end
end
gems
class Polynomial
def initialize(polynomial)
if polynomial.length < 2
raise ArgumentError.new("Need at least 2 coefficients")
else
@polynomial = []
polynomial.reverse.each_with_index do |x, i|
@polynomial << Term.new(x, i, (i == (polynomial.size - 1)))
end
end