Skip to content

Instantly share code, notes, and snippets.

@kampfgnu
kampfgnu / git_remove_large_file
Created February 27, 2017 14:42
remove already commited large file from git history
git filter-branch --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch MY-BIG-DIRECTORY-OR-FILE' --tag-name-filter cat -- --all
@kampfgnu
kampfgnu / convertPDFToPNG3x.sh
Created March 4, 2018 09:52
convert vector pdf to iOS image assets
#!/bin/bash -e
# convert vector pdf to iOS image assets
# copy this script to the folder where the pdf files live and run "./convertPDFToPNG3x.sh" in terminal.
# this will generate [filename]@3x.png, [filename]@2x.png and [filename].png images in the same folder
# Ensure we're running in location of script.
cd "`dirname $0`"
@kampfgnu
kampfgnu / renameImageCaptureImportedFilesToDate.sh
Last active October 8, 2018 15:09
rename files to their creation date
cd $1
for file in *.{JPG,jpg}
do date=$(stat -f %B $file)
dateFormatted=$(date -r $date +%Y-%m-%d' '%H.%M.%S)
mv $file "$dateFormatted.jpg"
done
for file in *.{MOV,mov}
do date=$(stat -f %B $file)
@kampfgnu
kampfgnu / gist:12043ae747e06c9dc55c05aa5d49dcc2
Created November 26, 2018 17:21
list size of subfolders larger or equal 1 GB
du -h -d 1 | grep '[0-9]G\>'
@kampfgnu
kampfgnu / mygamepad.py
Created February 15, 2019 15:52
listen for gamepad events and do some stuff for my home audio setup
#!/usr/bin/python
# --------------------------------------------------------------------------
#
# --------------------------------------------------------------------------
#import evdev
from evdev import InputDevice, categorize, ecodes
from subprocess import call
#creates object 'gamepad' to store the data
http://loopstream01.apa.at/?channel=oe1&shoutcast=0&ua=flash&id=[loopStreamId]
e.g.
http://loopstream01.apa.at/?channel=oe1&shoutcast=0&ua=flash&id=2019-09-08_1405_tl_51_7DaysSun21_1069721.mp3
# cd $1
for file in *.{JPG,jpg,JPEG,jpeg}
do date=$(stat -f %B $file)
dateFormatted=$(date -r $date +%Y-%m-%d' '%H.%M.%S)
mv $file "$dateFormatted.jpg"
done
for file in *.{PNG,png}
do date=$(stat -f %B $file)
import os, time
from stat import * # ST_SIZE etc
from os import walk
import datetime
extensions = [".jpeg", ".jpg", ".png", ".mov", ".aae", ".mp4"]
files = []
for (dirpath, dirnames, filenames) in walk("./"):
files.extend(filenames)
@kampfgnu
kampfgnu / gist:5670865cb7fc94c4f803f06c27ba0cfe
Last active December 8, 2020 11:22
disk usage recursive list size sorted size ASC (the "/" after "*" is used to list folders only)
du -sh */ | sort -hr
@kampfgnu
kampfgnu / gist:8b75aadc449938588741827921627925
Created December 8, 2020 11:20
dump tables of a db to single files with hardcoded password
#!/bin/bash
# dump-tables-mysql.sh
# Descr: Dump MySQL table data into separate SQL files for a specified database.
# Usage: Run without args for usage info.
# Author: @Trutane
# Ref: http://stackoverflow.com/q/3669121/138325
# Notes:
# * Script will prompt for password for db access.
# * Output files are compressed and saved in the current working dir, unless DIR is