Skip to content

Instantly share code, notes, and snippets.

View pedrozath's full-sized avatar

Pedro Maciel pedrozath

View GitHub Profile
@pedrozath
pedrozath / logical_binary_connectives.rb
Last active August 25, 2024 19:25
A study onto Binary Connectives
LOGIC_GATE = -> (*truth_table) do
->(*args) { truth_table[args.join.to_i(2)] }
end
NOT = LOGIC_GATE[1,0]
AND = LOGIC_GATE[0,0,0,1]
OR = LOGIC_GATE[0,1,1,1]
# other logic gates can be composed with the above ones
# NAND = NOT >> AND
class Square
end
class EmptySquare < Square
def to_s
'º'
end
end
class FoodSquare < Square
x = Class.new do
def initialize
puts self.class.to_s
end
end
x.new
# outputs <Class:XXXXXXXXXX>
Batata = x
# frozen_string_literal: true
c = ''
c += '09811110811'
def da_boas_vindas
puts '###Jogo da adivinhação###'
puts 'Qual seu nome? '
nome = gets.strip
puts "\n\n\n"
puts "Começaremos o jogo para você #{nome}"
module Coltrane
module UI
module Views
class Index < View
questions({
path: {
statement: "Welcome to Coltrane #{Coltrane::VERSION}",
options: %w[notes chords scales progressions exit]
}
})
module Coltrane
module UI
module Views
class ShowScale < View
questions({
scale: {
statement: 'Which Scale?',
options: Commands::AvailableClassicScales.run
},
class ComponentsController < ApplicationController
def show
render html: view_context.component(params[:component], html_attrs: JSON(params[:attributes]))
end
end
@pedrozath
pedrozath / classes_javascript.js
Last active September 30, 2023 03:07
Classes JavaScript
// ----------- Criando Classes ----------------------
var Modal = function(options) {
// aqui vai o construtor do objeto, código que vai ser rodado durante o instanciamento
this.options = options
}
Modal.prototype = {
// aqui vão os métodos da instancia, um a um como chaves/valores desse objeto
open: function(){
<<-SQL
SELECT photos.* FROM "photos"
INNER JOIN "subcategories" ON "photos"."subcategory_id" = "subcategories"."id"
INNER JOIN "categories" ON "subcategories"."category_id" = "categories"."id"
LEFT OUTER JOIN "market_category_exclusions" ON "categories"."id" = "market_category_exclusions"."category_id"
AND "market_category_exclusions"."market" = 'cortinas'
WHERE "market_category_exclusions"."id" IS NULL;
SQL
def breakbulk_cargo_originids
Manifest.find(43445)
.bol_segments
.first
.containers
.pluck(:originid)
.compact
.uniq
end