Skip to content

Instantly share code, notes, and snippets.

View naikrovek's full-sized avatar

Jeremiah Johnson naikrovek

View GitHub Profile
@naikrovek
naikrovek / gist:643a9799171d20820cb9
Created June 18, 2014 17:39
Java implementation of the Floyd-Steinberg dithering algorithm. 24-bit -> 3-bit color.
// from :
// http://stackoverflow.com/questions/5940188/how-to-convert-a-24-bit-png-to-3-bit-png-using-floyd-steinberg-dithering
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
void sixteenRandomBytes(unsigned char buf[16]) {
for (int i = 0; i < 16; i++) {
buf[i] = rand() & 0xff;
}
}
// PKCS #7 padding
// Do this before encrypting to get the message
// up to a multiple of 16 bytes.
size_t pad(unsigned char *buf, size_t messageLength) {
@naikrovek
naikrovek / README.md
Last active October 12, 2022 08:45
AutoHotKey Scripts for arranging app windows on a UHD monitor.

start AutoHotKeyu64.exe wm4k.ahd should launch it. both of the files in this gist should be in the same directory.

with NUMLOCK off, pushing number keys will move windows around. 8 will resize a window to fit 1/8th of your screen (1/4 width, 1/2 height.)

Similar operations for 1, 2, 3, 4, and 6. CTRL does things in combination with 3, 4, and 6, so try those.

Numpad * (with numlock off, always) will arrange a window to occupy 1/12th of the screen (1/6th horizontally and 1/2 vertically).

NEW - Numpad+ and Numpad- will adjust a window's position horizontally

@naikrovek
naikrovek / settings.json
Created May 14, 2021 13:41
windows terminal settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
// Add custom keybindings to this array. To unbind a key
// combination from your defaults.json, set the command to
// "unbound". To learn more about keybindings, visit
// https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and
// Ctrl+Shift+V in your defaults.json. These two lines
@naikrovek
naikrovek / main.go
Created April 27, 2021 10:56
wasm-go-playground change
package main
import (
"embed"
"log"
"net/http"
)
//go:embed cmd/* prebuilt/* index.html jquery-linedtextarea.js playground.js sharing.js style.css wasm_exec.js
var content embed.FS
<?xml version='1.0' encoding='utf-8'?>
<PanelName>ADV7533</PanelName>
<PanelDescription>ADV7533 DSI2HDMI (1920x1080 24bpp)</PanelDescription>
<Group id='EDID Configuration'>
<ManufactureID>0xAF0D</ManufactureID>
<ProductCode>0x0011</ProductCode>
<SerialNumber>0x000000</SerialNumber>
<WeekofManufacture>0x09</WeekofManufacture>
<YearofManufacture>0x13</YearofManufacture>
<EDIDVersion>1</EDIDVersion>
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;
@naikrovek
naikrovek / AES128Cipher.java
Last active April 29, 2020 13:21
AES Encryption in Java.
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
@naikrovek
naikrovek / main.go
Last active January 27, 2020 16:07
package main
import (
"bytes"
"database/sql"
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
@naikrovek
naikrovek / SpaceMouse.cpp
Created May 31, 2019 15:31
excerpt from SpaceMouse.cpp
while (hid_read(Device, pOutput, 28) > 0 && ctr < maxreads)
{
drecieved = true;
if (printdebug)
{
dreport += FString::FromHexBlob(pOutput, 28);
}
unsigned char* pCurr = pOutput;