Skip to content

Instantly share code, notes, and snippets.

@keeler
keeler / fix_apt_update_old_release.sh
Created December 19, 2020 18:55
Address apt-get error 'The repository no longer has a release file'
# Happens when you didn't update to latest ubuntu when you should have.
# For shame. Here's how to fix.
# Credit to: https:digitalocean.com/community/questions/unable-to-apt-update-my-ubuntu-19-04
cp /etc/apt/sources.list ~/sources.list.bak
sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update && sudo apt-get dist-upgrade
@keeler
keeler / make_hsk_flashcards.sh
Created July 7, 2020 04:07
Transforms HSK vocab lists on Github into TSVs of flashcards for import into AnkiApp on iOS.
#!/bin/bash
# Transform list into flashcards with chars on front and pinyin/defn on back.
list_to_flashcards () {
LEVEL=$1
URL="https://raw.githubusercontent.com/glxxyz/hskhsk.com/main/data/lists/HSK%20Official%20With%20Definitions%202012%20L${LEVEL}%20freqorder.txt"
OUTFILE="HSK${LEVEL}.tsv"
curl -s $URL \
| sed 's/\r$//' \
@keeler
keeler / gitconfig
Last active December 5, 2017 22:04
Git aliases
[alias]
co = checkout
ci = commit
st = status -s
br = branch
ls = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit --decorate
ll = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit --decorate --numstat
type = cat-file -t
dump = cat-file -p
undo = reset --soft HEAD~1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
int main(int argc, char** argv)
{
if(argc != 2)
{
printf("usage: %s <pid>", argv[0]);
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
const int size = 256;
char ip_address[size];
int hw_type;
int flags;