Skip to content

Instantly share code, notes, and snippets.

def active
inactive_at.nil?
end
def generate_site_code
# Remove all non letters characters
site_name = name.gsub(/[^a-zA-Z]/, '')
# Make sure the site name is at least 5 characters
site_name += Array(('a'..'z')).shuffle[0, (5 - site_name.length)].join if site_name.length < 5
# The site code is made up of the country and state code plus the first 5 characters of the site name
code = country.code[0..1] + (city.state.code? ? city.state.code[0..2] : country.description[0..2]) + site_name[0..4]
self.code = code.upcase
$ ->
$(".app_url").data("timeout", null).keyup ->
url = $(this).val()
clearTimeout $(this).data("timeout")
$(this).data "timeout", setTimeout(checkForValidUrl(url), 10000)
- (void)saveUser {
AppDelegate *delegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
[[delegate facebook] requestWithGraphPath:@"me" andDelegate:self];
}
dataPages = [[NSArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"http://dribbble.com/system/users/4870/screenshots/203015/bacardi-mojito.jpg?1309590925", @"1",
@"http://dribbble.com/system/users/19849/screenshots/203160/mc-donalds-character.png?1309591886", @"1_full",
@"http://dribbble.com/system/users/4605/screenshots/202970/for_dribbble.png?1309582909", @"2",
@"http://dribbble.com/system/users/19849/screenshots/203160/mc-donalds-character.png?1309591886", @"2_full",
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"http://dribbble.com/system/users/3460/screenshots/203157/avatar.png?1309591592", @"1",
@"http://dribbble.com/system/users/4870/screenshots/203015/bacardi-mojito.jpg?1309590925", @"2",
- (void)setPageIndex:(NSInteger)newPageIndex
{
pageIndex = newPageIndex;
if (pageIndex >= 0 && pageIndex < [[DataSource sharedDataSource] numDataPages])
{
// NSArray *pageData =
// [[DataSource sharedDataSource] dataForPage:pageIndex];
//
// image_one.image = [pageData objectAtIndex:0];
- (void)setPageIndex:(NSInteger)newPageIndex
{
pageIndex = newPageIndex;
if (pageIndex >= 0 && pageIndex < [[DataSource sharedDataSource] numDataPages])
{
// NSArray *pageData =
// [[DataSource sharedDataSource] dataForPage:pageIndex];
//
// image_one.image = [pageData objectAtIndex:0];
#import "DataSource.h"
#import "SynthesizeSingleton.h"
@implementation DataSource
SYNTHESIZE_SINGLETON_FOR_CLASS(DataSource);
//
// init
//
dataPages = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"image1.png"],
[UIImage imageNamed:@"image2.png"],
nil];
#import "DataSource.h"
#import "SynthesizeSingleton.h"
@implementation DataSource
SYNTHESIZE_SINGLETON_FOR_CLASS(DataSource);
//
// init
//