Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chriseidhof
chriseidhof / swiftui.swift
Last active March 15, 2023 06:53
SwiftUI - iOS
import Combine
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
import Foundation
import SwiftUI
import UIKit
import os.log
import os
@tbranyen
tbranyen / canvas.js
Created February 2, 2012 18:07
Lightweight canvas wrapper.
// Basic Usage:
//
// var main = new Canvas({ elem: "canvas" }, function(options) {
// // Instantiate anything specific here...
// // Main draw loop
// this.draw = function() {
//
// };
// });
//
/// Similar to a `Binding`, but this is also observable/dynamic.
@propertyDelegate
@dynamicMemberLookup
final class Derived<A>: BindableObject {
let didChange = PassthroughSubject<A, Never>()
fileprivate var cancellables: [AnyCancellable] = []
private let get: () -> (A)
private let mutate: ((inout A) -> ()) -> ()
init(get: @escaping () -> A, mutate: @escaping ((inout A) -> ()) -> ()) {
self.get = get
define([
// jquery core is always required
'jquery/core',
// jquery utilities
'jquery/ajax',
'jquery/data'
], function(jq, ajax, data) {
// Use an AMD package here to gain access to nested internal modules.
require.config({
packages: [{
name: "jquery",
location: "vendor/jquery/src",
main: "index.js"
}]
});
// If we are using AMD, we don't care about core.
if (!HTMLVideoElement.prototype.canPlayType) {
HTMLVideoElement.prototype.canPlayType = function(type) {
return [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",