Skip to content

Instantly share code, notes, and snippets.

@asaph
asaph / remove-artwork-from-flac-files.sh
Created Mar 18, 2021
Remove Artwork From Flac Files
View remove-artwork-from-flac-files.sh
#!/bin/sh
metaflac --remove --block-type=PICTURE *.flac
@asaph
asaph / convert-flac-files-to-96k-apple-lossless.sh
Created Mar 18, 2021
Convert Flac files to 96 kHz Apple Lossless
View convert-flac-files-to-96k-apple-lossless.sh
#!/bin/sh
for f in *.flac; do ffmpeg -i "$f" -acodec alac -ar 96000 "${f%.flac}.m4a"; done
@asaph
asaph / attach-artwork-to-flac-files.sh
Created Mar 18, 2021
Attach Artwork to Flac Files
View attach-artwork-to-flac-files.sh
#!/bin/sh
metaflac --import-picture-from="image.jpg" *.flac
@asaph
asaph / attach-artwork-to-apple-lossless-files.sh
Created Mar 18, 2021
Attach Artwork to Apple Lossless Files
View attach-artwork-to-apple-lossless-files.sh
#!/bin/sh
for f in *.m4a; do atomicparsley "$f" --artwork "image.jpg" --overWrite; done
@asaph
asaph / mysql-backup-remote.sh
Created Nov 2, 2017
Back Up Remote MySQL Database
View mysql-backup-remote.sh
#!/bin/sh
mysqldump -h host -u username -p --compress --single-transaction databasename | gzip > /tmp/databasename.sql.gz
@asaph
asaph / mysql-backup-local.sh
Created Nov 2, 2017
Back Up Local MySQL Database
View mysql-backup-local.sh
#!/bin/sh
mysqldump -h 127.0.0.1 -u username -p --single-transaction databasename | gzip > /tmp/databasename.sql.gz
@asaph
asaph / createQRCode.java
Created Apr 25, 2016
Create a QR Code PNG Image
View createQRCode.java
public static void createQRCode(String barCodeData, String filePath, int height, int width)
throws WriterException, IOException {
BitMatrix matrix = new MultiFormatWriter().encode(barCodeData, BarcodeFormat.QR_CODE,
width, height);
try (FileOutputStream out = new FileOutputStream(filePath)) {
MatrixToImageWriter.writeToStream(matrix, "png", out);
}
}
@asaph
asaph / getGoogleAuthenticatorBarCode.java
Created Apr 25, 2016
Create the data string for the Google Authenticator QR Code
View getGoogleAuthenticatorBarCode.java
public static String getGoogleAuthenticatorBarCode(String secretKey, String account, String issuer) {
String normalizedBase32Key = secretKey.replace(" ", "").toUpperCase();
try {
return "otpauth://totp/"
+ URLEncoder.encode(issuer + ":" + account, "UTF-8").replace("+", "%20")
+ "?secret=" + URLEncoder.encode(normalizedBase32Key, "UTF-8").replace("+", "%20")
+ "&issuer=" + URLEncoder.encode(issuer, "UTF-8").replace("+", "%20");
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
@asaph
asaph / pom.xml
Created Apr 25, 2016
Google ZXing QR Code Maven Dependency
View pom.xml
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.2.1</version>
</dependency>
@asaph
asaph / GoogleAuthenticatorDemo.java
Created Apr 25, 2016
Generate 6 digit 2fa codes in sync with Google Authenticator
View GoogleAuthenticatorDemo.java
String secretKey = "quu6 ea2g horg md22 sn2y ku6v kisc kyag";
String lastCode = null;
while (true) {
String code = getTOTPCode(secretKey);
if (!code.equals(lastCode)) {
// output a new 6 digit code
System.out.println(code);
}
lastCode = code;
try {