Skip to content

Instantly share code, notes, and snippets.

View basilfx's full-sized avatar

Bas Stottelaar basilfx

View GitHub Profile
@basilfx
basilfx / FeatureContext.php
Created September 24, 2015 19:28
JavaScript errors in Behat 3 + Mink 2 + Selenium 2
<?php
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\MinkExtension\Context\MinkContext;
class FeatureContext extends MinkContext
{
/**
* Grab the JavaScript errors from the session. Only works in companion
* with a global window variable `errors` that contains the JavaScript
@basilfx
basilfx / git-check-add.py
Last active August 29, 2015 14:24
Git Check Before Add
#!/usr/bin/env python
import sys
def main():
"""
Main entry point.
"""
if "commit -am" in " ".join(sys.argv).lower():
@basilfx
basilfx / git-multi-status.py
Created July 8, 2015 09:24
Git Multi-Branch Status
#!/usr/bin/env python
import os
import sys
import subprocess
import multiprocessing
# List of folders to check status on
FOLDERS = [
# Put your project folders here -- absolute paths please.
@basilfx
basilfx / .profile
Last active May 31, 2023 08:36
Git add-then-commit confirmation
# Git commit protection
check_git() {
python ~/.shell/git-check-add.py $* && $GIT_BIN $*
}
GIT_BIN=`which git`
alias git=check_git
compdef check_git=git
@basilfx
basilfx / README.md
Created March 29, 2015 08:58
Python 2/3 Autocomplete

Python 2/3 Autocomplete + history

Add autocomplete and history to your Python REPL. Saves history per interpreter/version file.

Installation

  • Create a ~/.python/ folder.
  • Move the autocomplete script in that folder.
  • Add export PYTHONSTARTUP=~/.python/autocomplete to your ~/.profile file.
  • Happy coding!

Known issues

@basilfx
basilfx / toc.js
Created December 28, 2014 13:36
Github Markdown TOC generator
var sections = $("h2");
var output = "";
for (var i = 0; i < sections.length; i++) {
var link = $(sections[i]).find("a").prop("href");
var text = $(sections[i]).text().trim()
output = output + "* [" + text + "](" + link + ")\n";
}
@basilfx
basilfx / mycaption.sty
Last active August 29, 2015 14:06
Captions in the margin of a two-sided book, including wide (margin) images.
%!TEX root=test.tex
%%
%% This is file `mycaption.sty',
%% generated with the docstrip utility + positioning modifications.
%%
%% The original source files were:
%%
%% mcaption.dtx (with options: `package')
%%
@basilfx
basilfx / tmux-notify.pl
Last active November 29, 2021 11:01
Irssi and tmux-notify
use strict;
use warnings;
use vars qw($VERSION %IRSSI);
use Irssi;
# Script info
$VERSION = '0.1';
%IRSSI = (
authors => 'Bas Stottelaar',
@basilfx
basilfx / GUIDE.md
Last active July 23, 2019 17:46
Install MT7601U WiFi adapter driver for OpenELEC (Raspberry Pi)

I bought (a few) Wireless-N WiFi adapters from Ebay to enable WiFi on my OpenELEC-featured Raspberry Pi. I was hoping it would work out-of-the-box, but that wasn't true. Some attempts such as modprobe rt2x00usb did not work as expected because it's a totally different chipset.

The output of lsusb:

...
Bus 001 Device 004: ID 148f:7601 Ralink Technology, Corp.
...
@basilfx
basilfx / utils.py
Created May 18, 2014 20:56
Gevent download, cache and stream
import os
import shutil
import gevent
def download_and_cache(remote_fd, target_file, on_error=None, on_completed=None):
"""
"""
temp_file = "%s.temp" % target_file