Skip to content

Instantly share code, notes, and snippets.

@jurisgalang
jurisgalang / totp
Last active November 17, 2017 00:46
Ruby implementation of the Time-Based One-Time Password (TOTP) Algorithm described at http://tools.ietf.org/html/rfc6238
[jgalang@rashomon:~/Code/skunkworks/2fa]
∴ ruby totp_demo.rb
Time(sec) Time (UTC format) Value of T(Hex) TOTP Mode OK
------------------------------------------------------------------------------------------
59 1970-01-01 00:00:59 0000000000000001 94287082 SHA1 ✔
59 1970-01-01 00:00:59 0000000000000001 46119246 SHA256 ✔
59 1970-01-01 00:00:59 0000000000000001 90693936 SHA512 ✔
1111111109 2005-03-18 01:58:29 00000000023523EC 07081804 SHA1 ✔
1111111109 2005-03-18 01:58:29 00000000023523EC 68084774 SHA256 ✔
@jurisgalang
jurisgalang / gist:3967058
Created October 28, 2012 00:50
Fuzzy tile image rendering in Processing
PImage image = loadImage("/Users/jgalang/Desktop/yoko2.jpg");
void setup() {
if (image.height != displayHeight) {
//image = image.get();
image.resize(0, displayHeight);
//image.loadPixels();
}
size(image.width, displayHeight, P3D);
@jurisgalang
jurisgalang / slitcamera.pde
Created October 24, 2012 04:25
Slit camera simulation in Processing
// just fire it up and dance slow in front of the camera...
import processing.video.*;
Capture device;
void setup() {
size(640, 320);
device = new Capture(this, width, height, 30);
device.start();
@jurisgalang
jurisgalang / recursive-backtracker.html
Created July 30, 2012 16:00
Maze generation using the depth-first search algorithm.
<html>
<head>
<script src="processing.js"></script>
</head>
<body>
<canvas id="maze" style="border: 2px solid #202020"></canvas>
<script type="text/javascript">
var sketch = new Processing.Sketch();
var MAXCOLS = 40;
@jurisgalang
jurisgalang / named-parameters.rb
Created November 10, 2010 21:48
Module to enable/simulated named parameters support in Ruby
# NamedParameters
# ---------------
# This module enables/simulates named parameters support in Ruby
# see: http://en.wikipedia.org/wiki/named_parameter
#
# This is also available as a Ruby gem, the project is available at
# https://github.com/jurisgalang/named-parameters - and is more up-to-date
# than this gist.
#
# To install the gem:
@jurisgalang
jurisgalang / gist:663353
Created November 4, 2010 23:00
Gitisms - useful git invocations for everyday use.
# get the name of the currently checked out tag
git describe --tags --abbrev=0
# list all branches (local and remote)
git branch -a
# list all tags
git tag
# delete a tag
@jurisgalang
jurisgalang / breeding-strings.rb
Created October 31, 2010 07:19
Source code for the Breeding Strings article.
#!/usr/bin/env ruby
# encoding: utf-8
=begin
* Name: string-breeder.rb
* This script will breed the string value: "Hello World" (sans quotes)
* or whatever was passed as the argument.
* No warranties implied, but feel free to copy, modify, and share.
* Author: Juris Galang
* Date: February 2009