Skip to content

Instantly share code, notes, and snippets.

View alexbevi's full-sized avatar
🙀

Alex Bevilacqua alexbevi

🙀
View GitHub Profile
# Day 1
sum = 0
File.readlines('day01.txt', chomp: true).each do |line|
sum += line.scan(/\d/).values_at(0, -1).join.to_i
end
puts sum
@alexbevi
alexbevi / lightgallery_tag.rb
Created May 2, 2023 16:27
lightGallery inline gallery plugin for Jekyll
# Title: LightGallery Tag for Jekyll
# Authors: Alex Bevilacqua <alex@alexbevi.com>
# Description: incorporate the LightGallery inline JavaScript gallery
#
# Adaption of "Photos tag for Jekyll" by Devin Weaver, and the derived
# "Gallery Tag for Jekyll" by Kevin Brown.
#
# Installation:
#
# {% gallery_includes %}
@alexbevi
alexbevi / mongodb-roadmap.md
Last active February 8, 2023 18:40
MongoDB Roadmap (proposal for roadmap.sh)
  • MongoDB Basics
    • SQL vs NoSQL
    • What is MongoDB?
    • What is MongoDB Atlas?
    • When to use MongoDB?
  • MongoDB data model and data types
    • BSON (Binary JSON) data types
      • Double
      • String
  • Object
@alexbevi
alexbevi / DEMO.md
Last active January 24, 2023 21:09
Ruby on Rails Global Summit 23: Ruby on Rails and MongoDB

Install Rails 7

# make sure rails is setup
gem install rails                                                                                                          
# output
@alexbevi
alexbevi / 2021-09.TODO
Last active September 14, 2021 12:37
2021-09 (September)
TODO:
☐ [Drivers] Schedule an EMEA/AMER sync @created(21-02-05 06:49)
☐ [Drivers] Schedule an Atlas Log Ingestion demo @created(21-02-05 06:49)
☐ [sharding] Update TSWRITING-1531 @created(21-01-04 09:58)
☐ [Q+I] Research index versions article @created(21-02-05 06:59)
☐ [Q+I] https://docs.google.com/document/d/1ba0uGSwcaOilYANjzfNda6wv77yozI3tenGFCUPDM9A/edit @created(21-05-05 12:52)
☐ Awaitable ismaster lightning talk @created(21-06-07 16:17)
☐ TSWRITING-1912? @created(21-07-05 07:47)
☐ Review TSWRITING-1519 @created(21-04-02 09:34) 
☐ Review Pocket Guide to TimeSeries for Diego @created(21-06-17 09:10)
@alexbevi
alexbevi / generate-games-list.rb
Last active May 31, 2021 13:03
Generate a Markdown Table from the ScummVM source code
def replace_target(path, target)
p = path.split('/')
p[-1] = target
return p.join('/').to_s
end
def cleanup_title(c)
title = c.gsub('{','').gsub('}','').gsub("\t", ' ').split(', ')[1..-1].join.strip
title = title.delete_prefix('"').delete_suffix('"').delete_suffix(' ,').delete_suffix("\",").delete_suffix("\"").delete_suffix("\" ;")
title
@alexbevi
alexbevi / printSyncSourceTree.js
Last active January 27, 2022 07:44
MongoDB Replica Set Sync Source Tree
function printReplicationTree(rs) {
print("\nReplication Sync Source Tree\n============================");
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
var idMapping = rs.members.reduce((acc, el, i) => {
acc[el.name] = i;
return acc;
}, {});
@alexbevi
alexbevi / README.md
Last active January 14, 2021 16:31
Dump BSON File Contents as JSON

dump_bson.rb

Usage

# Use -f/--filename to pass the file to emit JSON for
ruby dump_bson.rb -f auditLog_prod01.bson
....
{"atype":"authenticate","ts":"2020-11-21 06:25:22 UTC","local":{"ip":"127.0.0.1","port":27013},"remote":{"ip":"127.0.0.1","port":55842},"users":[{"user":"__system","db":"local"}],"roles":[],"param":{"user":"__system","db":"local","mechanism":"SCRAM-SHA-1"},"result":0}
{"atype":"shutdown","ts":"2020-11-21 06:25:23 UTC","local":{"ip":"127.0.0.1","port":27013},"remote":{"ip":"127.0.0.1","port":55842},"users":[{"user":"__system","db":"local"}],"roles":[],"param":{},"result":0}
@alexbevi
alexbevi / measureInitialSyncProgress.js
Last active December 1, 2023 12:18
MongoDB 5.0+ Initial Sync Progress Monitoring
/*
* measureInitialSyncProgress
* @author Alex Bevilacqua <alex@alexbevi.com>
* @updated 2021-02-23
*
* Can be run against a MongoDB 4.2.12+ mongod that is in STARTUP2 (intitial sync) state to gain some
* insight into how the sync is progressing based on the improvements introduced with SERVER-47863.
* For versions of MongoDB < 4.2.12, see https://www.alexbevi.com/blog/2020/02/13/mongodb-initial-sync-progress-monitoring
*
* usage:
@alexbevi
alexbevi / measureIndexUsage.js
Last active March 23, 2020 20:13
Measure the index utilization for all collections in a database before/after an operation
/**
* measureIndexUsage(block)
*
* Measure the index utilization before/after a block is run. The block can contain
* one to many operations, however the index utilization will only measure the collections
* associated with the current `db` instance.
*
* NOTE: this script does not "isolate" the operation(s) run so if running in a busy
* environment the results may represent other operations index utilization.
*