Skip to content

Instantly share code, notes, and snippets.

View lukasvermeer's full-sized avatar

Lukas Vermeer lukasvermeer

View GitHub Profile
@lukasvermeer
lukasvermeer / circle_flips.jl
Created January 24, 2019 13:33
Simple Julia simulation to solve puzzle posed in https://www.twitter.com/jben0/status/1088146700735139840
# simulation to solve puzzle posed in https://www.twitter.com/jben0/status/1088146700735139840
k = 10
# enumerate all potential combinations of flips
# (also copies first two students to end of the string to fake a circle)
f = map(x->(x^2)[1:k+2],[ bitstring(n)[65-k:64] for n in 0:2^k-1 ])
# condition on at least one student with heads on either side
c = filter(l->size(collect(eachmatch(r"1.1",l)),1)>0,f)
This file has been truncated, but you can view the full file.
's anderendaags
's avonds
's middags
's nachts
's ochtends
's-Gravenhage
's-Hertogenbosch
06-nummer
1 aprilgek
1 aprilgrap
# Simulation to estimate emperical odds to win the Haba game "Boomgaard".
# Set number of games to play
NUM.SIM = 10000
# Simulate one turn. Roll die and pick fruit or move bird.
# Input: game state.
# Output: game state after this turn.
turn <- function(state) {
roll <- sample(1:6,1)
@lukasvermeer
lukasvermeer / colors.pl
Created September 19, 2017 20:54
A small Perl script to test color settings.
#!/usr/bin/perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@lukasvermeer
lukasvermeer / local_storage_draft.html
Created August 15, 2017 10:09
Using browser local storage to store form values for dynamic form using Vue.
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<form id="app">
<button v-if="hasStoredState()" @click.prevent="load">Load draft!</button>
<button v-if="hasStoredState()" @click.prevent="clear">Delete draft!</button>
@lukasvermeer
lukasvermeer / CauseMap_cals-vs-weight.jl
Created June 22, 2017 09:36
Attempt to uncover causal link between calorie intake and weight using CCM method as implemented in CauseMap Julia module.
using CauseMap
# specify parameter ranges to test over
E_vals = 2:10 # range to test of system dimensionality
tau_s_vals = 1:1 # range for lag length for manifold reconstruction
tau_p_vals = 0:15 # range to test for time lag of causal effect
# weight and calorie intake data
weight = [69.0,68.7,68.1,68.3,67.6,68.0,68.2,66.7,67.7,67.1,67.1,67.3,67.0,67.5,66.0,66.6,67.0,66.7,66.7,66.4,66.4,66.2,65.8,66.2,65.8,65.6,65.5,65.4,66.4,65.0,65.4,65.2,64.9,64.4,64.6,65.0,64.6,64.4,64.5,63.9,63.6,63.7,64.0,64.0,63.7,63.8,63.4,63.7,64.0,63.7,64.2,64.1,63.8,63.8]
cals = [2207.0,1275.0,1069.0,1760.0,1498.0,2544.0,1116.0,1495.0,1224.0,1584.0,1381.0,1084.0,1723.0,1276.0,1356.0,1337.0,1674.0,1516.0,1499.0,1759.0,1221.0,1476.0,1212.0,2023.0,1528.0,1279.0,2130.0,1519.0,1954.0,1590.0,1769.0,1411.0,1337.0,1798.0,1756.0,899.0,1243.0,1411.0,1463.0,1284.0,2199.0,1611.0,1855.0,1498.0,1727.0,1517.0,1474.0,1876.0,1929.0,1518.0,1265.0,1641.0,1175.0,1387.0]
@lukasvermeer
lukasvermeer / elementary.pl
Created January 10, 2016 20:17
Check if input can be constructed from chemical element symbols. (For a puzzle).
use strict;
use warnings;
use Data::Dumper;
die "Malfunction. Need input." unless $ARGV[0];
my @e = ( 'H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca','Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn','Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn','Sb','Te','I','Xe','Cs','Ba','La','Ce','Pr','Nd','Pm','Sm','Eu','Gd','Tb','Dy','Ho','Er','Tm','Yb','Lu','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg','Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Th','Pa','U','Np','Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Db','Sg','Bh','Hs','Mt','Ds','Rg','Cn' );
my %eh = map { lc($_) => $_ } @e;
@lukasvermeer
lukasvermeer / ana.pl
Created January 10, 2016 14:00
Given a word and a file with more words, find anagrams.
use strict;
use warnings;
use Data::Dumper;
die "Malfunction. Need input." unless $ARGV[0] and $ARGV[1];
my @m = sort split('',lc($ARGV[0]));
my $m = (join "?", @m) . "?";
@lukasvermeer
lukasvermeer / combined_words.pl
Created December 18, 2015 20:50
Quick hack to find 7-letter words that are also two 4-letter words that share the first/last letter. (Needed that for a puzzle ...).
use strict;
use warnings;
use Data::Dumper;
open(W, "woorden.txt");
my %w;
while (my $line = <W>) {
chomp($line);
if (length $line == 4) {
# This might break all the things. Be careful.
#
# So I got a new Kodi media thing.
# And I wanted to create a new (clear) library.
# But I also wanted to keep watched status for things I'd watched.
# What follows are manual steps I took.
#
# dump the data on the old server
sqlite3 ~/.kodi/userdata/Database/MyVideos93.db