Skip to content

Instantly share code, notes, and snippets.

View gregkepler's full-sized avatar

Greg Kepler gregkepler

View GitHub Profile
@gregkepler
gregkepler / Mobile OS detection
Created October 22, 2014 20:25
Snippets for detecting if browser is on an android or iOS device
// is android
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1;
// ios detection
var isIOS = false;
var iDevice = ['iPad', 'iPhone', 'iPod'];
for ( i = 0 ; i < iDevice.length ; i++ ) {
if( navigator.platform === iDevice[i] ){
@gregkepler
gregkepler / vendor prefix
Created October 22, 2014 20:22
vendor prefix
// from http://davidwalsh.name/vendor-prefix
window.prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1],
dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
return {
@gregkepler
gregkepler / TweenLiteFileSave.as
Last active August 29, 2015 14:04
Flash save png sequence and manual advance timeline
// import TweenLite for tweening and TimelineLite for keeping track of tweens
import com.greensock.TimelineLite;
import com.greensock.TweenLite;
// import filestream classes for saving images to disk (available only in AIR SDK)
import flash.filesystem.*;
// import PNGEncoder (available here https://github.com/mikechambers/as3corelib)
import com.adobe.images.PNGEncoder;
@gregkepler
gregkepler / CinderTimerEventLoop.cpp
Created February 9, 2014 13:21
Timed Event loops - AS3 vs Cinder
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
#include "cinder/Timeline.h"
#include "cinder/Rand.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class CinderEventLoopApp : public AppBasic {
@gregkepler
gregkepler / lines.frag
Last active February 24, 2020 04:37
Starter fragment shader for basic repeatable lines
// ShaderToy Inputs
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iGlobalTime; // shader playback time (in seconds)
const float PI=3.14159265358979323846;
float round( float x ) {
float val = mod( x, x );
if( val >= 0.5 ){
return ceil( x );
@gregkepler
gregkepler / photos.json
Last active December 25, 2015 07:48
Saves all photos and videos in a json file of instagram photos.
// json file should be formatted something like
{
"data": {
"photos": [
{
...
"images": {
"low_resolution": {
"url": "http://distilleryimage3.s3.amazonaws.com/###_6.jpg",
"width": 306,
@gregkepler
gregkepler / JsonIosApp.cpp
Created July 4, 2013 00:36
Cinder app to demonstrate how the app crashes when run on iOS when it parses a json file containing a float.
#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
#include "cinder/Json.h"
using namespace ci;
using namespace ci::app;
using namespace std;
JsonTree queryData( const std::string &query );
@gregkepler
gregkepler / NoiseRangeTest.cpp
Created November 4, 2012 14:12
Cinder Noise Range Test
#include "cinder/app/AppBasic.h"
#include "cinder/Perlin.h"
#include "cinder/Rand.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class NoiseRangeTest : public AppBasic {
public:
@gregkepler
gregkepler / PathSimplify.cpp
Created June 29, 2012 20:36
Path Simplification Algorithm for use in Cinder C++ Framework
//
// PathSimplify.cpp
// PathFitter
//
// Created by Greg Kepler on 4/18/12.
// Copyright (c) 2012 The Barbarian Group. All rights reserved.
//
#include <iostream>
#include "PathSimplify.h"