Skip to content

Instantly share code, notes, and snippets.

@lpsmith
lpsmith / HHHT.m
Created Jan 23, 2019
Expected first sighting of HHHH versus HHHT in a sequence of coin flips of a fair coin.
View HHHT.m
hhhh_transition_matrix = [
0.5 0.5 0.5 0.5 0 0;
0.5 0 0 0 0 0;
0 0.5 0 0 0 0;
0 0 0.5 0 0 0;
0 0 0 0.5 0 0;
0 0 0 0 1 1
];
hhht_transition_matrix = [
@lpsmith
lpsmith / decodeqr
Created Aug 29, 2017
Bash scripts for working with qr codes
View decodeqr
#!/bin/bash
DECODEQR_TMPDIR=$(mktemp --tmpdir=$TMPDIR -d)
if [ $? -eq 0 -a ! -z "$DECODEQR_TMPDIR" ]; then
#mkfifo $DECODEQR_TMPDIR/tmp.png
gnome-screenshot -f $DECODEQR_TMPDIR/tmp.png
zbarimg --quiet $DECODEQR_TMPDIR/tmp.png
rm -rf $DECODEQR_TMPDIR
fi
@lpsmith
lpsmith / ddclient.service
Created Aug 24, 2017
ddclient unit file for systemd
View ddclient.service
[Unit]
Description=ddclient service
After=network.target
[Service]
ExecStart=/usr/local/sbin/ddclient -file /etc/ddclient/ddclient.conf -daemon 300 -foreground -pid /dev/null
User=ddclient
Restart=always
RestartSec=300
View LogFollower.hs
{-# LANGUAGE ScopedTypeVariables #-}
module LogFollower where
import Control.Concurrent (threadDelay)
import Control.Exception
import Data.ByteString.Char8 as BS
import Data.ByteString.Lazy as BL
import Data.IORef
import Data.Function(fix)
View Setup.hs
import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.Simple.LocalBuildInfo
import Distribution.PackageDescription
import Distribution.Version
import Text.Groom
-- This checks the direct dependency of the bytestring package being
-- compiled against to set the bytestring_has_itoa_c and
@lpsmith
lpsmith / pgtest.c
Created Jan 18, 2011
Example of binary IO using libpq
View pgtest.c
// This is a demonstration of binary input into postgres using libpq. It
// is based on postgresql-9.0.2/src/test/examples/testlibpq3.c
//
// Create a table appropriate to this test in a database as follows:
//
// CREATE TABLE test (name BYTEA);
//
// See also http://article.gmane.org/gmane.comp.lang.haskell.cafe/85116
You can’t perform that action at this time.