This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<flash_profile version="1.0" name="pngExport"> | |
<PublishFormatProperties enabled="true"> | |
<defaultNames>1</defaultNames> | |
<flash>0</flash> | |
<generator>0</generator> | |
<projectorWin>0</projectorWin> | |
<projectorMac>0</projectorMac> | |
<html>0</html> | |
<gif>0</gif> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fl.outputPanel.clear(); | |
var trace = fl.trace; | |
fl.showIdleMessage(false); | |
var runOnAllItems = true; | |
var runOnAllFiles = true; | |
var runOnSubdirectories = false; | |
var flashDocs = []; | |
var docOrg = fl.getDocumentDOM(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Image, | |
ScrollView, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Evaluates one tick of a spring using the Runge-Kutta Algorithm. | |
// This is generally a bit mathy, here is a reasonable intro for those interested: | |
// http://gafferongames.com/game-physics/integration-basics/ | |
// (double)stepSize: the duration between steps. This should be around 1/60th of a second. Values too large will not work as the spring adjusts itself over time based on previous values, so if values are larger than 1/60th of a second this method should be called for each whole 1/60th of a second segment plus the remainder. | |
// external variables | |
// (double) _curT: How far along the spring the current value is, 0 being start and 1 being end. Because this is a spring that value will go beyond 1 and then back below 1 etc, as it 'springs'. | |
// (double) _tVelocity: the current velocity of the spring. | |
// (BOOL) _stopSpring: indicates the spring has settled to minimum amount and should be considered the last 'tick' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func getUnicodeIndex()->Int { | |
return Int(self.unicodeScalars[self.unicodeScalars.startIndex].value) | |
} | |
static func getUnicodeRangeFrom(from:Int, to:Int, closedRange:Bool)->String { | |
let step = from > to ? -1 : 1; | |
let final = closedRange ? to + step : to | |
let chars = Int[]((from..final).by(step)).map{String(UnicodeScalar($0))} | |
return "".join(chars) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What are nested and curried functions? How do you use them in Swift? | |
// nesting/currying allows piping function calls together like fn(1)(2)(3) | |
// multiple functions, requires fnA(1) + fnB(2) + fnC(3) syntax | |
func daysToSeconds(days:Int)->Int { | |
return days * 24 * 60 * 60 | |
} | |
func hoursToSeconds(hours:Int)->Int { | |
return hours * 60 * 60 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to you safely convert an AnyObject with a number value into a Double? | |
let anyDouble:AnyObject = 6.41 | |
if let xx = anyDouble as? NSNumber { | |
println( Double(xx)) // prints 6.41 | |
} | |
// will throw an error if the conversion fails! | |
let casted = Double(anyDouble as NSNumber) // 6.41 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How do you compare tuples for equality? | |
var tupleA = (1, "one") | |
var tupleB = (1, "one") | |
// tup == tup2 // error: tuples can not be compared with ==, can not be used as hash key etc | |
// If you need to test for object equality, a tuple is not suitable | |
tupleA.0 == tupleB.0 && tupleA.1 == tupleB.1 // but you can do this | |
// you can also use element names | |
var tupleC = (a:1, b:"one") | |
tupleA.0 == tupleC.a && tupleA.1 == tupleC.b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How do you get the keys from a dictionary? | |
let array = [1,2,3] | |
let dict = [1: "One", 2: "Two", 3: "Three"] | |
// cast to get the keys in an array | |
var keys = Array(dict.keys) | |
keys == array // comapre arrays with == | |
var values = Array(dict.values) // the same works for values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias Sig = (num:Int)->Int[] | |
var wrap:Sig = {(num:Int) in return [num]} | |
wrap(num:3) // [3] | |
wrap(num:4) // [4] | |
func numLog() -> Sig{ | |
var log:Int[] = [] | |
return { | |
log += $0 |
NewerOlder