Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require 'securerandom'
LETTERS = ('a'..'z').to_a.freeze
BIG_LETTERS = ('A'..'Z').to_a.freeze
DIGITS = ('0'..'9').to_a.freeze
SPECIAL = '~`!@#$%^&*()_+{}][;:\'"/?>.<,'.split.freeze
ALL = (LETTERS + BIG_LETTERS + DIGITS + SPECIAL).freeze
@cutalion
cutalion / relation.rb
Last active February 11, 2022 14:40
rom-sql's "Relation#exist?" using EXISTS
# override original exist? so that it does not use COUNT()
def exist?(*args, &block)
sql = where(*args, &block).dataset.unordered.select(1).exists
db.select(sql.as(:exists)).first[:exists]
end
alias any? exist?
private
def db

Keybase proof

I hereby claim:

  • I am cutalion on github.
  • I am cutalion (https://keybase.io/cutalion) on keybase.
  • I have a public key ASCxHyC7j9qjGEbi58EVnguJc8s-TwbR9YLfegmqtwWXjAo

To claim this, I am signing this object:

@cutalion
cutalion / main.rs
Created March 6, 2023 16:56
Game of life written by ChatGPT
use std::fmt;
// Define the dimensions of the game board
const ROWS: usize = 20;
const COLS: usize = 20;
// Define the Cell struct
#[derive(Clone, Copy)]
struct Cell(bool);