Some examples related to my tweet rant https://twitter.com/dsymetweets/status/1294276915260522496
In project programming this hit me this week with a bug:
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 |
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'rails', '~> 6.1' | |
gem 'byebug' | |
end |
Some examples related to my tweet rant https://twitter.com/dsymetweets/status/1294276915260522496
In project programming this hit me this week with a bug:
# 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 |
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>...]
from itertools import cycle | |
import telepot | |
bot_tokens = [ | |
# array of string tokens | |
] | |
bots = [telepot.Bot(token) for token in bot_tokens] |
<?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 |