Skip to content

Instantly share code, notes, and snippets.

View knbknb's full-sized avatar
💭
🙅‍♀️💡💤😴🛌🤪🧔

Knut Behrends knbknb

💭
🙅‍♀️💡💤😴🛌🤪🧔
View GitHub Profile
@knbknb
knbknb / WekaAPIDemo.java
Last active July 22, 2016 07:26
Weka IBM Tutorial, LinReg, answer for SO Question
package demo;
// see http://stackoverflow.com/questions/38464468/weka-linear-regression-doesnt-load/
import weka.classifiers.functions.LinearRegression;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
@knbknb
knbknb / twitter_stream_download.py
Created January 6, 2018 09:32
Twitter Streaming API; get Tweets
# To run this code, first edit config.py with your configuration (Auth data), then install necessary modules, then:
#
# Call
#
# mkdir data
# python twitter_stream_download.py -q apple -d data
#
#
# It will produce the list of tweets for the query "apple"
# in the file data/stream_apple.json
@knbknb
knbknb / amzn.csv
Created January 17, 2018 18:28 — forked from lebek/amzn.csv
Responsive Visualizations: Basic Graph
date close
2014-02-07 361.08
2014-02-06 354.59
2014-02-05 346.45
2014-02-04 347.95
2014-02-03 346.15
2014-01-31 358.69
2014-01-30 403.01
2014-01-29 384.2
2014-01-28 394.43
@knbknb
knbknb / github_issues.sh
Created February 7, 2018 22:05
bash script to create a tab-separated list of github issues on the command line
#!/bin/sh
# https://stackoverflow.com/questions/48659631/github-issues-api-and-jq-filter-and-grep
# get github issues
GITHUB_PAT=5b01b116....
#user=Leaflet
#repo=Leaflet
user=stedolan
repo=jq
url=https://$GITHUB_PAT:x-oauth-basic@api.github.com/repos/$user/$repo/issues
echo curl -k -I $url?state=all\\\&per_page=10
@knbknb
knbknb / unnest_united_nations_data_frame.R
Last active March 1, 2018 13:24
R code: # group_by / nest / mutate /unnest ## demonstrates an idiom that I tend to forget the details of
# from the datacamp course
# 'Exploratory Data Analysis in R: Case Study'
# by David Robinson
#
# this gist demonstrates an idiom that I tend to forget the details of
# group_by / nest / model /unnest
#
# Load purrr, tidyr, and broom
library(purrr)
library(tidyr)
@knbknb
knbknb / coreNLP_test.R
Last active April 23, 2018 10:54
call coreNLP v3.9.1from R
#Sys.setenv(JAVA_OPTIONS = "-Xmx8g -Xms1G -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit")
library(tidyverse)
library(coreNLP)
# from: https://stackoverflow.com/questions/48455079/extract-city-names-from-large-text-with-r
# using COreNLP to extract tokens
# knb 20180422
outputloc <- "/opt/smallapps/corenlp/"
nlpver <- 2018
if(nlpver != 2018){
@knbknb
knbknb / perceptron-simple.R
Last active August 16, 2018 09:47
Rosenblatt's perceptron - this R code is from 2013, based on a forum post by a chinese user. Online course "learning from data", instructor Prof Yaser Abu-Mostafa # http://work.caltech.edu/telecourse.html
# https://gist.github.com/knbknb/1d17caecd9b800d5148a30d537013668
# Thu Aug 16 11:24:05 2018 ------------------------------
# Rosenblatt's perceptron
# this is from 2013, based on a forum post by a chinese user (don't remember his name)
# "learning from data" course, Prof Yaser Abu-Mostafa
# http://work.caltech.edu/telecourse.html
# create a xy-plot and an animated gif visualizing the training process
data(iris)
@knbknb
knbknb / .eslintrc.json
Created October 5, 2018 20:29 — forked from coryhouse/.eslintrc.json
.eslintrc.json file for "Building a JavaScript Development" Pluralsight course
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
@knbknb
knbknb / CalendarioLiga2013-14.csv
Last active October 7, 2018 12:01
Input files for "Why I Think Atletico De Madrid Will Win 2013/14 Spanish Liga Of Football", by A.S. Chinchon, 2014
home.team score away.team round score_home score_visiting home.wins away.wins
Athletic 4-2 Valladolid 20 4 2 3 0
Atletico 1-1 Sevilla 20 1 1 1 1
Betis 0-5 R. Madrid 20 0 5 0 3
Espanyol 1-0 Celta 20 1 0 3 0
Villarreal 2-0 Almeria 20 2 0 3 0
Malaga 0-0 Valencia 20 0 0 1 1
Elche 2-0 Rayo 20 2 0 3 0
Getafe 2-2 R. Sociedad 20 2 2 1 1
Levante 1-1 Barcelona 20 1 1 1 1
@knbknb
knbknb / node-client-server-todolist-mini-cli-app.md
Last active November 18, 2018 10:11
a TODO-list CLI app implemented using only builtin node modules (EventEmitter, process, readline)

Run the app on the command line with: node client.js. This implicitly loads server.js.

From Samir Buna's "Advanced NodeJS" course on Pluralsight

client.js

const EventEmitter = require('events');
const readline = require('readline');

const rl = readline.createInterface({