Skip to content

Instantly share code, notes, and snippets.

View rosterloh's full-sized avatar

Richard Osterloh rosterloh

View GitHub Profile
@rosterloh
rosterloh / index.js
Last active August 29, 2015 14:06
Node upload progress report
fs = require('fs');
http.createServer(function(request, response) {
var newFile = fs.createWriteStream('readme_copy.md');
var fileBytes = request.headers['content-length'];
var uploadedBytes = 0;
request.pipe(newFile);
request.on('data', function(chunk) {
@rosterloh
rosterloh / controller.js
Created October 1, 2014 08:43
Ble Multi device
$scope.onError = function(err) {
console.log('Error: '+err);
};
$scope.onData = function(id, data) {
console.log(data+' from '+id);
var a = new Uint8Array(data);
};
var Peripheral = function (deviceId) {
@rosterloh
rosterloh / links.scss
Created October 6, 2014 14:00
Using colour functions in sass
@rosterloh
rosterloh / header.java
Created October 17, 2014 17:09
Android developer javadoc template for Android Studio (Settings->IDE Settings->File and Code Templates->Includes)
/**
* @author Richard Osterloh <richard.osterloh.com>
* @version 1
* @since ${DATE}.
*/
@rosterloh
rosterloh / compareTo.js
Created October 20, 2014 07:07
Confirm Password Validation in AngularJS
var compareTo = function() {
return {
require: "ngModel",
scope: {
otherModelValue: "=compareTo"
},
link: function(scope, element, attributes, ngModel) {
ngModel.$validators.compareTo = function(modelValue) {
return modelValue == scope.otherModelValue;
@rosterloh
rosterloh / alias.sh
Created October 23, 2014 08:17
Useful bash alias list
# paste in bashrc
alias ls="ls --color=auto"
alias ll="ls --color -al"
alias grep='grep --color=auto'
# md5check [file] [key]
md5check() { md5sum "$1" | grep "$2";}
# Generate strong password
alias genpasswd="strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo"
@rosterloh
rosterloh / CMakeLists.txt
Last active August 29, 2015 14:08
Makefile for GCC MBED development on the Nordic NRF51882
#
# CMake configuration
#
# Please refer to http://www.cmake.org/cmake/help/documentation.html
# You may also refer to http://www.cmake.org/cmake/help/syntax.html for a quick
# introduction to CMake's syntax.
cmake_minimum_required (VERSION 2.8)
# The name of our project is "BLE_HEART_RATE". CMakeLists files in this project can
@rosterloh
rosterloh / download.html
Created October 27, 2014 07:46
Javascript - Creating a downloadable file
<!DOCTYPE html>
<html>
<head>
<style type="text/css">...</style>
<script type="text/JavaScript">
window.onload = function() {
var txt = document.getElementById('txt');
txt.value = window.onload + '';
document.getElementById('link').onclick = function(code) {
this.href = 'data:text/plain;charset=utf-8,'
@rosterloh
rosterloh / Part1.java
Created October 27, 2014 22:45
WikiBrain Spacial Computing Assignment
package org.wikibrain.cookbook.MOOC;
import com.vividsolutions.jts.geom.Geometry;
import gnu.trove.iterator.TIntIterator;
import gnu.trove.set.TIntSet;
import org.geotools.referencing.GeodeticCalculator;
import org.wikibrain.conf.ConfigurationException;
import org.wikibrain.conf.Configurator;
import org.wikibrain.core.cmd.Env;
import org.wikibrain.core.cmd.EnvBuilder;
import android.transition.AutoTransition;
import android.transition.Scene;
import android.transition.Transition;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.RelativeLayout;
import android.transition.TransitionManager;
public class TransitionsActivity extends Activity {