Skip to content

Instantly share code, notes, and snippets.

View amberstar's full-sized avatar

Amber Star amberstar

View GitHub Profile
@amberstar
amberstar / PiP
Created June 14, 2019 20:02
Javascript to make video on current page PiP
javascript:(function(){document.querySelectorAll("video").forEach(function(video){if(window.getComputedStyle(video).display!=='none'){video.webkitSetPresentationMode("picture-in-picture");}});})();
@amberstar
amberstar / openssl-build.sh
Last active February 1, 2018 13:23 — forked from felix-schwarz/openssl-build.sh
Updated script that builds OpenSSL for OS X, iOS and tvOS. Bitcode enabled for iOS, tvOS. Updated to build for tvOS, use the latest SDKs, skip installing man pages (to save time), download the OpenSSL source over HTTPS, patch OpenSSL for tvOS to not use fork(). Currently requires Xcode7.1b or later (for the tvOS SDK).
#!/bin/bash
# This script downloads and builds the iOS, tvOS and Mac openSSL libraries with Bitcode enabled
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# https://gist.github.com/foozmeat/5154962
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Felix Schwarz, IOSPIRIT GmbH, @felix_schwarz.
@amberstar
amberstar / Dispatcher_Sensor.swift
Last active December 11, 2016 03:16
Trigger updates via. property observer
// embed in the target (note props are read only)
protocol MySensor {
var name: String { get }
var age: Int { get }
}
// an example target that holds sensor
protocol MyView {
var sensor: MySensor { get set }
}
@amberstar
amberstar / ModifyBehavior.swift
Created December 2, 2016 18:17
Modify behavior of struct
struct ModifyBehavior {
var value: Int
static var operation1: (inout ModifyBehavior) -> Int = { instance in
instance._operationToUse = operation2
return instance.value
}
static var operation2: (inout ModifyBehavior) -> Int = { instance in
instance.value = 0;
// events
public struct ComponentEvents {
public var appEvent = Port<(component: Component, event: EventType)>()
}
subcomponent.events.appEvent.subscribe { component, event in
self.applicationEvent(component, event: event)
}
func applicationEvent(component: Component, event: Event) {
@amberstar
amberstar / Counter-2.swift
Last active February 7, 2016 20:23
Counter Ref
//: [Previous](@previous)
import UIKit
import Behavior
import XCPlayground
//: ## Task: Create a small counter application
//: This approach uses ports and behaviors
struct Counter {
@amberstar
amberstar / Copyable.swift
Last active February 3, 2018 22:59
Copyable
protocol Copyable {
typealias CopyType
func copy() -> CopyType
}
class A: Copyable {
var x: Int
init(x: Int) { self.x = x }
func copy() -> A {