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
@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 ]
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
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 12, 2024 03:46
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@zach-klippenstein
zach-klippenstein / ChangePassword.java
Last active April 3, 2024 18:04
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall (rsdio@metastatic.org), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@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
@ryanb
ryanb / abilities.rb
Created September 15, 2012 19:23
How you can break up large Ability class in CanCan
module Abilities
def self.ability_for(user)
if user.admin?
AdminAbility.new(user)
else user
MemberAbility.new(user)
else
GuestAbility.new
end
end
@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
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete