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 | |
require "nokogiri" | |
require "json" | |
module Cfdi | |
module_function | |
def parse_file(xml_path) | |
doc = Nokogiri::XML(File.read(xml_path)) |
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 | |
require 'bundler/inline' | |
gemfile(true) do | |
gem 'rails', '~> 7.0' | |
gem 'sqlite3' | |
end | |
require 'active_record' |
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 | |
source "https://rubygems.org" | |
gem "bunny", "~> 2.19" |
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 | |
require 'json' | |
require 'net/http' | |
require 'concurrent' | |
class RickAndMorty | |
def character(id) | |
response = get_response("https://rickandmortyapi.com/api/character/#{id}") | |
return {} unless response.is_a?(Net::HTTPSuccess) |
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 'bundler/inline'; gemfile(true) { gem 'rails', '~> 6.1.3'; gem 'puma' } | |
require 'rails'; require 'action_controller/railtie'; | |
Codes = Struct.new(:id) { def to_json(args = {}) = { id: id, hex: SecureRandom.hex, iat: Time.now.utc.to_i }.to_json(args) } | |
class CodesApp < Rails::Application | |
config.secret_key_base = '4bdd3baa5f573f06c71cfb0504273e7ed1cf95858d7be6268bd1c7f800bbd03e1169e89106a9cf99541ac1b75ad4685d731723a30660c2cc66912609fd008090' | |
Rails.logger = Logger.new($stdout) | |
end | |
Rails.application.routes.draw { get '/:id', to: lambda { |env| [200, { 'Content-Type' => 'application/json' }, [Codes.new(env['action_dispatch.request.path_parameters'][:id]).to_json]] } } | |
run CodesApp |
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 Bomb | |
def method_missing(meth, *args, &blk) | |
self.class.send(:define_method, "is_#{meth}?") { true } | |
send("is_#{meth}?") | |
end | |
end | |
if __FILE__ == $0 | |
require 'SecureRandom' | |
loop { Bomb.new.send(SecureRandom.hex) } |
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 | |
require "httparty" | |
class Converter | |
def initialize(filename) | |
@content = File.open(filename).read | |
end | |
attr_reader :content |
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 | |
require 'HTTparty' | |
require 'nokogiri' | |
require 'colorize' | |
require 'action_view' | |
class Analyzer | |
def initialize(gem) | |
@gem = gem |
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
source "https://rubygems.org" | |
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |
ruby '2.3.8' | |
# Specify your gem's dependencies in ams_vs_jbuilder.gemspec | |
gemspec | |
gem 'benchmark-ips' | |
gem 'active_model_serializers', '0.9.4' |
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 'digest' | |
NUM_ZEROES = 6 | |
class Block | |
def find_nonce(message) | |
nonce = "HELP I'M TRAPPED IN A NONCE FACTORY" | |
count = 0 | |
until valid_nonce?(nonce, message) | |
print '.' if count % 10_000 == 0 |
NewerOlder