Skip to content

Instantly share code, notes, and snippets.

@erosb
erosb / SuppressedExceptionDemo.java
Created January 27, 2020 10:12
Demoing how can an exception be suppressed in java: thrown from AutoCloseable#close() when the try block throws an other exception
import java.util.*;
import java.net.*;
import java.io.*;
import static java.util.regex.Pattern.compile;
import static java.util.Arrays.binarySearch;
class SuppressedExceptionDemo {
static class ExcOnCloseWriter extends BufferedWriter {
@erosb
erosb / rc.lua
Last active May 31, 2021 18:58
awesomewm pulseaudio output (sink) selector menu entry generator
function create_handler_for_sound_output_idx(idx)
return function()
-- sets the selected sink to be the default
os.execute("pacmd set-default-sink " .. idx)
-- goes through inputs and directs them to the selected sink
local fhandle = io.popen("pacmd list-sink-inputs")
local result = fhandle:read("*a")
for line in string.gmatch(result, "[^\n]+") do
if string.find(line, "index") then
68,71c68,69
< for(var i = 0; i<removeItemBtn.length; i++){
<
< (function(index){
< removeItemBtn[i].onclick = function(){
---
> var onClickGenerator = function(index) {
> return function() {
73,76c71,74
<