Skip to content

Instantly share code, notes, and snippets.

View Simsso's full-sized avatar

Timo Denk Simsso

View GitHub Profile
@Simsso
Simsso / fnn.py
Created July 1, 2017 12:19
Feed-forward Neural Network in Tensorflow
import tensorflow as tf
import numpy as np
from random import randint
def init_weights(shape):
# Initializes a Tensor of size (x,y) with random weights
weights = tf.random_normal(shape, stddev=1)
return tf.Variable(weights)
@Simsso
Simsso / java-multithreading.java
Created January 30, 2018 06:10
Java Simple Multithreading
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
public class Main {
public static void main(String[] args) throws InterruptedException, ExecutionException {
class Query1Callable implements Callable<String> {
private final String arg1;
private Query1Callable(String arg1) {
@Simsso
Simsso / Dockerfile
Created May 8, 2018 07:18
Haskell 8 Dockerfile for project "haskelldockertest"
# source: https://github.com/freebroccolo/docker-haskell/blob/master/examples/7.10/snap/Dockerfile
FROM haskell:8
WORKDIR /opt/app
RUN cabal update
# Cache dependency installation
COPY ./haskelldockertest.cabal /opt/app/haskelldockertest.cabal
@Simsso
Simsso / acc.py
Created July 6, 2018 13:26
TensorFlow Classification Accuracy Op
acc = tf.reduce_mean(tf.cast(tf.equal(tf.argmax(softmax, axis=1), tf.cast(labels, tf.int64)), 'float'), name='acc')
@Simsso
Simsso / article.tex
Last active May 24, 2019 17:51
LaTeX Simple Boilerplate
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
% math
\usepackage{amsmath}
\usepackage{amssymb} % special set sybmols e.g. for real numbers R
\usepackage{bm} % bold math
\usepackage{isomath}
% bracket fix (see https://tex.stackexchange.com/questions/2607)
@Simsso
Simsso / default.ino
Last active April 5, 2020 07:57
Arduino sketch boilerplate
// library imports
#define SERIAL_DEBUG
// global variables
void setup() {
#ifdef SERIAL_DEBUG
Serial.begin(9600);
Serial.println("Initializing...");
@Simsso
Simsso / vector-lookup-in-matrix.py
Created June 3, 2020 15:50
TensorFlow code for performing a lookup of values in matrix rows using the indices stored in a vector.
import tensorflow as tf
def vec_lookup_in_mat(mat: tf.Tensor, vec: tf.Tensor):
"""
Performs a lookup of values in the matrix rows using the indices stored in the vector.
For example, given the matrix [[1, 2, 3], [4, 5, 6]] and the vector [0, 2], the function would return a vector
consisting of the entry with index zero in the first row and index 2 in the second row, i.e. [0, 6].
:param mat: Tensor of shape [m, n, ...], values will be looked up from it; dtype any
:param vec: Tensor of shape [m], indices for each row of the matrix; dtype int32
@Simsso
Simsso / raspi-photo-ssh.sh
Created August 8, 2020 10:04
Connects to a raspi, takes a photo, downloads it, and shows it (on Mac)
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
timestamp=$(date +%s)
ip=192.168.1.102
echo "Taking a photo..."
ssh pi@$ip "mkdir -p cam && cd cam && raspistill -o cam-$timestamp.jpg"
@Simsso
Simsso / multi-cursor-cheatsheet.md
Last active August 19, 2021 12:30
Hotkeys for multi cursor action in three different IDEs (for Mac)
Action Sublime VSCode PyCharm
Select next occurrence Cmd + D Cmd + D Alt + J
Select all occurrences Control + Cmd + G
Break selection into one cursor per line Cmd + Shift + L Shift + Option + I Option + Mouse selection
@Simsso
Simsso / calendar-aggregation-violin.js
Last active August 14, 2021 13:58
Code for Google Apps Script which reads a calendar and writes aggregated information into a Google spreadsheet. Details can be found in this blog post: https://timodenk.com/blog/populate-sheet-with-calendar-data/
const TIME_MIN = new Date('2020-10-27');
const CAL_ID = 'simssosdenk@gmail.com';
const QUERIES = ['violin lesson', 'violin practice'];
const RESULT_BATCH_SIZE = 40;
// App Script console testing endpoint
function main() {
loadWeeklyPracticeTime().forEach(x => console.log(x));
}