Skip to content

Instantly share code, notes, and snippets.

View fnielsen's full-sized avatar

Finn Årup Nielsen fnielsen

View GitHub Profile
@fnielsen
fnielsen / Nielsen2014Data_femalehurricanes.ipynb
Last active August 29, 2015 14:02
Modeling of Female Hurricanes dataset.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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):
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 / 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()
@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."""
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 / 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
@fnielsen
fnielsen / fftprimeproblem.py
Created May 7, 2015 18:42
FFT prime problem
# https://github.com/fnielsen/everything
from everything import *
import pyfftw.interfaces.scipy_fftpack
def is_prime(n):
"""https://stackoverflow.com/questions/18833759/"""
if n % 2 == 0 and n > 2:
return False