Skip to content

Instantly share code, notes, and snippets.

View crsnbrt's full-sized avatar

Carson Britt crsnbrt

View GitHub Profile
/*
* A concatination and minification of THREE.js shaders and postprocessing scripts
* these are not included in the core threejs package,
* the purpose of this gist is to simplify including multiple scripts on codepen.
*/
//http://threejs.org/examples/js/shaders/CopyShader.js
THREE.CopyShader={uniforms:{tDiffuse:{type:"t",value:null},opacity:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")};
//http://threejs.org/examples/js/shaders/RGBShiftShader.js
THREE.RGBShiftShader={uniforms:{tDiffuse:{type:"t",value:null},amount:{type:"f",value:.005},angle:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( posi
@crsnbrt
crsnbrt / Death Star Trench Run.markdown
Created January 4, 2016 15:28
Death Star Trench Run
@crsnbrt
crsnbrt / index.html
Last active December 23, 2015 15:21
ojVWdR
ul.controls
li: button#info Info
li: button#reset Generate
li: button#options Options
.info.module.hidden
p Change some options and regenerate the city!
.options.module.hidden
section
@crsnbrt
crsnbrt / wp-config.json
Last active August 8, 2016 03:33
Script to generate instance of Wordpress from config file with wp-cli tools. Used in build/CI process to keep Wordpress core files of of your repo. Assumes your repo has "plugins/", "themes/", and "wp-config.json"
{
"version":"4.2.2",
"database":{
"dbhost":"127.0.0.1:3306",
"dbuser":"DB_USER",
"dbname":"DB_NAME",
"dbpass":"DB_PASS"
},
"plugins": [
{ "name":"wordpress-importer", "version": "0.6.1" }
@crsnbrt
crsnbrt / hackernews.css
Last active February 25, 2016 22:31
Some CSS snippets for use with custom css browser extensions i.e. stylebot, stylish, etc
body {
margin: 0;
}
.athing a:visited {
color: #B2B2B2;
}
#hnmain {
width: 100%;
@crsnbrt
crsnbrt / img_resize.py
Last active August 29, 2015 14:18
Batch resize a nested folder structure of images.
import os
from PIL import Image
from os.path import dirname
import_dir = './'
output_dir = './'
img_count = 0
file_count = 0
resize_count = 0
@crsnbrt
crsnbrt / img_compress.py
Last active August 29, 2015 14:09
Loop recursively through a directory and compress all image files using the TinyPng Api https://tinypng.com/developers
import os
from os.path import dirname
from urllib2 import Request, urlopen
from base64 import b64encode
compress_png = True
compress_jpg = True
import_dir = '<INPUT DIR>'
output_dir = "<OUTPUT DIR>"
tiny_png_key = '<API KEY>'
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@crsnbrt
crsnbrt / tracking.js
Last active September 27, 2019 09:21
Google Analytics Event Helper
//ga click helper
$('[data-tracking]').on('click', function(){
var track_string = $(this).data('tracking').toLowerCase();
if(!track_string){return false;}
var track_arr = track_string.split(",");
if(track_arr.length < 2){return false;}
var category = track_arr[0];
var action = track_arr[1];
@crsnbrt
crsnbrt / bluetooth.ino
Last active August 29, 2015 14:07
Arduino sketch for intercepting digital inputs of four buttons and broadcasting a corresponding serial value via Bluetooth.
const char BUTTON_CHARS[] = {(char)48, (char)49, (char)50, (char)51};
const int BUTTON_COUNT = 4;
const int BUTTON_PINS[] = {4, 5, 6, 7};
int button_states[] = {0, 0, 0, 0};
int button_last_states[] = {0, 0, 0, 0};
void setup() {
pinMode(BUTTON_PINS[0], INPUT);
pinMode(BUTTON_PINS[1], INPUT);
pinMode(BUTTON_PINS[2], INPUT);