This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array(T) | |
# Returns true if the two arrays share no common elements. | |
def disjointed?(other : Array(U)) forall U | |
(self & other).size == 0 | |
end | |
end | |
arr1 = [1 ,2 ,3, 4] | |
arr2 = [3, 4, 5, 6] | |
arr3 = [5, 6, 7, 8] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jose' | |
message = "Jodie Whittaker is the greatest Doctor ever!" | |
# A128GCM Symmetric Key Encryption/Decryption | |
puts "-----Symmetric Key Encryption/Decryption-----" | |
secret = 'some128bitsecret' | |
jwk = JOSE::JWK.from_oct(secret) | |
encrypted_a128gcmkw = JOSE::JWE.block_encrypt(jwk, message, { "alg" => "A128GCMKW", "enc" => "A128GCM" }).compact | |
puts "encrypted JWE: #{encrypted_a128gcmkw}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jose' | |
# HS256 Symmetric Signature | |
secret = 'some128bitsecret' | |
jwk = JOSE::JWK.from_oct(secret) | |
header = { "alg" => "HS256" } | |
payload = { "iss" => "Chris Larsen", | |
"sub" => "JWTs", | |
"aud" => "Silicon Halton Software P2P", | |
"iat" => 1540121863 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Gen(T) | |
getter value : T | |
def initialize(@value : T) | |
end | |
def self.build(value : K) : Gen(K) forall K | |
Gen(K).new(value) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abort "Need a regex pattern" unless ARGV.size > 0 | |
regex = ARGV.shift | |
STDIN.each_line do |i| | |
puts i if i =~ %r(#{regex}) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usage = <<-STRING | |
Usage: cl-tutorial [option] | |
Command: | |
time, --time, -t show the current time | |
help, --help, -h show this help | |
version, --version, -v show version | |
STRING | |
if ARGV.size == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install software-properties-common | |
sudo apt-add-repository -y ppa:rael-gc/rvm | |
sudo add-apt-repository ppa:webupd8team/atom | |
sudo apt-get update | |
sudo apt-get install rvm |