Skip to content

Instantly share code, notes, and snippets.

View santeriv's full-sized avatar

Santeri Vesalainen santeriv

View GitHub Profile
@santeriv
santeriv / pd_poller.sh
Last active January 10, 2020 09:36
a Play Diplomacy script for getting turns action map by game id and sending a notification of a map link to microsoft teams (if it finds a new turn)
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
#set -o xtrace
## SETTINGS
@santeriv
santeriv / mtp_pictures_exiftool_howto.md
Last active September 7, 2019 10:09
Copy pictures from MTP source dir utilizing exiftool and it's date features

Problem: Whatsup pictures where missing timestamps utilized exiftool AllDates attribute 'filename'

  1. dir
mkdir run_date_here
cd run_date_here
mkdir pics
cd pics
@santeriv
santeriv / gist:d941b0fdac1e616afe5b17922db4447a
Created July 12, 2018 23:38
javascript console snippet, simple recursion and map-fun with arrays
const sl = (array, extra) => {
extra = extra || 1;
console.log('-'.repeat(extra),array[0].title, array[1].title, array[2].title, array[3].title, array[4].title, array[5].title, array[6].title);
return array.length === 7 ? "simple slicing done" : sl(array.slice(1), extra=extra+1);
};
const shuffleArray = arr => (
arr
.map(a => [Math.random(), a])
.sort((a, b) => a[0] - b[0])
.map(a => a[1])
@santeriv
santeriv / .bashrc
Last active February 28, 2018 08:24
Git branch and dirty ('green' or 'red' + ' *' ) state in Bash prompt.
function git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (*\([^)]*\))*/\1/'
}
function markup_git_branch {
if [[ -n $@ ]]; then
if [[ -z $(git status --porcelain 2> /dev/null | tail -n1) ]]; then
echo -e " \001\033[32m\002($@)\001\033[0m\002"
else
@santeriv
santeriv / post-receive
Last active November 8, 2017 10:25
Deployment Hook example locally
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
echo 'Changes pushed master.'
fi
Verifying that +santeriv is my blockchain ID. https://onename.com/santeriv
@santeriv
santeriv / affirmation
Created August 13, 2014 19:59
MuleSoft Contributor Agreement Acceptance by Santeri Vesalainen
I, Santeri Vesalainen, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Wed Aug 13 2014 22:59:34 GMT+0300 (Suomen kesäaika)
/*
Story goes like this :
4th of kind-a-thing siblings finds last thing's children 4th child and removes it and then asks her parent to make her a sibling
*/
$("#section-5").siblings("table:nth-of-type(4)").find("tr").last().children().remove('td:nth-of-type(4)').parent().prepend('<td />')
@santeriv
santeriv / VaadinChildrenTraverse.java
Created January 9, 2014 06:27
Recursive traversal finder for children Components. Filling the "traversing utility gap" what too much usage of http://api.jquery.com/category/Traversing/ has caused. Vaadin fundamental traversing consists of Component.getParent(), HasComponents.iterator() and AbstractComponent.findAncestor(Class<T> parentType) . And there should be also HasComp…
/**
* A Vaadin helper utility for getting children of Component By.type
*
* @param rootComponent - component where to start
* @param criteriaType
* @return List of components that match type
*/
public static List<Component> getChildrenByClass(HasComponents rootComponent, final Class<?> criteriaType ) {
return getChildren(rootComponent,By.type(criteriaType));
}