Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Glenn garfieldnate

View GitHub Profile
View valgrind suppressions for std::string
{
Dynamic Linker Bug
Memcheck:Cond
fun:_dl_relocate_object
fun:dl_main
fun:_dl_sysdep_start
fun:_dl_start
obj:/lib/ld-2.6.so
}
{
@garfieldnate
garfieldnate / build_dict.py
Created July 14, 2022 09:42
Create custom user dictionary for use in MeCab through Fugashi
View build_dict.py
# Generate custom MeCab dictionary to be used with unidic-lite
import sys
from fugashi.fugashi import build_dictionary
import unidic_lite
args = (
sys.argv[0]
@garfieldnate
garfieldnate / asserts.sh
Created January 12, 2022 17:00
assert command output in Bash
View asserts.sh
#!/bin/bash
pass() {
message=$1;
# bold green
echo -e "$(tput setaf 2)$(tput bold)$message$(tput sgr 0)"
}
fail() {
message=$1;
@garfieldnate
garfieldnate / assert_ipython_globals_managed.py
Created May 11, 2021 14:07
check that your handling of global variables in a Jupyter notebook is clean
View assert_ipython_globals_managed.py
import inspect
from IPython.display import display, HTML
def html(s):
return display(HTML(s))
def ok(message="OK"):
html(f"<div class=\"alert alert-block alert-success\">{message}</div>")
def _acceptable_global(name, value):
@garfieldnate
garfieldnate / import_khamsapt.py
Last active January 12, 2020 09:17
Parse CSV vocab output from ThaiDict app
View import_khamsapt.py
# Parse CSV vocab output from ThaiDict app
import csv
import sys
# from tango.tango import model
def row_to_vocab(row):
v = {
'headword': row['th'],
'pronunciation': row['pron'],
@garfieldnate
garfieldnate / build.gradle
Created July 8, 2018 14:27
Example gradle build that uploads to Bintray and Maven Central
View build.gradle
// Useful tasks:
// (default) jar: creates library jar
// fatJar: creates executable jar
// bintrayUpload: performs full publishingTasks/publication
apply plugin: 'java'
wrapper {
gradleVersion = '4.8.1'
}
@garfieldnate
garfieldnate / imgcat.py
Last active October 9, 2020 09:16
Python 2/3 version of imgcat tool, which displays images inline in iTerm2
View imgcat.py
from __future__ import print_function
import base64
import os
import select
import sys
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
@garfieldnate
garfieldnate / list_chars.pl
Last active August 29, 2015 14:07
List non-ascii characters in input file
View list_chars.pl
# This will look through an input utf8 file and print a list
# of all of the non-ascii characters found there. Not good for
# big files, since it stores and sorts all occurrences.
use strict;
use warnings;
use charnames ':full';
binmode STDOUT, 'utf8';
open my $fh, '<:utf8', $ARGV[0];
@garfieldnate
garfieldnate / knowledge.txt
Last active August 29, 2015 13:56
WICS Knowledge Transfer
View knowledge.txt
First, you can go and watch an intro video on ITS here: http://www.youtube.com/watch?v=5Goet3hX6Jo
Here's the ITS 2.0 specification: http://www.w3.org/TR/its20/. I recommend reading sections 1 and 2 straightaway.
The ITS Interest Group mailing archive: http://lists.w3.org/Archives/Public/public-i18n-its-ig/
You can join and ask good questions. You'll find lots from me. But do make sure they are good questions about ITS.
You can go and watch an intro video on WICS here: http://tinyurl.com/luzwgzd
Here are the GitHub repositories. The first two are managed by Logrus, and I have a commit bit to the converter one. The third repo is managed by us and is a fork of the converter repo managed by Logrus (please use it and not the Logrus one). It has the added functionality of a WICS "project", as well as some bug fixes:
@garfieldnate
garfieldnate / TRG Projects NathanG Knows About
Last active August 29, 2015 13:56
These are all of the projects I can remember having worked on with TRG. I'll update it if I think of more, or you can fork it and add more if you'd like.
View TRG Projects NathanG Knows About
The following are hosted on GitHub:
TBX::Min
read/edit/write TBX-Min data
Convert::TBX::[UTX|Min|Basic]
convert between UTX, TBX-Min and TBX-Basic.
Convert::MRC
convert MRC to TBX-Basic
TBX::XCS
read XCS files