Skip to content

Instantly share code, notes, and snippets.

View fnielsen's full-sized avatar

Finn Årup Nielsen fnielsen

View GitHub Profile
@fnielsen
fnielsen / gist:3efb548dc4958206331b
Created May 4, 2015 18:29
Danish Wikipedia page view statistics
wget https://dumps.wikimedia.org/other/pagecounts-all-sites/2015/2015-05/pagecounts-20150501-000000.gz
gzip -cd pagecounts-20150501-000000.gz | grep "^da " | perl -anle "print @F[2] . ' ' . @F[1] unless @F[1] =~ /(Bruger|Brugerdiskussion|da|Diskussion|Fil|Hj\%C3\%A6lp|Hj\%C3\%A6lp-diskussion|Kategori|Kategoridiskussion|MediaWiki|Portal|Skabelon|Skabelondiskussion|Speciel|Wikipedia|Wikipedia-diskussion):/i" | sort -nr | less
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fnielsen
fnielsen / string_for_tokenization.py
Created September 21, 2014 22:50
String for tokenization
s = u"""DTU course 02819 is taught by Mr. Finn Årup Nielsen,
Ph.D. Some of aspects of the course are: machine learning and web
2.0. The telephone to Finn is (+45) 4525 3921, and his email is
faan@dtu.dk. A book published by O'Reilly called 'Programming
Collective Intelligence' might be useful. It costs $39.99 or 285.00
kroner in Polyteknisk Boghandle. Is 'Text Processing in Python'
appropriate for the course? Perhaps! The constructor function in
Python is called "__init__()". fMRI will not be a topic of the
course."""
@fnielsen
fnielsen / tagcloud.py
Created September 19, 2014 15:40
Tag cloud with Python
from collections import Counter
from nltk.corpus import brown
from pytagcloud import create_tag_image, make_tags
from PIL import Image
# Developed from https://pypi.python.org/pypi/pytagcloud
create_tag_image(make_tags(Counter(brown.words()).most_common(150), maxsize=300), 'cloud.png', size=(900, 600), fontname='Lobster')
Image.open('cloud.png').show()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fnielsen
fnielsen / Nielsen2014Python_case.ipynb
Last active January 27, 2016 19:48
Nielsen2014Python_case.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fnielsen
fnielsen / awesome
Created July 17, 2014 19:35
Awesome
import re
import requests
import pandas as pd
import matplotlib.pyplot as plt
pd.Series({re.findall('^(.+)\n', section)[0]: len(re.findall('^\*', section, flags=re.MULTILINE)) for section in re.split('^##[^#]', requests.get('https://raw.githubusercontent.com/josephmisiti/awesome-machine-learning/master/README.md').text, flags=re.MULTILINE)[1:-1]}).plot(kind='barh', title="'Awesome' machine learning links")
plt.show()
@fnielsen
fnielsen / implication.py
Last active August 29, 2015 14:02
Self-referential implication
from math import exp
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x):
return 1.0 / (1.0 + exp(-x))
def implication(a, b):