Skip to content

Instantly share code, notes, and snippets.

@jost125
jost125 / .tigrc
Last active June 23, 2024 04:33
Custom tig shortcuts
# Custom commands
bind generic <Ctrl-A> !git commit --amend
# Custom commands in tig status, works after pressing key on selected file from list
bind generic i !git add -p %(file)
# Custom commands in tig, works after pressing key on selected commit from list
bind generic f !git commit --fixup=%(commit)
bind generic <Ctrl-H> !@sh -c "echo -n %(commit) | xclip -selection primary" # copy commit hash into primary clipboard
set $utm_hash "";
if ($args ~* "^(.*&?)utm_source=([a-zA-Z0-9._-]*)(&(.*))?") {
set $args $1$4;
set $utm_hash "$utm_hash&utm_source=$2";
}
if ($args ~* "^(.*&?)utm_medium=([a-zA-Z0-9._-]*)(&(.*))?") {
set $args $1$4;
set $utm_hash "$utm_hash&utm_medium=$2";
#!/bin/bash
if [ -z "$1" ]
then
echo "usage: $0 <prefix>"
exit -1
fi
redis-cli EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 $1:*
UPDATE campaign_item
CROSS JOIN (SELECT @sort_order := 0, SET @campaign := 0)
SET sort_order = (@sort_order := IF(campaign_id = @campaign, @sort_order, (@campaign := campaign_id) - campaign_id) + 1)
ORDER BY campaign_id, sort_order, id;
@jost125
jost125 / .git_bash_prompt.sh
Last active June 27, 2018 16:57
basic git prompt
# Bash PS1 for Git repositories showing branch and relative path inside
# the Repository
# Reset
RESET="\[\033[0m\]"
# Regular Colors
BLACK="\[\033[0;30m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
@jost125
jost125 / branch-cleanup.sh
Last active August 2, 2021 11:31
Checkouts to master and delete all fully merged branches
#!/bin/bash
git checkout master
for b in $(git branch | grep -v master); do git branch -d $b; done
git fetch -p
@jost125
jost125 / setfacl-nette
Last active April 5, 2018 10:37
Permissions setfacl in Nette project
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX temp log
sudo setfacl -dR -m u:www-data:rwX -m u:`whoami`:rwX temp log
class QuickSorter[T <% Ordered[T]] {
def sort(list: List[T]) : List[T] = {
list match {
case Nil => Nil
case pivot :: rest =>
val (smaller, higher) = rest.partition(_ < pivot)
sort(smaller) ++ (pivot :: sort(higher))
}
}
}