Skip to content

Instantly share code, notes, and snippets.

View Simsso's full-sized avatar

Timo Denk Simsso

View GitHub Profile
@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 / 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 / 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 / plot.tex
Last active January 4, 2017 16:04
Simple plot with tikz for LaTeX documents
\begin{tikzpicture}
\pgfplotsset{
scale only axis,
}
\begin{axis}[
%axis x line*=bottom,
%axis y line*=left,
xlabel=$A$,
@Simsso
Simsso / browser-notification.js
Created August 1, 2016 04:05
Browser Notification
function showBrowserNotification(text) {
// check if the browser supports notifications
if (!("Notification" in window)) {
// no support
}
// check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
var notification = new Notification(text);
}
@Simsso
Simsso / sort-array-by-date.js
Created August 1, 2016 01:35
Sort Array of Objects by Date
array.sort(function(a,b){
// Turn your strings into dates, and then subtract them
// to get a value that is either negative, positive, or zero.
return new Date(b.date) - new Date(a.date);
});
@Simsso
Simsso / pubsub.js
Last active April 9, 2019 11:04 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
// events - a super-basic Javascript (publish subscribe) pattern
const events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@Simsso
Simsso / smooth-scroll.js
Created May 17, 2016 11:25
Smooth scrolling of links like <a href="#bla"> with possible user interruption
// smooth scrolling of links like <a href="#bla">
var $viewport = $('html, body');
$('a[href*="#"]:not([href="#"])').on('click', function(e) {
if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$viewport.animate({
scrollTop: target.offset().top // scroll to target
}, 1000);
@Simsso
Simsso / bootstrap-modal-events.md
Last active January 24, 2018 21:02
List of Bootstrap modal events with description
  • show.bs.modal: fired just before the modal is open.

  • shown.bs.modal: fired after the modal is shown.

  • hide.bs.modal: fired just before the modal is hidden.

  • hidden.bs.modal: fired after the modal is closed.

  • loaded.bs.modal: fired when remote content is successfully loaded in the modal’s content area using the remote option mentioned above.

@Simsso
Simsso / show-error-code.ino
Created May 16, 2016 10:22
Shows the given error code in binary format at the passed pin
// Show error code
// Shows the given error code in binary format at the passed pin
// A short blink represents a binary "0", long blink a binary "1".
// MSB first
//
// @param uint8_t code: The error code to "blink", [0;255]
// @param uint8_t pin: The output pin to use, default: 13
//
// @return void
void showErrorCode(uint8_t code, uint8_t pin = 13) {