View pre-commit
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
#!/bin/bash | |
SWIFT_LINT=./Pods/SwiftLint/swiftlint | |
if [[ -e "${SWIFT_LINT}" ]]; then | |
# Export files in SCRIPT_INPUT_FILE_$count to lint against later | |
count=0 | |
while IFS= read -r file_path; do | |
export SCRIPT_INPUT_FILE_$count="$file_path" | |
count=$((count + 1)) |
View Setup NSFetchedResultsController with UITableView.swift
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 MyViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
do { | |
try fetchedResultsController.performFetch() | |
} catch { | |
print("Error") | |
} | |
} |
View DynamicKey.swift
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
/** | |
``` | |
// 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
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
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
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
{ | |
"images" : [ | |
{ | |
"size" : "29x29", | |
"idiom" : "iphone", | |
"filename" : "app-icon-58.png", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "40x40", |
View mocha-guide-to-testing.js
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
// # 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
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
<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
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
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
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
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
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
<?php | |
function computeHoiioSignature($payload, $accessToken) { | |
// hash_hmac will return a hex of the digest | |
$signature =hash_hmac('sha256', $payload, $accessToken); | |
return $signature; | |
} | |
?> |
NewerOlder