Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias Paumgarten roboshoes

View GitHub Profile
@roboshoes
roboshoes / Gulpfile.js
Last active Nov 11, 2015 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
View Gulpfile.js
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 / Default (Windows).sublime-keymap
Last active Dec 12, 2015
Personal Sublime Text 2 settings
View Default (Windows).sublime-keymap
[
{ "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 Dec 13, 2015
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…
View _cover-background.scss
@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 / index.js
Last active Mar 7, 2017
Find attribute in node or parent.
View index.js
// 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 / .bash_profile
Last active Mar 10, 2017
Personal terminal style
View .bash_profile
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 / shader-pass.js
Created Mar 20, 2017
A short implementation of a shader pass based on (mostly stolen from) https://github.com/stackgl/gl-particles
View shader-pass.js
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 );",
"}"
@roboshoes
roboshoes / append-license.js
Last active Apr 26, 2017
Appand Apache 2.0 license to all .js files found in a js folder
View append-license.js
const path = require( "path" );
const fs = require( "fs" );
const license = new Buffer( `/**
* Copyright 2016 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@roboshoes
roboshoes / Gulpfile.js
Last active May 15, 2017
Spawning a GAE dev_appserver.py using gulp wrapper.
View Gulpfile.js
const spawn = require( "child_process" ).spawn;
var server;
gulp.task( "gae", function() {
if ( server ) server.kill();
server = spawn( "python", [
'C:/Users/<your user>/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/dev_appserver.py',
"--port", "8080",
@roboshoes
roboshoes / Spherical.cs
Last active Nov 22, 2017
Implementation of spherical coordinates in C# (based on https://github.com/mrdoob/three.js/blob/master/src/math/Spherical.js)
View Spherical.cs
using UnityEngine;
public struct Spherical {
public float Radius;
public float Phi;
public float Theta;
Spherical( float radius = 1f, float phi = 0f, float theta = 0f ) {
Radius = radius;
@roboshoes
roboshoes / tween.js
Last active Jan 25, 2018
Small tweening function for the quick tween.
View tween.js
export function tween( time, update ) {
const start = Date.now();
var isCanceled = false;
var isComplete = false;
var chain = [];
function loop() {
if ( isCanceled ) return;