Skip to content

Instantly share code, notes, and snippets.

@jaseg
jaseg / gist:cce6a9d250c2d9a120bc
Created July 12, 2014 17:24
Play music links on a subreddit using ipython
In [1]: %rehashx
In [2]: import praw
In [3]: urls = [e.url.replace('https', 'http') for e in praw.Reddit('ipython').get_subreddit('indie_rock').get_hot(limit=30) if 'youtu' in e.url or 'soundcloud' in e.url]
In [4]: for url in urls:
!mpv --no-video "$url"
....:
Playing: http://www.youtube.com/watch?v=sXfLPNv-Axs
[quvi] Checking URL...
[stream] Video --vid=1 (vp8)
[stream] Audio (+) --aid=1 (*) (vorbis)
@jaseg
jaseg / addall.py
Last active August 29, 2015 14:02
Pipe new releases from torrent index RSS feeds into transmission
#!/usr/bin/env python3
import time
import sys
from datetime import datetime
import feedparser
import requests
import json
import sqlite3
import ast
@jaseg
jaseg / fade.py
Created May 25, 2014 12:40
Rainbow terminal cursors
#!/usr/bin/env python
from colorsys import hsv_to_rgb
from time import sleep
from itertools import cycle
for i in cycle(range(100)):
print('\033]12;#{:02x}{:02x}{:02x}\007'.format(*map(lambda x: int(x*255), hsv_to_rgb(i/100, 1, 1))), end='', flush=True)
sleep(0.05)
@jaseg
jaseg / setup.py
Created May 19, 2014 14:41
Install npm with pip
#!/usr/bin/env python3
from distutils.core import setup
from setuptools.command.install import install
script = """#!/bin/sh
# A word about this shell script:
#
# It must work everywhere, including on systems that lack
# a /bin/bash, map 'sh' to ksh, ksh97, bash, ash, or zsh,
@jaseg
jaseg / Makefile
Created May 2, 2014 05:43
How to write a signal handler in amd64 assembly
all:
gcc -Wall -o foo main.c test.S
@jaseg
jaseg / README.md
Created April 28, 2014 10:55
systemd service file for running a transmission-daemon through OpenVPN

What is still missing

  • mullvad-up.sh as called from openvpn.conf would be unnecessary if openvpn would fork after setting up the tun interface, for then its contents could be realized with a few systemd ExecStartPost-directives.
  • Some means of automatically detecting and stopping/reconnecting a broken connection would be nice.
  • Due to libcurl being buggy, transmission-daemon leaks DNS requests. I don't mind, if you do, consider using a couple of iptables rules to route any packets coming from transmission's UID through a special routing table.

Which thinkpad should I buy?

New Kbd Old Kbd
Small X230/X230t X220/X220t
Large T430/T430s T420/T420s
Station W530 W520/W510

#40 series (T440, X240, W540, etc)

@jaseg
jaseg / README.md
Last active March 26, 2024 14:21
Convert openldap .schema files to .ldif files

This is old!

Hey there,

occassionally, people still seem to stumble across this script because it seems it shows up in some search results. Please be aware that I made this script ten years ago, and by now, there is probably a better way to achieve the same result.

Have a nice day!

@jaseg
jaseg / setkeyboard
Last active January 3, 2016 00:48
My xkb setup
#!/bin/bash
# Remaps [TAB] to mean [ESCAPE] (nice for vim) and properly assigns the "Windows
# key" to MOD4 (nice for the awesome window manager)
# Also, sprinkles some unicode over unused or poorly used keys.
# <LGST> is that key next to left shift that is not found on US keyboards
xkbcomp - $DISPLAY<<EOF
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwertz)"};
xkb_types { include "complete"};
xkb_compat { include "complete"};
@jaseg
jaseg / gist:8314578
Created January 8, 2014 10:14
sed script to put `quoted strings` in text in {braces}

:0;s/`/{/;s/`/}/;t0

Because sed does more than just s///