Skip to content

Instantly share code, notes, and snippets.

View ptb's full-sized avatar

Peter T Bosse II ptb

View GitHub Profile
@ptb
ptb / gist:246dd516342c6a89152f
Created August 2, 2014 11:49
jQuery AJAX-only
grunt custom:-ajax/jsonp,-ajax/parseXML,-ajax/script,-attributes,-core/access,-core/init,-core/parseHTML,-core/ready,-css,-data,-deprecated,-dimensions,-effects,-event,-exports/global,-manipulation,-offset,-queue,-serialize,-sizzle,-traversing,-wrap
onEvent: (event) ->
event.preventDefault()
event.stopPropagation()
return if window.throttle
window.throttle = true
setTimeout (->
window.throttle = false
), 100
# throttled work here
(function(){var requirejs,require,define;(function(n){function r(n,t){return w.call(n,t)}function h(n,t){var o,s,f,e,h,p,c,b,r,l,w,u=t&&t.split("/"),a=i.map,y=a&&a["*"]||{};if(n&&n.charAt(0)===".")if(t){for(u=u.slice(0,u.length-1),n=n.split("/"),h=n.length-1,i.nodeIdCompat&&v.test(n[h])&&(n[h]=n[h].replace(v,"")),n=u.concat(n),r=0;r<n.length;r+=1)if(w=n[r],w===".")n.splice(r,1),r-=1;else if(w==="..")if(r===1&&(n[2]===".."||n[0]===".."))break;else r>0&&(n.splice(r-1,2),r-=2);n=n.join("/")}else n.indexOf("./")===0&&(n=n.substring(2));if((u||y)&&a){for(o=n.split("/"),r=o.length;r>0;r-=1){if(s=o.slice(0,r).join("/"),u)for(l=u.length;l>0;l-=1)if(f=a[u.slice(0,l).join("/")],f&&(f=f[s],f)){e=f,p=r;break}if(e)break;!c&&y&&y[s]&&(c=y[s],b=r)}!e&&c&&(e=c,p=b),e&&(o.splice(0,p,e),n=o.join("/"))}return n}function y(t,i){return function(){return u.apply(n,b.call(arguments,0).concat([t,i]))}}function k(n){return function(t){return h(t,n)}}function p(n){return function(i){t[n]=i}}function s(i){if(r(e,i)){var u=e[i];delete e
<!DOCTYPE html>
<html class='no-js' lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta charset='UTF-8' />
<title></title>
<meta content='initial-scale=1, maximum-scale=1, user-scalable=0, width=device-width' name='viewport' />
<style>
#calendar table {
font-weight: 700;
font-family: "Helvetica Neue", sans-serif;
@ptb
ptb / commit.sh
Last active August 29, 2015 14:01
Commit All File Changes to Git Repository, Automatically
#!/bin/sh
/usr/bin/find . -type d -empty -exec touch {}/.keep \;
/usr/local/bin/git add --all /Users/ptb/Copy/; /usr/local/bin/git commit --message='' --allow-empty-message
@ptb
ptb / respimg.rb
Created May 20, 2014 14:38
Command-line image resizer for Bootstrap grid
#!/usr/bin/env ruby
require 'pathname'
require 'optparse'
require 'ostruct'
require 'rmagick'
class RespImgs
CONTAINER_WIDTH = { xs: 320, sm: 750, md: 970, lg: 1170 }
NUM_COLUMNS = 12
@ptb
ptb / adblock-openwrt.sh
Last active February 24, 2017 14:08
OpenWRT pixelserv, dnsmasq, ad block
#!/bin/sh
DNSSERVER=172.16.1.1
/usr/bin/wget -qO- http://mvps.org/winhelp2002/hosts.txt | /bin/grep -v -e localhost -e=feeds.feedburner.com | /bin/grep '^0.0.0.0' | /bin/sed "s/^0\.0\.0\.0/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-1
/usr/bin/wget -qO- http://www.malwaredomainlist.com/hostslist/hosts.txt | /bin/grep -v -e localhost | /bin/grep '^127.0.0.1' | /bin/sed "s/^127\.0\.0\.1/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-2
/usr/bin/wget -qO- http://hosts-file.net/ad_servers.txt | /bin/grep -v -e localhost | /bin/grep '^127.0.0.1' | /bin/sed "s/^127\.0\.0\.1/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-3
/usr/bin/wget -qO- http://adaway.org/hosts.txt | /bin/grep -v -e localhost | /bin/grep '^127.0.0.1' | /bin/sed "s/^127\.0\.0\.1/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-4
/bin/cat /etc/hosts.block-1 /etc/hosts.block-2 /etc/hosts.block-3 /etc/hosts.block-4 | /bin/sed 's/
@ptb
ptb / application_controller.rb
Created April 9, 2014 14:43
Rails 4.1 Action Pack Variants for iOS and Android
class ApplicationController < ActionController::Base
before_action :detect_device_type
private
def detect_device_type
case request.user_agent
when /ip(hone|od)/i
request.variant = :ipod
when /android.+mobile/i
<!DOCTYPE html>
<html class='no-js' lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta charset='UTF-8' />
<title>April 2014</title>
<meta content='initial-scale=1, width=device-width' name='viewport' />
<style type='text/css'>
*, *::before, *::after {
box-sizing: border-box;
}
border-width: 0 0 1px
border-bottom-style: solid
border-bottom-color: #c8c7cc
/* :root.retina */
border-image-source: url("data:image/svg+xml;charset=utf-8,<svg height='1' width='1' xmlns='http://www.w3.org/2000/svg'><rect height='.5' width='1' y='.5' fill='%23c8c7cc'/></svg>")
border-image-slice: 0 0 1