Skip to content

Instantly share code, notes, and snippets.

@yy
yy / monex.py
Last active November 4, 2020 01:49
MONitor multiple files & EXecute the given command.
#!/usr/bin/env python
# encoding: utf-8
"""
MONitor & EXecute
Yong-Yeol Ahn (http://yongyeol.com/)
This script monitors multiple files and executes the given command when
any of those files is changed.
"""
@yy
yy / Makefile
Created February 3, 2011 02:11
A sample makefile for a paper in LaTeX.
TEX = pdflatex -interaction nonstopmode
BIB = bibtex
GS = gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite
COVER = cover
PAPER = paper_main
SUPP = paper_supp
BIBFILE = temp.bib
BUNDLE = paper_bundle.pdf
#!/usr/bin/env python
import sys
import json
import httplib
class FuncAssociate(object):
"""Query funcassociate to find out enriched GO terms."""
host = 'llama.mshri.on.ca'
query_url = '/cgi/funcassociate/serv'
@yy
yy / lesmis.ipynb
Created March 9, 2014 04:46
Basic network analysis of Les Misérables
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yy
yy / wordcruncher.ipynb
Created August 31, 2014 18:11
word cruncher
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yy
yy / logodds.py
Created May 8, 2015 19:14
Identify over-represented words in a given corpus compared with other corpora and a background corpus based on log odds ratio with informative prior.
def logodds(corpora_dic, bg_counter):
""" It calculates the log odds ratio of term i's frequency between
a target corpus and another corpus, with the prior information from
a background corpus. Inputs are:
- a dictionary of Counter objects (corpora of our interest)
- a Counter objects (background corpus)
Output is a dictionary of dictionaries. Each dictionary contains the log
odds ratio of each word.
@yy
yy / ismylegoavailable.sh
Created October 28, 2017 21:32
A quick and dirty zsh script for checking availability of a Lego set. (uses Mac automation script for notification)
while true; do lynx --dump "https://shop.lego.com/en-US/LEGO-NASA-Apollo-Saturn-V-21309" | grep "Available now" && osascript -e 'display notification "Lego set available!" with title "Lego alert!!"'; sleep 60; done
@yy
yy / template2ofproj.py
Last active September 9, 2018 14:27
Create an Omnifocus project from a template file (the first argument). The variables should be written as: `{variable}`
#!/usr/bin/env python3
import re
import sys
if __name__ == "__main__":
template_path = sys.argv[1]
content = open(template_path).read()
var_pattern = re.compile('{.+?}')
variables = set(re.findall(var_pattern, content))
@yy
yy / dates_of_certain_day_of_week.py
Created May 9, 2020 21:44
A simple script to get the list of Mondays, Tuesdays, etc. for a given date period.
#!/usr/bin/env python
"""Print the dates of certain day of week given date range."""
import argparse
from datetime import date
import pandas as pd
def parse_dayofweek(dow):
"""Return pandas frequency string from day of the week name."""