Skip to content

Instantly share code, notes, and snippets.

@trajing
trajing / restore-colors-and-font.css
Last active August 11, 2021 20:35
Twitter Reversion Userstyle
@-moz-document domain("twitter.com") {
:root {
--follow-text-color: white;
--accent-color: rgb(121, 75, 196);
}
* {
font-family: "Segoe UI" !important;
}
@trajing
trajing / zero_corruption.py
Last active July 1, 2020 04:16
LUCAH corruption zeroing script
import os, pathlib, shutil
print("this doesn't work")
exit()
save_file_dir = pathlib.Path(os.environ['APPDATA']).parent \
/ 'LocalLow' / 'melessthanthree' / 'Lucah_ Born of a Dream'
save_file_location = save_file_dir / 'savedGames.gd'
backup_file_location = save_file_dir / 'savedGames.gd.bak'
@trajing
trajing / fut-cuda.bash
Last active May 3, 2020 07:27
Simple bash script to get CUDA futhark compilation going
#!/usr/bin/env bash
# nonstandard things: bash; ripgrep; mktemp
name=$(basename $@ .fut)
tmpf=$(mktemp)
futhark cuda $@ 2>&1 | tee $tmpf | rg gcc > /dev/null
if [ $? -eq 0 ]
then
gcc -L/opt/cuda/lib64 -I/opt/cuda/include -lm -lcuda -lnvrtc $name.c -o $name
@trajing
trajing / ss13.sh
Last active May 12, 2019 22:48 — forked from Xaltonon/ss13.sh
#!/bin/sh
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
mkdir -p log
echo -e "${GREEN}Checking for wine...${NC}"
@trajing
trajing / error
Created October 25, 2018 14:48
c++ template error
factorial.cpp: In function ‘std::deque<int> pairwise_add(std::deque<int>, std::deque<int>)’:
factorial.cpp:11:24: error: could not convert ‘std::transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation) [with _IIter1 = std::_Deque_iterator<int, int&, int*>; _IIter2 = std::_Deque_iterator<int, int&, int*>; _OIter = std::_Deque_iterator<int, int&, int*>; _BinaryOperation = std::plus<int>](std::deque<_Tp, _Alloc>::end() [with _Tp = int; _Alloc = std::allocator<int>; std::deque<_Tp, _Alloc>::iterator = std::_Deque_iterator<int, int&, int*>](), std::deque<_Tp, _Alloc>::begin() [with _Tp = int; _Alloc = std::allocator<int>; std::deque<_Tp, _Alloc>::iterator = std::_Deque_iterator<int, int&, int*>](), std::deque<_Tp, _Alloc>::begin() [with _Tp = int; _Alloc = std::allocator<int>; std::deque<_Tp, _Alloc>::iterator = std::_Deque_iterator<int, int&, int*>](), (std::plus<int>(), std::plus<int>()))’ from ‘std::_Deque_iterator<int, int&, int*>’ to ‘std::deque<int>’
return std::transform(v1.begin(), v1.end(), v2.be
@trajing
trajing / 01-writeup.md
Last active April 14, 2019 01:21
Python switch/case Using Dynamic except

switch/case in Python

A manner of replicating the functionality of switch and case in other languages using variable type arguments to Python's except keyword.

Dynamic except

Python's except keyword takes as an argument either a type or tuple of types specifying what exceptions to capture (you can also bind the exception object to a variable, but we don't care about that right now.) it functions like so:

try:
@trajing
trajing / memoizer.rb
Created November 14, 2015 23:15
Ruby Simple Memoization
# Play with this at https://eval.in/468799
class Memoizer
class MemoEmpty; end
def initialize(proc = nil, &block) # I should write something to make this easier as well.
@marker == MemoEmpty.new
@cache = {}
@cache.default = @marker
if block_given?
@block = block
elsif proc
@trajing
trajing / ap2ptp.lua
Created September 24, 2015 21:07
AP2PTP
function init(modemBinding, starterChannel, nextChannelFn)
modemBinding.open(starterChannel)
local stateTable = {
modemBinding = modemBinding,
chan = starterChannel,
nextfn = nextChannelFn
}
return stateTable -- Until I can figure out metatables, this will be strictly function-based.
end