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
<?xml version="1.0" encoding="UTF-8"?> | |
<phpunit | |
colors="true" | |
stopOnFailure="false" | |
backupGlobals="false" | |
backupStaticAttributes="false" | |
convertErrorsToExceptions="true" | |
convertNoticesToExceptions="true" | |
convertWarningsToExceptions="true" |
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
<?php | |
class CITest extends PHPUnit_Framework_TestCase | |
{ | |
private $CI; | |
public function setUp() | |
{ | |
// Load CI instance normally | |
$this->CI = &get_instance(); | |
} |
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
<?php | |
$data = []; | |
// www-form-urlencoded | |
$opts = array('http' => array('method' => 'POST', | |
'header' => 'Content-Type: application/x-www-form-urlencoded', | |
'content' => http_build_query($data) | |
)); | |
// json |
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
let fileMgr = NSFileManager.defaultManager() func saveToFile(str: String, file: String) { var path = NSHomeDirectory().stringByAppendingPathComponent ("Documents").stringByAppendingPathComponent(file) Note Each app can write only to certain a certain folder inside the application home (for example, the Documents folder). The most common error is probably trying to create a file in the wrong place. var data = str.dataUsingEncoding(NSUTF8StringEncoding) var ok = fileMgr.createFileAtPath(path, contents: data, attributes: nil) } func retrieveFromFile(file: String) -> String? { var path = NSHomeDirectory().stringByAppendingPathComponent ("Documents").stringByAppendingPathComponent(file) if let data = fileMgr.contentsAtPath(path) { return NSString(data:data, encoding: NSUTF8StringEncoding) } return nil } func deleteFile(file: String) { var path = NSHomeDirectory().stringByAppendingPathComponent ("Documents").stringByAppendingPathComponent(file) var ok = fileMgr.remo |
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
self.dismissViewControllerAnimated(true, completion: {});//This is intended to dismiss the Info sceen. |
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
navigationController?.popViewControllerAnimated(true) |
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
yum --disablerepo="*" --enablerepo="geekery" list available | |
yum --disablerepo="*" --enablerepo="geekery" update |
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
#!/bin/sh | |
vips_version_minimum=8.2.2 | |
vips_version_latest_major_minor=8.2 | |
vips_version_latest_patch=2 | |
install_libvips_from_source() { | |
echo "Compiling libvips $vips_version_latest_major_minor.$vips_version_latest_patch from source" | |
curl -O http://www.vips.ecs.soton.ac.uk/supported/$vips_version_latest_major_minor/vips-$vips_version_latest_major_minor.$vips_version_latest_patch.tar.gz | |
tar zvxf vips-$vips_version_latest_major_minor.$vips_version_latest_patch.tar.gz |
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
<?php | |
$var = "some text"; | |
$text = <<<EOT | |
Place your text between the EOT. It's | |
the delimiter that ends the text | |
of your multiline string. | |
$var | |
EOT; | |
// The difference between Heredoc and Nowdoc is, that php code embedded in an heredoc gets executed, while php code in Nowdoc will be printed out as is. |