Skip to content

Instantly share code, notes, and snippets.

View tigerhawkvok's full-sized avatar

Philip Kahn tigerhawkvok

View GitHub Profile
@tigerhawkvok
tigerhawkvok / stringify.js
Last active December 27, 2015 23:39
Stringify implementation -- played with after speaking with Andrew about it
function stringify(o) {
var c=new Array;
$.each(o,function(key,val){
if(typeof(val)!='object' || Array.isArray(val)) c.push(clean(key)+':'+clean(val));
else c.push(clean(key)+':'+stringify(val));
});
return "{"+c.join(",")+"}";
}
function clean(string) {
return escape(string).split('"').join('\"');
@tigerhawkvok
tigerhawkvok / _quinput.py
Last active February 26, 2019 21:58
Cross-Platform Python getch, with a Y/N module for interpreter prompts.
"""
Python 2 and Python 3 input wrapper with helper Yes/No class for feedbackless boolean input
@author Philip Kahn
@date 2016
"""
class _qinput:
"""Take care of the changes in inputs between Python 2 and 3, as well as enabling a getch-like functionality"""
def __init__(self):
try:
@tigerhawkvok
tigerhawkvok / loadJQuery.js
Last active August 29, 2015 13:57
If jQuery isn't already loaded, keep trying with fallbacks.
/***
* See https://gist.github.com/tigerhawkvok/9673154 for the latest version
* Put any functions you want to load at the very end in a public function named loadLast().
***/
function cascadeJQLoad(i) { // Use alternate CDNs where appropriate to load jQuery
if (typeof(i) != "number") i = 0;
// the actual paths to your jQuery CDNs. You should also have a local version here.
var jq_paths = [
"ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js",
@tigerhawkvok
tigerhawkvok / Cakefile
Last active August 29, 2015 14:01
Cakefile
# Snatched and tweaked from
# https://gist.github.com/jrmoran/1537200
fs = require 'fs'
{exec, spawn} = require 'child_process'
# order of files in `inFiles` is important
config =
srcDir: 'coffee'
outDir: 'js'
@tigerhawkvok
tigerhawkvok / FCCLetter.md
Last active August 29, 2015 14:01
Letter to the FCC

I'm sorry to say your proposed rules are a farce.

You claim:

If the network operator slowed the speed below that which the consumer bought it would be commercially unreasonable and therefore prohibited. If a network operator blocked access to lawful content it would violate our no-blocking rule and be commercially unreasonable and therefore be doubly prohibited.

Except you must have no concept of the weasel-words that ISPs use. You cannot buy bandwidth in the US. You buy "up-to" bandwidth. 1 kbps is still "up to" 1 Gbps. A two-tiered, have-and-have-not interent is absolutely allowed in your proposal.

ISPs say:

@tigerhawkvok
tigerhawkvok / RUNME.bat
Last active August 29, 2015 14:01
Infinite screenshots
python infinite_screenshots.py
pause
@tigerhawkvok
tigerhawkvok / delete-remote-tags.sh
Created June 10, 2014 20:01
Delete all remote tags
#!/bin/sh
# From http://isabelcastillo.com/bulk-delete-tags-in-local-git-repo-and-github-com
git ls-remote --tags origin | awk '/^(.*)(\s+)(.*[a-zA-Z0-9])$/ {print ":" $2}' | xargs git push origin
@tigerhawkvok
tigerhawkvok / expanded_view.xml
Created April 7, 2015 19:30
Wine Expanded View for StackOverflow
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="20sp"
card_view:cardPreventCornerOverlap="true"
@tigerhawkvok
tigerhawkvok / toTitleCase.coffee
Last active August 29, 2015 14:22
CoffeeScript toTitleCase
String::toTitleCase = ->
# From http://stackoverflow.com/a/6475125/1877527
str =
@replace /([^\W_]+[^\s-]*) */g, (txt) ->
txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
# Certain minor words should be left lowercase unless
# they are the first or last words in the string
lowers = [
"A"
@tigerhawkvok
tigerhawkvok / loadJS.coffee
Created May 27, 2015 20:20
Load Javascript file after page load
loadJS = (src, callback = new Object(), doCallbackOnError = true) ->
###
# Load a new javascript file
#
# If it's already been loaded, jump straight to the callback
#
# @param string src The source URL of the file
# @param function callback Function to execute after the script has
# been loaded
# @param bool doCallbackOnError Should the callback be executed if