Skip to content

Instantly share code, notes, and snippets.

@mmmaly
mmmaly / gen-pronounceable-passwords.sh
Created June 12, 2013 21:21
Generate very pronounceable passwords
tr -cd a-z\\n < /dev/urandom | grep -o -P "[aeiouy]?([bcdfghjklmnprstvxz][aeiouy]){2,}[bcdfghjklmnprstvxz]?"
@mmmaly
mmmaly / mov2avi.sh
Created June 14, 2013 16:38
Convert all iPhone videos (MOV) to AVI
for i in *.MOV; do ffmpeg -sameq -i $i -vcodec msmpeg4v2 -acodec libmp3lame ${i%.MOV}.avi; done
@mmmaly
mmmaly / ssh-certificate-setup
Last active March 11, 2017 20:20
Use ssh certificates to set up a forced command for a simple server monitoring with one-year validity.
# Create the "certification authority". The private key of CA does not have to (and must not) be copied anywhere.
user@home$ ssh-keygen /home/user/.ssh/certification_authority
# Make CA public key trusted on a server.
user@home$ scp /home/user/.ssh/certification_authority.pub root@server:
root@server# cd; (echo -n "cert-authority "; cat certification_authority.pub ) >> .ssh/authorized_keys
# Generate a certificate for any command you can think of
# Example -- command: "tailf /var/log/messages" validity: 52 weeks from now Permissions: none (no forwarding etc.)
user@home$ ssh-keygen -f tailfmessages.key
@mmmaly
mmmaly / rename-time.sh
Created March 13, 2014 22:20
rename images and videos according to their creation time
#!/bin/bash
#rename iPhone image/video files
#use only for tagged files
for i in *.mov
do
TIME=`exiftool "$i" | grep "Media Create Date" | sed -e 's/Media Create Date *: //'`
TOUCHTIME=`echo $TIME | sed -e 's/:/-/;s/:/-/;'`
FILENAME=`echo $TIME | sed -e 's/:/-/g;s/ /_/'`
@mmmaly
mmmaly / pdftest
Created July 12, 2014 10:26
pdf test greasemonkey
// ==UserScript==
// @name pdf test
// @namespace http://www.example.com
// @description Alerts with title and href of any pdf link.
// @include http*.sk/*
// ==/UserScript==
var links = document.getElementsByClassName('pdf');
alert(links.length + ' pdfs on page');
@mmmaly
mmmaly / gist:7a02d765b08827913254
Created October 6, 2014 22:32
update stands command
for i in *.jpg; do s=${i%.jpg}; echo UPDATE stands set standPhoto=\"stands/$s.jpg\" where standName=\"$s\"\; ; done
@mmmaly
mmmaly / transcribe.sh
Created November 13, 2018 18:31
Call Google speech recognize
#!/bin/bash
fileogg=$1
name=${fileogg%.ogg}
file=$name.flac
ffmpeg -i $fileogg -ar 16000 $file 2>/dev/null
gsutil cp $file gs://transcribe
gcloud ml speech recognize-long-running gs://transcribe/$file --sample-rate 16000 --encoding flac --language-code='sk-SK' --async > $$.id
id=`jq -r .name < $$.id `
gcloud ml speech operations wait $id > $name.json