Skip to content

Instantly share code, notes, and snippets.

### 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 / 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 {
map $http_upgrade $connection_upgrade {
default "upgrade";
"" "";
}
server {
listen 80;
location / {
proxy_pass http://docker;
#!/usr/bin/env perl
use Data::Printer colored => 1;
use Modern::Perl;
use Mojo::JSON;
my @in;
say $_ ? p($_) : @in for Mojo::JSON->new->decode(@in = <STDIN>)
@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 / autolayout.swift
Created September 24, 2014 21:15
Some auto-layout notes - code and visual format language
var loginButton = (self.facebookLoginView.subviews.filter({ $0 is UIButton }) as Array).first as UIButton
// Tells auto-layout that we're doing this in code, specifying everything
self.facebookLoginView.setTranslatesAutoresizingMaskIntoConstraints(false)
// V:|-(60)-[facebookLoginView(100)]
let loginHeight = NSLayoutConstraint(
item: self.facebookLoginView,
attribute: NSLayoutAttribute.Height,
relatedBy: NSLayoutRelation.Equal,
@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 / 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 {
@tempire
tempire / closure.m
Last active May 11, 2016 21:06
objc block closure
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated duration:(NSTimeInterval)duration completion:(void(^)(BOOL finished))completion {
void (^highlight)(UIView *, BOOL) = ^void(UIView *view, BOOL highlight) {
if (highlight) {
view.layer.borderWidth = 0.0;
view.layer.borderColor = [UIColor clearColor].CGColor;
view.layer.shadowOpacity = 0.0;
}
else {
@tempire
tempire / template_loader.pl
Last active December 26, 2015 04:19
Load templates from __DATA__ @@Sections with replacement
use Modern::Perl;
use Mojo::Template;
use Mojo::Loader;
say Mojo::Template->new->render(Mojo::Loader->new->data(__PACKAGE__, 'hello'),
qw/ glen hinkle /);
__DATA__
@@ hello
% my ($fname, $lname) = @_;