Skip to content

Instantly share code, notes, and snippets.

View grepwood's full-sized avatar

grepwood

  • /root
View GitHub Profile
@grepwood
grepwood / malloc_wsl_socket.sh
Created November 30, 2023 23:44
malloc and free WSL interop sockets
#!/usr/bin/env bash
# malloc_wsl_interop_socket synopsis
# stdout: absolute path to valid interop socket
function malloc_wsl_interop_socket {
local INTEROP_PARENT_PID=0
local INTEROP_SOCKET_PID=0
local INTEROP_BAIT_PROCESS='sleep infinity'
pushd / >/dev/null
(/mnt/c/Windows/system32/wsl.exe ${INTEROP_BAIT_PROCESS[@]} >/dev/null) &
@grepwood
grepwood / square.sh
Last active August 30, 2022 16:18
Draws squares in Bash
#!/bin/bash
function internal_rtfm {
echo "Draw squares in bash, with different sides and corners"
echo "Usage: $0 x y z"
echo " x - size of the square to draw"
echo " y - character for sides"
echo " z - character for corners"
exit
}
#!/bin/bash
# Hi I am grepwood, this is OpenTTD, and this - is Jackass
# Before we begin proper, let's define ourselves some functions because we like to keep it simple
function compile {
DESIRED_VERSION=$1
TARBALL_FILE="openttd-$DESIRED_VERSION-source.tar.xz" # XZ, because we like our bandwidth
TARBALL_LINK="http://binaries.openttd.org/releases/$DESIRED_VERSION/$TARBALL_FILE"
COMPILE_OPTIONS="--prefix-dir=/usr/local --enable-profiling --enable-lto --enable-dedicated --with-liblzma --without-liblzo2 --with-threads"
CFLAGS="-march=native -O2 -pipe"
OBS=`cat /proc/cpuinfo | grep vendor_id | wc -l`
@grepwood
grepwood / play_acm.c
Created September 28, 2014 18:17
Plays Interplay's ACM files in SDL2
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <SDL2/SDL.h>
#include <dataio/BigEndian.h>
#include <acm/libacm.h>
/* Written circa 2014 by grepwood@sucs.org */
/* This program will utilize libacm and some string logic
@grepwood
grepwood / fallout4-setup.sh
Created September 20, 2018 01:07
Setup Fallout 4 on Wine
#!/usr/bin/env bash
SCRIPT_NAME="$(basename "${0}")"
FALLOUT4_EXECUTABLE="Fallout4.exe"
WINE_REGISTRY_KEY="HKEY_CURRENT_USER\\Software\\Wine"
FALLOUT4_APPDEFAULTS_REGISTRY_KEY="HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\${FALLOUT4_EXECUTABLE}"
FALLOUT4_INSTALL_REGISTRY_KEY='HKEY_LOCAL_MACHINE\Software\Bethesda Softworks\Fallout4'
USER_SHELL_FOLDERS_REGISTRY_KEY='HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
#!/usr/bin/env python3.6
import requests
import json
import re
from datetime import datetime
from datetime import timedelta
def token():
headers = {
'Accept': 'application/json',
@grepwood
grepwood / start_civ5
Last active July 5, 2018 14:51
Workaround for audio bugs in Gentoo to make Civ5 work again
#!/usr/bin/env bash
set -e
function disable_pa {
if [ $(sudo grep ^autospawn /etc/pulse/client.conf | wc -l) -ne 0 ]; then
sudo sed 's/^autospawn\ =\ yes/autospawn\ =\ no/g' -i /etc/pulse/client.conf
else
sudo su - -c "echo 'autospawn = no' >> /etc/pulse/client.conf"
fi
echo "Disabled Pulseaudio"
}
@grepwood
grepwood / properly_update_portage.sh
Last active August 29, 2015 14:12
Stop living in 2008 and embrace C++11 - useful for people who still have Qt4
#!/bin/bash
function fix_qt4_ebuilds {
pushd /usr/portage/dev-qt
ELEMENT=(core dbus gui script svg)
JOB_PID=$$
for((COUNTER=0, ARRAY_SIZE=${#ELEMENT[*]}; COUNTER < ARRAY_SIZE; ++COUNTER)) do
CCURRENT_ELEMENT=${ELEMENT[COUNTER]}
EBUILD=`ls qt$CURRENT_ELEMENT/qt$CURRENT_ELEMENT-4*.ebuild | tail -n1`
if [ "`grep ^IUSE $EBUILD | grep c\+\+0x | wc -l`" -eq "0" ]; then
cat $EBUILD | sed 's/^IUSE=\"/IUSE=\"c\+\+0x\ /' > ebuild.$JOB_PID
#!/usr/bin/python
import subprocess, shutil, os, sqlite3, re, sys
import utils
def validate_email(email, mode=None):
# There are a lot of characters permitted in email addresses, but
# Dovecot's sqlite driver seems to get confused if there are any
# unusual characters in the address. Bah. Also note that since
# the mailbox path name is based on the email address, the address
@grepwood
grepwood / setup_pdns.sh
Created December 2, 2014 08:38
Sets up PowerDNS on a host in slave or master mode
#!/bin/bash
# Before running this script
RUNLEVELS="235"
HAVE_PASS=0
FEEDED_KEY=""
ROLE=""
JOB_PID=$$
NAN=1
NUMREGEX='^[0-9]+$'
DEPS=""