Skip to content

Instantly share code, notes, and snippets.

@SpecLad
SpecLad / demo-classification.py
Created December 15, 2022 16:48
CVAT/PyTorch demos
#!/usr/bin/env python
import logging
import os
import cvat_sdk
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
@SpecLad
SpecLad / yt-lone-vids.py
Last active June 8, 2019 20:49
Tool to find YouTube videos not in playlists
#!/usr/bin/env python3
"""
This script will find, for a given YouTube channel, videos on that channel
that are not in any playlists on that channel.
It requires the google-api-python-client package.
"""
import apiclient.discovery
@SpecLad
SpecLad / wires.py
Last active January 21, 2018 17:16
Tools for not exploding
#!/usr/bin/env python3
import collections
import sys
def rindex(l, e):
return len(l) - 1 - l[::-1].index(e)
@SpecLad
SpecLad / wavdump.py
Created December 27, 2014 23:07
Dump components and optionally raw samples from WAVE files
#!/usr/bin/python3
import argparse
import chunk
import contextlib
import struct
info_chunks = set((
b'IARL', b'IART', b'ICMS', b'ICMT', b'ICOP', b'ICRD', b'ICRP',
b'IDIM', b'IDPI', b'IENG', b'IGNR', b'IKEY', b'ILGT', b'IMED', b'INAM',
@SpecLad
SpecLad / qgetent.py
Created November 25, 2014 22:24
Dump entities from Quake map files
#!/usr/bin/python3
import glob
import os.path
import struct
import sys
def main():
dir_name = sys.argv[1]
@SpecLad
SpecLad / BrainFuck.java
Created November 15, 2014 22:12
brainfuck interpreter in Java
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.ListIterator;
public class BrainFuck {
@SpecLad
SpecLad / m3uread.py
Created October 18, 2014 18:12
m3u2nsfe - script to convert NEZplug NSF M3U playlists into NSFE files
import collections
import csv
_csv_params = {
'strict': True,
'quoting': csv.QUOTE_NONE,
'escapechar': '\\',
}
def _parse_song_num(s):
@SpecLad
SpecLad / led.c
Created May 12, 2014 17:38
Control keyboard LEDs from command line
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
int main(int argc, char * argv[]) {
@SpecLad
SpecLad / Main.hs
Created November 30, 2013 15:19
Sinewave simulator
module Main where
import Control.Exception
import Control.Monad
import Data.Int
import Data.IORef
import Foreign.C
import Foreign.Marshal
import Foreign.Ptr
import Foreign.Storable
@SpecLad
SpecLad / github-pr-plot.py
Last active December 27, 2015 14:59
Output number of GitHub pull requests as a function of time
#!/usr/bin/env python3
import collections
import datetime
import getpass
import itertools
import os
import sys
import dateutil.parser