Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jtangelder
jtangelder / PreventGhostClick.js
Last active January 17, 2024 21:55
PreventGhostClick
/**
* Prevent click events after a touchend.
*
* Inspired/copy-paste from this article of Google by Ryan Fioravanti
* https://developers.google.com/mobile/articles/fast_buttons#ghost
*
* USAGE:
* Prevent the click event for an certain element
* ````
* PreventGhostClick(myElement);
// SmoothScroll for websites v1.2.1
// Licensed under the terms of the MIT license.
// People involved
// - Balazs Galambosi (maintainer)
// - Michael Herf (Pulse Algorithm)
(function(){
// Scroll Variables (tweakable)
@jtangelder
jtangelder / teletekst.py
Last active June 8, 2021 11:42
CLI teletekst.
import urllib.request
import urllib.error
import json
import re
import cmd
import html
def getTeletekstPage(page):
url = 'http://teletekst-data.nos.nl/json/%s' % (page)
res = urllib.request.urlopen(url)
@jtangelder
jtangelder / server.py
Created December 24, 2014 11:50
Python SimpleHTTPServer with HTML5 pushState support
#!/usr/bin/env python
# execute in the folder you want the server to run
# starts at port 80
import os
import urlparse
import SimpleHTTPServer
import SocketServer
@jtangelder
jtangelder / index.html
Last active June 5, 2017 11:48
Battery level volume control
<!DOCTYPE html>
<html>
<body>
<h1>Battery level volume control</h1>
<div id="player"></div>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
let player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
@jtangelder
jtangelder / push_service_worker.js
Created November 16, 2016 12:20
Twitter push serviceWorker
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// no_unit_test
module.exports = {
visible: function(client) { return client.visibilityState === 'visible'; },
topLevel: function(client) { return client.frameType === 'top-level'; },
focused: function(client) { return client.focused; },
urlEndsWith: function(endsWith) {
return function(client) { return client.url.endsWith(endsWith); };
}
};
@jtangelder
jtangelder / createResource.js
Last active March 20, 2016 17:55
Redux resources, untested
/*
Create (cacheable) resources, and endpoints that require some state that you want to hide from the
arguments, like a JWT for authenticating remote calls.
Returns a function that will be accepted by redux-thunk.
*/
/**
* create a redux-resource function
* @param {Function} remote(args, getState)

Keybase proof

I hereby claim:

  • I am jtangelder on github.
  • I am jtangelder (https://keybase.io/jtangelder) on keybase.
  • I have a public key ASCKQzxwTobC0hWn_XhXcj4xV7vaufd6s1ZVFlhlNF4Mbgo

To claim this, I am signing this object:

@jtangelder
jtangelder / modernizr.positionfixed.js
Created September 5, 2013 13:12
Modernizr position fixed check. A modified version of https://gist.github.com/bobslaede/1221602
;(function(Modernizr, window) {
Modernizr.addTest('positionfixed', function () {
var ret;
// no (solid) support on <Android2 and <iOS4
var ua = navigator.userAgent;
if(ua.match(/android [0-2]/i) || ua.match(/(iphone|ipad|ipod).+(OS [0-4])/i)) {
return false;
}
@jtangelder
jtangelder / jquery.raf.coffee
Last active December 21, 2015 22:38
hack jQuery to use requestAnimationFrame for animations
# hack jQuery to use requestAnimationFrame for animations
((win, $)->
# use Modernizr to get the (prefixed)DOM method
raf = Modernizr.prefixed('requestAnimationFrame', win)
if not raf
return
animating = false;