Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cyril's full-sized avatar
🌶️
I like spicy pad thai

Cyril Kato cyril

🌶️
I like spicy pad thai
View GitHub Profile
@cyril
cyril / megalotto.rb
Last active August 29, 2015 14:06 — forked from jodosha/megalotto.rb
Thread-safe MegaLotto
module MegaLotto
class Configuration
attr_accessor :drawing_count
def initialize
@drawing_count = 6
end
end
class Drawing

Keybase proof

I hereby claim:

  • I am cyril on github.
  • I am cyril (https://keybase.io/cyril) on keybase.
  • I have a public key whose fingerprint is 9E6D 8A8E D99B A715 796D B523 0089 4A44 BA96 18B3

To claim this, I am signing this object:

@cyril
cyril / duck.rb
Created September 2, 2015 23:10
A duck class in Ruby
# duck.rb
class Duck
def walks
'Klop klop!'
end
def swims
'Swoosh...'
end
@cyril
cyril / duck_test.txt
Created September 2, 2015 23:14
A test for the Duck class in Ruby
$ ruby duck_spec.rb
..I
1. Info: undefined method `sings' for #<Duck:0x007fb60383b740> (NoMethodError).
Ran 3 tests in 0.00038 seconds
100% compliant - 1 infos, 0 failures, 0 errors
@cyril
cyril / app_test.txt
Last active September 2, 2015 23:20
According to RSpec, App.new is 42.
$ rspec wat_spec.rb
.
Finished in 0.00146 seconds (files took 0.17203 seconds to load)
1 example, 0 failures
@cyril
cyril / app_spec.rb
Last active September 3, 2015 20:08
Basic usage of RSpec (with a surprise)
class App
def equal?(*)
true
end
end
require 'rspec'
RSpec.describe App do
it 'is the answer to life, the universe and everything' do
@cyril
cyril / ascenseur-1-specs.rb
Last active December 27, 2015 08:19
Exercices with Ruby specs
require 'minitest/autorun'
require_relative 'ascenceur-1'
describe Elevator do
before do
@elevator = Elevator.new
end
describe "the elevator dashboard" do
it "must serve several floors" do
@cyril
cyril / duck_spec.rb
Last active February 28, 2016 15:35
A spec for the Duck class in Ruby
# duck_spec.rb
require_relative 'duck'
require 'fix'
@bird = Duck.new
Fix.describe @bird do
on :swims do
it { MUST eql 'Swoosh...' }
end
@cyril
cyril / 4sbox_6x4-1.rb
Last active June 27, 2018 08:51
Draft of cryptographic hash functions
=begin
* 4 substitution box (6x4-bit)
* Copyright (c) 2008 Cyril Kato
* Code licensed under the BSD License:
http://www.opensource.org/licenses/bsd-license.php
* version: 1
=end
SBOX = [
[
@cyril
cyril / crypto-sha.html
Created December 18, 2020 21:58
Uses the SubtleCrypto interface of the Web Cryptography API to hash a message using SHA-1, SHA-256, SHA-512.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Crypto SHA</title>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<script>
function SHA256() {
var str = document.getElementById('plainTextGCM').value;