Skip to content

Instantly share code, notes, and snippets.

@liamfraser
liamfraser / purge_stability.py
Created April 22, 2015 14:16
Removes #[unstable], #[stable], and #[deprecated] attributes from Rust software
#!/usr/bin/env python3
import sys
import os
target_dir = sys.argv[1]
removes = ['#[unstable', '#[stable', '#[deprecated']
for file in os.listdir(target_dir):
@liamfraser
liamfraser / wc.pl
Created November 5, 2014 19:48
Simple LaTeX word counter
#!/usr/bin/env perl
use strict;
use warnings;
no warnings 'experimental::smartmatch';
# This script counts the number of words in LaTeX section and subsection
# declarations with the ability to ignore lstlisting and various sections
my ($file) = @ARGV;
@liamfraser
liamfraser / wifix
Created October 19, 2014 10:45
Forces shitty router to stick to channel 1
#!/usr/bin/env python2
# Logs into router and makes sure the channel is set to 1
import telnetlib
t = telnetlib.Telnet('192.168.157.254', 23)
t.read_until('Login:')
t.write('admin\r\n')
t.read_until('Password:')
#!/usr/bin/env python3
class Module:
def __init__(self, name, credits):
self.name = name
self.credits = credits
self.mark = None
def calc(self):
return self.credits * self.mark
@liamfraser
liamfraser / disable-blanking
Created May 24, 2014 20:42
Disable screen blanking on a Linux box
#!/bin/sh
xset -dpms
xset s off
void eject_disc(char * cdrom)
{
int fd;
// open the device
fd = open(cdrom, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
fprintf(stderr, "Error: Couldn't open %s\n", cdrom);
return;