Skip to content

Instantly share code, notes, and snippets.

@jvorcak
jvorcak / humanize-duration.js
Last active July 10, 2019 14:37
Humanize duration wrapper
import React from 'react'
import humanizeDuration from "humanize-duration"
const shortEnglishHumanizer = humanizeDuration.humanizer({
language: 'shortEn',
spacer: '',
delimiter: ' ',
languages: {
shortEn: {
y: function() { return 'y' },
@jvorcak
jvorcak / gist:499b99aa8fa5cd9bce774f3b05a1635b
Created May 10, 2018 17:37
Extract hash from SHA-1 cert
echo 83:F4...CD:46 | xxd -r -p | openssl base64
@jvorcak
jvorcak / keysetter.js
Created August 27, 2018 14:12
Key Setter
/*
This function can be used in `compose` to decide on a key for a given component
@example:
export default compose(
connect(state => ({
a: state.a,
b: state.b,
})),
KeySetter(props => `${props.a}-${props.b}`), // remounts a component if one of `a` or `b` changes.
@jvorcak
jvorcak / kill-tmux-sessions.sh
Created May 3, 2019 07:06
kill specific tmux sessions based on awk expression
tmux list-sessions | awk 'BEGIN{FS=":"}{print $1}' | xargs -n 1 tmux kill-session -t
source (https://askubuntu.com/a/1014428)
https://stackoverflow.com/questions/14371376/how-do-you-make-many-files-public-in-google-cloud-storage
@jvorcak
jvorcak / clean-docker-images
Created May 23, 2019 05:22
Cleans old docker images
docker rmi $(docker images -f dangling=true -q)
d = {'a':'Apple', 'b':'Banana','c':'Carrot'}
a,b,c = [d[k] for k in ('a', 'b','c')]
a == 'Apple'
b == 'Banana'
c == 'Carrot'
@jvorcak
jvorcak / gist:4751c6a572553ebf3d3738d5f7f5a7e2
Created September 19, 2019 10:07
git diff in real-time
watch --color -n 1 git diff --color
@jvorcak
jvorcak / gist:395e8705bf0031fe9a43669bc1d15aeb
Created October 16, 2019 06:15
Submitting multiple forms in Django
<form action="" method="post">
{% csrf_token %}
{{ form.as_ul }}
<button type="submit" name="form_1">Submit</button>
</form>
<form action="" method="post">
{% csrf_token %}
{{ form.as_ul }}
<button type="submit" name="form_2">Submit</button>
</form>
@jvorcak
jvorcak / join-for-objects.py
Created January 30, 2020 17:02
Python join for objects
from itertools import chain
list(chain.from_iterable((a, 1) for a in ['a', 'b', 'c']))[:-1]
Out: ['a', 1, 'b', 1, 'c']