Skip to content

Instantly share code, notes, and snippets.

@pbkhrv
pbkhrv / ghi_fzf_autocomplete.sh
Last active March 26, 2016 20:56
ghi + fzf autocomplete
# ghi is a GitHub issues CLI https://github.com/stephencelis/ghi
# fzf is "A command-line fuzzy finder" https://github.com/junegunn/fzf
# Usage:
# Image you need to comment on an issue but you dont remember its number.
# Instead of searching for the number first and then typing "ghi edit <number>",
# use the fzf fuzzy complete function:
#
# ghi comment **<TAB>
#
@pbkhrv
pbkhrv / gist:e95984c0ae207978f855
Last active February 6, 2016 23:31
Sketch of possible text representations of a getguesstimate.com spreadsheet
Naive thinking of ways to represent @getguesstimate spreadsheets as text....
Using http://www.getguesstimate.com/models/314 as an example
in YML
count_meltdowns:
label: Number of meltdowns
formula: normal(0,2) # distributions use function notation?
minutes_per_meltdown:
@pbkhrv
pbkhrv / merge-left.clj
Last active January 19, 2016 04:13
(merge-left & maps) - like merge, but doesn't overwrite previously defined keys
(defn merge-left [& maps]
(apply merge-with (cons (fn [old _] old) maps)))
@pbkhrv
pbkhrv / cljs-http-put-file-to-presigned-s3-url.cljs
Created December 29, 2015 00:29
PUT file to S3 via a presigned url, from Clojurescript using cljs-http
;; require the following:
;; [cljs-http.client :as http]
;; [cljs-http.core :as http-core]
;;
;; put-url must be a presigned URL generated by something like
;; http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3Client.html#generatePresignedUrl(com.amazonaws.services.s3.model.GeneratePresignedUrlRequest)
(defn put-file [content-type file-obj put-url]
(let [req {:request-method "PUT"
:headers {"content-type" content-type}
@pbkhrv
pbkhrv / gist:a67b79e6b217f0314db5
Created October 14, 2014 20:59
Alfred workflow to schedule todos in Things for certain number of days in the future
-- make a workflow, call it with "task name +days"
on alfred_script(q)
if application "Things" is running then
else
tell application "Things" to activate
tell application "Finder"
set visible of process "Things" to false
end tell
delay 1
@pbkhrv
pbkhrv / gist:0d17c4c3f69e372cdcd0
Created October 13, 2014 22:29
reading all of stdin into a variable in NodeJS?
function readWholeStdin() {
process.stdin.resume();
process.stdin.setEncoding('utf8');
var buffer = '';
process.stdin.on('data', function(chunk) {
buffer += chunk;
});
var deferred = Q.defer();
process.stdin.on('end', function() {
@pbkhrv
pbkhrv / gist:906a682abbf41e772ec5
Created September 25, 2014 19:57
shellshock research: wrap /bin/sh and log all calls to it to see what is potentially vulnerable
/*
* rename /bin/sh to /bin/sh.org for the script to work
*
* compile with 'gcc -Wall sh-wrap.c -o sh-wrap'
*
* can do same for bash
*/
#include <unistd.h>
#include <stdio.h>
@pbkhrv
pbkhrv / gist:5542785
Last active December 17, 2015 03:19
Bash prompt script that reflects the state of the git repository in the current directory by showing current branch name and several indicators. Add it to your .profile
# * uncommitted changes
# ^ stashed changes
# > ahead of origin
# < behind origin
# ↕ diverged from origin
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}