Skip to content

Instantly share code, notes, and snippets.

View tigerhawkvok's full-sized avatar

Philip Kahn tigerhawkvok

View GitHub Profile
@tigerhawkvok
tigerhawkvok / StringUnescaper.coffee
Last active March 4, 2016 21:04
Unescape even fairly mutilated escaped string in Javascript
String::unescape = (strict = false) ->
###
# Take escaped text, and return the unescaped version
#
# @param string str | String to be used
# @param bool strict | Stict mode will remove all HTML
#
# Test it here:
# https://jsfiddle.net/tigerhawkvok/t9pn1dn5/
#
@tigerhawkvok
tigerhawkvok / restartAudio.bat
Created March 4, 2016 20:30
Restart Windows Audio Service (with admin permissions, if needed)
rem Written for buggy audio drivers that need to be restarted
rem In my case, the Claro 8.18 drivers bug out every once in a while on Windows 10, and need restarting to not sound poppy
@echo off
goto check_Permissions
:check_Permissions
echo Administrative permissions required to run this script. Checking...
net session >nul 2>&1
@tigerhawkvok
tigerhawkvok / polymerHelper.coffee
Created July 28, 2015 04:21
Workaround for lack of paper-dropdown
bindPaperMenuButton = (selector = "paper-menu-button", unbindTargets = true) ->
###
# Use a paper-menu-button and make the
# .dropdown-label gain the selected value
#
# Reference:
# https://github.com/polymerelements/paper-menu-button
# https://elements.polymer-project.org/elements/paper-menu-button
###
for dropdown in $(selector)
@tigerhawkvok
tigerhawkvok / README.md
Last active August 29, 2015 14:23
EBV Shipping estimator

Hey guys!

I've showed most of you guys this, but here's the breakdown:

http://eastbayvivarium.com/shipping-estimator.html

First things first, enter the weight of the animal. It defaults to grams, but tapping the toggle will change the entry to pounds.

@tigerhawkvok
tigerhawkvok / api.php
Created June 10, 2015 05:24
Easypost Integration
<?php
/***
* Target file for asynchronous hits
***/
if(isset($_SERVER['QUERY_STRING'])) parse_str($_SERVER['QUERY_STRING'],$_GET);
require_once('./core/core.php');
<!-- BROWSE HAPPY BEGINS HERE -->
<style>
.browsehappy {
display:block;
width:100%;
height:100px;
background-color:#f2dede;
margin: 0 0 10px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 22px;
@tigerhawkvok
tigerhawkvok / core.coffee
Last active August 29, 2015 14:22
Core Coffeescript helper functions
# Set up basic URI parameters
# Uses
# https://github.com/allmarkedup/purl
try
uri = new Object()
uri.o = $.url()
uri.urlString = uri.o.attr('protocol') + '://' + uri.o.attr('host') + uri.o.attr("directory")
uri.query = uri.o.attr("fragment")
catch e
console.warn("PURL not installed!")
@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
@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 / 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"