Skip to content

Instantly share code, notes, and snippets.

View rosterloh's full-sized avatar

Richard Osterloh rosterloh

View GitHub Profile
@rosterloh
rosterloh / ga_error.js
Created April 14, 2014 08:30
Track Errors with Google Analytics
// 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 April 24, 2014 09:20
Custom factory for AngularJS Socket.io service
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 13:00
The world's most basic socket.io AngularJS factory
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);
});
});
#!/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 June 19, 2014 12:55
Gist for checking device android version
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 August 18, 2014 13:20
Angular Socket.io provider
/*
* 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) {
@rosterloh
rosterloh / android-setup.sh
Created August 21, 2014 08:08
Setup script for Android build server
#!/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
(function () {
'use strict';
/**
* @class MainCtrl
* @classdesc Main Controller for doing awesome things
* @ngInject
*/
function MainCtrl ($scope, SomeFactory) {
@rosterloh
rosterloh / app.js
Created August 27, 2014 11:49
Deep linking a tabbed UI
(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 September 4, 2014 12:57
Node.js Port Scan Function
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){