Skip to content

Instantly share code, notes, and snippets.

View joshpetit's full-sized avatar
🟩
God is Good, Life is Good, can't ask for more.

Joshua Petitma joshpetit

🟩
God is Good, Life is Good, can't ask for more.
View GitHub Profile
@joshpetit
joshpetit / dtsp
Created September 10, 2020 19:31
Download the last taken screenshot to your phone via kdeconnect
# !bin/bash
file=$(ls -Art ~/Pictures/| grep Screenshot\ from\ | tail -n 1)
kdeconnect-handler ~/Pictures/"$file"
@joshpetit
joshpetit / image-info.sh
Last active September 8, 2020 15:03
Sxiv image-info script to display ISO, Shutter Speed, Aperture. Requires exiv2
#!/bin/sh
# Called by sxiv(1) whenever an image gets loaded,
# with the name of the image file as its first argument.
# The output is displayed in sxiv's status bar.
# Arguments:
# $1: path to image file
# $2: image width
# $3: image height
@joshpetit
joshpetit / zathu
Created August 30, 2020 10:40 — forked from michaelmrose/zathu
zathura config
# Zathura configuration file
# See man `man zathurarc'
# Open document in fit-width mode by default
set adjust-open "best-fit"
# One page per row by default
set pages-per-row 1
#stop at page boundries
@joshpetit
joshpetit / togglebluetooth.sh
Created July 31, 2020 00:23
Script to toggle bluetooth on and off, I add a shortcut in the settings so I can quickly run it.
#!/bin/bash
output=$(bluetoothctl show | sed -n -e 's/^.*Powered: //p')
if [[ $output = no ]]; then
bluetoothctl power on
notify-send -h int:transient:1 "Bluetooth" "On"
else
bluetoothctl power off
notify-send -h int:transient:1 "Bluetooth" "Off"
fi
@joshpetit
joshpetit / listTargetDataLines.java
Created July 24, 2020 18:06
A snippet from marytts Audio Recorder
Mixer.Info[] aInfos = AudioSystem.getMixerInfo();
for (int i = 0; i < aInfos.length; i++) {
Mixer mixer = AudioSystem.getMixer(aInfos[i]);
// mixer.open();
Line.Info[] lines = mixer.getTargetLineInfo();
System.out.println((aInfos[i].getName()));
for (int j = 0; j < lines.length; j++) {
System.out.println((" " + lines[j].toString()));
if (lines[j] instanceof DataLine.Info) {
AudioFormat[] formats = ((DataLine.Info) lines[j]).getFormats();
@joshpetit
joshpetit / pom.xml
Last active July 28, 2020 00:50
Maven Properties Tag
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
@joshpetit
joshpetit / AudioFormat.java
Created July 24, 2020 00:54
A good audio format for Java audio
AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
44100,
16,
2,
4,
44100,
false);
@joshpetit
joshpetit / MicStuff.java
Last active July 24, 2020 00:56
Simple microphone that replays what is recorded
import javax.sound.sampled.*;
import java.io.*;
import java.util.Scanner;
public class MicStuff {
public static void main(String[] args) throws LineUnavailableException, IOException, UnsupportedAudioFileException {
AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
44100,
16,
2,