This file contains 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
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 |
This file contains 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 Square | |
end | |
class EmptySquare < Square | |
def to_s | |
'º' | |
end | |
end | |
class FoodSquare < Square |
This file contains 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
x = Class.new do | |
def initialize | |
puts self.class.to_s | |
end | |
end | |
x.new | |
# outputs <Class:XXXXXXXXXX> | |
Batata = x |
This file contains 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
# 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}" |
This file contains 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
module Coltrane | |
module UI | |
module Views | |
class Index < View | |
questions({ | |
path: { | |
statement: "Welcome to Coltrane #{Coltrane::VERSION}", | |
options: %w[notes chords scales progressions exit] | |
} | |
}) |
This file contains 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
module Coltrane | |
module UI | |
module Views | |
class ShowScale < View | |
questions({ | |
scale: { | |
statement: 'Which Scale?', | |
options: Commands::AvailableClassicScales.run | |
}, |
This file contains 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 ComponentsController < ApplicationController | |
def show | |
render html: view_context.component(params[:component], html_attrs: JSON(params[:attributes])) | |
end | |
end |
This file contains 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
// ----------- 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(){ |
This file contains 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
<<-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 |
This file contains 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
def breakbulk_cargo_originids | |
Manifest.find(43445) | |
.bol_segments | |
.first | |
.containers | |
.pluck(:originid) | |
.compact | |
.uniq | |
end |
NewerOlder