Skip to content

Instantly share code, notes, and snippets.

View viluon's full-sized avatar
👁️
stop the race towards misaligned AI

Andrew Kvapil viluon

👁️
stop the race towards misaligned AI
View GitHub Profile
@adriankeenan
adriankeenan / thinkpad_p1_gen4_usbcpd_charging.md
Last active May 9, 2024 08:05
ThinkPad P1 Gen 4 USB-C PD Charging Testing

The ThinkPad P1 has no official requirements for USB-C chargers. This is the result of testing a few different USB-C chargers on my Gen 4 P1.

Notes:

  • Machine BIOS is N40ET44W 1.26.
  • This configuration (i7 11850H, RTX A3000) shipped with a 230W AC charger.
  • Result wattage read from Lenovo Vantage on Windows 11 Pro.
  • Windows does not acknowledge unsupported chargers at all (eg does not show any error messages). A KDE desktop does show a message that the wattage is too low for unsupported chargers.
  • Tested with a 100W C-C cable or 100W TB4 cable.

| Charger | Charger Wattage | Result |

@MCJack123
MCJack123 / deflate-ans.lua
Last active July 1, 2024 00:29
A variant of DEFLATE using tabled asymmetrical numeral systems
-- DEFLATE-ANS: A variant of DEFLATE that uses asymmetrical numeral systems
-- instead of Huffman coding, increasing decompression speed with similar
-- compression ratios.
--
-- The block format matches RFC 1951 DEFLATE, with some minor adjustments:
-- * Bit fields are always stored most significant bit first, and bytes are
-- stored most significant byte first. This is for convenience in the bit
-- decoder.
-- * Huffman-encoded blocks are replaced with tANS-encoded blocks. These blocks
-- start with an initial X value (which is R bits long), followed by the codes
@Validark
Validark / aho-corasick.lua
Created July 18, 2021 12:31
A clean implementation of the aho-corasick algorithm taking full advantage of Lua's __index metamethod.
-- We can re-use metatables where possible
local lookupCache = {
__index = function(self, i)
local v = { __index = i }
self[i] = v
return v
end
}
local function use_aho_corasick(automaton, str)
@progandy
progandy / README.md
Last active September 26, 2023 08:27
Sway output mirror and screencast

Sway output mirror and screencast

Mirror

wf-recorder

With wf-recorder it is possible to record one output. When ffmpeg is compiled with sdl support, then it is possible to use "sdl" as the muxer and replay the recorded video instead of writing it to a file.

@MCJack123
MCJack123 / unbios.lua
Last active December 26, 2023 12:45
UnBIOS: Load custom BIOSes in ComputerCraft without modifying ROM
-- UnBIOS by JackMacWindows
-- This will undo most of the changes/additions made in the BIOS, but some things may remain wrapped if `debug` is unavailable
-- To use, just place a `bios.lua` in the root of the drive, and run this program
-- Here's a list of things that are irreversibly changed:
-- * both `bit` and `bit32` are kept for compatibility
-- * string metatable blocking (on old versions of CC)
-- In addition, if `debug` is not available these things are also irreversibly changed:
-- * old Lua 5.1 `load` function (for loading from a function)
-- * `loadstring` prefixing (before CC:T 1.96.0)
-- * `http.request`

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@spacejam
spacejam / rr-with-rust.md
Last active July 21, 2024 20:59
using rr with rust

using rust with rr

rr is a great debugging tool. it records a trace of a program's execution, as well as the results of any syscalls it executes, so that you can "rewind" while you debug, and get deterministic forward and reverse instrumented playback. it works with rust, but by default if you try it out, it could be pretty ugly when you inspect variables. if this bothers you, configure gdb to use a rust pretty-printer

rr is probably in your system's package manager.

usage

This work, excluding the Arch Linux logo, is made available under CC0: https://creativecommons.org/publicdomain/zero/1.0/
@chrisdone
chrisdone / Parsing.md
Last active February 9, 2022 11:50
Good parser messages with Parsec

Intro

I've been working on a parser for a Haskell-like syntax called Duet. In the implementation I've taken particular care to make an awesome tokenizer and parser that is super helpful to learners.

Jasper Van der Jeugt made a talk about producing good error messages recently, which coincides nicely with my parallel work on this. So I thought I'd also share my

E017 DO YOU EXPECT ME TO FIGURE THIS OUT?
E079 PROGRAMMER IS INSUFFICIENTLY POLITE
E099 PROGRAMMER IS OVERLY POLITE
E111 COMMUNIST PLOT DETECTED, COMPILER IS SUICIDING
E123 PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON
E127 SAYING ’ABRACADABRA’ WITHOUT A MAGIC WAND WON’T DO YOU ANY GOOD
E129 PROGRAM HAS GOTTEN LOST
E139 I WASN’T PLANNING TO GO THERE ANYWAY
E182 YOU MUST LIKE THIS LABEL A LOT!
E197 SO! 65535 LABELS AREN’T ENOUGH FOR YOU?