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
// Author - Santosh Rajan | |
import Foundation | |
let jsonObject: [AnyObject] = [ | |
["name": "John", "age": 21], | |
["name": "Bob", "age": 35], | |
] | |
func JSONStringify(value: AnyObject, prettyPrinted: Bool = false) -> String { |
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
class VerticalLayout: UIView { | |
var yOffsets: [CGFloat] = [] | |
init(width: CGFloat) { | |
super.init(frame: CGRectMake(0, 0, width, 0)) | |
} | |
required init(coder aDecoder: NSCoder) { |
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
// Author - Santosh Rajan | |
import Foundation | |
let string = "[ {\"name\": \"John\", \"age\": 21}, {\"name\": \"Bob\", \"age\": 35} ]" | |
func JSONParseArray(jsonString: String) -> [AnyObject] { | |
if let data = jsonString.dataUsingEncoding(NSUTF8StringEncoding) { | |
if let array = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(0), error: nil) as? [AnyObject] { | |
return array |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
view.backgroundColor = UIColor.lightGrayColor() | |
var vLayout = VerticalFitLayout(width: view.frame.width) | |
vLayout.backgroundColor = UIColor.cyanColor() | |
view.addSubview(vLayout) |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
view.backgroundColor = UIColor.lightGrayColor() | |
var hLayout = HorizontalFitLayout(height: 150) | |
hLayout.backgroundColor = UIColor.cyanColor() | |
view.addSubview(hLayout) |
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
import Foundation | |
typealias ParseResult = (output: Any, rest: Substring)? | |
func stringParser(input: Substring) -> ParseResult { | |
if input[input.startIndex] != "\"" { | |
return nil | |
} | |
var isEscape = true | |
func inspectChar(char: Character) -> Bool { |
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
import Foundation | |
typealias ParseResult = (output: Any, rest: Substring)? | |
func stringParser(input: Substring) -> ParseResult { | |
if input[input.startIndex] != "\"" { | |
return nil | |
} | |
var isEscape = true | |
let index = input.index() { |
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
var fs = require("fs"), | |
src = fs.readFileSync(process.argv[2], 'utf8') | |
// createParser and createBodyParser creates parsers. A parser takes a string, | |
// and if successful returns an array of two elements. The object representation | |
// of consumed portion and the remainder of of the string. If failure returns null. | |
var markdownParser = createBodyParser("markdown", | |
createParser('newline', /^(\n+)/), | |
createParser('h1', /^# ([^\n]+)/), |
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
;; http://lispyscript.com | |
;; LispyScript example using nodejs, expressjs and twitter bootstrap | |
;; LispyScript templates are written in LispyScript! | |
;; Html5 templates support all html5 tags | |
;; The express server | |
(var express (require "express")) | |
(var app (express)) | |
(app.listen 3000) |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
println(view.frame) | |
view.backgroundColor = UIColor.lightGrayColor() | |
let view1 = UIView(frame: CGRectMake(100, 50, 100, 100)) |
NewerOlder