Skip to content

Instantly share code, notes, and snippets.

View adamjleonard's full-sized avatar

Adam Leonard adamjleonard

View GitHub Profile
class TaskApp extends Spine.Controller
# Add event listeners
events:
"submit form": "create"
"click .clear": "clear"
# Create some local variables refering to elements
elements:
".items": "items"
"form input": "input"
@adamjleonard
adamjleonard / gist:1854567
Created February 17, 2012 17:45
Test is failing on comparing the two and I believe it's due to the ids of the PieceTypeCommoditys. Not sure how to go about making it not compare the ids.
'PieceTemplate#grouped_piece_type_commodities one piece with two commodities that are the same should return one commodity with count 2' FAILED
expected: [{:count=>2, :commodity=>#<PieceTypeCommodity id: 352, name: "Beer", packaging_type_id: nil, created_at: "2012-02-17 17:41:40", updated_at: "2012-02-17 17:41:40", weight: #<BigDecimal:1055f7520,'0.567E2',18(18)>, weight_unit: "KGS", nmfc_number: nil, quantity: nil, commodity_class_id: nil, piece_type_id: 781>}],
got: [{:count=>2, :commodity=>#<PieceTypeCommodity id: 353, name: "Beer", packaging_type_id: nil, created_at: "2012-02-17 17:41:40", updated_at: "2012-02-17 17:41:40", weight: #<BigDecimal:1055f6120,'0.567E2',18(18)>, weight_unit: "KGS", nmfc_number: nil, quantity: nil, commodity_class_id: nil, piece_type_id: 781>}] (using ==)
fizzbuzz = (['fizz' unless i % 3] + ['buzz' unless i % 5] or i for i in [1..100])
console.log fizzbuzz

MessagePack for Ruby version 5

Today, I released the new version of MessagePack for Ruby!

Even faster

I rewrote all the code and achieved significant performance improvement, especially for serialization. I compared the new version to the old version (v4) using ruby-serializers benchmark, and the new version is faster for all data sets including Twitter, Image, Integers, Geo and 3D model.

def main():
for number in range (100, 201):
if number % 5 == 0 and number % 7 == 0:
return print(number,'World Cup!')
if number % 5 == 0:
return print(number, 'World')
if number % 7 == 0:
return print(number, 'Cup')

Building our first Camera App

In the first ever SwiftCast TV screencast. We will teach you how to build a Camera application that allows you to take a photo, select an existing photo, and view our selected photo. Let’s get started.

Chapter 1: Setting up our Application

Create a new Application by clicking "Create a new Xcode project". When asked to Choose a template for your new project, we are going to select "Single View Application" under iOS/Application. Then click the "Next" button.

func requestFingerprintAuthentication() {
}
func requestFingerprintAuthentication() {
let context = LAContext()
var authError: NSError?
let authenticationReason: String = "To display a message to the user"
}
func requestFingerprintAuthentication() {
let context = LAContext()
var authError: NSError?
let authenticationReason: String = "To display a message to the user"
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {
}
}
func requestFingerprintAuthentication() {
let context = LAContext()
var authError: NSError?
let authenticationReason: String = "To display a message to the user"
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: authenticationReason, reply: {
(success: Bool, error: NSError?) -> Void in
if success {
dispatch_async(dispatch_get_main_queue(), {