Skip to content

Instantly share code, notes, and snippets.

View tigerhawkvok's full-sized avatar

Philip Kahn tigerhawkvok

View GitHub Profile
@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!")
<!-- 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 / 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');
@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 / 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 / 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 / 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 / pandoc_convert.command
Created November 12, 2016 19:19
Convert all HTML files into Markdown files in a given directory
#!/bin/bash
find . -type f -iregex .*\.html$ | while read line
do
printf 'Converting >>>%s<<<\n' "$line"
P_MD=${line%".html"}.markdown
pandoc --ignore-args -r html -w markdown < "${line}" | awk 'NR > 130' | sed '/<div class="site-info">/,$d' > "${P_MD}"
done
@tigerhawkvok
tigerhawkvok / urlMatch.coffee
Last active March 29, 2017 03:14
Basic Web URL validation
###
# This was created as part of an attempt to handle well-formatted but regular URL input from the client
#
# In my specific use case, it was just fetching license URLs so it frankly just needed to work for
# Creative Commons, GPL, MIT, and other common license URLS
#
# Longer, more robust patterns like
# https://gist.github.com/gruber/8891611
#
# Were proving fussy when integrating a pattern with <paper-input>
@tigerhawkvok
tigerhawkvok / noExponents.coffee
Created May 11, 2017 22:16
Remove exponents from a number in scientific notation, and return "normal" values
String::noExponents = (explicitNum = true) ->
###
# Remove scientific notation from a number
#
# After
# http://stackoverflow.com/a/18719988/1877527
###
data = @.split /[eE]/
if data.length is 1
return data[0]