Skip to content

Instantly share code, notes, and snippets.

@btoews
btoews / repro.rb
Last active May 5, 2023 14:22
AR bug repro
# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '=6.1.5.1'
gem 'sqlite3'
end
@btoews
btoews / rand_five.c
Last active December 3, 2019 18:07
Libsodium sealed box with non-random ephemeral key
#include <stdio.h>
#include <sodium.h>
const char *rand_five_implementation_name(void) {
return "five";
}
uint32_t rand_five_random(void) {
return 5;
}
@btoews
btoews / encoded_attr.rb
Last active June 3, 2019 15:30
encoded attribute example
module EncodedAttr
ENCODINGS = %i(raw b64 url_b64)
module ClassMethods
def encoded_attr(name, default_encoding:, encodings: ENCODINGS)
raise ArgumentError unless ENCODINGS.include?(default_encoding)
encodings.each do |encoding|
if encoding == default_encoding
alias_method "#{encoding}_#{name}", name
@btoews
btoews / *ocsptest.rb
Created September 27, 2018 22:36
Comodo OCSP Test
require "openssl"
begin
require "faraday"
rescue LoadError
puts "You need the 'faraday' gem for making HTTP requests. Run 'gem install faraday'"
exit 1
end
DIGEST = OpenSSL::Digest::SHA256
@btoews
btoews / blob.go
Created December 7, 2017 22:32
Blob Reader
package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"time"
)
@btoews
btoews / gist:3fbb84a9fc482a0fae11c8bacc9d4d3a
Created May 24, 2017 16:28
Test output using OpenSSL::PKey::EC
$ bundle exec rake
/Users/mastahyeti/.rbenv/versions/2.3.3/bin/ruby -I/Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib:/Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-support-3.6.0/lib /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
Randomized with seed 47449
Acme::Client::SelfSignCertificate
sets the certificates version (FAILED - 1)
sets the certificates serial number (FAILED - 2)
generate a self sign certificate
generate a self sign certificate from a provided private key (FAILED - 3)
@btoews
btoews / gcm_params.go
Created February 25, 2017 00:42
Golang CK_GCM_PARAMS
package main
/*
#include <stdio.h>
#include <stdlib.h>
#define CK_BYTE_PTR unsigned char *
#define CK_ULONG unsigned long long
typedef struct CK_GCM_PARAMS {
CK_BYTE_PTR pIv;
CK_ULONG ulIvLen;
@btoews
btoews / query.graphql
Created October 24, 2016 17:35
GitHub Query
query($id: ID!) {
node(id: $id) {
... on AssignedEvent {
actor {
id
}
issue {
id
}
repository {
@btoews
btoews / test
Created August 1, 2016 21:21
test
test
@btoews
btoews / demo.go
Last active April 22, 2016 17:56
error demo
package main
import (
"crypto/sha256"
"fmt"
"hash"
)
type Signer struct {
hash.Hash