Skip to content

Instantly share code, notes, and snippets.

@helospark
helospark / userChrome.css
Created November 30, 2025 10:41
Fix Firefox mute icon to not expand tab, moved left and behave like before v136 version
/* Setup userChrome.css using https://www.userchrome.org/how-create-userchrome-css.html and add this content into the file */
/* This will make the mute button behave like it was before v136 by positioning mute button to the left of the tab instead of the site favicon and not expanding the tab */
.tabbrowser-tab:is([muted], [soundplaying], [activemedia-blocked]) {
#tabbrowser-tabs[orient="horizontal"] &:not([pinned]) {
--tab-min-width: inherit !important;
--tab-min-width-pref: inherit !important;
min-width: max(var(--tab-min-width-pref, var(--tab-min-width))) !important;
}
}
@helospark
helospark / FirefoxBackup.java
Last active May 7, 2025 16:00
Saves firefox open tabs, so they are not lost in case Firefox crashes.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;
@helospark
helospark / MultiplicationPersistance.java
Created January 5, 2024 12:35
Finds multiplicative persistance numbers
/**
* Finds multiplicative persistance numbers.
* Due to parallel nature, it sometimes not finding the smallest possible multiplicative persistance numbers
* Video: https://www.youtube.com/watch?v=Wim9WJeDTHQ
* Oeis: https://oeis.org/A003001
*/
package com.test;
import java.math.BigInteger;
import java.util.ArrayList;
@helospark
helospark / InstructionCounter.java
Created May 10, 2022 07:51
Calculates which are most/least used x64_86 asm instructions
package com.test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@helospark
helospark / WordleSolver.java
Created January 26, 2022 07:53
Solves wordle game
package com.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
@helospark
helospark / SourceDataLineWriteHangs.java
Created May 8, 2021 11:21
Repro OpenJDK hanging bug on Linux (using ALSA) playback device. It doesn't always work with the same SIZE, delay, and stream size parameters on every machine. I guess it depends on sound hardware, buffers, etc.
package com.test;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
/**
OpenJDK bug report:
package com.helospark.bike;
/**
* Calculates how many watts I have to generate to burn the amount of calories on my exercise bike generator.
* @author helospark
*/
public class ExerciseBikeKcalToWh {
static final int kcalEaten = 640;
public static void main(String[] args) {
package com.helospark.bike;
/**
* Calculates the amount of calories & body fat burned from generated electric power in my exercise bike generator.
* @author helospark
*/
public class ExerciseBikeWhToKcal {
static final int wh = 95;
public static void main(String[] args) {
@helospark
helospark / scrape_bet.sh
Created September 19, 2020 11:35
Scrape daily stock data from Budapest Stock Exchange (BÉT) and saves data to Graphite DB
stocks="3564,4IG 6494,ALTEO 4042,ANY 6329,APPENINN 8208,AUTOWALLIS 424,BIF 6515,CIGPANNONIA 9864,DUNAHOUSE 4338,GSPARK 506,KONZUM 7217,MASTERPLAST 518,MOL 511,MTELEKOM 540,OPUS 528,OTP 546,PANNERGY 604,RABA 608,RICHTER 3263,TAKAREKJZB 11141,WABERERS 639,ZWACK"
curl -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0' -v "https://bet.hu/oldalak/adatletoltes" > /tmp/out.html 2>&1
sessionid=`cat /tmp/out.html | grep JSESSIONID | sed 's/< set-cookie: JSESSIONID=//g' | sed 's/;.*//g'`
csrf=`cat /tmp/out.html | grep csrf | sed 's/\s\+<meta name="_csrf" content="//g' | sed 's/".*//g'`
defaultStart=`date --date="2 day ago" +"%Y.%m.%d."`
today=`date +"%Y.%m.%d."`
# Max is 5 years
startDate=$1
@helospark
helospark / SunExchangeCalculator.java
Last active October 9, 2019 19:24
Simulates return and results on the SunExchange
package com.helospark.invest;
import java.util.ArrayList;
import java.util.List;
/**
* Simulates return and results on the SunExchange.
*/
public class SunExchangeCalculator {
private static final double ZAR_TO_USD = 0.066;