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) &
#!/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 / 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'
@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 / 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
}
@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=""
@grepwood
grepwood / ssl_test.pl
Last active August 29, 2015 14:09
Tests SSL connection with specified host and port
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
use HTTP::Request;
use LWP::UserAgent;
use Net::SSLeay;
use IO::Socket::SSL;
my $options=();
@grepwood
grepwood / iw-lsmailq.pl
Last active August 29, 2015 14:07
Lists mail queue count with InterWorx API
#!/usr/bin/perl -w
# Tough skin and sharp criticism ahead
use strict;
use warnings;
# Dependencies
use File::Slurp;
use Getopt::Std;
require RPC::XML;
require RPC::XML::Client;