Skip to content

Instantly share code, notes, and snippets.

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

Knut Behrends knbknb

💭
🙅‍♀️💡💤😴🛌🤪🧔
View GitHub Profile
@knbknb
knbknb / query-pubmed-3-terms.R
Last active December 24, 2020 11:49 — forked from leipzig/microarray.R
Pubmed Queries: last paper on microarray bioinformatics, when to appear?
# Tidyverse-R-code from 2020
# (this code is also artificially slowed down, with purrr::slowly(),
# to avoid HTTP 429 errors (too many requests)
library(tidyverse)
library(httr)
library(xml2)
library(lubridate)
theme_set(theme_bw())
@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 / 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 / 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 / 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 / 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 / csv2xts--and-more.R
Last active January 30, 2019 20:06
personal mini cheat sheet: R time series - xts from csv file, and more xts basics that I tend to forget
# see also:
# https://s3.amazonaws.com/assets.datacamp.com/blog_assets/xts_Cheat_Sheet_R.pdf
# Open csv file using read.zoo
my_tsdata <- read.zoo("my_tsdata.csv", sep = ",", FUN = as.Date, header = TRUE, index.column = 1)
my_tsdata <- as.xts(my_tsdata)
@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 / 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){