Skip to content

Instantly share code, notes, and snippets.

@marksands
marksands / Example.swift
Created January 9, 2018 01:24 — forked from IanKeen/Driver+Create.swift
RxSwift subject to provide public triggering but private subscription
class API {
func obtainIds() -> Observable<[Int]> {
return .just([1,2,3,4])
}
}
class ViewModel {
let update: AnyObserver<Void>
let dataUpdated: Observable<[String]>
@marksands
marksands / NSObject+Debounce.h
Created February 1, 2017 19:20 — forked from berzniz/NSObject+Debounce.h
Debounce method for Objective C
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@marksands
marksands / RBTree.swift
Created January 17, 2017 15:27 — forked from airspeedswift/RBTree.swift
red black tree updated for 2.1b2
private enum ListNode<Element> {
case End
indirect case Node(Element, next: ListNode<Element>)
func cons(x: Element) -> ListNode<Element> {
return .Node(x, next: self)
}
}
public struct ListIndex<Element> {
@marksands
marksands / NonemptyCollection.swift
Created January 17, 2017 15:27 — forked from airspeedswift/NonemptyCollection.swift
Non-empty collection in Swift
protocol NonemptyCollection: Collection {
var first: Iterator.Element { get }
}
enum NonemptyIndex<Base: Collection>: Comparable {
case head
case tail(Base.Index)
static func ==(lhs: NonemptyIndex, rhs: NonemptyIndex) -> Bool {
switch (lhs,rhs) {
@marksands
marksands / ghi.rb
Created April 10, 2010 04:48 — forked from macournoyer/ghi.rb
#!/usr/bin/env ruby
require "rubygems"
require "mutter"
require "httparty"
REMOTE = "origin"
REPO = `git config --get remote.#{REMOTE}.url`.chomp[/github\.com[\/\:]([^\/]+\/[^\/]+)\.git/, 1]
USER = `git config --get github.user`.chomp
TOKEN = `git config --get github.token`.chomp
require "rubygems"
require "net/http"
require "uri"
require "aws/s3"
AWS::S3::Base.establish_connection!(
:access_key_id => 'ACCESS KEY',
:secret_access_key => 'SECRET KEY'
)
#!/usr/bin/python
# Program to convert a number into the format
# hh mm ss.sssss
# Input format: ./converter.py DEC RA
import math
import sys
import string
def to_dec(inp):