Skip to content

Instantly share code, notes, and snippets.

View dustintheweb's full-sized avatar
🎯
Focusing

Dustin Hoffmann dustintheweb

🎯
Focusing
View GitHub Profile
@dustintheweb
dustintheweb / convert-svg-png
Created May 1, 2014 21:05
Batch Convert SVG to PNG (transparent/ alpha) using ImageMagick
// ImageMagick - Convert SVG to PNG w/ transparency
//
// - open terminal
//
// - confirm you have imagemagick installed
// --- type: convert -v
//
// - cd to folder
//
// - single file
@dustintheweb
dustintheweb / google-app-engine-cloud-git-sourcetree.md
Last active November 26, 2021 08:13
Set up a Google Cloud Git Repo in SourceTree

###Setting up a Google Cloud Git Repo // now with SourceTree bonus!
*Note: this guide is relavent only to repos natively hosted on Google Cloud


**Prereq:** - OSX - SourceTree - git - A Google App Engine / Cloud project
@dustintheweb
dustintheweb / force-safari-to-redraw.js
Created March 24, 2014 22:33
Force Safari to redraw when it's being a slow idiot
var someFn = function() {
$('<style></style>').appendTo($(document.body)).remove(); // force safari redraw
};
@dustintheweb
dustintheweb / horizontal-skroll-shim.js
Last active September 15, 2020 14:59
Simulate a horizontal touch scroll event in skrollr.js
// >> Horizontal Touch Scroll Simulator >>>>>>>>>>>>>>>
// prereq: skrollr.js: https://github.com/Prinzhorn/skrollr
function fakeHorzScroll(){
var tStartX, tStopY, touch, mXPos, xPro;
$(window).bind('touchstart', function(e) {
tStartX = e.originalEvent.touches[0].pageX;
e.preventDefault();
@dustintheweb
dustintheweb / simple-parallax.js
Created October 13, 2018 19:13
Simple Parallax
const main = {};
const updateScroll = () => {
main.winScroll = $(window).scrollTop();
};
const parallaxLoad = () => {
const $someEl = $('.someEl');
$someEl.each((i,el) => {
let $el = $(el);
@dustintheweb
dustintheweb / in-viewport.js
Last active October 13, 2018 18:59
Elements in Viewport Fn
const main = {};
const inViewport = ($el) => {
let winTop = main.winScroll;
let winBtm = winTop + main.winHeight;
let $elTop = $el.offset().top;
let $elBtm = $elTop + $el.outerHeight();
return $elBtm > winTop && $elTop < winBtm;
}
if (inViewport($el) === true) {
@dustintheweb
dustintheweb / scroll-direction.js
Created October 13, 2018 18:56
Scroll Direction Fn
const main = {};
const updateScroll = () => {
main.winScroll = $(window).scrollTop();
if (!main.winScrollMem) {
main.winScrollMem = 0;
}
if (main.winScroll > main.winScrollMem) {
main.winScrollDir = 'down';
} else {
main.winScrollDir = 'up';
@dustintheweb
dustintheweb / index.html
Created February 28, 2015 11:43
AngularJS: Multiple ternary statements in ng-class
<!doctype html>
<html ng-app="myApp">
<head>...</head>
<body ng-controller="myController" ng-class="(toggleClass1 ? 'class-1' : '')+' '+(toggleClass2 ? 'class-2' : '')">
<div>
stuff...
<div class="button1" ng-click="$toggleClass1 = !$toggleClass1"></div>
stuff...
<div class="button2" ng-click="$toggleClass2 = !$toggleClass2"></div>
</div>
@dustintheweb
dustintheweb / stock-android-browser-check.js
Created July 8, 2013 22:03
Check if the browser user agent is the stock android browser.
// Stock Android Browser Check >>>>>>>>>>>>>>>>
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1 && ua.indexOf("mobile") && ua.indexOf("chrome")==-1
if(isAndroid) {
// stuff
}
@dustintheweb
dustintheweb / 29392738.md
Created April 2, 2015 16:32
Solution: Correctly configuring a static site with advanced routing - http://stackoverflow.com/posts/29392738

Ok I finally have this figured out.

First off, if you aren't familiar with the way GAE handles templating... it's a bit different than you would expect, but a pillar of getting this to work correctly.

This is what you want at the bottom of your app.yaml

- url: /
  static_files: dist/index.html
  upload: dist/index.html

expiration: "15m"