Skip to content

Instantly share code, notes, and snippets.

View DTHENG's full-sized avatar

Daniel Thengvall DTHENG

View GitHub Profile
@DTHENG
DTHENG / wyre-vscode-theme.json
Last active October 29, 2017 02:33
Wyre Theme - VSCode Workbench Color Settings
{
"workbench.colorTheme": "Default Light+",
"workbench.colorCustomizations": {
"activityBar.foreground": "#0055ff",
"activityBar.background": "#FAFAFA",
"activityBar.border": "#E7E9EB",
"activityBar.dropBackground": "#E7E9EB",
"activityBarBadge.background": "#1a32af",
"activityBarBadge.foreground": "#FAFAFA",
"statusBar.background": "#FAFAFA",

Keybase proof

I hereby claim:

  • I am dtheng on github.
  • I am dtheng (https://keybase.io/dtheng) on keybase.
  • I have a public key whose fingerprint is 1AEA B94C 0B7D 38A2 E253 3050 2AF2 03F3 E4B9 E225

To claim this, I am signing this object:

@DTHENG
DTHENG / UIColor+random.swift
Last active May 18, 2017 23:53
Random color from UIColor
import UIKit
extension UIColor {
static func random() -> UIColor {
switch (arc4random_uniform(15)) {
case 0:
return UIColor.blackColor()
case 1:
return UIColor.darkGrayColor()
@DTHENG
DTHENG / fitFill.swift
Last active June 28, 2016 22:37
Create a new CGRect to Fit or Fill an existing CGRect
import UIKit
extension CGRect {
func fit(width : CGFloat, height : CGFloat, fill : Bool) -> CGRect {
let isWidthGreater = width > height
let ratio = isWidthGreater ? width / height : height / width
let w = isWidthGreater ? (fill ? self.width * ratio : self.width) : (fill ? self.width : self.width / ratio)
let h = !isWidthGreater ? (fill ? self.height * ratio : self.height) : (fill ? self.height : self.height / ratio)
return CGRect(x: isWidthGreater ? (fill ? 0 - ((w - self.width) / 2) : 0) : (fill ? 0 : (self.width - w) / 2),
#!/usr/bin/env python
import hashlib
import hmac
import time
import json
import urllib2
import datetime
# Q. Do you have A Websocket API?
# A. Yes, and we strongly recommend you to use it. Please, check our JavaScript websocket implementation for our WebSocket API here:
@DTHENG
DTHENG / ViewController.m
Last active August 29, 2015 14:17
DTObservable subscriber
[exampleObservable subscribe:[[DTSubscriber alloc] init:^(NSDictionary *profile) {
BOOL twentyFive = [profile[@"age"] intValue] == 25;
NSLog(@"Is age 25? %@", twentyFive ? @"YES" : @"NO");
} onError:^(NSError *error) {
NSLog(@"%@", error);
}]];
@DTHENG
DTHENG / ViewController.m
Last active August 29, 2015 14:17
DTObservable create
DTObservable *exampleObservable = [[DTObservable alloc] init:^(DTSubscriber *subscriber) {
NSDictionary *profile = @{
@"firstName": @"Daniel",
@"lastName": @"Thengvall",
@"age": @25};
// Lets pretend something cpu intensive happens here
[NSThread sleepForTimeInterval:1.f];
@DTHENG
DTHENG / Podfile
Last active August 29, 2015 14:17
DTObservable cocoapods
pod 'DTObservable'
@DTHENG
DTHENG / ViewController.m
Last active August 29, 2015 14:17
DTObservable import
#import <DTObservable/DTObservable.h>
@DTHENG
DTHENG / ViewController.m
Last active August 29, 2015 14:17
DTObservable Example
#import <DTObservable/DTObservable.h>
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
DTObservable *exampleObservable = [[DTObservable alloc] init:^(DTSubscriber *subscriber) {
NSDictionary *profile = @{