Skip to content

Instantly share code, notes, and snippets.

Mathias Fredriksson mafredri

Block or report user

Report or block mafredri

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mafredri
mafredri / subl.sh
Last active Aug 29, 2015
Extended subl for SublimeText to open *.sublime-project files if available.
View subl.sh
# 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 Aug 29, 2015
ZSH Performance: variable vs captured subshell output
View var_subshell_perf.zsh
#!/usr/bin/env zsh
test1() {
test_var=$1
}
test2() {
print -n $1
}
@mafredri
mafredri / pure_benchmark.zsh
Created Jul 22, 2015
Benchmarking modifications to prompt pure
View pure_benchmark.zsh
#!/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 Aug 10, 2015
Install zsh HEAD from git through Homebrew
View zsh-git.rb.patch
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 Feb 13, 2016
tealeg/xlsx PR #149 breaking change demonstration
View main.go
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
Fake AMD module loader for kasper/phoenix (tested with TypeScript + outFile)
View phoenix-amd-loader.js
/**
* 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 Jan 9, 2017
Benchmark opening new zpty instances vs keeping a long running one (zsh-async) for executing asynchronous tasks
View benchmark.log
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 Jan 12, 2017
Quick performance test for setting a variable via capturing output to sub-shell vs a typeset in the running function
View set_variable_performance_test.result.log
=== 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)
@mafredri
mafredri / build_chromium_headless.sh
Created Mar 9, 2017
Script to build (and update) headless Chromium on Ubuntu
View build_chromium_headless.sh
#!/usr/bin/env zsh
# This script checks out the latest chromium and builds the headless
# version of it. When the chromium source is already present, the
# repository is updated.
#
# A .tar.gz is created in $DIR containing the headless_shell binary,
# this binary runs chromium. The resulting binary should be quite
# portable given that the (few) dependencies are installed on the target
# machine.
@mafredri
mafredri / check_connection.sh
Last active May 22, 2017
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.
View check_connection.sh
#!/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"
You can’t perform that action at this time.