Skip to content

Instantly share code, notes, and snippets.

@jiverson
jiverson / gist:5b84b0d7b0c641fe82c7
Created October 6, 2015 01:20 — forked from masimplo/gist:324e77a2dd20fb4aa227
Decorating $http service to support url interpolation
function httpDecorator($delegate: ng.IHttpService) {
var $http = $delegate;
var wrapper = () => {
// interpolate the url
var config = arguments[0];
config.url = interpolateUrl(config.url, config.params, config.data);
return $http.apply($http, arguments);
};
@jiverson
jiverson / cycle-metasyntactic-variables.vim
Created September 30, 2015 00:00 — forked from hail2u/cycle-metasyntactic-variables.vim
'foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'の上で<C-a>/<C-x>すると順にサイクルしてくれるやつ。レジスター使ってる。
" Cycle metasyntactic variables
function! s:CycleMetasyntacticVariables(num)
if type(a:num) != type(0)
return
endif
let vars = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud']
let cvar = expand('<cword>')
let i = index(vars, cvar)
@jiverson
jiverson / filters.js
Last active August 29, 2015 14:25 — forked from kirkbushell/filters.js
Default value filter for Angular JS applications - allows you to output a variable, and assign it a default value if it has a value of 0, null, or is an empty string. Very similar to PHP's empty() function, but provides a default value instead of a boolean.
/**
* Sets a default value for a given input.
*
* @param mixed input
* @param string defaultValue
* @return string
*/
module.filter( 'default', [ '$filter', function( $filter ) {
return function( input, defaultValue ) {
if ( !input ) return defaultValue;
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var sass = require('node-sass');
var ENV = process.env.SASS_ENV || 'development';
var file = 'variables.scss';
//if in dev, directly pass file to sass
if (ENV === "development") {
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
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 {
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} }
// 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
@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);
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>