Skip to content

Instantly share code, notes, and snippets.

View markauskas's full-sized avatar

Tomas Markauskas markauskas

View GitHub Profile
@markauskas
markauskas / fun.rb
Created February 23, 2010 01:10 — forked from terrbear/fun.rb
class Fun
include ScheduledJob
run_every 24.hours
def perform
puts "performing!!!"
end
end
module Jobs
module ScheduledJob
def self.included(base)
base.extend(ClassMethods)
end
def perform_with_schedule
Delayed::Job.enqueue self, 0, self.class.schedule.from_now.getutc
perform_without_schedule
end
module ActionController
module Resources
class Resource
# Redefining methods from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/resources.rb so that the RESTful routes accept member_path option
def member_path
@member_path || options[:member_path] || "#{shallow_path_prefix}/#{path_segment}/:id"
end
def default_url_options(options = {})
# resource hack so that url_for(@post) works like it should
# if a post was given as a parameter to `post_path` it will be assigned to the first (unnassigned) parameter of the route (year)
if options[:controller] == "posts" && options[:year].is_a?(Post)
post = options[:year]
options[:year] = post.year
options.merge(:month => post.month, :slug => post.slug)
else
{}
end
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
browser.contentHandlers.types.6.title = 'Google Reader'
browser.contentHandlers.types.6.type = 'application/vnd.mozilla.maybe.feed'
browser.contentHandlers.types.6.uri = 'http://www.google.com/reader/view/feed/%s'
@markauskas
markauskas / landing.rb
Created December 25, 2009 18:18 — forked from mid/landing.rb
require 'rubygems'
require 'sinatra'
require 'haml'
Domains = %w{gemsmith vogsphere youngman seraph intercessory cyaonline significantwhitespace 14159265358979}
DefaultDomain = 'default'
# what domain does the host contain?
# put this here because helpers are a pain to test!
def view_for_domain(host)
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness