Skip to content

Instantly share code, notes, and snippets.

View denten's full-sized avatar

Dennis Yi Tenen denten

View GitHub Profile
@denten
denten / gist:0ea103a082233b6b06a2e1eabf0f5b86
Created June 29, 2018 02:48
making low battery suspend work with nix os
services.udev.extraRules = ''
SUBSYSTEM=="power_supply"
ATTR{status}=="Discharging"
ATTR{capacity}=="[0-5]"
RUN+="/run/current-system/sw/bin/systemctl hibernate"
'';
@denten
denten / print.sh
Last active August 29, 2015 14:25
#!/bin/bash
# this bash script simplifies long pandoc incantations
# sh print.sh [-d|p|m] filename.md
# remember to update the cases with your own paths / pandoc commands
# pass the file name as an argument
if [ $# -eq 0 ]
then
echo "pass the file name"
@denten
denten / keybase.md
Created July 20, 2015 14:16
Keybase Verification

Keybase proof

I hereby claim:

  • I am denten on github.
  • I am denten (https://keybase.io/denten) on keybase.
  • I have a public key whose fingerprint is 1A8E E770 7D12 E21A 74D4 4EF9 0F2F 4130 D9C1 0F89

To claim this, I am signing this object:

@denten
denten / gist:4886b62c7292a776fa8e
Created May 20, 2014 03:19
lazy mongodb corpus
import pymongo
from nltk.data import LazyLoader
from nltk.tokenize import TreebankWordTokenizer
from nltk.util import AbstractLazySequence, LazyMap, LazyConcatenation
class MongoDBLazySequence(AbstractLazySequence):
def __init__(self, host='localhost', port=27017, db='test', collection='corpus', field='text'):
self.conn = pymongo.Connection(host, port)
self.collection = self.conn[db][collection]
self.field = field
@denten
denten / test.ipynb
Last active August 29, 2015 14:01
tc-tech-talk
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@denten
denten / gist:7f37e8f54f6ad6e78b51
Created May 13, 2014 18:14
plotting with pandas
import pandas as pd
# check out other read methods http://pandas.pydata.org/pandas-docs/stable/io.html
df = pd.read_csv('data/network-csv/network.csv')
df.describe()
df.plot(x='col_name_1', y='col_name_2', style='o')
import nltk
wsj = nltk.corpus.treebank.tagged_words(simplify_tags=True)
cdf = nltk.ConditionalFreqDist((tag, word) for (word, tag) in wsj)
wordlist = cdf['VN'].keys()
for ndx, (word, tag) in enumerate(wsj):
if word in wordlist and tag == 'IN':
print wsj_list[ndx-1:ndx+1], ndx, i
@denten
denten / gist:11388676
Last active August 29, 2015 14:00
iteration of ConcatenatedCorpusView bug in NLTK
import nltk
wsj = nltk.corpus.treebank.tagged_words(simplify_tags=True)
cdf = nltk.ConditionalFreqDist((tag, word) for (word, tag) in wsj)
wordlist = cdf['VN'].keys()
# Bug 1: strange iteration exceptions in the for loop
# Solution: wsj is a custom NLTK data type "ConcatenatedCorpusView"
# convert wsj into a native python type "list" for better iteration.
Configuration file: /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/_config.yml
Source: /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk
Destination: /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/_site
Generating... Compiling LESS: lessc --yui-compress /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/static/css/style.less /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/_site/static/css/style.css
/home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/_plugins/lessjs.rb:45:in `block in generate': LESS compilation error (RuntimeError)
from /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/_plugins/lessjs.rb:24:in `each'
from /home/denten/gDrive/Code/Web/denten.github.io/sbin.dk/_plugins/lessjs.rb:24:in `generate'
from /var/lib/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:227:in `block in generate'
from /var/lib/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:226:in `each'
from /var/lib/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:226:in `genera
Columbia's *Record* has recently asked me to define digital humanities for an upcoming issue about the state of the field on campus. My best attempt at it was to write:
Digital humanities are a diverse set of overlapping academic practices which usually include some mixture of 1) computational and otherwise experimental approaches to the study of the human condition; 2) modalities of cultural preservation, content curation, and knowledge design; and finally, 3) social advocacy and professional reform in response to developments in information technology.