Skip to content

Instantly share code, notes, and snippets.

"centres":[
{"name":"PCF Centre Block 121","code":...},
{"name":"PCF Centre Block 121","code":...}
...
]
var error: NSError?
let bundle = NSBundle.mainBundle()
let path = bundle.pathForResource("data", ofType: "json")
let content = NSString.stringWithContentsOfFile(path) as String
if let jsonDictionary = jsonDict {
println("json parsed successfully")
let total = jsonDictionary["centres"]!.count
let json_data = JSONValue(jsonDictionary)
if json_data{
for var index = 0; index < total; ++index {
var name = json_data["centres"][index]["name"].string
if name {
//processing value
}
var data:NSData! = content.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
let jsonDict : NSDictionary? = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &error) as? NSDictionary
if let err = error {
println("error parsing json")
}
function isVibrationEnabled(){
return (navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate) ;
}
@aladine
aladine / uptime.bat
Last active October 29, 2015 09:50
Measure uptime of desktop
@echo off
TITLE Uptime
For /f "tokens=1,2,3 delims=" %%a in ("%TIME%") do (set mytime=%%a%%b)
::('time /t')
net stats workstation | find "since"
echo Statistics current time is %mytime%
:: display 5s then close the window
timeout /t 5 /nobreak > NUL
@aladine
aladine / svn_update.bat
Last active September 28, 2015 01:46
SVN Update
@echo off
TITLE SVN Update
D:
cd D:\trunk\test
svn update
pause
@aladine
aladine / svn_status.bat
Last active September 28, 2015 01:45
Check SVN status of a repo
@echo off
TITLE SVN Status
D:
cd D:\trunk\test
svn st
pause
@aladine
aladine / node_start.bat
Created September 28, 2015 01:45
Start a node JS process
@echo off
TITLE NodeJS Starting
D:
cd D:\trunk\test
node app.js
pause
@aladine
aladine / copy_to_svn.bat
Created September 28, 2015 01:49
Copy files to SVN folder
ECHO OFF
::CMD will no longer show us what command it’s executing(cleaner)
COPY /Y D:\FX\trunk\subfolder D:\trunk\subfolder
:: /Y means overwrite if there is any file exist
PAUSE
COPY /Y D:\FX\trunk\ D:\trunk\
PAUSE