Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Schwartz benschw

View GitHub Profile
@benschw
benschw / gist:5516070
Last active Dec 16, 2015
intercepting 401 responses from $http calls in AngularJS
View gist:5516070
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives'], function ($routeProvider, $locationProvider, $httpProvider) {
var interceptor = ['$rootScope', '$q', function (scope, $q) {
function success(response) {
return response;
}
function error(response) {
var status = response.status;
@benschw
benschw / gist:5516156
Last active Dec 16, 2015
AngularJS Breadcrumbs Service
View gist:5516156
// https://github.com/angular-app/angular-app
angular.module('services.breadcrumbs', []);
angular.module('services.breadcrumbs').factory('breadcrumbs', ['$rootScope', '$location', function($rootScope, $location){
var breadcrumbs = [];
var breadcrumbsService = {};
//we want to update breadcrumbs only when a route is actually changed
//as $location.path() will get updated imediatelly (even if route change fails!)
@benschw
benschw / gist:5518277
Last active Dec 17, 2015
private package with bower
View gist:5518277
{
"name": "myproject",
"version": "1.0.0",
"dependencies": {
"jquery": "1.8.0",
"twitter/bootstrap": "2.1.1",
"myrepo":"git://myrepo.com/myrepo"
}
}
@benschw
benschw / gist:5518392
Last active Dec 17, 2015
$stateParams Service and GET parameters
View gist:5518392
// If you had a url on your state of:
url: '/users/:id/details/{type}/{repeat:[0-9]+}?from&to'
// Then you navigated your browser to:
'/users/123/details//0'
// Your $stateParams object would be
{ id:'123', type:'', repeat:'0' }
// Then you navigated your browser to:
@benschw
benschw / gist:5518413
Created May 4, 2013
Target views relatively or absolutely with AngularJS ui-router
View gist:5518413
$stateProvider
.state('contacts.detail', {
views: {
// relatively targets the "info" view in "contacts.detail" state:
"info" : { /* ... */ }
// relatively targets the unnamed view in "contacts.detail" state:
"" : { /* ... */ }
// absolutely targets the "detail" view in parent "contacts" state:
"detail@contacts" : { /* ... */ }
// absolutely targets the unnamed view in parent "contacts" state:
@benschw
benschw / gist:5551387
Created May 9, 2013
runt virtualbox vm headless with ssh@2222
View gist:5551387
~$ VBoxManage modifyvm "ubuntu-vm" --natpf1 "guestssh,tcp,127.0.0.1,2222,,22"
~$ VBoxHeadless -s ubuntu-vm
@benschw
benschw / gist:5551397
Last active Dec 17, 2015
openbox on debian wheezy
View gist:5551397

debian openbox install notes

[log in]
$ su
# aptitude install sudo
# adduser ben sudo
# exit
$ exit
[log in]
$ sudo aptitude install menu openbox obconf xinit
@benschw
benschw / gist:5551403
Created May 9, 2013
os x software list
View gist:5551403
  • Firefox 3.5.dmg
  • Adium_1.3.5.dmg
  • charles_macosx.zip
  • Dropbox 0.6.507.dmg
  • Growl-1.1.5.dmg
  • iTerm_0.9.6.dmg
  • KeePassX-0.4.0.dmg
  • MacCallGrind 1.0b3.app/
  • MacPorts-1.7.1-10.5-Leopard.dmg
  • MissingDrawer_2009-01-27.zip.zip
@benschw
benschw / gist:5551410
Created May 9, 2013
clear out terminal logs with os x terminals start loading slow
View gist:5551410
/private/var/log/asl/*.asl
@benschw
benschw / wikipedia-cli.sh
Created May 9, 2013
wikipedia cli shell script
View wikipedia-cli.sh
#!/bin/sh
dig +short txt ${1}.wp.dg.cx