Skip to content

Instantly share code, notes, and snippets.

@jiverson
jiverson / app.js
Last active August 29, 2015 14:13 — forked from imjoshholloway/app.js
angular.module('myApp', ['ngPluralizeHtml'])
function AppController() {
var vm = this;
vm.count = 10;
}
.controller('AppController', AppController);
// Let's define a basic Swift class.
class Fruit {
var type=1
var name="Apple"
var delicious=true
}
// We can get at some info about an instance of an object using reflect(), which returns a Mirror.
reflect(Fruit()).count
reflect(Fruit())[1].0
import Cocoa
// Only needed until we have class variables
var __SwizzleSayHello = { (who:String) -> String in
return "Hello, \(who)"
}
class Swizzle {
//Only needed until we have class variables
class var _sayHello : (String)->String { get{ return __SwizzleSayHello } set (swizzle) {__SwizzleSayHello = swizzle} }
class Container {
typealias Resolver = () -> AnyObject
private var _resolvers: [String: Resolver] = [:]
func register<T: AnyObject>(resolver: @autoclosure () -> T) {
let name = NSStringFromClass(T.self)
_resolvers[name] = resolver
}
func get<T: AnyObject>() -> T {
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
}
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
// Add a check to make sure this exists
@jiverson
jiverson / gist:8b84b7697120f30017a9
Created February 25, 2015 06:20
Xcode select change
xcode-select --help
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
@jiverson
jiverson / test.js
Created February 25, 2015 17:14
sinon testing
describe.skip('handler only', function() {
// this suite of tests will show database mocking. if you don't want to mock the database, you will have to
// use mf-test-helpers to setup the data you want before running the test (what we've always done)
it('calls the route handler directly with mocked data', function(done) {
// stub dependencies
// stub mfData.query
var queryStub = sinon.stub(mfData.db, 'query');
// removeSnapshotForCoursesNoLongerInSeries
@jiverson
jiverson / watchcomm.swift
Created February 28, 2015 06:40
Phone to Watch communication
// Phone
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
if let request = userInfo!["request"] as? String {
if request == "refreshData" {
reply(["fromPhone": NSKeyedArchiver.archivedDataWithRootObject("iPhone data")])
return
}
}
@jiverson
jiverson / cssboot.html
Created March 9, 2015 17:50
Css Bootstrap
<div class="span8 offset2">
<div class="row-fluid" ng-repeat="graph in graphsModel track by $index" ng-if="$index%2==0">
<div class="span6">
<img width="500px" ng-src="{{graphsModel[$index].url}}">
</div>
<div class="span6">
<img width="500px" ng-src="{{graphsModel[$index + 1].url}}">
</div>
</div>
</div>
@jiverson
jiverson / partial
Created April 23, 2015 16:24
partial script loader
(function () {
"use strict";
angular.module('utils.htmlPartialScriptLoader', [])
.factory('htmlPartialScriptLoader', htmlPartialScriptLoader);
function htmlPartialScriptLoader($q, scriptsForPartial) {
return {
response: response