Skip to content

Instantly share code, notes, and snippets.

View lukasvermeer's full-sized avatar

Lukas Vermeer lukasvermeer

View GitHub Profile
@lukasvermeer
lukasvermeer / gist:5070529
Created March 2, 2013 11:01
Find words for the game 4 Pics 1 Word. Takes a bunch of letters ("elnopq" in this case) and prints four letter words that can be formed using a subset of those letters.
perl -ne 'if((join "",sort split(//,lc))=~/^\s*e?l?n?o?p?q?$/&$_=~/^\w{4}$/){print $_};' /usr/share/dict/words
@lukasvermeer
lukasvermeer / add_one_letter.pl
Last active December 28, 2015 21:19
Quick and dirty hack to find alternative sentences that can be created by adding a single letter to an input sentence. Probably only works on Mac (because it expects a dictionary file in a specific place).
use strict;
use warnings;
die "Malfunction. Need input." unless $ARGV[0];
open(W, "/usr/share/dict/words");
my @w;
while (my $line = <W>) {
chomp($line);
push(@w, lc($line));
@lukasvermeer
lukasvermeer / Example Output
Last active August 29, 2015 14:12
Johan envisioned a Twitter bot that introduces people who say "X, said no one ever" to people who've said X. Here's a start.
Max:Said No One Ever lukas$ date && python ___SNOE.py
Thu Dec 25 13:50:35 CET 2014
---
@ezafar3 Tweeted: "Awesome weather today #SaidNoOneEver"
- http://twitter.com/ezafar3/status/548089419648208896
@BrittanyRiitano Said: "Melbourne definitely delivered the awesome weather today for chrissy!"
- http://twitter.com/BrittanyRiitano/status/548012278457446400
---
@ezafar3 Tweeted: "Awesome weather today #SaidNoOneEver"
- http://twitter.com/ezafar3/status/548089419648208896
# 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
@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) {
@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 / 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 / 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 / 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 / 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++) {