This file contains hidden or 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)) |
This file contains hidden or 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\": 35, \"children\": [\"Jack\", \"Jill\"]}" | |
func JSONParseDictionary(jsonString: String) -> [String: AnyObject] { | |
if let data = jsonString.dataUsingEncoding(NSUTF8StringEncoding) { | |
if let dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(0), error: nil) as? [String: AnyObject] { | |
return dictionary |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 sequenced callback example | |
;; No need for nested callbacks. Just write your callbacks in a sequence and pass "(next)" as | |
;; your callback, which will set the next function in the sequence as your callback. | |
;; | |
;; This example is a simple node server that will serve static plain text file to the browser. | |
;; | |
(var fs (require "fs")) | |
(var http (require "http")) |
This file contains hidden or 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) |
NewerOlder