Skip to content

Instantly share code, notes, and snippets.

View runlevel5's full-sized avatar

Trung Lê runlevel5

View GitHub Profile
class User < ActiveRecord::Base
acts_as_authentic do |c|
c.transition_from_restful_authentication = true
#AuthLogic defaults
#c.validate_email_field = true
#c.validates_length_of_email_field_options = {:within => 6..100}
#c.validates_format_of_email_field_options = {:with => email_regex, :message => I18n.t(‘error_messages.email_invalid’, :default => “should look like an email address.”)}
#c.validate_password_field = true
#c.validates_length_of_password_field_options = {:minimum => 4, :if => :require_password?}
@runlevel5
runlevel5 / gist:1191557
Created September 3, 2011 18:12
Anagram Solver
#!/usr/bin/env ruby
# Given a file containing one word per line, print out all the combinations of
# words that are anagrams; each line in the output should contain a set of
# input words that are anagrams of each other. No word should appear in the
# output more than once.
#
# For added programming pleasure, find the longest words that are anagrams,
# and the set of anagrams containing the most words.
@runlevel5
runlevel5 / spree_table_names
Created October 29, 2011 06:02
Spree dynamic table name list
module Spree
module TableNameHelpers
activators_table_name = Spree::Activator.table_name
addresses_table_name = Spree::Address.table_name
alerts_table_name = Spree::Alert.table_name
assets_table_name = Spree::Asset.table_name
calculators_table_name = Spree::Calculator.table_name
configurations_table_name = Spree::Configuration.table_name
countries_table_name = Spree::Country.table_name
credit_cards_table_name = Spree::Creditcard.table_name
0 tests, 0 assertions, 0 failures, 0 errors
Using the ci profile...
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.spree/order" is no longer supported
.............................name: ascend_by_master_price
arguments: []
wrong number of arguments (1 for 0)
/Users/macbookair/Sites/SPREE/spree/core/app/models/spree/product_scope.rb:29:in `ascend_by_master_price'
/Users/macbookair/Sites/SPREE/spree/core/app/models/spree/product_scope.rb:29:in `send'
/Users/macbookair/Sites/SPREE/spree/core/app/models/spree/product_scope.rb:29:in `apply_on'
/Users/macbookair/Sites/SPREE/spree/core/app/models/spree/product_scope.rb:45:in `check_validity_of_scope'
@runlevel5
runlevel5 / remove_office_2011.rb
Created December 20, 2011 10:44
Script to remove Office 2011 from OS X [Ruby]
#!/usr/bin/env ruby -wKU
require 'fileutils'
paths = ["/Applications/Microsoft Office 2011/",
"/Applications/Remote Desktop Connection",
"/Applications/Microsoft Communicator",
"/Applications/Microsoft Messenger",
"/Users/username/Library/Preferences/Microsoft/Office 2011/",
"/~/Library/Application Support/Microsoft/",
"/~/Documents/Microsoft User Data/",
"/Library/Automator",
{
06012012 = (
{
end = 1325854800;
id = 16;
TODO
----
Day View:
-----------------
1. Date header is blue if today else grey
2. Arrow should change to dark version on hover and toggle back on release
3. Change the header to loading.. or use loading indicator while waiting for the JSON message fetch
4. Vertical align the time and event title
5. If Event has location, the row should be like this:
@runlevel5
runlevel5 / gist:1610873
Created January 14, 2012 10:00
Credit adjustment for spree
order_number = 'R4678748'
o = Order.find_by_number(order_number)
adjustment_amount = o.total
rma_adjustment = o.adjustments.find_by_adjustment_source_type('ReturnAuthorization')
rma_adjustment.amount = rma_adjustment.amount - adjustment_amount
== Month View
-------------
1. Month Grid:
- Date number must be centered horizontally
- 'Today' tile color change from 'WHITE' to 'DARK PINK' with Shadow Inset, see picture: http://www.iphonefreak.com/wp-content/uploads/2010/06/iphone_4_calendar.jpg
2. Event Listing:
- add one 1px line border-top for Event Listing block (ask me if you don't understand)
- all-day color must be black instead of red
Calendar
tweaks to text and layout as per visual
enable view buttons from all views: LIST, DAY, MONTH
Details view: add location, link, RSVP by date, and fine-tune layout style
Fix bar initially appearing below month view