Skip to content

Instantly share code, notes, and snippets.

View josegomezr's full-sized avatar
🎯
Focusing

Jose D. Gomez R. josegomezr

🎯
Focusing
View GitHub Profile
@josegomezr
josegomezr / dummy_event_bus.rb
Created May 2, 2024 11:53
Very much not-production ready Event-bus based off `ActiveSupport::Instrumentation`.
require 'active_support'
class CustomEventBus
def initialize()
@subscribers = {}
end
def subscribe(pattern = nil, callback = nil, &block)
puts "[#{self.class}] #subscribe TO: #{pattern.inspect}, with callback=#{callback.class.inspect}, block=#{block.class.inspect}"
@subscribers[pattern] ||= callback || block
@josegomezr
josegomezr / inline-self-contained-rails-test.rb
Created June 1, 2023 15:21
Reminder for myself: self contained file for making quick isolated rails tests
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rails', '~> 6.1'
gem 'byebug'
end
@josegomezr
josegomezr / rant.md
Created August 16, 2020 10:33 — forked from dsyme/rant.md
@josegomezr
josegomezr / README.md
Created July 6, 2020 07:49
Base64 editor for the lazy!

Why you want me to use this shit?

I'm really tired of the following manual script:

B64FILE=path/to/b64file
base64 -d $B64FILE > $B64FILE.plain
$EDITOR $B64FILE.plain
base64 -w $B64FILE.plain > $B64FILE
@josegomezr
josegomezr / pull_cloudwatch_log.sh
Created May 11, 2020 17:24
Pull a complete cloudwatch logstream to your local machine
# usage bash pull_cloudwatch_log.sh <log-group name> <log-stream-name> [<output-file>]
LOG_GROUP="${1:-log-group-name}"
LOG_STREAM="${2:-log-stream-name}"
OUTFILE="${3:-output.log}"
echo "Fetching logstream: $LOG_STREAM"
LOGOUTPUT="$(aws logs get-log-events --log-group-name $LOG_GROUP --log-stream-name $LOG_STREAM --output text --start-from-head)"
echo "Flushing chunk on $OUTFILE"
echo "$LOGOUTPUT" >> $OUTFILE
@josegomezr
josegomezr / README.md
Last active April 30, 2020 10:57
Ruby script to see the DDL ran by rails in a migration

Place this in the rails root of your project. And then call

ruby rails_migration_checker.rb <path/to/migration 1> [<path/to/migration 2>...]
@josegomezr
josegomezr / README.md
Created April 8, 2020 13:57
Python Structured logging aggregator

A very dummy parser for structured logging format into SQLite db.

@josegomezr
josegomezr / trollbots.py
Last active August 22, 2019 14:48
TrollBots.py
from itertools import cycle
import telepot
bot_tokens = [
# array of string tokens
]
bots = [telepot.Bot(token) for token in bot_tokens]
@josegomezr
josegomezr / plugin.php
Created April 28, 2019 02:08
WooCommerce base custom payment gateway
<?php
/*
Plugin Name: Custom Payment Gateway
Description: Custom payment gateway example
Author: Lafif Astahdziq
Author URI: https://lafif.me
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@josegomezr
josegomezr / README.md
Last active April 25, 2019 17:10
DataLogger Parser for termoDaQ

DataLogger parser for TermoDaQ

Parsed the raw data gathered by TermoDaQ into js objects.

Test it

> node main.js 
[ { rawLine:
     '91.458364,123.178515,9/25/2019,09:0:16.00,80.3375,80.1000,80.1000,0.9687,0.1365',