Skip to content

Instantly share code, notes, and snippets.

@shaunhey
shaunhey / efi.sh
Created June 29, 2023 22:48
Script to recreate Arch Linux EFI boot entries
#!/bin/sh
# Delete the existing entries
#sudo efibootmgr --unicode -B -b 0001
sudo efibootmgr --unicode -B -b 0000
# Create the new entries
sudo efibootmgr -c \
--label "Arch Linux" \
--loader /vmlinuz-linux \
@shaunhey
shaunhey / dbus_mpris_notify.py
Created April 27, 2017 01:46
Example on how to use python-dbus to receive notification of song changes
#!/usr/bin/env python
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
def on_properties_changed(interface, props, invalidated_props):
if "Metadata" in props:
metadata = props.get("Metadata")
@shaunhey
shaunhey / program.cs
Created January 31, 2016 21:14
Playing with simple genetic algorithms...
using System;
using System.Collections.Generic;
using System.Text;
namespace ml
{
public class Citizen
{
private static int _nextId = 0;
@shaunhey
shaunhey / waves.py
Created December 5, 2015 21:45
Pygame script to create a waving flag effect
import pygame
def main():
arc = 0.25
base_angle = 0.0
circle_width = 20
circle_height = 20
fps = 60
speed = 0.1
window_width = 800
@shaunhey
shaunhey / convert_flac_to_mp3
Last active March 29, 2019 13:49
Quick script to scan FLAC files and convert those to MP3 that don't exist
#!/bin/bash
# Quick script to scan FLAC files and convert those to MP3 that don't exist
queuefile="/tmp/flac2mp3queue.txt"
echo "****************************************************************"
echo "Begin process at `date`"
if [ -f "$queuefile" ]
then
@shaunhey
shaunhey / flac2mp3
Created August 26, 2015 03:52
Script to convert all FLAC files in the current folder to 320k MP3 files
#!/bin/sh
# Script to convert all FLAC files in the current
# folder to 320k MP3 files
parallel ffmpeg -i "{}" -ab 320k "{.}.mp3" ::: *.flac
@shaunhey
shaunhey / ripcd
Created August 26, 2015 03:39
Script to rip a CD in FLAC format using Morituri
#!/bin/sh
# Script to rip a CD in FLAC format using Morituri
# Offset is for Optiarc AD-7710H
rip cd rip --offset 48 --track-template="%A/%d/%t %a - %n" --disc-template="%A/%d/%A - %d"
@shaunhey
shaunhey / crawler.py
Created October 18, 2014 21:55
Pygame script to generate "crawling" effect
import pygame, random, sys, time
def main():
width = 640
height = 480
x = width / 2
y = height / 2
shade = 0
<html>
<head>
<script type="text/javascript">
var NONE = 0;
var PLUS = 1;
var MINUS = -1;
function calculateWeightedProduct(digit, weight, sign) {
var value = digit * weight;
@shaunhey
shaunhey / arch.sh
Created February 12, 2013 04:21
bash script for entering Arch Linux chroot on Samsung Chromebook (ARM) -- Based on the excellent instructions found at http://solvitor.com/2013/01/02/lamp-stack-on-an-arm-chromebook/
#!/bin/bash
echo "chrooting to Arch Linux"
sudo cp /etc/resolv.conf /usr/local/arch/etc/resolv.conf
sudo mount -o bind /dev /usr/local/arch/dev
sudo mount -t devpts -o rw,nosuid,noexec,relatime,mode=620,gid=5 none /usr/local/arch/dev/pts
sudo mount -t proc proc /usr/local/arch/proc
sudo mount -t sysfs sys /usr/local/arch/sys
sudo chroot /usr/local/arch /bin/su - <your username here>
echo "leaving Arch Linux chroot"