Skip to content

Instantly share code, notes, and snippets.

View seanbreckenridge's full-sized avatar
🍍

seanbreckenridge

🍍
View GitHub Profile
@seanbreckenridge
seanbreckenridge / download_computer_science_61.py
Last active June 23, 2022 16:50
A script to download all the videos for the Berkley Computer Science 61A class
# A script to download all the videos from
# https://archive.org/details/ucberkeley-webcast-PL3E89002AA9B9879E?sort=titleSorter
# python3.7
# pip3 install --user selenium youtube-dl
import youtube_dl
from selenium import webdriver
driver = None
@seanbreckenridge
seanbreckenridge / aiofiles_test.py
Last active August 5, 2019 00:15
Read a file asynchronously using aiofiles, remove empty lines from a file
# python3 aiofiles_test.ty some_file_with_newlines
import sys
import asyncio
import aiofiles
async def read(filename):
async with aiofiles.open(filename, mode='r') as f:
return await f.read()
@seanbreckenridge
seanbreckenridge / __getattribute__.py
Last active September 15, 2019 16:28
Testing a hack around an existing library, to add pre/post hooks to functions
class Library:
def a(self, n):
print('a' * n)
def b(self, n):
print('b' * n)
class Extender(Library):
#!/usr/bin/env python3
import time
from ratelimit import limits
from backoff import on_exception, fibo
import requests
LIMIT = 10
WITHIN_TIME = 15
@seanbreckenridge
seanbreckenridge / gen.ex
Created October 30, 2019 20:41
Trivial elixir GenServer example
defmodule Basic do
use GenServer
# starts the process
def start_link do
GenServer.start_link(__MODULE__, "Hello")
end
# initializes data for process
def init(initial_data) do
@seanbreckenridge
seanbreckenridge / bext.py
Last active November 13, 2019 06:01
use __doc__ as error string
"""
Install bext by doing this stuff
Linux
Mac
"""
import sys, random, time
<?php
function getScoredBy($scoredBy):
{
$scoredByNum = str_replace(
[',', ' users', ' user'],
'',
$scoredBy
);
@seanbreckenridge
seanbreckenridge / backup_server.sh
Last active July 4, 2020 12:16
backup important files from my server
#!/bin/bash
# Backs up stuff from my server
# run with https://sean.fish/d/housekeeping?dark
BACKUP_LOG='/tmp/backup.log'
mv "${HOME}/.cache/backup_dir.tar.gz" "${HOME}/.cache/backup_dir.tar.gz.bak"
date >> /tmp/backup.log
ssh vultr "~/vps/backup" >> "${BACKUP_LOG}" && \
scp vultr:~/vps/backup_dir.tar.gz "${HOME}/.cache" >> "${BACKUP_LOG}"
@seanbreckenridge
seanbreckenridge / remsync_output.txt
Created March 30, 2020 05:07
example remsync output
$ remsync assets elm.json
'assets' -> '/home/sean/.local/share/remsync/assets'
'assets/Montserrat-BoldItalic.ttf' -> '/home/sean/.local/share/remsync/assets/Montserrat-BoldItalic.ttf'
'assets/favicon' -> '/home/sean/.local/share/remsync/assets/favicon'
'assets/favicon/apple-touch-icon.png' -> '/home/sean/.local/share/remsync/assets/favicon/apple-touch-icon.png'
'assets/favicon/favicon-32x32.png' -> '/home/sean/.local/share/remsync/assets/favicon/favicon-32x32.png'
'assets/favicon/favicon-16x16.png' -> '/home/sean/.local/share/remsync/assets/favicon/favicon-16x16.png'
'assets/favicon/favicon.ico' -> '/home/sean/.local/share/remsync/assets/favicon/favicon.ico'
'assets/favicon/android-chrome-192x192.png' -> '/home/sean/.local/share/remsync/assets/favicon/android-chrome-192x192.png'
'assets/favicon/android-chrome-512x512.png' -> '/home/sean/.local/share/remsync/assets/favicon/android-chrome-512x512.png'
@seanbreckenridge
seanbreckenridge / qtile_display_kb.py
Last active March 23, 2023 13:17
print a table of the current keybindings in qtile (v 0.15.1)
#!/usr/bin/env python
#
# Copyright (c) 2017, Piotr Przymus
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: