Skip to content

Instantly share code, notes, and snippets.

View antonagestam's full-sized avatar
🍉

Anton Agestam antonagestam

🍉
View GitHub Profile
@antonagestam
antonagestam / quicklook
Last active December 22, 2016 09:42
quicklook improvements
from https://twitter.com/Viss/status/809168960495063040
$ brew install Caskroom/cask/qlstephen
$ defaults write com.apple.finder QLEnableTextSelection -bool TRUE
$ killall Finder
$ brew install Caskroom/cask/qlcolorcode
$ qlmanage -r
@antonagestam
antonagestam / keybase.md
Created December 21, 2016 09:13
keybase.md

Keybase proof

I hereby claim:

  • I am antonagestam on github.
  • I am antonagestam (https://keybase.io/antonagestam) on keybase.
  • I have a public key ASAlMX3lP7UfVfGXWkM1XC13pab0Uy3TSbaDmtfzl0-brgo

To claim this, I am signing this object:

@antonagestam
antonagestam / CMakeLists.txt
Created February 14, 2017 23:28 — forked from adrien-f/CMakeLists.txt
CLion and Arduino via Platform.io
cmake_minimum_required(VERSION 3.2)
project(YourProject)
add_subdirectory(src)
add_subdirectory(lib)
@antonagestam
antonagestam / .bash_profile
Last active April 6, 2017 12:59
auto venv
# Extend builtin cd function to automatically activate virtual env of
# current directory.
function cd(){
builtin cd "$@"
if [[ -e .oncd ]];
then
echo "Found .oncd ..."
source .oncd
fi
@antonagestam
antonagestam / gist:44d3e7da310c95c1a05706e70e8fb307
Created May 4, 2017 16:18
alfred 1password search workflow
/bin/bash
osascript -e 'open location "x-onepassword-helper://search/{query}"'
@antonagestam
antonagestam / runsafe.sh
Created October 10, 2017 20:09
Run a process and make sure it is not running concurrently
#!/usr/bin/env bash
# Run a process and make sure it is not running concurrently. If it is already
# running, then refuse to run it and exit
if [[ ! -z ${4+x} || -z ${3+x} ]]; then
echo ""
echo "Error: Unexpected arguments"
echo ""
echo "usage: $0 <pidfile> <logfile> \"<cmd>\""
@antonagestam
antonagestam / draw_loop.js
Last active December 8, 2018 01:07
Asynchronous animation loop
/*
A slightly more condensed version of https://esdiscuss.org/topic/promises-async-functions-and-requestanimationframe-together
*/
let animation_frame = () => new Promise(window.requestAnimationFrame);
(async () => {
while (true) {
await animation_frame();
// draw
}
@antonagestam
antonagestam / log.sh
Last active September 19, 2018 09:16
helper functions for formatting log output
#!/usr/bin/env bash
# The logging functions all take input both as arguments and as stdin so that
# logging can be piped from other commands. The commands use this themselves:
# `log_sub` pipes into `log` which pipes into `prefix`.
prefix () {
local replace="s/^/$1/"
if (( $# > 1 )); then
get_lock () {
# get_lock assures only one process of a kind can be active at a time. It
# takes a path to a lockfile as its first argument and the number of seconds
# to let processes run for as its second argument. Use release_lock to
# remove the lockfile.
#
# To get an infinite lock, pass "infinite" as the locktime argument. This
# makes processes trying to acquire locks exit immediately if one already
# exists.
@antonagestam
antonagestam / namedtuplecursor.py
Created May 28, 2018 15:23
aiomysql named tuple cursor
from collections import namedtuple
from aiomysql.cursors import Cursor, SSCursor
class _NamedTupleCursorMixin:
async def _do_get_result(self):
await super()._do_get_result()
fields = []
if self._description:
for f in self._result.fields: