Skip to content

Instantly share code, notes, and snippets.

View mikkohei13's full-sized avatar

Mikko Heikkinen mikkohei13

View GitHub Profile
@mikkohei13
mikkohei13 / handle_birdnet_csv.py
Last active June 26, 2022 07:46
Tool to concatenate and extend BirdNET CSV files
import os
import pandas as pd
import datetime
import re
def get_datafile_list(directory, limit):
datafile_list = []
objects = os.listdir(directory)
i = 0
# Code courtesy of William Morris
# Requires setting your personal token, and installing this:
# apt-get install libcurl4-openssl-dev libssl-dev
install.packages("finbif")
install.packages("ggplot2")
library(finbif)
library(ggplot2)
Lähde:
Talvilintulaskenta - http://tun.fi/HR.39 [metadata], Creative Commons Nimeä
Aineistolataus Lajitietokeskuksesta http://tun.fi/HBF.59676
id yearDecember WBC.sorbusBerriesAtCensus
http://tun.fi/JX.100009 1990 1
http://tun.fi/JX.100131 1990 1
http://tun.fi/JX.100396 1990 1
http://tun.fi/JX.100605 1990 1
http://tun.fi/JX.100902 1990 2
@mikkohei13
mikkohei13 / capture.py
Created April 10, 2021 18:57
Capture stills from Youtube video
import pafy
import cv2
import math
from datetime import datetime
url = "add url here"
video = pafy.new(url)
best = video.getbest(preftype="mp4")
@mikkohei13
mikkohei13 / rainRadarExtract.py
Created October 16, 2020 21:31
Python code to extract rain intensity colors from FMI rain radar maps.
from PIL import Image
import colorsys
def rgb2hsv(rgb):
r = rgb[0] / 255
g = rgb[1] / 255
b = rgb[2] / 255
hsvRaw = colorsys.rgb_to_hsv(r, g, b)
@mikkohei13
mikkohei13 / talvilintureitit.php
Created December 20, 2015 22:40
Työkalu html-taulukon luomiseen talvilintulaskentareittiluettelosta
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<style>
.number
{
text-align: right;
}
</style>
<pre>
// Regex for matching strings that do not contain comma:
// BAsed on: http://stackoverflow.com/questions/717644/regular-expression-that-doesnt-contain-certain-string
^((?!,).)*$
<?php
// Getting species/taxon images from EOL
$species = $_GET['species'];
$species = str_replace(" ", "+", $species);
// Id
// Documentation: http://eol.org/api/docs/pages
$idUrl = "http://eol.org/api/search/1.0.json?q=" . $species . "&page=1&exact=false&filter_by_taxon_concept_id=&filter_by_hierarchy_entry_id=&filter_by_string=&cache_ttl=";
/**
* Return base url automatically for Codeigniter
* Source: http://snipplr.com/view/16894/codeigniter-automatic-base-url-configuration/
*/
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
/**
* Gets the last commit date from .git repository
* @param string $gitLocation location of .git/logs/HEAD
* @return string date of last commit YYYY-mm-dd
*/
function gitLastCommitInfo($gitLocation)
{
$commitArray = file($gitLocation); // All commits from file
$lastCommit = array_pop($commitArray); // Latest commit
$lastCommitArray = explode("\t", $lastCommit);