Skip to content

Instantly share code, notes, and snippets.

View PhillRob's full-sized avatar
🌐
At the office (for most of the time)

Philipp R PhillRob

🌐
At the office (for most of the time)
View GitHub Profile
@PhillRob
PhillRob / gekko-neural-network-config.js
Last active February 12, 2021 20:36
Neural network settings for BTC-USDT gekko trading bot on binance. Advice published on twitter https://twitter.com/phillr0
// neuralnet settings
config.neuralnet = {
threshold_buy: 1,
threshold_sell: -1,
learning_rate: 0.02,
momentum: 0.5,
decay: 0.01,
stoploss_enabled: false,
stoploss_threshold: 0.85,
hodl_threshold: 0.90,
Verifying my Blockstack ID is secured with the address 1EoroS9TcrFC3iWasWZULB7d9NycDRfoC5 https://explorer.blockstack.org/address/1EoroS9TcrFC3iWasWZULB7d9NycDRfoC5
@PhillRob
PhillRob / form-id-fulcrumapp.R
Last active January 7, 2017 12:21
form-id-fulcrumapp.R
library(httr); library(jsonlite)
# this gets a list of the available forms to later query for the records per form
baseurl <- "https://api.fulcrumapp.com"
path <- "/api/v2/forms.json"
XApiToken = "your-api-token"
form.list <-
GET(
url = paste0(baseurl, path),
add_headers(`X-ApiToken` = XApiToken),
@PhillRob
PhillRob / first.gbif.record.R
Last active January 18, 2017 04:36
gets the first occurrence record per speciesKey and ISO2 country code from gbif.org based on eventDate
# load rgbif package
install.packages("rgbif"); library(rgbif)
# create a matrix with one line per query
country <- c('AU', 'US', 'DE') #iso2 country code
species <- c(2768885, 3020791) # alternativly get the gbif speciesKeys based on species names
sp <- c("Asparagus officinalis", "Prunus avium")
species <- sapply(sp, function(x) name_backbone(x, rank="plants")$speciesKey)
m <- rbind(cbind(country[1], species), cbind(country[2], species), cbind(country[3], species))
# API
## install packages
install.packages(c("httr", "jsonlite", "lubridate"))
library(httr)
library(jsonlite)
options(stringsAsFactors = FALSE)
## set variables to get all records per form id
baseurl <- "https://api.fulcrumapp.com"
path <- "/api/v2/"
m qgis.utils import iface
layer = iface.activeLayer()
layer.startEditing()
compare_field_index = 2
concat_field_index = 9
new_field_index = 14
feature_dict = {f.id(): f for f in layer.getFeatures()}
for f in feature_dict.values():
if f[concat_field_index]:
new_field_text = f[concat_field_index]
@PhillRob
PhillRob / harvesine.dist.R
Created January 2, 2016 05:50
test the distance between two strata within a species.
ha <- function(x){
x$Lat<-(as.numeric(paste(x$Lat)))
x$Lon<-(as.numeric(paste(x$Lon)))
pre<-x[(x[,17]==0),]
post<-x[(x[,17]==1),]
if(nrow(pre)<2| nrow(post)<2){results<-paste("not enought records per phase")}else{
early <- x[(which.min(x$Year)),]
e1 <- early[1,]
predist<-apply(pre, 1, function(x) distHaversine(as.numeric(e1[4:3]),as.numeric(x[4:3]), r=6378137))
postdist<-apply(post, 1, function(x) distHaversine(as.numeric(e1[4:3]),as.numeric(x[4:3]), r=6378137))
@PhillRob
PhillRob / kew.sid.scraping.R
Last active December 31, 2015 07:24
scraping for dispersal data on the kew/sid website.
disp.sp <- function(x) {
print(x)
x.genus <- unlist( strsplit(x," "))[1]
x.species <- unlist( strsplit(x," "))[2]
sp.test <- getURL(paste0("http://data.kew.org/sid/SidServlet?Clade=&Order=&Family=&APG=off&Genus=", x.genus,"&Species=",x.species,"&StorBehav=0&DsFlag=on"))
if (grepl("0 records found.", sp.test))
{
#return("Not_found")
results<-c(x,"Not_found")
@PhillRob
PhillRob / issg-check.R
Last active October 21, 2015 10:28
checks if species is included in issg.org
isgg<- function(x) {
species<-gsub(" ","+",x)
sp <- getURL(paste0("http://www.issg.org/database/species/search.asp?sts=sss&st=sss&fr=1&x=16&y=13&sn=", species,"&rn=&hci=-1&ei=-1&lang=EN"))
if (length(grep("No invasive species currently recorded",sp))) {
return("Not_found")
} else {return("Found")}
}
@PhillRob
PhillRob / get.eol.trait.R
Last active September 24, 2015 06:58
returns the first 8 trait values for any given species in EOL relying on the reol, traints and dplyr packages.
get.eol.trait <- function(sp,trait)
{
if (length(trait)==0)
{
print("need trait")
stop()
}
library("reol"); library("traits"); library("dplyr")
pages<-DownloadSearchedTaxa(sp, to.file=F, MyKey=NULL, verbose=TRUE)
pages1<-as.numeric(gsub("eol","",colnames(as.data.frame(pages))))