Skip to content

Instantly share code, notes, and snippets.

View ch1ago's full-sized avatar
🏠
Working mostly from home since 2006

Thiago Almeida ch1ago

🏠
Working mostly from home since 2006
  • Mexico City
  • 10:33 (UTC -06:00)
View GitHub Profile
# use case
DockerShell.start("kroki_service", "yuzutech/kroki", "9001", "8000") do
log stick :b, color, "I just think Ruby is the Best for coding!"
sleep 10
end
__BEGIN__
class MicroSystem::DockerShell < DevSystem::Shell
class TelegramClient < AppClient
def self.bot_token
".............................................."
end
def self.base_url
"https://api.telegram.org/bot#{bot_token}"
end
helper_class :loggable,
@ch1ago
ch1ago / UPDATED.picoruby_command.rb
Last active November 5, 2024 02:01
liza picoruby:deploy
class PicorubyCommand < DevSystem::SimpleCommand
section :filters
def before
super
@t = Time.now
log "simple_args #{ simple_args }"
log "simple_booleans #{ simple_booleans }"
log "simple_strings #{ simple_strings }"
require 'socket'
class MyIcmpSocket
ICMP_ECHO_REQUEST_TYPE = 8
ICMP_ECHO_REQUEST_CODE = 0
ICMP_HEADER_SIZE = 8
def initialize
@socket = Socket.new(Socket::AF_INET, Socket::SOCK_RAW, Socket::IPPROTO_ICMP)
end
@ch1ago
ch1ago / calculator_command.rb
Last active January 22, 2023 22:22
tres exemplos de controllers Command para a landing page
class CalculatorCommand < AppCommand
class Error < StandardError; end
def self.sum(a, b)= a + b
def self.sub(a, b)= a - b
def self.mul(a, b)= a * b
def self.div(a, b)= a / b
def self.call (args)
log "Called #{self}.#{__method__} with args #{args}"
class BookCommand < AppCommand
def self.call args
log :higher, "Called #{self}.#{__method__} with args #{args}"
new(args).call
end
def initialize args
@args = args
end
require 'uri'
require 'json'
require 'net/http'
# https://dog.ceo/dog-api/
class DogCeoAPI
def self.get_random_mocked
{
"message" => "https://images.dog.ceo/breeds/terrier-welsh/lucy.jpg",
"status" => "success"
module CpfJames
module_function
def protect(string)
string.split(' ').map { |s| valid?(s) ? mask(s) : s }.join(' ')
end
def valid?(s)
!!s.match(/\d{3}.\d{3}.\d{3}-\d{2}/)
end
@ch1ago
ch1ago / install_wifi_on_ubuntu.sh
Created December 21, 2019 01:46
install wifi on ubuntu
sudo apt install firmware-b43-installer
@ch1ago
ch1ago / faxtures.rb
Created October 12, 2018 21:33
Faxtures (pronounced Facts-tures) are special fixture files that read, write, and COMPARE large outputs
module Faxtures
module_function
class Error < StandardError; end
class ReadFileNotFound < Error; end
# def read(*names, name, &block)
# TODO: read file line by line for RAM optimization
# end