This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20:22 1.9.2@r3 [~/Source/Rails/fat_free_crm.r3] (rails3)$ rails c | |
Loading development environment (Rails 3.0.3) | |
ruby-1.9.2-p0 > ActiveRecord::Base.time_zone_aware_attributes | |
true | |
ruby-1.9.2-p0 > Time.zone = "Pacific Time (US & Canada)" | |
"Pacific Time (US & Canada)" | |
ruby-1.9.2-p0 > x1 = Account.create(:name => "x1", :updated_at => 1.day.ago) | |
#<Account:0x0000010476b218> { | |
:id => 131, | |
:user_id => nil, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generic version of the waiting-for-pause trick: | |
// execute callback only after a pause in user input; the function returned | |
// can be used to handle an event type that tightly repeats (such as typing | |
// or scrolling events); it will execute the callback only if the given timout | |
// period has passed since the last time the same event fired | |
function createOnPause(callback, timeout, _this) { | |
return function(e) { | |
var _that = this; | |
if (arguments.callee.timer) | |
clearTimeout(arguments.callee.timer); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: | |
# $ ./script/railssh | |
APP_PATH = File.expand_path('../../config/application', __FILE__) | |
require File.expand_path('../../config/boot', __FILE__) | |
require APP_PATH | |
Rails.application.require_environment! | |
module Kernel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 0.4.0 TODO | |
# | |
# - merge Windows fix | |
# - merge Stephan's ap/object | |
# - merge Mongo(?) | |
# - specs for arbitrary Obj | |
# - rescue LoadError if in specs if Rails is not installed | |
# - require unless defined?(::AwesomePrint) (when required from .irbrc) | |
# - Obj overrides :send | |
# - Obj overrides :method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original | |
Dir.glob("./commands/*.rb").each do |command| | |
$commands << command.split("/").last.split('.rb').first | |
end | |
# Refactored | |
Dir.glob("./commands/*.rb").each do |command| | |
$commands << File.basename(command, '.*') | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.console or do -> | |
window.console = {} | |
for method in [ "log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd" ] | |
window.console[method] = -> | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plain bubble sort. | |
def bubble_sort(array) | |
loop do | |
swapped = false | |
(array.size - 1).times do |i| | |
if array[i] > array[i+1] | |
array[i], array[i+1] = array[i+1], array[i] | |
swapped = true | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function k() { | |
kill -9 $(ps ax | grep $1 | grep -v grep | awk '{print $1}') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
$:.unshift("/Library/RubyMotion/lib") | |
require 'motion/project' | |
require '~/Source/Ruby/Motion/motion_awesome_print/lib/awesome_print' | |
Motion::Project::App.setup do |app| | |
# Use `rake config' to see complete project settings. | |
app.name = 'hello' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Alert | |
def initialize(title, message, *buttons) | |
# | |
# Delegating to self. | |
# | |
@alert = UIAlertView.alloc.initWithTitle(title, message:message, delegate:self, cancelButtonTitle:"Cancel", otherButtonTitles:"OK", nil) | |
@alert.show | |
self | |
end |