Skip to content

Instantly share code, notes, and snippets.

View roboshoes's full-sized avatar

Mathias Paumgarten roboshoes

View GitHub Profile
@roboshoes
roboshoes / touchmouse.js
Created April 13, 2012 10:43
This snippet maps mouse events and touch events onto one single event. This makes it easier in the code since you have to listen to only one event regardles whether it's desktop or mobile.
(function() {
/* == GLOBAL DECLERATIONS == */
TouchMouseEvent = {
DOWN: "touchmousedown",
UP: "touchmouseup",
MOVE: "touchmousemove"
}
/* == EVENT LISTENERS == */
@roboshoes
roboshoes / Default (Windows).sublime-keymap
Last active December 12, 2015 04:49
Personal Sublime Text 2 settings
[
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+e"], "command": "encode_html_entities" }
]
@roboshoes
roboshoes / _cover-background.scss
Last active December 13, 2015 22:09
This let's you set a background image with background-size set to cover and have it working down to IE8 (I believe also IE7?!). It's based on SCSS and uses Compass (http://compass-style.org/). There is one little flaw: while the `url()` is reltive to the css file the filter is relative to the HTML document. The whole "../../" is not really clean…
@mixin cover-background( $path ) {
background-image: url( "../../" + $path );
@include background-size( cover );
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $path + "', sizingMethod='scale')";
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="", sizingMethod="scale");
}
@roboshoes
roboshoes / .bash_profile
Last active March 10, 2017 19:54
Personal terminal style
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='\nubi ${debian_chroot:+($debian_chroot)}\[\033[00;33m\]\u \[\033[00;32m\]\w\[\033[00;36m\]$(parse_git_branch)\[\033[00m\]:\n➜ '
@roboshoes
roboshoes / Gulpfile.js
Last active November 11, 2015 20:08 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
var gulp = require( "gulp" );
var spawn = require( "child_process" ).spawn;
var node;
gulp.task( "server", function() {
if ( node ) node.kill();
node = spawn( "node", [ "app.js" ], { stdio: "inherit" } );
@roboshoes
roboshoes / package.json
Created July 27, 2016 18:11
NPM Scripts only build process for: TypeScript + Browserify, Jade, Less and serving and watching through Lite Server
{
"name": "",
"version": "0.1.0",
"scripts": {
"start": "npm run all && concurrently \"npm run tsc:w\" \"npm run less:w\" \"npm run watchify\" \"npm run lite\" \"npm run pug:w\" ",
"all" : "npm run prep && npm run assets && tsc && npm run browserify && npm run pug",
"lite": "lite-server public",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
@roboshoes
roboshoes / tween.js
Last active January 25, 2018 18:19
Small tweening function for the quick tween.
export function tween( time, update ) {
const start = Date.now();
var isCanceled = false;
var isComplete = false;
var chain = [];
function loop() {
if ( isCanceled ) return;
@roboshoes
roboshoes / index.html
Last active February 16, 2019 09:24
Basic setup with no dependencies to render fullscreen fragment shaders.
<!DOCTYPE html>
<html>
<head>
<style>
html, body {
margin: 0;
padding: 0;
overflow: hidden;
}
@roboshoes
roboshoes / index.js
Last active March 7, 2017 03:36
Find attribute in node or parent.
// find attribute
export function findInParent( node, attribute, levels = Infinity ) {
return node.getAttribute( attribute ) ||
( levels > 0 ? findInParent( node.parentElement, attribute, --levels ) : null );
}
// find anything
export function findInParent( node, filter, levels = Infinity ) {
return filter( node ) ||
@roboshoes
roboshoes / shader-pass.js
Created March 20, 2017 02:29
A short implementation of a shader pass based on (mostly stolen from) https://github.com/stackgl/gl-particles
import drawTriangle from "a-big-triangle";
import createShader from "gl-shader";
import createFBO from "gl-fbo";
const vertex = [
"precision mediump float;",
"attribute vec2 position;",
"void main() {",
" gl_Position = vec4( position, 1, 1 );",
"}"