Skip to content

Instantly share code, notes, and snippets.

View oddlyzen's full-sized avatar
:electron:
Working with Electron

Mark Coates oddlyzen

:electron:
Working with Electron
View GitHub Profile
#!/usr/bin/env ruby
# :title:Category Filter Tests
# = Name
# Test the categories (left-nav checkboxes) filter
# = Description
# Show that the filter is working as intended.
require "selenium_helper"
module ZepFrog
module DasPermalinkor
def self.included(base)
base.extend Permalinkor
end
module Permalinkor
def das_permalinked(options = {})
options[:name] ||= :permalink
@oddlyzen
oddlyzen / gist:61453
Created February 10, 2009 16:42
For code review by ZepFrog team (2/13/09)
# init.rb
ActiveRecord::Base.send(:include, ZepFrog::DasPermalinkor)
# /lib/zepfrog/das_permalinkor.rb
module ZepFrog
module DasPermalinkor
def self.included(base)
base.extend Permalinkor
end
# Cron jobs start here --------------------------------------------------------------
def self.check_trial
accounts = BillingAccount.find(:all, :include => :user, :conditions => ["kind = 'trial' and status = 'active'"])
accounts.each do |a|
if a.expires_at.to_s == Time.today.strftime("%Y-%m-%d")
pay_me = execute_payment(:customer_profile_id => a.customer_profile_id, :customer_payment_profile_id => a.customer_payment_profile_id, :user_id => a.user_id)
if pay_me.success?
a.kind = "full"
a.expires_at = 1.year.from_now
a.save!
@oddlyzen
oddlyzen / gist:67320
Created February 20, 2009 05:02
An example of Russian to English and English to Russian using Mibbit's translator tool. Check out the last lines of each transcript for the real coolness.
(in mibbit.com/Firefox)
You are now sending with translation to English
You are now receiving with translation to Russian
23:27 bitpimpin hello. (hello.)
You are now sending with translation to Russian
23:28 bitpimpin This is a test. (Это тест.)
23:28 bitpimpin Hello. (Здравствуйте.)
You are now receiving with translation to English
23:28 bitpimpin Test (Проверка)
23:28 bitpimpin Okay, if this actually works, this is OMG universal translator (Хорошо, если это действительно работает, это OMG универсальный переводчик)
@oddlyzen
oddlyzen / gist:67384
Created February 20, 2009 08:58
Permutation of a Tweet.
Electrons flush into infinity & a hot robot hibernates: to dream of electric foos, to become digital meme in analog shell.
def serialize_to_json(options={})
namespace = options[:namespace].nil? ? 'ZEP' : options[:namespace]
if options[:data]
list = options[:data]
js = ""
js << "<script type=\"text/javascript\">"
js << "\n\tif (typeof #{namespace} !== 'object') { var #{namespace} = {}; }\n"
js << "\n\tif (typeof #{namespace}.models !== 'object') { #{namespace}.models = {}; }\n"
list.each do |obj|
if obj.respond_to? :to_json
namespace :rdoc do
desc "Generate RDocs for ZepInvest (exluding RESTful Authentication Plugin)"
task :generate do
`rdoc --exclude restful_authentication -o zepdocs ; open zepdocs/index.html`
end
desc "Remove old docs and regenerate RDocs for ZepInvest (exluding RESTful Authentication Plugin)"
task :regenerate do
`rm -rf zepdocs`
# for multiline ruby statements in haml...
= { :foo => :bar, |
:baz => :foo, |
:quux => :zz}.inspect |
# the magical 'pipe' strikes again.
@oddlyzen
oddlyzen / gist:83685
Created March 23, 2009 17:57
A simple IRC bot.
#!/usr/local/bin/ruby
# Attributed to user 413x from rubystuff.org
require "socket"
# Don't allow use of "tainted" data by potentially dangerous operations
$SAFE=1
# The irc class, which talks to the server and holds the main event loop