Skip to content

Instantly share code, notes, and snippets.

@urtens
urtens / gist:aa4fff72cf9969cfd61682663b49c59f
Created March 4, 2018 10:17
MongoDB: Get document insertion date
db.collection.find().sort({ts: 1}).limit(1).forEach(function (doc){ d = doc._id.getTimestamp(); print(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()) })
@urtens
urtens / git-squash.sh
Created February 7, 2017 17:26
git: squash last commits
# From http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git/5201642#5201642
git reset --soft HEAD~3 &&
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"

Keybase proof

I hereby claim:

  • I am urtens on github.
  • I am urtens (https://keybase.io/urtens) on keybase.
  • I have a public key whose fingerprint is C0D5 BB6B 389E 68E5 ED99 D06A 0985 1843 4B14 B1C1

To claim this, I am signing this object:

@urtens
urtens / resize_screen.sh
Created November 4, 2016 12:08
Fix scaling when a non-hidpi monitor is plugged into my hidpi laptop
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
git update-index --skip-worktree FILENAME
ssh-keygen -y -f ~/.ssh/id_rsa
@urtens
urtens / delete_ecs_service.sh
Created February 4, 2016 14:41
Delete ecs service
#!/bin/bash
set -o pipefail
CLUSTER=$1
SERVICE=$2
echo getting service info
DETAILS=$(aws ecs describe-services --cluster $CLUSTER --services $SERVICE)