Skip to content

Instantly share code, notes, and snippets.

an experiment in strategizing semantle-like puzzles
(adjective, value)
good
(bad)
(adverb, value)
yes
(no)
@joseph
joseph / WKWebViews+keyboardRequiresUserInteraction.swift
Last active October 23, 2017 16:03 — forked from Pranit-Harekar/WKWebViews+keyboardRequiresUserInteraction.swift
Add keyboardRequiresUserInteraction to WKWebViews
import WebKit
// This swizzle allows JavaScript to set the focus on an input, not just when a user is interacting.
//
extension WKWebView {
private typealias StartAssistingNodeMethodType = @convention(c) (Any, Selector, UnsafeRawPointer, Bool, Bool, Any) -> Void
private typealias StartAssistingNodeClosureType = @convention(block) (Any, UnsafeRawPointer, Bool, Bool, Any) -> Void
func focusInputsWithoutUserInteraction() {
@joseph
joseph / touch_hound.js
Created October 13, 2014 16:41
TouchHound translates touch events back into iframes, for iOS8 home screen app workaround
define(function (require) {
var Gala = require('gala');
var C = require('common');
var TouchHound = function (element) {
this._ = {};
this._.element = element;
var handle = this._handleEvent.bind(this);
this._.handler = new Gala.ContactHandler(
@joseph
joseph / klass4.js
Last active August 29, 2015 13:57
JS class pattern [4]
// AMD module definition:
define(function (require) {
// An instantiable class:
var ClassName = function () {
// All private instance data is stored in this._
this._ = {};
this._initialize();
}, PROTO = ClassName.prototype;
@joseph
joseph / klass3.js
Created March 25, 2014 21:18
JS class pattern [3]
// AMD module definition:
define(function (require) {
// An instantiable class:
var ClassName = function () {
// All private instance data is stored in this._
this._ = {};
this._initialize();
};
@joseph
joseph / klass2.js
Last active August 29, 2015 13:57
JS class pattern [2]
// AMD module definition:
define(function (require) {
// An instantiable class:
var K = function () {
this._initialize();
this._p = {};
};
@joseph
joseph / klass1.js
Last active August 29, 2015 13:57
JS class pattern [1] — "KIP"
// AMD module definition:
define(function (require) {
// An instantiable class:
var K = function () {
// This represents the public interface for the object.
var I = this;
// Properties of the object:
var P = I._p = {};
@joseph
joseph / gist:6981446
Created October 14, 2013 20:10
The first function is specific to my Monocle-based app. But the second one is arguably useful, despite the name. It creates an AudioBuffer of the smallest viable mp3 (per http://www.hydrogenaudio.org/forums//lofiversion/index.php/t26315.html) and plays it immediately. You would invoke this from a click or touch event to "unlock" the AudioContext…
function panderToMobileSafari() {
if (!Monocle.Browser.is.MobileSafari || p.pandered) { return; }
oneHandClapping(p.context);
p.pandered = true;
debug('Pandered to MobileSafari.');
}
function oneHandClapping(audioCtx) {
var arr = [
@joseph
joseph / audlbls-to-smil.rb
Created October 11, 2013 14:04
A guileless script for converting Audacity labels to SMIL, with very little configurability.
#!/usr/bin/env ruby
file_path = ARGV.shift
base_name = File.basename(file_path, '.txt')
html_file = base_name+'.html'
sound_file = 'audio/'+base_name+'.mp3'
out = %Q`<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL"
xmlns:epub="http://www.idpf.org/2007/ops"
@joseph
joseph / .master.screenrc
Created September 26, 2012 08:23
Screen for vagrant
#==============================================================================
# MASTER SCREENRC FILE
# This contains the default 'screen' settings I like to use across all
# environments.
# Created: 4 Nov 2006
# Author: Joseph Pearson
# Based to a greater or lesser extent on various resources on the 'net.
#------------------------------------------------------------------------------
startup_message off