Skip to content

Instantly share code, notes, and snippets.

View supercoffee's full-sized avatar

Benjamin Daschel supercoffee

View GitHub Profile
@supercoffee
supercoffee / gist:6b3318a6823f00b61ea1
Created September 19, 2014 01:24
udev ethernet rules
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="e8:de:27:04:19:00", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="LAN"
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:bc:03:bd:6e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="WAN"
@supercoffee
supercoffee / convertiso.sh
Last active October 7, 2017 05:18
Create Linux USB installers from ISOs to boot on Mac hardware
#! /bin/bash
#usage: sudo ./convertiso.sh /path/to/iso/file /dev/path/to/usb
#converts a regular ISO file to Apple UDRW file for writing to USB
#then flashes then new image to the specified USB device
#check is script has been run as root /sudo
if [[ $UID != 0 ]]; then
echo "Please run the script as root."
exit 1
@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>
@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 / 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 / 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 / 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 / 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 / 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 / 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}))