Skip to content

Instantly share code, notes, and snippets.

@shmaltorhbooks
shmaltorhbooks / path.js
Created May 23, 2017 06:47
get object property by path
Object.getValue = function(obj, path) {
if (typeof obj === 'undefined' || obj === null) return;
path = path.split(/[\.\[\]\"\']{1,2}/);
for (let i = 0, l = path.length; i < l; i += 1) {
if (path[i] !== '') {
obj = obj[path[i]];
if (typeof obj === 'undefined' || obj === null) {
return;
}
}
@shmaltorhbooks
shmaltorhbooks / docker.sh
Created November 30, 2018 10:15
docker cache
# cleans all dangling images. This is useful for removing intermediate images left over from multiple builds
alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)'
# for removing stopped containers
alias docker_clean_ps='docker rm $(docker ps --filter=status=exited --filter=status=created -q)'
# This would kill and remove all images in your cache
docker kill $(docker ps -q)
docker_clean_ps
docker rmi $(docker images -a -q)
@shmaltorhbooks
shmaltorhbooks / .bashrc
Last active October 24, 2025 13:10
paratest with multiple db instances
alias paratest='php bin/console test:init:database:pool -e=test 10 && vendor/bin/paratest -f -p 10 —max-batch-size 5 —coverage-html=build/coverage'
@shmaltorhbooks
shmaltorhbooks / ffmpeg.sh
Last active November 27, 2024 15:14
ffmpeg commands
# compress to 960:540 and reduce framerate to 30fps
ffmpeg -i input.mp4 -vf "fps=30,scale=960:540" output.mp4
# cut fragment from 3 sec to 8 sec
ffmpeg -i input.mp4 -ss 00:00:03 -t 00:00:08 -async 1 -c copy fragment.mp4
# concat files: create list and compress
for %%i in (*.mp4) do echo file '%%i'>> mylist.txt
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
@shmaltorhbooks
shmaltorhbooks / tc-brute.sh
Created November 29, 2022 13:26 — forked from melpomene/tc-brute.sh
Truecrypt brute force script
#!/bin/sh
# Before use:
# * Put line seperated wordlist in file 'wordlist'
# * Change device /dev/sdX to the drive/file you want to brute force
# Call with 'sudo tc-brute.sh < wordlist'.
while read line
do
if truecrypt -t -k "" --protect-hidden=no --non-interactive /dev/sdX -p $line
@shmaltorhbooks
shmaltorhbooks / git_change_author.sh
Created February 18, 2025 12:07
Change user in all commits
git filter-branch -f --env-filter '
OLD_EMAIL="[email protected]"
NEW_NAME="New Username"
NEW_EMAIL="[email protected]"
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi