Skip to content

Instantly share code, notes, and snippets.

import requests
def segment_image(image_path, api_key):
with open(image_path, 'rb') as image_file:
response = requests.post(
'https://api.deepai.org/api/deepmask',
files={'image': image_file},
headers={'api-key': api_key}
)
if response.status_code == 200:
@tempire
tempire / mojojs.sh
Created September 6, 2022 18:53
Hot reloading of mojojs typescript daemon
npx tsc-watch --onsuccess "node lib/index.js server"
my $hashref;
method_that_returns_promise
->then(sub {
$hashref = shift;
return 1;
})
->then(sub {
### Keybase proof
I hereby claim:
* I am tempire on github.
* I am tempire (https://keybase.io/tempire) on keybase.
* I have a public key ASDIRg2rJmI_Ly2SlcDphF4jfba_l3Hw2MbSHaFm0wlQZwo
To claim this, I am signing this object:
@tempire
tempire / client_certificate.swift
Last active September 1, 2022 09:41
WKWebView with client certificate
//
// ViewController.swift
// CertificateRequest
//
// Created by Glen Hinkle on 3/4/19.
// Copyright © 2019 Zombie Dolphin LLC. All rights reserved.
//
// Works with iOS 12
//
@tempire
tempire / WKWebView
Last active February 16, 2019 17:06
// In the MTR view controller
let vc = storyboard.instantiateViewController(withIdentifier: "WebViewController")
self.navigationController?.pushViewController(vc, animated: true)
// Web View Controller, assuming a matching view controller in the storyboard
class WebViewController: UIViewController {
@tempire
tempire / realm-classes.swift
Created December 24, 2016 01:36
realm classes
import RealmSwift
class ParentThing: Object {
dynamic var name: String = ""
dynamic var oktaId: String = ""
dynamic var employeeId: String = ""
dynamic var salesforceId: String = ""
dynamic var someOptionalThing: String?
@tempire
tempire / custom_collection-swift2.swift
Created November 12, 2016 19:32
Swift 2.2-2.3 Custom collection
// From Ray Wenderlich, converted to swift 2
extension Structs: CustomStringConvertible {
var description: String {
return contents.description
}
}
extension Structs: ArrayLiteralConvertible {
init(arrayLiteral elements: Element...) {
@tempire
tempire / ble.swift
Last active February 24, 2023 12:35
bluetooth LE advertise/scan
//
// Check.swift
// Points
//
// Created by Glen Hinkle on 10/2/16.
// Copyright © 2016 Zombie Dolphin. All rights reserved.
//
import Foundation
import CoreBluetooth
@tempire
tempire / vcs.swift
Created June 30, 2016 06:05
Typed view controller and storyboard
// Allows
// Storyboard.Main.viewController(MainVC)
enum Storyboard: String {
case Main
static let values = [Main]
static var boards = [Storyboard:UIStoryboard]()
func viewController<A: UIViewController>(type: A.Type) -> A {