Skip to content

Instantly share code, notes, and snippets.

View supercoffee's full-sized avatar

Benjamin Daschel supercoffee

View GitHub Profile
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@supercoffee
supercoffee / prune-stash
Created April 24, 2017 17:31
Prune git stashes
#!/usr/bin/env bash
stashCount=`git stash list | wc -l`
keep=10
for ((i=$stashCount+1; i>$keep; i--))
do
git stash drop stash@{$i}
done
@supercoffee
supercoffee / pre-push.py
Created April 11, 2017 20:26
Prevent push to Upstream Git
#!/usr/bin/env python3
import argparse
DISALLOWED_PUSH = ['upstream']
def assert_safe_push(remote, branch):
if remote in DISALLOWED_PUSH:
print('Error: push to {remote} is not allowed'.format(**{'remote': remote}))
@supercoffee
supercoffee / ModelResetExtension.php
Created February 24, 2017 05:41
Reset the booted flag of Laravel models between Tests.
<?php
use Codeception\Extension;
use Illuminate\Database\Eloquent\Model;
class ModelResetExtension extends Extension
{
public static $events = [
'test.after' => 'resetModelBootFlags'
];
@supercoffee
supercoffee / mac-setup.sh
Last active July 25, 2018 07:04
install software on mac
#!/usr/bin/env bash
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# browsers
brew cask install opera google-chrome firefox lastpass google-hangouts
# office and files
brew cask install libreoffice evernote gimp google-drive
@supercoffee
supercoffee / dynamic-forms.html
Created June 16, 2016 23:32
Angular dynamic forms with model binding and ng-repeat
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body ng-controller="MyController">
<form>
<div ng-repeat="(name, display) in form">
<label for="{{ name }}">{{ display }}</label>
@supercoffee
supercoffee / README.md
Last active June 14, 2016 16:11
Run a shell script to start vagrant VMs at login

How to use

Download com.bendaschel.onlogin.plist.

In a terminal, type the following commands

cp com.bendaschel.vagrantup.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/com.bendaschel.onlogin.plist
@supercoffee
supercoffee / Gradle zip Task
Created February 13, 2016 06:44
Zip the source folder and README of an Android project for submission
task zipTask(type: Zip) {
baseName = 'bDaschelLab5'
rename 'app-debug.apk', "${baseName}.apk"
into baseName
from 'build/outputs/apk/app-debug.apk'
from 'README.md'
from ('src') {
into 'src'
}
}
@supercoffee
supercoffee / Robolectric Test Class
Last active February 29, 2016 01:14
Robolectric Test Class Template for Android Studio
#*
How to use this template:
Open up the preferences menu in Android studio.
Navigate to Editor > File and Code Templates
Click the green + button above the templates tab
Name the template whatever you want. Make sure that it has "java" as an extension.
Paste this whole thing in the text area.
Click Ok.
This template will appear when you invoke the "New" context menu in the project pane.
*#
@supercoffee
supercoffee / private.xml
Last active October 29, 2016 19:04
Remap Shift + space to underscore_ with Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>shift space</name>
<identifier>private_shift_space</identifier>
<autogen>
__KeyToKey__
KeyCode::SPACE, ModifierFlag::SHIFT_L,
KeyCode::MINUS
</autogen>