Skip to content

Instantly share code, notes, and snippets.

@zz85
zz85 / werckmeister.js
Created November 29, 2011 20:19
midi number to frequency using Werckmeister I (III) temperament
// by https://github.com/zz85
// http://en.wikipedia.org/wiki/Werckmeister_temperament
// Werckmeister I (III): "correct temperament" based on 1/4 comma divisions
var werckmeister = [
1, // c
256/243, // c#
64 / 81 * Math.pow(2, 1/2), // d
32/27, // d#
@beccadax
beccadax / ControllerShakeRecognizer.swift
Created October 15, 2015 19:07
Notes when a tvOS controller is shaken. Unfortunately, it requires a fair bit of force...
import Foundation
import GameController
private let epsilonMotion = 1.0
private func near(a: Double, _ b: Double) -> Bool {
return abs(a - b) < epsilonMotion
}
private let minimumNotableAcceleration = 1.0
#!/bin/sh
info_plist="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
spot_environment=$(echo "$GCC_PREPROCESSOR_DEFINITIONS" | sed -n 's/^.*ENVIRONMENT=\(.\)/\1/p')
facebook_url="fb0000000000${spot_environment}"
current_facebook_url=$(/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$info_plist")
@joshhudnall
joshhudnall / UIAlertViewCrashFix.h
Created April 28, 2015 23:13
A potential fix to a new crash in iOS 8.3 where UIAlertViews will crash because they expect a different auto rotation behavior than what they are getting.
//
// UIAlertViewCrashFix.h
//
// Created by Josh Hudnall on 4/28/15.
//
//
#import <Foundation/Foundation.h>
@interface UIAlertController (CrashFix)
@cemolcay
cemolcay / ABLLinkManager.swift
Last active December 2, 2018 21:42
Swift 4.0 port for LinkKit iOS of Ableton Link
//
// ABLLinkManager.swift
//
// Created by Cem Olcay on 5.03.2018.
// Copyright © 2018 cemolcay. All rights reserved.
//
import Foundation
import AVFoundation
@FlorianMielke
FlorianMielke / FMInfoPanelViewController.h
Created December 6, 2011 06:58
Info Panel attached to a UIScrollViewIndicator like in the Path 2 app. More information: http://cl.ly/CN2p
//
// FMInfoPanelViewController.h
// Created by Florian Mielke (@FlorianMielke) on 06.12.11.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
@interface FMInfoPanelViewController : UIViewController <UIScrollViewDelegate>
@cabeca
cabeca / simulator_populator
Created September 23, 2014 21:30
This script removes and recreates all simulators in Xcode 6.
#!/usr/bin/env ruby
device_types_output = `xcrun simctl list devicetypes`
device_types = device_types_output.scan /(.*) \((.*)\)/
runtimes_output = `xcrun simctl list runtimes`
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/
devices_output = `xcrun simctl list devices`
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/
@dkun7944
dkun7944 / UIView+3DFloatingEffect.swift
Last active February 9, 2021 20:19
Extension to add a cool 3D floating effect to any UIView.
extension UIView {
func add3DFloatingEffect(withDepth depth: Double = 1 / 12, duration: Double = 5) {
let depthAngle = depth * .pi
let rotationAnimationY = CABasicAnimation(keyPath: "transform.rotation.y")
rotationAnimationY.fromValue = NSNumber(floatLiteral: -1 * depthAngle)
rotationAnimationY.toValue = NSNumber(floatLiteral: depthAngle)
rotationAnimationY.duration = duration
rotationAnimationY.repeatCount = Float(Int.max)
rotationAnimationY.autoreverses = true
rotationAnimationY.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
@cerupcat
cerupcat / Tappable UIView
Last active January 29, 2022 16:09
Turn any UIView into a tappable button that animates and calls a selector
import Foundation
import UIKit
@propertyWrapper
class Tappable<T: UIView>: NSObject, UIGestureRecognizerDelegate {
// MARK: - Public Properties
public var wrappedValue: T? {
willSet {
removeGesture()
import SwiftUI
struct NewStopView: View {
let stop: Model.Stop
var body: some View {
Text("New Layout").font(.title)
RouteLayout(spacing: 8) {
ForEach(stop.routes ?? []) { route in
RouteView(route: route)