Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Osterloh rosterloh

View GitHub Profile
@rosterloh
rosterloh / ga_error.js
Created Apr 14, 2014
Track Errors with Google Analytics
View ga_error.js
// Track basic JavaScript errors
window.addEventListener('error', function(e) {
_gaq.push([
'_trackEvent',
'JavaScript Error',
e.message,
e.filename + ': ' + e.lineno,
true
]);
});
@rosterloh
rosterloh / angular-socket-io.js
Created Apr 24, 2014
Custom factory for AngularJS Socket.io service
View angular-socket-io.js
factory('socket', ['$rootScope', 'io', function($rootScope, io) {
var socket = io.connect(),
events = {},
that = {};
var addCallback = function(name, callback) {
var event = events[name],
wrappedCallback = wrapCallback(callback);
if (!event) {
@rosterloh
rosterloh / socket.js
Created May 2, 2014
The world's most basic socket.io AngularJS factory
View socket.js
appServices.factory('socket', function ($rootScope) {
var socket = io.connect('http://localhost:3000');
return {
on: function (eventName, callback) {
socket.on(eventName, function () {
var args = arguments;
$rootScope.$apply(function () {
callback.apply(socket, args);
});
});
View split_bootimg.pl
#!/usr/bin/perl
######################################################################
#
# File : split_bootimg.pl
# Author(s) : William Enck <enck@cse.psu.edu>
# Description : Split appart an Android boot image created
# with mkbootimg. The format can be found in
# android-src/system/core/mkbootimg/bootimg.h
#
# Thanks to alansj on xda-developers.com for
@rosterloh
rosterloh / androidVersion.java
Created Jun 19, 2014
Gist for checking device android version
View androidVersion.java
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
AlertDialog.Builder dialog = new AlertDialog.Builder(BlueBand.this);
dialog.setTitle("Error");
dialog.setMessage("Support Android 4.3 or above only.");
dialog.setNegativeButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.exit(0);
@rosterloh
rosterloh / angular-socket.js
Created Aug 18, 2014
Angular Socket.io provider
View angular-socket.js
/*
* Provider for Socket.io service
* first argument is the name of the service (not the name of the provider!) and second one is the constructor function for the provide
*/
//angular.module('module').provider('$socket', $socketProvider() {
var angular.module('socket.io', []);
module.provider('$socket', function $socketProvider() {
var ioUrl = '';
var ioConfig = {};
this.setConnectionUrl = function setConnectionUrl(url) {
View main-ctrl.js
(function () {
'use strict';
/**
* @class MainCtrl
* @classdesc Main Controller for doing awesome things
* @ngInject
*/
function MainCtrl ($scope, SomeFactory) {
@rosterloh
rosterloh / android-setup.sh
Created Aug 21, 2014
Setup script for Android build server
View android-setup.sh
#!/bin/bash
###########################################################################################
# Complete Nameless setup script for Debian/Ubuntu Systems #
###########################################################################################
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
export CCACHE_DIR=/home/ccache
sed -i 's/main$/main universe/' /etc/apt/sources.list
apt-get -qq update
apt-get install -y python-software-properties software-properties-common bsdmainutils curl file screen ccache
apt-get purge openjdk-\* icedtea-\* icedtea6-\* -y
@rosterloh
rosterloh / app.js
Created Aug 27, 2014
Deep linking a tabbed UI
View app.js
(function(){
var app = angular.module("routedTabs", ["ui.router", "ui.bootstrap"]);
app.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/main/tab1");
$stateProvider
.state("main", { abtract: true, url:"/main", templateUrl:"main.html" })
@rosterloh
rosterloh / scan.js
Created Sep 4, 2014
Node.js Port Scan Function
View scan.js
var child = require("child_process");
var async = require("async");
var net = require("net");
var os = require("os");
function scan(port, cb){
var hosts = {};
var result = [];
async.series([
function scan(next, c){