Skip to content

Instantly share code, notes, and snippets.

require 'mysql'
require 'active_record'
ActiveRecord::Base.logger = Logger.new('debug.log')
configuration = YAML::load(IO.read('config/database.yml'))
ActiveRecord::Base.establish_connection(configuration['development'])
class FactorWeight < ActiveRecord::Base
end
import UIKit
import XCTest
@testable import Society6
class ModelFactoryTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
<?php
include('../predis/lib/Predis/Autoloader.php');
$m = new MongoClient(); // connect
$collection = $m->opencorkage->selectCollection("restaurants.losangeles");
$base_url = 'http://www.opentable.com/';
$simple_info = 'httphandlers/RestaurantInfoLiteNew.ashx?rid=';
$restaurant_listings = 'los-angeles-restaurant-listings';
//
// AttributtedStrings.swift
// eHow
//
// Created by Joel Kopelioff on 3/5/15.
// Copyright (c) 2015 Demand Media. All rights reserved.
//
import Foundation
@jkopelioff
jkopelioff / RoundedButtons.swift
Created August 27, 2015 18:08
Rounded UI Button extension
//
// RoundedUIButtion.swift
// eHow
//
// Created by Joel Kopelioff on 4/13/15.
// Copyright (c) 2015 Demand Media. All rights reserved.
//
import UIKit
@jkopelioff
jkopelioff / LinkedStoryboardSegue.swift
Created August 18, 2015 18:42
Custom segue to link storyboards
//
// LinkedStoryboardSegue.swift
//
//
import UIKit
class LinkedStoryboardSegue: UIStoryboardSegue {
@jkopelioff
jkopelioff / NSObject+Utils.swift
Created August 14, 2015 19:45
A function equivalent to "valueForKeyPath" but supports Array substructure
public extension NSObject {
func valueForKeyPathWithIndexes(fullPath:String) -> AnyObject? {
var testrange:NSRange = (fullPath as NSString).rangeOfString("[")
if testrange.location == NSNotFound {
return self.valueForKeyPath(fullPath)
}
let parts:Array = fullPath.componentsSeparatedByString(".")
@jkopelioff
jkopelioff / ModelFactory.swift
Created August 13, 2015 22:53
Model Factory that maps Dictionary value to Model properties
//
// ModelFactory.swift
// Society6
//
// Created by Joel Kopelioff on 8/10/15.
// Copyright (c) 2015 Demandmedia Inc. All rights reserved.
//
import Foundation
@jkopelioff
jkopelioff / String+Regex.swift
Created August 13, 2015 20:27
Additional functionality to Strings using regex
extension String {
func matchRegex(pattern: Regex) -> Bool {
let range: NSRange = NSMakeRange(0, count(self))
if pattern.regex != nil {
let matches: [AnyObject] = pattern.regex!.matchesInString(self, options: pattern.matchingOptions, range: range)
return matches.count > 0
}
return false
}
@jkopelioff
jkopelioff / ExpandOutModalTransitioningManager.swift
Last active August 29, 2015 14:26
ExpandOutModalTransitioningManager.swift
//
// ExpandOutModalTransitioningManager.swift
// eHow
//
// Created by Joel Kopelioff on 7/9/15.
// Copyright (c) 2015 Demand Media.
//
// 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