Skip to content

Instantly share code, notes, and snippets.

View infertux's full-sized avatar
:shipit:

Cédric Félizard infertux

:shipit:
View GitHub Profile
anonymous
anonymous / cryptovisual_qr_encoder
Created August 7, 2014 18:07
create two random-looking images that reveal a QR code when superposed
#!/bin/bash
# This script reads text from stdin, generates its QR code and splits it into two visual cryptographic images. Both images appear random and have as many whites as blacks. Only when print on transparent film (or extremely thin paper) and superposed, the ciphered qrcode appears as gray/black dots.
# We use the program "qrencode" to generate a QR at an average 7% error-correction rate ("low" quality; the lowest available). We create then a random array and we visual-XOR it with the QR code to retrieve the ciphered code. Only the random array (nonce or one-time pad) and the ciphered array are recorded, and only when both are superposed they reveal the QR code.
# The visual-cryptographic scheme used is inspired of http://leemon.com/crypto/VisualCrypto.html . It transforms 0s and 1s into diagonal 2x2 squares (01\10 and 10\01). The visual XOR either repeats (gray superposition; corresponding to a white dot) or flips (black superposition; corresponding to a black dot), following the QR code.
# Security
@infertux
infertux / bootstrap_ruby.sh
Last active August 29, 2015 14:06
Download, configure and install Ruby and Bundler on a Debian-family or Redhat-family fresh system
#!/bin/bash -eu
# Download, configure and install Ruby and Bundler on a Debian-family or Redhat-family fresh system
# https://gist.github.com/infertux/a5252bf8023f0a0e9380
RUBY="2.2.2"
SHA256="5ffc0f317e429e6b29d4a98ac521c3ce65481bfd22a8cf845fa02a7b113d9b44"
# This runs as root on the server
[ $UID -eq 0 ]
@gavinwahl
gavinwahl / example.sql
Last active August 29, 2015 14:19
Temporal foreign key
DROP TABLE IF EXISTS parent;
DROP TABLE IF EXISTS child;
CREATE TABLE parent(
identity_id integer,
valid_range int4range
);
CREATE TABLE child(
valid_range int4range,
@infertux
infertux / unicorn_connections
Created August 11, 2015 12:56
Munin plugin to monitor the number of Unicorn connections on a socket
#!/bin/bash
# -*- sh -*-
# vim: ft=sh
: << =cut
=head1 NAME
unicorn_connections - Plugin to monitor the number of Unicorn connections
l={};s=m=[];i=pc=mc=0
alias p proc
h={'>':p{mc+=1},'<':p{mc-=1},'+':p{m[mc]+=1},'-':p{m[mc]-=1},'.':p{putc m[mc]}}
j={'[':->(i){s<<i;->(){pc=l[pc-1]+1 if m[mc]==0}},']':->(i){o=s.pop;l[o]=i;p{pc=o}}}
ins=DATA.each_char.map{|c|c=:"#{c}";x=(j[c]||->(_){h[c]||p{}}).(i);i+=1;x}
while k=ins[pc];pc+=1;m[mc]||=0;k.();end
__END__
[ This program prints "Hello World!" and a newline to the screen, its
length is 106 active command characters. [It is not the shortest.]
@timruffles
timruffles / ruby_pipes.rb
Created December 4, 2012 12:07
ruby pipeline lambdas
class Proc
def |(g)
lambda {|*args|
g.(self.(*args))
}
end
end
class Printer
@infertux
infertux / axp_pmu
Created February 13, 2016 22:38
Munin plugin to monitor AXP PMU on sunxi SoCs
#!/bin/sh
# -*- sh -*-
# vim: ft=sh
: << =cut
=head1 NAME
axp_pmu - Plugin to monitor power
@infertux
infertux / V3.car.diff
Created April 4, 2016 14:07
Turn Stunt Rally CAR game into a JET FIGHTER game ;)
--- V3.car 2015-09-18 09:21:11.000000000 +0000
+++ V3.car 2016-04-01 14:51:17.783726416 +0000
@@ -61,16 +61,16 @@
#---------------------------
[ hover ]
-hAbove = 2.5
+hAbove = 4.0
hRayLen = 4.0
@infertux
infertux / checkout.rb
Created June 14, 2011 19:26
Code kata
class CheckOut
def initialize(rules)
@items = Hash.new { 0 }
@pricer = Pricer.new(rules)
end
def scan(sku)
@items[sku] += 1
end
(2 * 2 * 5 * 7 * 37 * 149 * 5417 * 148781 * 51939996061871).to_s(16).scan(/../).map { |x| x.hex.chr }.join