Skip to content

Instantly share code, notes, and snippets.

View BenGoldberg1's full-sized avatar

Ben Goldberg BenGoldberg1

View GitHub Profile
@BenGoldberg1
BenGoldberg1 / F11-Fullscreen.ahk
Created February 26, 2021 02:44
Borderless window mode which cleans up after itself
;;; Known issues:
;;;
;;; - Weird results for windows with custom decorations such as
;;; Chrome, or programs with a Ribbon interface.
;;; - Emacs will be maximized behind instead of in front of
;;; the taskbar. Workaround: WinHide ahk_class Shell_TrayWnd
global id2undoer := Object()
#SingleInstance force
@BenGoldberg1
BenGoldberg1 / unpickable.txt
Created December 1, 2020 02:59
Unpickable Lock Idea
For several types of locks, the best known means of bypassing them is by by picking.
For many locks, including pin-tumbler, wafer-tumber, disc-tumbler, and tubular lock, picking requires not just a pick to fiddle with the innards of the lock, but also a tensioner to keep the fiddled-with components in the position that the person picking the lock has moved them to.
This idea is to make a lock which cannot be tensioned, which in turn means that it cannot be picked.
Here's how it works:
The lock plug, the part of the lock which the user puts the key into, and which would normally be rotated by turning the key, and which is normally connected to the latch or deadbolt, is instead welded/bolted/splined to the housing / lock body, and is not connected to the latch or deadbolt. Naturally, it is unable to be turned.
This is an idea for a memory allocator which whose purpose is to make it much faster to save and load lots of pieces of data.
The fucntions of the library would be named persistant_malloc, persistant_free, persistant_realloc, persistant_calloc, persistant_pointer2integer, persistant_integer2pointer, all of which take a first argument which has a handle which contains all of the data tables typical of a malloc library. There would also be something like persistant_malloc_fopen, persistant_malloc_fsave, persistant_malloc_fclose, for creating the handle, storing it's contents to disk, and freeing the handle.
None of the three allocation functions will use sbrk to allocate memory, nor do they use mmap with MAP_ANONYMOUS to ask the OS to give them new blank pages; instead, they lengthen a certain disk file, and then mmap the region from the file's former end to it's new end, with the flags MAP_SHARED, and PROT_READ | PROT_READ.
The pointer2integer function gets a handle and a pointer; the pointer must have bee
@BenGoldberg1
BenGoldberg1 / Primes3.cpp
Created September 22, 2017 03:05
Yet another primes streamer.
#include <iostream>
#include <deque>
// This code requires -std=c++11 or better because lambda.
int main() {
std::deque<unsigned> primes;
std::deque< std::deque<unsigned> > factors( 3 );
unsigned a_prime = 3, a_square_prime = 9, maybe_prime = 3;
std::cout << "2 3";
@BenGoldberg1
BenGoldberg1 / AutoNick.pl
Last active October 14, 2017 02:17
Hexchat Script to acquire preferred nick asap.
#!perl
package AutoNick;
use strict;
use warnings;
use HexChat qw,:all,;
# Change this to a true value to see some debug output.
use constant DEBUGGING => 0;
@BenGoldberg1
BenGoldberg1 / NativeCall.pm6
Created June 28, 2017 04:01
Failing Attempt at improving NativeCall (see second attached file)
use nqp;
module NativeCall {
use NativeCall::Types;
use NativeCall::Compiler::GNU;
use NativeCall::Compiler::MSVC;
#'{
my package EXPORT::DEFAULT {
@BenGoldberg1
BenGoldberg1 / Perl6.c
Last active March 7, 2017 23:37
Perl6 Hexchat plugin
#include "Perl6.h"
#include <moar.h>
#define HEXCHAT_PLUGIN_HANDLE (perl6hc_ph)
#include "hexchat-plugin.h"
#define PNAME "Perl6"
#define PDESC "Perl 6 scripting interface"
#define VERSION "0.1"
sub ben_sort {
return unless @_ > 1;
while( 1 ) {
my $prior = shift;
my @sublists = ([$prior]);
my $sublist_ix = 0;
for my $item (splice @_) {
my $cmp = $item <=> $prior;
$sublist_ix += $cmp;
if( $sublist_ix < 0 ) {
@BenGoldberg1
BenGoldberg1 / ack.pl6
Last active October 7, 2016 03:28
Yet another Ackermann function impl.
use v6;
sub ack(Int $m is copy, Int $n is copy) {
my @stack;
loop {
if $m > 3 {
--$m;
push @stack, ($m xx $n).Slip;
--$m;
push @stack, (3 .. $m).reverse.Slip;
$n = 13;
# From https://docs.perl6.org/routine/trusts.html
class B {...};
class A {
trusts B;
has $!foo;
method !foo { return-rw $!foo }
method perl { "A.new(foo => $!foo)" }
};
class B {
has A $.a .= new;