Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼

aanton

🐼
View GitHub Profile
@aanton
aanton / .zshrc
Last active November 13, 2017 20:58
fzf & fd combo for improving your ZSH shell
View .zshrc
# fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_OPTS="--multi --reverse --border --inline-info --preview '([ -e {} ] && (head -20 {} || tree -C {} | head -20 ) || (echo {})) 2> /dev/null' --preview-window=right:40%:wrap"
export FZF_CTRL_R_OPTS="--no-preview"
export FZF_CTRL_T_OPTS="--bind 'ctrl-x:execute(subl -a {})'"
# fzf bindigs
bindkey '^P' fzf-file-widget
@aanton
aanton / Personal.xml
Last active May 3, 2018 05:13
PHPStorm keymap
View Personal.xml
<keymap version="1" name="Personal" parent="Default for XWin">
<action id="BaseOnThisFunction" />
<action id="CheckinProject" />
<action id="CloseActiveTab">
<keyboard-shortcut first-keystroke="shift ctrl w" />
</action>
<action id="CloseContent">
<keyboard-shortcut first-keystroke="ctrl w" />
</action>
<action id="CompareTwoFiles" />
@aanton
aanton / puppeteer.js
Created September 15, 2017 14:09
Puppeteer screenshot demo
View puppeteer.js
'use strict';
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
timeout: 1000
@aanton
aanton / atom-update.sh
Last active September 1, 2016 07:00
Atom auto-update script for Debian/Ubuntu Linux
View atom-update.sh
#!/bin/bash
if [ $EUID != 0 ]; then
echo "You must be root to run this script" 1>&2
exit 1
fi
URL_RELEASES="https://github.com/atom/atom/releases/latest"
NEW_RELEASE=$(curl -sL $URL_RELEASES | egrep -o 'href="([^"#]+)atom-amd64.deb"' | cut -d'"' -f2 | sort | uniq)
NEW_VERSION=$(echo $NEW_RELEASE | egrep -o '[0-9]+\.[0-9]+\.[0-9]+')
CURRENT_VERSION=$(atom --version | fgrep Atom | awk '{print $3}')
View keybase.md

Keybase proof

I hereby claim:

  • I am aanton on github.
  • I am aanton (https://keybase.io/aanton) on keybase.
  • I have a public key ASDy6XVLDZ6WeKCLIJPiQziwfLE1D9XsZqlZxLtyjkMcmgo

To claim this, I am signing this object:

@aanton
aanton / .gitconfig
Created February 16, 2016 10:26
My .gitconfig
View .gitconfig
[core]
editor = vim
pager = less -r
[alias]
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --all --date=iso
local = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=iso
[color]
ui = auto
[color "branch"]
current = yellow reverse
@aanton
aanton / debug-charsets-requests.php
Created September 24, 2015 20:48
PHP example to debug requests done in ISO-8859-1 & UTF-8 pages
View debug-charsets-requests.php
<?php
$debug = [];
// Configure charset
$charsets = ['utf-8', 'iso-8859-1'];
$charset = array_key_exists('charset', $_REQUEST) &&
in_array(mb_strtolower($_REQUEST['charset']), $charsets) ? mb_strtolower($_REQUEST['charset']) : 'utf-8';
ini_set('default_charset', $charset);
mb_internal_encoding(ini_get('default_charset'));
@aanton
aanton / memcache-list-all-keys.rb
Last active August 29, 2015 14:13 — forked from bkimble/gist:1365005
List all keys stored in memcache
View memcache-list-all-keys.rb
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
# Forked from https://gist.github.com/bkimble/1365005
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@aanton
aanton / ConsistentHash.php
Created April 4, 2014 07:47
Consistent hashing
View ConsistentHash.php
<?php
/**
* @see https://github.com/pda/flexihash
* @see http://www.martinbroadhurst.com/Consistent-Hash-Ring.html
*/
class ConsistentHash
{
/** @var int Number of positions to hash each target. This has the effect of distributing the servers more evenly over the ring. Note that this has nothing to do with server replication */
private $replicas;