This file contains 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
$(document).ready(function() { | |
$('.team_title').editable("name", { | |
type : 'text', | |
rows : 8, | |
authenticity_token: encodeURIComponent('<%= form_authenticity_token if protect_against_forgery? %>'), | |
cancel : 'Cancel', | |
submit : 'OK', | |
tooltip : 'Double-click to edit...', | |
}) | |
}); |
This file contains 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
def model | |
default_message_if_blank(read_attribute(:model)) | |
end | |
def default_message_if_blank(args) | |
if ["",nil].include? args | |
"None" | |
else | |
args |
This file contains 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 Blog < ActiveRecord::Base | |
has_many :posts | |
accepts_nested_attributes_for :posts, :allow_destroy => true | |
before_validation :set_self_as_parent | |
def set_self_as_parent | |
self.posts.each |post| | |
post.blog = self | |
end |
This file contains 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
# Open / create temp file | |
temp_file = Tempfile.new(["myfile",".txt"]) | |
# Write into temp file (this is where the problem is... I believe the myprogram is creating a new file) | |
raise "Problem with my proggy" unless system "/usr/local/bin/myprogram '#{temp_file.path}'" | |
# Read from temp file | |
puts temp_file.read | |
# Close / delete temp file |
This file contains 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
>> a=File.open("testmsg.emlx") | |
=> #<File:testmsg.emlx> | |
>> mail=TMail::Mail.parse(a.read) | |
=> #<TMail::Mail port=#<TMail::StringPort:id=0x8525896c> bodyport=nil> | |
>> mail.body | |
=> "This E-mail was sent from (Aficio MP C2050)\nAttachment: 20100209163759213.pdf\n" | |
>> mail.body+="testing" | |
=> "This E-mail was sent from (Aficio MP C2050)\nAttachment: 20100209163759213.pdf\ntesting" | |
>> mail.body | |
=> "" |
This file contains 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
-(IBAction)presentSalesView:(id)sender { | |
// We hold on to the salesViewController since we'll be using it a bunch | |
if (nil == self.salesViewController) { | |
SCSalesViewController *viewController = [[SCSalesViewController alloc] initWithNibName:@"SCSalesView" bundle:nil]; | |
self.salesViewController = viewController; | |
[viewController release]; | |
} | |
[self.navigationController pushViewController:self.salesViewController animated:YES]; | |
} |
This file contains 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
App.actionsController = Em.ArrayController.create({ | |
content: [], | |
sort: function() { | |
var array, newArray; | |
array = this.get('content').toArray(); | |
newArray = array.sort(function(a, b) { | |
var a_due, a_isdone, a_isstarred, b_due, b_isdone, b_isstarred; | |
a_isdone = a.get('isDone') ? 1 : 0; | |
b_isdone = b.get('isDone') ? 1 : 0; | |
a_isstarred = a.get('isStarred') ? 1 : 0; |
This file contains 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
{"projects":[{"id":1,"name":"Books","project_type_id":1}]} |
This file contains 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
// given a string SomeCrazyString => someCrazyStringID | |
NSString *keyName = [[NSString alloc] initWithFormat:@"%@%@ID", [[modelKey lowercaseString] substringToIndex:1], [modelKey substringFromIndex:1]]; | |
DDLogInfo(@"primaryKey[%@]: %@", modelKey, keyName); |
This file contains 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
_clockFormat = [[NSDateFormatter alloc] init]; | |
[_clockFormat setTimeStyle:NSDateFormatterLongStyle]; | |
[_clockFormat setLocale:[NSLocale systemLocale]]; | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
_clockTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); | |
dispatch_source_set_timer(_clockTimer, DISPATCH_TIME_NOW, kClockUpdateInterval * NSEC_PER_SEC, 0); | |
dispatch_source_set_event_handler(_clockTimer, ^{ | |
self.clock.text = [_clockFormat stringFromDate:[NSDate date]]; |
OlderNewer