Skip to content

Instantly share code, notes, and snippets.

View sortofsleepy's full-sized avatar

Joe sortofsleepy

View GitHub Profile
@sortofsleepy
sortofsleepy / default3.2+shader
Last active August 29, 2015 13:57
A bare minimum set of shaders necessary to get something rendering in OpenGL 3.2+
/** ======= VERTEX SHADER ==============*/
#version 150
in vec4 position;
in vec2 texcoord;
uniform mat4 modelViewProjectionMatrix;
# WHY IS THIS DATA LIKE THIS BAY AREA BIKE SHARE!!!!??????
{
#INSTEAD OF 79707 WHY CAN IT NOT JUST SAY "Trip ID" LIKE IN THE README???
"79707":79709,
"453":582,
"11/1/2013 9:23":"11/1/2013 9:24",
"South Van Ness at Market":"Temporary Transbay Terminal (Howard at Beale)",
"66":55,
"11/1/2013 9:31":"11/1/2013 9:34",
@sortofsleepy
sortofsleepy / html
Created July 22, 2014 01:16
$watch testing
<div ng-app="watchApp" ng-controller="watchCtrl">
<div ng-repeat="a in b">
<input type="text" ng-model="a.value" />{{a.value}}
</div>
<div ng-repeat="a in c">
<input type="text" ng-model="a.value" />{{a.value}}
</div>
@sortofsleepy
sortofsleepy / Infinite sine wave
Last active August 29, 2015 14:17
A attempt at making a sine wave draw continuously. Nearly there! but needs a bit of work.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="rStats.css"/>
<style>
canvas{
position: absolute;
/**
* A THREE.js representation of a SVG. Can convert
* SVG shapes into THREE.Mesh(s).
*
* TODO two.js integration may prove unnecessary later. Also, it's unclear how complex SVGs will look.
*
* Also note - things might not line up exactly, subtract 1/2 viewbox width/height from position
* to get the proper 0,0 position
*
* @param shapeid id of the svg or (later on down the line)path to svg
// Create the points of our cube
Vec3f v0(-100,-100,-100);
Vec3f v1( 100,-100,-100);
Vec3f v2( 100, 100,-100);
Vec3f v3(-100, 100,-100);
Vec3f v4(-100,-100, 100);
Vec3f v5( 100,-100, 100);
Vec3f v6( 100, 100, 100);
Vec3f v7(-100, 100, 100);
// Create the colors for each vertex
uniform float amplitude;
attribute float displacement;
varying vec3 vNormal;
varying vec2 vUv;
void main() {
vNormal = normal;
varying vec3 vNormal;
varying vec2 vUv;
uniform vec3 color;
uniform sampler2D texture;
void main() {
vec3 light = vec3( 0.5, 0.2, 1.0 );
light = normalize( light );
//by @kindofsleepy
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
@sortofsleepy
sortofsleepy / gist:6216833
Created August 13, 2013 00:50
In a list of items, this figures out where then end of a row is at any particular given time. 1. box_width = the width of a item in the list 2. work_width = the width of the container for the list
/*
Based on the item you click on, this function
figures out the ending index of that particular item's row.
*/
function getRow(index){
//this is the number of items that can fit in a row
var row = Math.floor(box_width / work_width);
//var insertpoint = index + row;