Skip to content

Instantly share code, notes, and snippets.

@silverhammermba
silverhammermba / state_machine.swift
Created October 20, 2023 11:47
Swift state machine example
protocol State {
func nextState() -> Self
}
class StateMachine<T: State> {
private(set) var currentState: T
init(_ initialState: T) {
currentState = initialState
}
@silverhammermba
silverhammermba / dice_system.rb
Created September 4, 2023 20:46
Script for calculating probabilities for custom dice system
require 'set'
class Or
def initialize *ands
@ands = ands
end
def to_a
@ands
end
@silverhammermba
silverhammermba / terrible.rb
Last active May 23, 2022 17:45
Generates word searches with only a single word to find, but every letter in the grid is in the word.
#!/usr/bin/env ruby
# terrible word search generator
# inspired by http://cnlohr.blogspot.com/2014/02/to-make-terrible-wordsearches.html
if ARGV.length != 3
STDERR.puts "usage: #$0 WIDTH HEIGHT WORD"
exit 1
end
$word = ARGV[2].upcase
@silverhammermba
silverhammermba / PKGBUILD
Created May 30, 2014 22:40
Synaptics Palm Detection patch
# $Id: PKGBUILD 213056 2014-05-18 13:44:18Z andyrtr $
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Thomas Bächler <thomas@archlinux.org>
# Contributor: Alexander Baldeck <alexander@archlinux.org>
pkgname=xf86-input-synaptics
pkgver=1.8.0
pkgrel=2
pkgdesc="Synaptics driver for notebook touchpads"
@silverhammermba
silverhammermba / dmesg
Created December 26, 2019 19:34
dmesg output for xpadneo issue
[ 0.000000] microcode: microcode updated early to revision 0x21, date = 2019-02-13
[ 0.000000] Linux version 5.4.6-arch1-1 (linux@archlinux) (gcc version 9.2.0 (GCC)) #1 SMP PREEMPT Sat, 21 Dec 2019 16:34:41 +0000
[ 0.000000] Command line: root=UUID=a487a5aa-c376-4a43-bd8c-35692a8fb46b rw initrd=/intel-ucode.img initrd=/initramfs-linux.img acpi_osi="!Windows 2012"
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
@silverhammermba
silverhammermba / gamma.html
Created December 7, 2017 20:53
hackin on gamma
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<article>
<h1>Yet another article about gamma correction</h1>
<style>
.gradstop {
@silverhammermba
silverhammermba / log.txt
Created May 4, 2017 15:42
Wine Steam Log
err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
fixme:ver:GetCurrentPackageId (0x32e470 (nil)): stub
fixme:process:ProcessIdToSessionId Unsupported for other processes.
fixme:winhttp:get_system_proxy_autoconfig_url no support on this platform
fixme:winhttp:WinHttpDetectAutoProxyConfigUrl discovery via DHCP not supported
fixme:ntdll:EtwEventRegister ({47a9201e-73b0-42ce-9821-7e134361bc6f}, 0x3f006740, 0x3f041d28, 0x3f041d20) stub.
fixme:ntdll:EtwEventRegister ({58a9201e-73b0-42ce-9821-7e134361bc70}, 0x3f0067
@silverhammermba
silverhammermba / example.rb
Last active May 20, 2016 01:42
method for testing a program with various settings
require_relative './test_run'
x = run(key_max: 25_000, threads: (1..4), iters: 1_000_000, n: 21, read: 10, branch: %w{locking2})
File.open('box.data', 'w') do |f|
x.each do |r|
r[:ticks].each { |y| f.puts "#{y} #{r[:threads]}" }
end
end
@silverhammermba
silverhammermba / themer.rb
Last active April 22, 2016 02:53
Generate awesome theme from background image
#!/usr/bin/env ruby
# pick a random background and generate an awesome theme based on it
require 'color'
require 'color/palette/monocontrast'
require 'erb'
require 'fileutils'
require 'imlib2'
require 'optparse'
require 'shellwords'
@silverhammermba
silverhammermba / roll.rb
Created April 25, 2013 23:04
Dice Rolling Script
#!/usr/bin/env ruby
# dice rolling from the command line
# e.g. 2x3d6+4, d6
def parse str
raise ArgumentError.new("Bad roll string: #{str}") unless str =~ /^((\d+)x)?(\d+)?d(\d+)([+-]\d+)?$/
times = 1
times = $2.to_i if $2
number = 1
number = $3.to_i if $3