View Setup NSFetchedResultsController with UITableView.swift
class MyViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
do { | |
try fetchedResultsController.performFetch() | |
} catch { | |
print("Error") | |
} | |
} |
View DynamicKey.swift
/** | |
``` | |
// Encode a model with properties of type [String : Any] | |
var propertiesContainer = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .properties) | |
if let properties = properties { | |
try propertiesContainer.encodeDynamicKeyValues(withDictionary: properties) | |
} | |
``` | |
*/ | |
struct DynamicKey: CodingKey { |
View UIImage+Resize.swift
extension UIImage { | |
func resizedImage(newSize:CGSize) -> UIImage { | |
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0); | |
self.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height)) | |
let newImage: UIImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return newImage | |
} |
View Contents.json
{ | |
"images" : [ | |
{ | |
"size" : "29x29", | |
"idiom" : "iphone", | |
"filename" : "app-icon-58.png", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "40x40", |
View mocha-guide-to-testing.js
// # Mocha Guide to Testing | |
// Objective is to explain describe(), it(), and before()/etc hooks | |
// 1. `describe()` is merely for grouping, which you can nest as deep | |
// 2. `it()` is a test case | |
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run | |
// before/after first/each it() or describe(). | |
// | |
// Which means, `before()` is run before first it()/describe() |
View activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<FrameLayout | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:layout_alignParentTop="true" |
View MainActivity.java
package com.example.stopwatch; | |
import android.os.Bundle; | |
import android.app.Activity; | |
import android.os.Handler; | |
import android.view.Menu; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; |
View HoiioSignature.java
public String computeHoiioSignature(byte[] payload, String accessToken) { | |
MessageDigest md = MessageDigest.getInstance("SHA-256"); | |
md.update(payload); | |
md.update(accessToken.getBytes("UTF-8")); | |
byte[] bytes = md.digest(); | |
String mySign = Hex.encodeHexString(bytes); | |
return mySign; | |
} |
View hoiio_signature.php
<?php | |
function computeHoiioSignature($payload, $accessToken) { | |
// hash_hmac will return a hex of the digest | |
$signature =hash_hmac('sha256', $payload, $accessToken); | |
return $signature; | |
} | |
?> |
View hoiio_signature.py
import hmac | |
import hashlib | |
def sign(payload, key): | |
dig = hmac.new(key, msg=payload, digestmod=hashlib.sha256).digest() | |
return dig.encode('hex') | |
if __name__ == "__main__": | |
import sys | |
if (len(sys.argv) == 3): |
NewerOlder