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 format_time_interval(from_time, to_time) | |
seconds = (to_time - from_time).abs.round | |
minutes, seconds = seconds.divmod(60) | |
if minutes > 60 * 24 | |
" " | |
elsif minutes > 60 | |
hours, minutes = | |
" %2dh %2dm " % minutes.divmod(60) | |
else | |
" %2dm %2ds " % [minutes, seconds] |
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 Account | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :subdomain, :type => String | |
embeds_many :users | |
accepts_nested_attributes_for :users | |
validates_presence_of :name, :subdomain | |
validates_uniqueness_of :subdomain, :case_sensitive => false |
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
#!/bin/sh | |
# | |
# Copyright (c) 2010 Warren Merrifield | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
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/models/user.rb | |
def apply_omniauth(omniauth) | |
case omniauth['provider'] | |
when 'facebook' | |
self.apply_facebook(omniauth) | |
when 'twitter' | |
self.apply_twitter(omniauth) | |
end | |
authentications.build(hash_from_omniauth(omniauth)) |
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
require 'rubygems' | |
require 'test/unit' | |
require 'em-http' | |
require 'vcr' | |
VCR.config do |c| | |
c.cassette_library_dir = 'fixtures/vcr_cassettes' | |
c.http_stubbing_library = :webmock | |
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
+ (NSManagedObject *)managedObjectFromStructure:(NSDictionary *)structureDictionary | |
entityName:(NSString *)entityName | |
withManagedObjectContext:(NSManagedObjectContext *)context { | |
NSMutableDictionary *mutableStructureDictionary = [structureDictionary mutableCopy]; | |
NSManagedObject *managedObject = [NSEntityDescription insertNewObjectForEntityForName:entityName | |
inManagedObjectContext:context]; | |
NSDictionary *relationshipsByName = [[managedObject entity] relationshipsByName]; |
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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter do | |
# Find Account_ID by seach for a domain - NOT Refactored yet | |
host_id = $memcache_instance.get('hosts/' + request.host) | |
unless host_id | |
host_db_row = BimbooHost.where( :host => request.host ).one | |
if host_db_row | |
$memcache_instance.set('hosts/' + request.host, host_db_row.bimboo_account_id, 60*60) |
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
#!/bin/sh | |
projectfile=`find -d . -name 'project.pbxproj'` | |
projectdir=`echo *.xcodeproj` | |
projectfile="${projectdir}/project.pbxproj" | |
tempfile="${projectdir}/project.pbxproj.out" | |
savefile="${projectdir}/project.pbxproj.mergesave" | |
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile | |
cp $projectfile $savefile |
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
@implementation MySharedThing | |
+ (id)sharedInstance | |
{ | |
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{ | |
return [[self alloc] init]; | |
}); | |
} | |
@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
// | |
// VKBlockSelector.h | |
// | |
#include <objc/runtime.h> | |
#import <Foundation/Foundation.h> | |
/* | |
* note: each file has its own! | |
*/ |
OlderNewer