Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Skoufis askoufis

View GitHub Profile
@askoufis
askoufis / tag_toggler.py
Created Jan 14, 2019
Anki 2.1 tag toggler
View tag_toggler.py
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)
@askoufis
askoufis / retry.sh
Created Apr 11, 2018
Bash retry function with exponential backoff
View retry.sh
#!/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 / kaomoji_dicgen.py
Created Sep 7, 2017
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.
View kaomoji_dicgen.py
# 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')])