Skip to content

Instantly share code, notes, and snippets.

View grepwood's full-sized avatar

grepwood

  • /root
View GitHub Profile
@grepwood
grepwood / update_iw_blocklist.pl
Last active August 29, 2015 14:07
Updates APF deny_hosts.rules via InterWorx API
#!/usr/bin/perl -w
# deps
use strict;
use warnings;
use Getopt::Std;
require RPC::XML;
require RPC::XML::Client;
use File::Slurp;
my $satisfied = 0;
@grepwood
grepwood / count_ips.c
Last active August 29, 2015 14:07
Automatically unban IPs and force IP unbanning for APF
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
/* If you're using Windows, OSX, or OpenVZ, it's recommended you get grepline
* You can find it here https://github.com/grepwood/grepline */
@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
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-libs/libsdl/libsdl-1.2.15-r4.ebuild,v 1.12 2014/05/15 16:15:03 ulm Exp $
EAPI=5
inherit autotools flag-o-matic multilib toolchain-funcs eutils
DESCRIPTION="Simple Direct Media Layer"
HOMEPAGE="http://www.libsdl.org/"
SRC_URI="http://www.libsdl.org/release/SDL-${PV}.tar.gz"
@grepwood
grepwood / make-debian-ps3-iso.sh
Created September 1, 2014 09:17
This script will convert the latest stable Debian PowerPC netinstall image to one that will work with PS3s running OtherOS++
#!/bin/bash
# This script depends on another script that compiles a patched Linux kernel
# If in doubt, just
# mkdir -p /home/ftp/ps3
# curl https://sucs.org/~grepwood/ps3/linux/kernels/tycho-3.15.10.tar.xz > /home/ftp/ps3/tycho-latest.tar.xz
JOB_PID=$$
curl https://www.debian.org/CD/netinst/ > index.html.$JOB_PID
ISO_URL=`grep powerpc index.html.$JOB_PID | grep -v torrent | sed 's/\">powerpc.*//' | sed 's/.*href=\"//'`
rm -f index.html.$JOB_PID
ISO_FILE=`echo $ISO_URL | sed 's/.*\/iso-cd\///'`
@grepwood
grepwood / rbenv-install-system-wide.sh
Last active August 29, 2015 14:05 — forked from jpfuentes2/rbenv-install-system-wide.sh
Quieter and works on Debian as well
#!/bin/bash
# rbenv system wide installation script
# Forked from https://gist.github.com/jpfuentes2/2002954
JOB_PID=$$
# Installs rbenv system wide on CentOS 5/6 and Debian, also allows single user installs.
if command -v yum >/dev/null 2>&1; then
DISTRO="Redhat"
elif command -v aptitude >/dev/null 2>&1; then
@grepwood
grepwood / purge-other-kernels-than-current.sh
Created August 25, 2014 10:43
This script completely purges other kernels than the current running. Useful for when you've upgraded to a newer one, it's stable, and you don't need the old one.
#!/bin/bash
CURRENT_KERNEL=`uname -r`
OLD_KERNELS=`ls /usr/src/ -l | grep -v ">"| awk '{print $9}' | grep linux | grep -v $CURRENT_KERNEL | sed -r 's/^.{6}//'`
AMOUNT_OF_OLD_KERNELS=`ls /usr/src/ -l | grep -v ">" | awk '{print $9}' | grep linux | grep -v $CURRENT_KERNEL | wc -l`
echo "Amount of kernels to get rid of: $AMOUNT_OF_OLD_KERNELS"
for (( COUNTER=0; COUNTER<$AMOUNT_OF_OLD_KERNELS; COUNTER++ ))
do
HEAD=$((COUNTER+1))
DIR=`ls /usr/src/ -l | grep -v ">" | awk '{print $9}' | grep linux | grep -v $CURRENT_KERNEL | head -n$HEAD | tail -n1`
echo -ne "Fetching package name of kernel #$HEAD... "
@grepwood
grepwood / reset-qmail-queue.sh
Created August 20, 2014 11:31
Resets qmail queue, appropriately archives the old one and leaves behind a useful symlink to the latest bad queue
#!/bin/bash
USER=`whoami`
if [ "$USER" != "root" ]; then
echo "Must be run as root or sudo."
else
cd /var/qmail
service smtp stop
# service send stop
ENTIRE_DATE=`date -R`
YEAR=`echo $ENTIRE_DATE | awk '{print $4}'`
#!/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 / openmw_language_detection.c
Created July 4, 2014 14:37
This function will detect known languages based on the kind of Morrowind gamedata is being fed to it
/* Written by Michael Dec <grepwood@sucs.org>
* Language detection of Morrowind gamedata
*/
structure LDesc_struct
{
unsigned char code; /* Fingers crossed Morrowind wasn't translated to more than 255 languages */
char desc[32]; /* 32 bytes in the .esm that indicate what language this is */
};