Skip to content

Instantly share code, notes, and snippets.

@gysel
gysel / day08-input.txt
Created December 18, 2019 20:20
Advent of Code 2019 in GO
2222222120222222022222222222201222222220202122220212022202002222022212220022222212220222022202220202222222222222220222222222222122222222222222012222222222222122222222222222222222212222222221222122221212122222202022122212222122222212220222222202220212222222222222222222222222222122222222222222012222222222222221222222222222222222201222222221222122220222122202222222022202222222222222221222122222220212222222222222220222222222222022212222222222002222222222222120222222222222222222212022222221212222220222022212002222022202221122222222222222122222220212222222222222220222222222222222222222222222122222222222222121221222122222222222222122222220222122221202122222022022222202220222222202222222222202222222222222222222220222222222222222212222222222212222222222222122222222122222222222221222222222222122221202122212112122022212222222222222222222122222220222222222222222220222222222202022202222222222202222222222222222222222222222222222221122222221212222221212222212202122222212220122222222222212222222222202222222222222222222222222
@gysel
gysel / OncompletionTestApplication.java
Last active September 18, 2017 13:40
Camel onCompletion example
package com.example.oncompletiontest;
import org.apache.camel.spring.boot.CamelSpringBootApplicationController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
public class OncompletionTestApplication {
@gysel
gysel / JNumberTextField.java
Created November 14, 2012 20:37
JTextField only accepting numeric values
/**
* A {@link JTextField} that skips all non-digit keys. The user is only able to enter numbers.
*
* @author Michi Gysel <michi@scythe.ch>
*
*/
public class JNumberTextField extends JTextField {
private static final long serialVersionUID = 1L;
@Override
@gysel
gysel / backup.sh
Last active October 11, 2015 18:17
simple backup script
dbname="mydb"
user="user"
pass="pass"
scriptpath="/home/sqlbackup"
logfile="$scriptpath/backup.log"
timestamp=`/bin/date +%Y%m%d-%H%M`
# number of days to keep the backups
keepfordays=14
mysqldump -u $user -h localhost -p$pass $dbname | gzip -9 > $scriptpath/backups/$dbname-$timestamp.sql.gz
@gysel
gysel / integrate.rb
Created August 4, 2012 12:45
Simple Integral implementation in Ruby
require 'bigdecimal'
def integrate (a, b, n)
a = a.to_f; b = b.to_f; n = n.to_i
result = 0.0
dx = (b - a) / n
dx_half = dx / 2
for i in 0 ... n
result += yield a + (i * dx)