Skip to content

Instantly share code, notes, and snippets.

View Val's full-sized avatar
🤔
I'm sorry, Dave, I'm afraid I can't do that

Laurent Vallar Val

🤔
I'm sorry, Dave, I'm afraid I can't do that
View GitHub Profile
@Val
Val / yubikey_otp_to_serial.sh
Created August 31, 2022 19:16
Calculate the Yubikey serial number from the OTP (bash only)
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'
# adapted from Python: https://gist.github.com/href/dad244512c320bd9b5d6ff50e7c7e0b2
declare -ra ALPHABET=(c b d e f g h i j k l n r t u v)
index_of() {
local -r element="$1"
@Val
Val / download_latest_crystal_tagged_deb.rb
Last active June 12, 2018 21:03
Ruby script to download latest Crystal tagged Debian package
#!/usr/bin/env ruby
# vim: ft=ruby syn=ruby fileencoding=utf-8 sw=2 ts=2 ai eol et si
#
# download_latest_crystal_tagged_deb.rb: this script looks up the latest
# successfull tagged build of crystal on Circle CI, extracts the build number
# of `dist_artifacts` job and retrieves it's Debian artifacts, depending of
# ARCH environment variable (default: 'amd64')
#
# (c) 2018 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below.
#

Keybase proof

I hereby claim:

  • I am Val on github.
  • I am val_ (https://keybase.io/val_) on keybase.
  • I have a public key whose fingerprint is 50ED 0818 014B 1FB1 1C95 0C0C 0011 DC24 B796 EB52

To claim this, I am signing this object:

@Val
Val / crystal_json_vs_yaml_serialization.cr
Created September 12, 2016 15:33
Crystal JSON vs YAML serialization
require "json"
require "yaml"
require "secure_random"
class SerializableKlass
YAML.mapping({
bool: { type: Bool, nilable: true},
float: { type: Float64, nilable: true},
int: { type: Int32, nilable: true},
str: { type: String, nilable: true}
@Val
Val / build_rest-like_api.rb
Created January 19, 2016 14:28
Token protected REST-like API using Grape, Swagger on top of Rails. Based on http://www.toptal.com/ruby/grape-gem-tutorial-how-to-build-a-rest-like-api-in-ruby/
# -*- mode:ruby;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*-
# vim: ft=ruby syn=ruby fileencoding=utf-8 sw=2 ts=2 ai eol et si
#
# build_rest-like_api.rb: sample REST-like API server
# (c) 2016 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below.
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
#!/usr/bin/env ruby
# -*- mode:ruby;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*-
# vim: ft=ruby syn=ruby fileencoding=utf-8 sw=2 ts=2 ai eol et si
#
# next_train_for.rb: french trains station in motion service client script
# (c) 2010-2014 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below.
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
#!/bin/sh
# -*- mode:shell-script;sh-tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*-
# vim: ft=shell syn=shell fileencoding=utf-8 sw=2 ts=2 ai eol et si
#
# send_sms.sh: Free Mobile (french provider) SMS service send message script
# (c) 2014 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below.
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
@Val
Val / rails_admin_sample_template.rb
Created October 1, 2012 09:36
Rails template to test list's filters on has_and_belongs_to_many associations
# -*- mode:ruby;indent-tabs-mode:nil;coding:utf-8 -*-
#
# rails_admin test template: (c) 2012 Laurent Vallar <val@zbla.net>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#