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
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 |
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 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}" |
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 BookCommand < AppCommand | |
def self.call args | |
log :higher, "Called #{self}.#{__method__} with args #{args}" | |
new(args).call | |
end | |
def initialize args | |
@args = args | |
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
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" |
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 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 |
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
sudo apt install firmware-b43-installer |
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 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 |
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
#!/usr/bin/env ruby | |
class Symbol | |
def with(*args, &block) | |
->(caller, *rest) { caller.send(self, *rest, *args, &block) } | |
end | |
end | |
require 'active_support/core_ext/string' | |
require 'colorize' |
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
inherit_from: | |
- .rubocop_todo.yml | |
AllCops: | |
DisplayCopNames: true | |
DisplayStyleGuide: true | |
ExtraDetails: true | |
EnabledByDefault: true | |
UseCache: true | |
CacheRootDirectory: ~ |
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
#... | |
n = Time.now | |
if n.friday? || n.saturday? || n.sunday? | |
Minitest::Test.class_eval do | |
def result_code | |
failure && failure.result_code || '👍 ' | |
end | |
end |
NewerOlder