Skip to content

Instantly share code, notes, and snippets.

@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 / ffmpeg.sh
Last active August 2, 2022 16:12
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 / .bashrc
Last active December 9, 2023 16:30
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 / 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 / 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;
}
}
<?php
declare(strict_types = 1);
namespace Tests\AppBundle\Form;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Test\TypeTestCase as TestCase;
use Symfony\Component\Validator\ConstraintViolationList;
@shmaltorhbooks
shmaltorhbooks / Dockerfile
Created February 13, 2017 13:03
Docker config for PHP 7.1 with composer, redis and xdebug
FROM php:7.1-fpm
ENV DEBIAN_FRONTEND noninteractive
RUN TERM=xterm
RUN export TERM=xterm
RUN echo 'PS1="\[\033[36m\]\u\[\033[m\]@\[\033[95;1m\]docker-application:\[\033[34m\]\w\[\033[m\]\$ "' >> ~/.bashrc
RUN echo "alias console='php bin/console'" >> ~/.bashrc
RUN echo "alias phpunit='php bin/phpunit'" >> ~/.bashrc
RUN apt-get dist-upgrade -y
@shmaltorhbooks
shmaltorhbooks / delete-old-files.sh
Created February 7, 2017 08:23
Delete files older that 5 days
find /path/to/files* -mtime +5 -exec rm {} \;
@shmaltorhbooks
shmaltorhbooks / NumberSystem.php
Created October 5, 2016 12:56
convert id between number systems
class NumberSystem
{
const DEFAULT_ALPHABET = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
public static function baseEncode($num, $alphabet = self::DEFAULT_ALPHABET) {
$baseCount = strlen($alphabet);
$encoded = '';
while ($num >= $baseCount) {
$div = $num/$baseCount;
$mod = ($num-($baseCount* (int) $div));
@shmaltorhbooks
shmaltorhbooks / RelativeAbsolutePathTransformer.php
Created September 25, 2015 11:32
Convert relative links to absolute path in href/src attributes
preg_replace('/((?:href|src) *= *[\'"](?!(\/\/|#|http|ftp)))/i', '$1' . $this->url, $value)