Skip to content

Instantly share code, notes, and snippets.

View Yegorov's full-sized avatar
🏢
Work it harder. Make it better. Do it faster.

Artem Yegorov

🏢
Work it harder. Make it better. Do it faster.
View GitHub Profile
@floehopper
floehopper / download
Created November 16, 2024 10:52
Download file using multiple parallel Range requests
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "typhoeus"
end
require "uri"
@kyrylo
kyrylo / colorized_logger.rb
Last active April 26, 2025 11:35
Nice colorized logs for Rails apps! With this initializer, you can instantly colorize your Rails development logs. Just copy and paste the code, and it’ll work. https://x.com/kyrylosilin/status/1852308566201237815
# frozen_string_literal: true
# config/initializers/colorized_logger.rb
# This initializer adds color to the Rails logger output. It's a nice way to
# visually distinguish log levels.
module ColorizedLogger
COLOR_CODES = {
debug: "\e[36m", # Cyan
info: "\e[32m", # Green
warn: "\e[33m", # Yellow
@mackuba
mackuba / follow_hashtag.rb
Created October 24, 2024 01:18
Script for following hashtags for my hashtag feed
#!/usr/bin/env ruby
# make sure you have Ruby installed, should be installed by default on macOS & Linux
# install Minisky lib with: [sudo] gem install minisky
# then run with: ruby follow_hashtag.rb somehashtag
require 'minisky'
if !File.exist?('config.yml')
puts "Create a config.yml file with contents like this:"
require 'prism'
require 'ripper'
chars = %w[1 % = a b == * . ( ) , % ? ** & [ ] { } | ; : => ~ ! ^ || && '' .. ... < > + $a @a] + [' ', "\n", ' if ', ' and ',' rescue ', ' in ']
p seed: seed = rand(10000)
srand seed
$VERBOSE=nil
(3..10).each do |n|
[chars.size**n, 100000].min.times do |i|
code = n.times.map{chars.sample}.join
p [n, i] if i % 1000 == 0
@dannguyen
dannguyen / README.openai-structured-output-demo.md
Last active May 25, 2025 00:53
A basic test of OpenAI's Structured Output feature against financial disclosure reports and a newspaper's police blotter. Code examples use the Python SDK and pydantic for the schema definition.

Extracting financial disclosure reports and police blotter narratives using OpenAI's Structured Output

tl;dr this demo shows how to call OpenAI's gpt-4o-mini model, provide it with URL of a screenshot of a document, and extract data that follows a schema you define. The results are pretty solid even with little effort in defining the data — and no effort doing data prep. OpenAI's API could be a cost-efficient tool for large scale data gathering projects involving public documents.

OpenAI announced Structured Outputs for its API, a feature that allows users to specify the fields and schema of extracted data, and guarantees that the JSON output will follow that specification.

For example, given a Congressional financial disclosure report, with assets defined in a table like this:

@ioquatix
ioquatix / connections.md
Last active June 19, 2025 09:40
Show how `with_connection` and `lease_connection` interact.

Permanent Connection Checkout

Rails 7.2 defaults:

Highscore.connection
# => #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x000000000080e8 env_name="development" role=:writing>

With config.active_record.permanent_connection_checkout = :disallowed:

@joeywang
joeywang / audit.md
Created September 23, 2024 21:43
Auditing in Database Applications: Ensuring Data Integrity and Compliance

Auditing in Database Applications: Ensuring Data Integrity and Compliance

In today's data-driven world, maintaining the integrity and security of information stored in databases is paramount. One crucial aspect of this is auditing - the practice of tracking and logging all changes made to data within a system. This article explores the importance of auditing in database applications and compares several popular auditing solutions.

Why Auditing Matters

Implementing a robust auditing system in your database application offers several key benefits:

  1. Compliance: Many industries are legally required to maintain an audit trail of changes to sensitive data.
  2. Security: Audit logs help detect unauthorized access or potential data breaches.
@hopsoft
hopsoft / README.md
Last active July 30, 2024 19:55
Simple Template Rendering

Simple Template Rendering

I'm experimenting with a simple template rendering solution that leverages Ruby's native String formatting. It feels a little bit like Mustache templates. Note that this demo adds new "formatting specifiers" to support Rainbow color mechanics.

Tip

See the files below for the implementation... and note that this is simply a proof of concept (POC)

Usage

require 'open3'
require 'reline'
class Reline::LineEditor
private def perform_completion(list, _just_show_list)
_preposing, target, _postposing = retrieve_completion_block
namespace = IRB.CurrentContext.io.retrieve_doc_namespace(target)
namespace = namespace.first if namespace.is_a?(Array)
if namespace.nil? || !('A'..'Z').include?(namespace[0])
namespace = IRB.conf[:__MAIN__]
# In your Gemfile
gem "localhost"

# Then, depending on your desired server
gem "falcon"
gem "puma"