Skip to content

Instantly share code, notes, and snippets.

View askoufis's full-sized avatar

Adam Skoufis askoufis

View GitHub Profile
@askoufis
askoufis / kaomoji_dicgen.py
Created September 7, 2017 13:21
Pulls kaomoji from http://kaomoji.n-at.me/kaomoji.html into a text file that can be parse by the Google Japanese IME. Taken from https://gist.github.com/kakakaya/3b40a074a6dc7e8717154e85c0aa52e6 and added a few lines to make it work for me.
# encoding=utf-8
from bs4 import BeautifulSoup
import requests
import sys
reload(sys)
sys.setdefaultencoding('utf8')
soup = BeautifulSoup(requests.get("http://kaomoji.n-at.me/kaomoji.html").text, "html.parser")
kaomojis = filter(None, ['かおもじ\t'+i.getText()+'\t顔文字' if '\n' not in i.getText() else None for i in soup.find_all('span', class_='kaomoji')])
@askoufis
askoufis / retry.sh
Created April 11, 2018 05:26
Bash retry function with exponential backoff
#!/bin/bash
# Retry a command with exponential backoff
function retry {
local maxAttempts=$1
local secondsDelay=1
local attemptCount=1
local output=
shift 1
@askoufis
askoufis / tag_toggler.py
Created January 14, 2019 10:09
Anki 2.1 tag toggler
from aqt import mw
from aqt.reviewer import Reviewer
class TagTogglerReviewer(Reviewer):
# Keep Python from complaining that self.shortcuts doesn't exist.
shortcuts = []
def __init__(self, mw):
super().__init__(mw)