Skip to content

Instantly share code, notes, and snippets.

@why-not
why-not / gist:4582705
Last active July 3, 2024 01:12
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])
#!/usr/bin/env python
'''Crop an image to just the portions containing text.
Usage:
./crop_morphology.py path/to/image.jpg
This will place the cropped image in path/to/image.crop.png.
For details on the methodology, see
@markwk
markwk / writings-tracking-with-git.bash
Last active July 12, 2024 10:42
My Writings Tracker with Git: A bash script for tracking my writings in plain tex files, calculate stats like word count, hashtags and new files, store stats to csv and commit to git.
#!/bin/bash
##################################
#
# THE ARCHIVE TRACKER
#
# REF: https://gist.github.com/markwk/c85a8a72bc8c03d0f510262bb5219a34/
#
# INTRODUCTION:
# Daily script to navigate to a directory of plain text files,
# add files to git repo, calculate key stats, store stats to csv
@phoenixenero
phoenixenero / stats.py
Last active October 5, 2021 13:14
pretty stats for Japanese Support Anki 2.1 Add-on
# -*- coding: utf-8 -*-
# Copyright: Damien Elmes <anki@ichi2.net>
# Used/unused kanji list code originally by 'LaC'
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
import unicodedata
from anki.hooks import addHook
from anki.utils import ids2str, splitFields
from aqt import mw
from aqt.webview import AnkiWebView
@kanjieater
kanjieater / __init__.py
Last active August 18, 2019 21:20
automate mia japanese calls
from aqt import mw
from aqt.qt import QAction, QKeySequence
from anki.hooks import addHook
buttonText = "-------------Bulk-add Routine------------"
ROUTE_1_KEY = 'Ctrl+9'
def setupMenu(browser):
from importlib import reload
"""
Download data from RescueTime.
Inspired by https://gist.github.com/veekas/2fe3cf30fe6375f5d121c6372a550000
Also see https://www.rescuetime.com/anapi/setup/documentation
"""
import urllib.parse
import urllib.request
import requests
@k3zi
k3zi / pronunciation-resources.md
Last active February 10, 2024 09:15
English and Japanese Pronunciation Resources

Pronunciation Resources

Comment if you would like to see a resource added to the list.

Guides / Courses

あいうえおフォニックス (🇬🇧 English, Web, Free)
English phonetics video series made for a Japanese audience.
https://youtube.com/channel/UCX2tvXwAItLs5RhFFSGn9LQ

Dogen: Japanese Phonetics Series (🇯🇵 Japanese, Web, Paid)