Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mafredri's full-sized avatar

Mathias Fredriksson mafredri

View GitHub Profile
@mafredri
mafredri / check_connection.sh
Last active May 22, 2017 01:57
Upgrade WiFi AP (e.g on OpenWRT) when there is a stronger BSSID in vicinity (based on signal strength). Useful when you are a member of a SSID which has multiple APs under the same SSID but you don't want to commit to only one BSSID.
#!/bin/sh
COUNT=0
LIMIT=5
INTERFACE=wlan1
NAME=$(basename $0)
CLEAN_NAME=${NAME%.sh}
PID="/var/run/$CLEAN_NAME.pid"
LOGGER="logger -t $CLEAN_NAME -s"

Keybase proof

I hereby claim:

  • I am mafredri on github.
  • I am mafredri (https://keybase.io/mafredri) on keybase.
  • I have a public key ASAcL0fP34_ZPvJ6-aV3RbVAF8TYNpudE2uPwkxbOw2KIgo

To claim this, I am signing this object:

@mafredri
mafredri / subl.sh
Last active August 29, 2015 14:22
Extended subl for SublimeText to open *.sublime-project files if available.
# Detect and open sublime-project files in the provided path, if no parameters
# are provided, open the $PWD. If the parameter is not a directory, call subl
# normally.
_subl() {
local params="$*"
local project
if test -z "$params"; then
params=.
fi
@mafredri
mafredri / var_subshell_perf.zsh
Last active August 29, 2015 14:25
ZSH Performance: variable vs captured subshell output
#!/usr/bin/env zsh
test1() {
test_var=$1
}
test2() {
print -n $1
}
@mafredri
mafredri / pure_benchmark.zsh
Created July 22, 2015 21:14
Benchmarking modifications to prompt pure
#!/usr/bin/env zsh
BRANCH=$1
BRANCHES=(master pure-nitro pure-nitro2)
BENCHDIR=benchmark
ROUNDS=100
if [[ ! -n $BRANCH ]]; then
[[ ! -d $BENCHDIR ]] && mkdir $BENCHDIR
for i in $BRANCHES; do
@mafredri
mafredri / zsh-git.rb.patch
Created August 10, 2015 22:27
Install zsh HEAD from git through Homebrew
diff --git a/Library/Formula/zsh.rb b/Library/Formula/zsh.rb
index e7e67a5..4dff75e 100644
--- a/Library/Formula/zsh.rb
+++ b/Library/Formula/zsh.rb
@@ -5,8 +5,11 @@ class Zsh < Formula
mirror "http://www.zsh.org/pub/zsh-5.0.8.tar.bz2"
sha256 "8079cf08cb8beff22f84b56bd72bb6e6962ff4718d816f3d83a633b4c9e17d23"
+ head "https://github.com/zsh-users/zsh.git"
+
@mafredri
mafredri / main.go
Created February 13, 2016 12:58
tealeg/xlsx PR #149 breaking change demonstration
package main
import "github.com/tealeg/xlsx"
func main() {
file := xlsx.NewFile()
sheet, err := file.AddSheet("Sheet1")
if err != nil {
panic(err.Error())
}
@mafredri
mafredri / phoenix-amd-loader.js
Created May 8, 2016 17:52
Fake AMD module loader for kasper/phoenix (tested with TypeScript + outFile)
/**
* Fake AMD-style modules for kasper/phoenix
*
* Works when compiling TypeScript with a single outfile and AMD modules.
*/
(function (global, require) {
var defines = {},
defQueue = [];
global.require = function (mod) {
@mafredri
mafredri / benchmark.log
Last active January 9, 2017 07:08
Benchmark opening new zpty instances vs keeping a long running one (zsh-async) for executing asynchronous tasks
Start async job (async_job):
1: 0.00011992
2: 0.00011015
3: 0.00010586
4: 0.00010514
5: 0.00022697
6: 0.00013900
7: 0.00010586
8: 0.00010395
9: 0.00011015
@mafredri
mafredri / set_variable_performance_test.result.log
Last active January 12, 2017 14:13
Quick performance test for setting a variable via capturing output to sub-shell vs a typeset in the running function
=== RUN test_bench_print_subshell_05
--- PASS: test_bench_print_subshell_05 (0.02s)
=== RUN test_bench_print_subshell_10
--- PASS: test_bench_print_subshell_10 (0.02s)
=== RUN test_bench_print_subshell_100
--- PASS: test_bench_print_subshell_100 (0.14s)
=== RUN test_bench_print_subshell_1000
--- PASS: test_bench_print_subshell_1000 (0.79s)
=== RUN test_bench_typeset_var_05
--- PASS: test_bench_typeset_var_05 (0.00s)