Skip to content

Instantly share code, notes, and snippets.

View eyeezzi's full-sized avatar

Uzziah Eyee eyeezzi

View GitHub Profile
@eyeezzi
eyeezzi / CustomerEntryViewModelTests.swift
Last active December 13, 2018 00:08
Testing ViewModels
import Foundation
@testable import Shopify_POS
class CustomerEntryViewModelTests: XCTestCase {
var viewModel: CustomerEntryViewModel!
override func setUp() {
super.setUp()
viewModel = CustomerEntryViewModel(/* mock properties */)
}
@eyeezzi
eyeezzi / UserCellTests.swift
Last active December 13, 2018 00:09
Testing Views
import FBSnapshotTestCase
@testable import APP_TARGET
class UserCellTests: FBSnapshotTestCase {
func testNarrowCellWithLongName() {
let cell = createCell(name: Mock.longName, country: Mock.shortCountry, rank: Mock.shortRank, width: .iphone)
FBSnapshotVerifyView(cell)
}
func testNarrowCellWithLongCountryName() {
@eyeezzi
eyeezzi / Array+Extensions.swift
Last active December 13, 2018 21:41
Testing Extensions
import Foundation
extension Array where Element == String {
func merged(into existingArray: [Element]) -> [Element] {
var index = Set(existingArray.map { $0.lowercased() })
var container = existingArray
forEach {
if !index.contains($0.lowercased()) {
container.insert($0, at: container.startIndex)
index.insert($0)
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
func uploadHandler(w http.ResponseWriter, r *http.Request) {
var img Image
body, err := ioutil.ReadAll(r.Body)
// if err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// return
// }
func uploadHandler(w http.ResponseWriter, r *http.Request) {
var m map[string]interface{}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@eyeezzi
eyeezzi / curl.md
Created January 3, 2018 19:04 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@eyeezzi
eyeezzi / read_json_in_http.go
Last active February 21, 2018 14:06
Alternative way to read JSON body using ioutil.ReadAll()
func CreateNote(w http.ResponseWriter, r *http.Request) {
var m map[string]interface{}
body, err := ioutil.ReadAll(r.Body)
if err = json.Unmarshal(body, &m); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
package main
import (
"encoding/json"
"fmt"
)
type User struct {
Fname string
Mname *string
@eyeezzi
eyeezzi / read_known_json.go
Last active January 3, 2018 03:53
How to read JSON data that matches a struct in Go.
package main
import (
"encoding/json"
"fmt"
)
type User struct {
Fname string
Lname string