Skip to content

Instantly share code, notes, and snippets.

View lifning's full-sized avatar
💜

liffy lifning

💜
View GitHub Profile
@lifning
lifning / now-playing.py
Last active September 28, 2015 00:08
xchat lastfm now-playing
# -*- coding: utf-8 -*-
# a last.fm now playing script originally written by Brandon Sutton
# some modifications by lifning
__module_name__ = "last.fm"
__module_version__ = "1.0"
__module_description__ = "/np for last.fm"
try:
import hexchat as xchat
except ImportError:
@lifning
lifning / libsnes-pygame.py
Created November 23, 2011 19:35
Quick and dirty libsnes-based emulator using pygame.
#!/usr/bin/env python2
import sys, getopt, ctypes, struct
import pygame, numpy
from snes import core as snes_core
# libsnes library to use by default.
@lifning
lifning / mmmulticamcamcam.sh
Created February 18, 2012 06:19
gstreamer-based camera simulator
#!/bin/bash
DEV=$(zenity --file-selection \
--filename=/dev/video0 \
--file-filter='V4L2 loopback devices | video*')
echo "Select a window to capture..."
XID=$(xwininfo -int | grep 'Window id' | awk '{print $4}')
# camera width/height
@lifning
lifning / jsdump.py
Last active December 17, 2021 01:43
A simple pygame-based script to dump joystick events. Useful if jstest isn't readily available.
#!/usr/bin/env python3
from pygame import display, joystick, event
from pygame import QUIT, JOYAXISMOTION, JOYBALLMOTION, JOYHATMOTION, JOYBUTTONUP, JOYBUTTONDOWN
h = {
(0,0): 'c',
(1,0): 'E', (1,1): 'NE', (0,1): 'N', (-1,1): 'NW',
(-1,0): 'W', (-1,-1): 'SW', (0,-1): 'S', (1,-1): 'SE'
}
@lifning
lifning / pddl-domain.lisp
Created June 9, 2012 03:37
some ideas for data format and so on.
(define (domain n64-zelda-majora)
(:requirements :typing :fluents :durative-actions)
(:types
item cycevt location object
)
(:constants
bow ocarina powder-keg goron-mask eponas-song song-of-time - item
@lifning
lifning / glc-encode.sh
Created June 14, 2012 09:18
A quick and dirty script to convert glc dumps to MKV using ffmpeg. Created because mencoder, which the glc encode script uses, is broken and old.
#!/bin/bash
mkfifo ${1}.{yuv,wav}
glc-play ${1} -y 1 -o ${1}.yuv &
glc-play ${1} -a 1 -o ${1}.wav &
ffmpeg -i ${1}.yuv -i ${1}.wav ${1}.mkv
rm -f ${1}.{yuv,wav}
@lifning
lifning / glc-stream.sh
Created June 16, 2012 01:42
Used in conjunction with glc and v4l2loopback, this can stream games.
#!/bin/bash
mkfifo fifo.glc
glc-capture -o fifo.glc -s "${@}" &
glc-play fifo.glc -y 1 -t -o - | yuv4mpeg_to_v4l2 /dev/video1
rm -f fifo.glc
@lifning
lifning / glc-stream-and-record.sh
Created June 16, 2012 07:32
An attempt at a streaming-and-recording GLC script that doesn't work.
#!/bin/bash
mkfifo fifo.{glc,yuv,wav} fifosound.glc
glc-capture -o - -s $* | tee -a fifosound.glc > fifo.glc &
ffmpeg -i fifo.yuv -i fifo.wav -o recording.mkv &
glc-play fifosound.glc -a 1 -t -o fifo.wav &
glc-play fifo.glc -y 1 -t -o - | tee -a fifo.yuv | yuv4mpeg_to_v4l2 /dev/video1
@lifning
lifning / get-checksums.sh
Created October 9, 2012 02:50
Quick and dirty script to get multiple types of checksum for a file.
#!/bin/bash
dir=$(mktemp -d)
cmd="cat \"${1}\" | tee"
shift
sums="md5 sha1"
if [ ! -z "${*}" ] ; then
sums="${@}"
@lifning
lifning / jtv-glc.sh
Created November 25, 2012 10:11
Scripts for streaming to twitch.tv on Linux.
#!/bin/bash
JTV_STREAM_KEY=$(cat ~/Dropbox/jtv-key)
JTV_STREAM_URL=rtmp://live.justin.tv/app/${JTV_STREAM_KEY}
exec glc-capture --disable-audio -f 30 -z none -o /dev/stdout -s "${@}" \
| glc-play /dev/stdin -y 1 -o /dev/stdout \
| ffmpeg \
-f yuv4mpegpipe -i /dev/stdin \
-f pulse -itsoffset 0.2 -sample_rate 22050 -i default \
-f flv -vcodec libx264 -vf "scale=-1:360" -r 30 \