Skip to content

Instantly share code, notes, and snippets.

View cliss's full-sized avatar

Casey Liss cliss

View GitHub Profile
@cliss
cliss / RxUIWebViewDelegateProxy.swift
Created March 29, 2016 13:48
Reactive Extensions for UIWebView
//
// RxUIWebViewDelegateProxy.swift
//
// Created by Casey Liss on 24/3/16.
// Copyright © 2016 Casey Liss. All rights reserved.
//
import Foundation
import RxSwift
import RxCocoa
@cliss
cliss / Playground.swift
Created March 16, 2016 23:17
Doing bad things with delegation
import UIKit
import CoreLocation
import XCPlayground
XCPlayground.XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
class LocationDelegate: NSObject, CLLocationManagerDelegate {
override var description: String {
get {
return "LocationDelegate"
@cliss
cliss / DebugTimer.cs
Created February 2, 2015 19:07
C# Debug Timer
public class DebugTimer : IDisposable
{
private readonly System.Diagnostics.Stopwatch _watch;
private readonly string _blockName;
/// <summary>
/// Creates a timer.
/// </summary>
/// <param name="blockName">Name of the block that's being timed</param>
public DebugTimer(string blockName)
@cliss
cliss / gist:c618e3e20f9539f69568
Created July 1, 2014 02:43
Accidental Bot Death Again
2014-07-01T02:42:51.132915+00:00 app[web.1]: /app/node_modules/ws/lib/WebSocket.js:187
2014-07-01T02:42:51.132453+00:00 app[web.1]:
2014-07-01T02:42:51.133218+00:00 app[web.1]: else throw new Error('not opened');
2014-07-01T02:42:51.133233+00:00 app[web.1]: ^
2014-07-01T02:42:51.135282+00:00 app[web.1]: Error: not opened
2014-07-01T02:42:51.135285+00:00 app[web.1]: at WebSocket.send (/app/node_modules/ws/lib/WebSocket.js:187:16)
2014-07-01T02:42:51.135287+00:00 app[web.1]: at /app/accidentalbot.js:17:20
2014-07-01T02:42:51.135288+00:00 app[web.1]: at Array.forEach (native)
2014-07-01T02:42:51.135290+00:00 app[web.1]: at sendToAll (/app/accidentalbot.js:16:17)
2014-07-01T02:42:51.135292+00:00 app[web.1]: at WebSocket.<anonymous> (/app/accidentalbot.js:266:21)
@cliss
cliss / gist:95771f78a664954a03b3
Created June 26, 2014 01:11
Accidentalbot Death
2014-06-26T01:10:17.378902+00:00 app[web.1]: events.js:74
2014-06-26T01:10:17.378536+00:00 app[web.1]:
2014-06-26T01:10:17.379267+00:00 app[web.1]: throw TypeError('Uncaught, unspecified "error" event.');
2014-06-26T01:10:17.379276+00:00 app[web.1]: ^
2014-06-26T01:10:17.381818+00:00 app[web.1]: TypeError: Uncaught, unspecified "error" event.
2014-06-26T01:10:17.381821+00:00 app[web.1]: at TypeError (<anonymous>)
2014-06-26T01:10:17.381823+00:00 app[web.1]: at WebSocket.emit (events.js:74:15)
2014-06-26T01:10:17.381825+00:00 app[web.1]: at Receiver.self._receiver.onerror (/app/node_modules/ws/lib/WebSocket.js:719:10)
2014-06-26T01:10:17.381827+00:00 app[web.1]: at Receiver.error (/app/node_modules/ws/lib/Receiver.js:301:8)
2014-06-26T01:10:17.381828+00:00 app[web.1]: at Receiver.processPacket (/app/node_modules/ws/lib/Receiver.js:187:10)
(lldb) po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]
<UIWindow: 0x10c569ec0; frame = (0 0; 320 568); opaque = NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x10c56ac60>; layer = <UIWindowLayer: 0x10c56a1f0>>
| <UILayoutContainerView: 0x10c033570; frame = (0 0; 320 568); autoresize = W+H; gestureRecognizers = <NSArray: 0x10c045e40>; layer = <CALayer: 0x10c0340d0>>
| | <UINavigationTransitionView: 0x10c02f890; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x10c0427e0>>
| | | <UIViewControllerWrapperView: 0x10c586540; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x10c584a10>>
| | | | <UIView: 0x10c0514b0; frame = (0 91; 320 386); autoresize = W+H; layer = <CALayer: 0x10c051570>>
| | | | | <TextViewWithPlaceholder: 0x10c04c400; baseClass = UITextView; frame = (0 0; 320 386); text = ''; clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x10c04e1c0>; layer = <CALayer: 0
@cliss
cliss / TackyLights.html
Created December 9, 2013 20:10
Tacky Lights Navigator. This small bit of HTML & Javascript takes a series of addresses, and converts that into an ordered list. Each item in the list is an Apple Maps navigation link from [Your Current Location] to [That House]. This file is designed to be hosted in Dropbox and then added to your home screen on your iPhone.
<html>
<head>
<title>Tacky Lights</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<meta name="viewport" content="width=device-width" />
<!--<link rel="apple-touch-icon-precomposed" sizes="120x120" href="put-your-holiday-icon-here" />-->
</head>
<body>
<ol id="list"></ol>
<script type="text/javascript">
@cliss
cliss / organize-photos.py
Created October 6, 2013 14:43
Photo management script. This script will copy photos from "~/Pictures/iPhone Incoming" into a tree the script creates, with folders representing month and years, and photo names timestamped. Completely based on the work of the amazing Dr. Drang; see here: http://www.leancrew.com/all-this/2013/10/photo-management-via-the-finder/ You can see more…
#!/usr/bin/python
import sys
import os, shutil
import subprocess
import os.path
from datetime import datetime
######################## Functions #########################
@cliss
cliss / CarouselItem.cs
Created August 2, 2013 13:39
Example of a C# class, CarouselItem, that uses attributes to decorate fields/ivars and also properties. The attribute is Column, which corresponds to a custom class I wrote which is called ColumnAttribute (convention dictates this), which is shown below as well.
[XmlRoot(ElementName="Item")]
public class CarouselItem
{
#region Fields
#pragma warning disable 649
[Column("URL")]
private string _url;
@cliss
cliss / gist:5374387
Last active November 27, 2019 19:06
Best of Top Gear
+----------------------------------------------+
| Series | Episode | Description |
+--------+---------+---------------------------+
| 5 | 5 | Jaguar at the Nurburgring |
| 5 | 8 | Race to Verbier |
| 8 | 0 | Winter Olympics Special |
| 8 | 3 | Amphibious Cars |
| 8 | 6 | Caravan Vacation |
| 9 | 3 | America Special |
| 10 | 0 | Polar Special |