Skip to content

Instantly share code, notes, and snippets.

View mamonu's full-sized avatar
🎯
Focusing

Theodore M mamonu

🎯
Focusing
View GitHub Profile
@mamonu
mamonu / stringclean.py
Created January 30, 2017 18:19
clean strings from unicode control chars
# Reference for the Unicode character categories:
# http://www.fileformat.info/info/unicode/category/index.htm
import re
import sys
import unicodedata
all_chars = (unichr(i) for i in xrange(sys.maxunicode))
control_chars = ''.join(c for c in all_chars if unicodedata.category(c) in set(['Cc','Cf','Cn','Co','Cs']))
control_char_re = re.compile('[%s]' % re.escape(control_chars))
@mamonu
mamonu / solrCURL.sh
Last active December 8, 2016 14:07
useful curl solr admin stuff
awk -F, '{$1=++i FS $1;}1' OFS=, file > newfile
# to ingest csv after correct schema is defined in schema.xml
defined schema:
<fields>
<field name="line" type="string" indexed="true" stored="true" required="true"/>
<field name="coicop" type="integer" indexed="true" stored="true"/>
@mamonu
mamonu / solrfuzzywuzzy.r
Created December 5, 2016 15:01
solr fuzzy parameters.
library(solrium)
library(formattable)
solr_connect("localhost:8080/solr/select", errors = "complete", verbose = TRUE)
solrdf<- solr_search(q='EXPDESC:dr+pepper', fl=c('score'),rows=100,wt='csv' )
@mamonu
mamonu / openstackinfo.txt
Created November 22, 2016 16:36
openstack info
How to use Openstack
Getting set up
Contact a Lab manager
They will need to set you up with an Openstack account (login and password)
They will also need to either include you on an existing project or set up a new one just for you
@mamonu
mamonu / installr.sh
Last active November 28, 2016 14:40
INSTALL R in Ubuntu 14.04
sudo apt-get update
sudo apt-get dist-upgrade
clear
sudo add-apt-repository ppa:enlightenment-git/ppa
sudo apt-get update
sudo apt-get install terminology
#Add R
@mamonu
mamonu / SOLRinst.sh
Last active November 9, 2016 17:48
some of the steps needed to install SOLR into ubuntu 14.04
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
#Edit .bashrc and add if not there the below part
#JAVA_HOME=<jdk-install-dir>
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH
@mamonu
mamonu / updateallpip.sh
Created November 3, 2016 23:27
Automatically update all the installed python packages
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@mamonu
mamonu / cluster_example.py
Created October 21, 2016 22:36 — forked from xim/cluster_example.py
Clustering K-Means by euclidian distance, yay!
import sys
import numpy
from nltk.cluster import KMeansClusterer, GAAClusterer, euclidean_distance
import nltk.corpus
from nltk import decorators
import nltk.stem
stemmer_func = nltk.stem.EnglishStemmer().stem
stopwords = set(nltk.corpus.stopwords.words('english'))

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x