Skip to content

Instantly share code, notes, and snippets.

View dannolan's full-sized avatar
😄
loged on

Dan Nolan dannolan

😄
loged on
View GitHub Profile
@dannolan
dannolan / bootstrap_pagination_helper.rb
Created July 13, 2012 04:52 — forked from oparrish/bootstrap_pagination_helper.rb
Link renderer to be used with will_paginate to render links to work with Twitter Bootstrap
module BootstrapPaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def page_number(page)
unless page == current_page
link(page, page, :rel => rel_value(page))
else
link(page, "#", :class => 'active')
end
@dannolan
dannolan / notronbing.js
Created August 31, 2012 02:48
For notron
$("#submitButton").on("click",function(event){
var text = $("#textField").val();
$(".nameClass").each(function(index,val){
$(val).text(text);
});
});​

List of Block Declaration Syntaxes

Throughout, let

  • return_type be the type of object/primitive/etc. you'd like to return (commonly void)
  • blockName be the variable name of the block you're creating
  • var_type be the type object/primitive/etc. you'd like to pass as an argument (leave blank for no parameters)
  • varName be the variable name of the given parameter And remember that you can create as many parameters as you'd like.

Blocks as Variables

Possibly the most common for of declaration.

@dannolan
dannolan / gordypls.py
Created June 23, 2014 23:35
gordy pls
import json
from pprint import pprint
json_data=open('formatted.json')
data = json.load(json_data)
# pprint(data['features'])
for x in data['features']:
print(x["properties"]["headline"])
class Array2D<T> {
let columns: Int
let rows: Int
var array: Array<T?> // private
init(columns: Int, rows: Int) {
self.columns = columns
self.rows = rows
array = Array<T?>(count: rows*columns, repeatedValue: nil)
}
@dannolan
dannolan / appInfo.swift
Created September 25, 2014 23:23
App Info Gist
import Foundation
class AppInfo {
class func appVersion () -> String{
let infoDictionary = NSBundle.mainBundle().infoDictionary
if let versionString:AnyObject = infoDictionary["CFBundleShortVersionString"]{
return "\(versionString)"
}else{
return "No Version"
}
@dannolan
dannolan / tvds.swift
Created September 29, 2014 10:06
Generic TVDS in Swift
//
// GenericDataSource.swift
//
// Created by Dan Nolan on 23/09/2014.
// Creative Commons blah blah just use this as however you want I release all witchcraft and magic rights to using this software or something
//
import Foundation
import UIKit
@dannolan
dannolan / mediaItem.swift
Last active August 29, 2015 14:10
This doesn't feel heaps cleaner...
class MediaItem : MTLModel, MTLJSONSerializing {
var mediaFileName : String!
var mediaMD5String : String!
var mediaFileURL : String!
var mediaFileSize : Int!
class func documentsDirectory() -> String{
return NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
}
@dannolan
dannolan / borked.swift
Created December 8, 2014 07:14
Swifty Swifty Buggy Swifto
enum DisplayOrientation : CGFloat{
case WideScreen = 0
case Portrait = 1.5707963268
case UpsideDown = 3.1415926536
case PortraitUpsideDown = 4.7123889804
}
@dannolan
dannolan / gist:7afe945481cb099b083d
Created May 4, 2015 07:19
Apple's Frequent Locations logging fails
May 4 17:10:14 iPod-touch routined[5308] <Notice>: 452416214.294107 (4/05/2015 17:10:14 AEST), [DATABASE]: failed to execute statement
May 4 17:10:14 iPod-touch routined[5308] <Notice>: 452416214.295157 (4/05/2015 17:10:14 AEST), [DATABASE]: statement, INSERT INTO Hint (Timestamp, Latitude, Longitude, HorizontalAccuracy) VALUES (?, ?, ?, ?), return code, 19, error, UNIQUE constraint failed: Hint.Timestamp, Hint.Latitude, Hint.Longitude
May 4 17:10:14 iPod-touch routined[5308] <Notice>: 452416214.307433 (4/05/2015 17:10:14 AEST), [DATABASE]: failed to finalize statement
May 4 17:10:14 iPod-touch routined[5308] <Notice>: 452416214.308205 (4/05/2015 17:10:14 AEST), [DATABASE]: statement, , return code, 19, error, UNIQUE constraint failed: Hint.Timestamp, Hint.Latitude, Hint.Longitude