Skip to content

Instantly share code, notes, and snippets.

Amber Star amberstar

Block or report user

Report or block amberstar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@amberstar
amberstar / PiP
Created Jun 14, 2019
Javascript to make video on current page PiP
View 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 Feb 1, 2018 — 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).
View openssl-build.sh
#!/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 Dec 11, 2016
Trigger updates via. property observer
View Dispatcher_Sensor.swift
// 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 Dec 2, 2016
Modify behavior of struct
View ModifyBehavior.swift
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;
View ResponderChainExample.swift
// 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) {
View Counter-2.swift
//: [Previous](@previous)
import UIKit
import Behavior
import XCPlayground
//: ## Task: Create a small counter application
//: This approach uses ports and behaviors
struct Counter {
View Copyable.swift
protocol Copyable {
typealias CopyType
func copy() -> CopyType
}
class A: Copyable {
var x: Int
init(x: Int) { self.x = x }
func copy() -> A {
You can’t perform that action at this time.