Skip to content

Instantly share code, notes, and snippets.

View dermotos's full-sized avatar

Dermot dermotos

  • Sydney, Australia
View GitHub Profile
@ZevEisenberg
ZevEisenberg / map float range.swift
Last active July 13, 2020 20:31
Mapping floating point numbers between two ranges in Swift
import QuartzCore
extension CGFloat {
func map(from from: ClosedInterval<CGFloat>, to: ClosedInterval<CGFloat>) -> CGFloat {
let result = ((self - from.start) / (from.end - from.start)) * (to.end - to.start) + to.start
return result
}
}
extension Double {
@ankitthakur
ankitthakur / AppleHomeKitUtilities.swift
Last active February 9, 2017 23:35
Apple HomeKit Utilities
//
// AppleHomeKitUtilities.swift
// AppleHomeKit
//
// Created by Ankit Thakur on 2/7/15.
// Copyright (c) 2015 Ankit Thakur. All rights reserved.
//
import UIKit
import HomeKit
@bryanluby
bryanluby / gist:fd5ac0a8c74c2c3241d9
Last active June 1, 2023 16:10
Switch on indexPath using tuple example in Swift.
switch (indexPath.section, indexPath.row) {
case (0, _): println("section 0")
case (1, _): println("section 1")
case (2, 0...2): println("section 2 0-2")
case (2, 3...5): println("section 2 3-5")
case (3, let row): println("\(row)")
default: println("")
}
@qerub
qerub / lifx-sunrise-simulator.rb
Last active September 9, 2020 11:44
LIFX Sunrise Simulator
require "lifx" # http://www.rubydoc.info/gems/lifx
def calculate_color(i) # 0 <= i <= 1
h = [40 * 2 * i, 40].min # will be 40 (yellow) at i=1/2 and stay there
s = 1.0 - [(i - 0.5) * 2, 0].max # will be 1 until i=1/2 and then go down to 0
b = i
LIFX::Color.hsbk(h, s, b, LIFX::Color::KELVIN_MIN)
end
duration = 10 * 60 # seconds
@rtt
rtt / tinder-api-documentation.md
Last active April 20, 2024 17:01
Tinder API Documentation

Tinder API documentation

Note: this was written in April/May 2014 and the API may has definitely changed since. I have nothing to do with Tinder, nor its API, and I do not offer any support for anything you may build on top of this. Proceed with caution

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 3, 2024 12:59
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@zoul
zoul / AVAssetExportSession+Testing.m
Created November 8, 2010 08:35
Export assets synchronously. Good for testing.
@implementation AVAssetExportSession (Testing)
- (void) exportSynchronously
{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self exportAsynchronouslyWithCompletionHandler:^{
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);