Skip to content

Instantly share code, notes, and snippets.

View 1danjordan's full-sized avatar

Daniel Jordan 1danjordan

View GitHub Profile
@piyushrj
piyushrj / date_identification.py
Created June 12, 2018 12:44
Adding custom Matcher rules to identify date patterns along with the ones identified with spacy's NER
import spacy, re, dateparser
from spacy.matcher import Matcher
from spacy.tokenizer import Tokenizer
from spacy import displacy
def custom_tokenizer(nlp, infix_reg):
"""
Function to return a customized tokenizer based on the infix regex
@wviechtb
wviechtb / bivariate_normal_wallpaper.r
Last active April 23, 2023 01:09
Code to generate wallpaper (bivariate normal distribution)
rm(list=ls())
setwd("/home/wviechtb/misc/wallpapers/bivariate_normal")
library(mvtnorm)
library(ellipse)
### specify the correlation for the bivariate normal distribution
rho <- 0.4
library("rlang")
#' @import rlang
`%>%` <- function(x, y) {
lhs <- rlang:::captureArg(x)
lhs_value <- eval_bare(lhs$expr, lhs$env)
@klmr
klmr / generator.md
Last active August 28, 2022 02:26
Python-like generators in R

A little experiment using restarts.

(And while we’re at it, let’s torture R’s syntax a little.)

![screenshot][]

In the following we will be using R’s “restarts” feature to implement the state machine that drives generators in languages such as Python. Generators allow lazily generating values on demand: a consumer invokes a generator, and consumes values as they are produced. A new value is only produced once the previous one has been consumed.

@cwidmer
cwidmer / compressed_pickle.py
Last active August 22, 2021 06:19
save/load compressed pickled objects in python
import cPickle
import bz2
def save(filename, myobj):
"""
save object to file using pickle
@param filename: name of destination file
@type filename: str
@mjallday
mjallday / currencies.py
Created August 12, 2011 09:09
Tuple of currencies for Python
# -*- coding: utf-8 -*-
"""
list of currencies currently in circulation
taken from http://www.currency-iso.org/iso_index/iso_tables/iso_tables_a1.htm
http://www.iso.org/iso/currency_codes_list-1.html
2011-08-11
"""