Skip to content

Instantly share code, notes, and snippets.

View bogn83's full-sized avatar

Bogomir Engel bogn83

View GitHub Profile
@bogn83
bogn83 / gist:6b97f789e71479a35b1fb15b559de350
Created June 13, 2024 16:37 — forked from kenn/gist:5105175
Unicorn memory usage improvement with Ruby 2.0.0

Unicorn memory usage improvement with Ruby 2.0.0

Here's a preliminary experiment to see how much memory is saved with the new copy-on-write friendly (bitmap marking) GC.

Calculated by memstats.rb https://gist.github.com/kenn/5105061 on Debian x86_64.

Master process:

# ./memstats.rb 20547
@bogn83
bogn83 / dci_alt.rb
Created February 15, 2023 21:15 — forked from elight/dci_alt.rb
DCI with delegation instead of extension
class User < ActiveRecord::Base
# ... lots of persistence stuff
end
class GitHubUserProvisioner < SimpleDelegator
def provision_with!(user_info, extra_user_hash)
self.github_login = extra_user_hash['login']
self.name = user_info['name']
self.email = user_info['email']
self.github_url = user_info['urls']['GitHub']
@bogn83
bogn83 / anonsplat.rb
Created December 14, 2021 12:22 — forked from morhekil/anonsplat.rb
Destructuring Ruby hashes with named parameters and anonymous splat
def stuff
yield action: 'Boom', schedule: '7PM', color: :red, debug: true
end
# When a hash is yielded to a block, we can used named arguments to
# capture the keys we want, and an anonymous splat to ignore
# everything else
stuff { |action:, schedule:, **| p "Doing #{action} at #{schedule}" }
#
@bogn83
bogn83 / 20211210-TLP-WHITE_LOG4J.md
Created December 13, 2021 12:48 — forked from SwitHak/20211210-TLP-WHITE_LOG4J.md
BlueTeam CheatSheet * Log4Shell* | Last updated: 2021-12-12 2204 UTC

Security Advisories / Bulletins linked to Log4Shell (CVE-2021-44228)

Errors, typos, something to say ?

  • If you want to add a link, comment or send it to me
  • Feel free to report any mistake directly below in the comment or in DM on Twitter @SwitHak

Other great ressources

@bogn83
bogn83 / sidekiq_retry_time.csv
Created August 12, 2021 09:27 — forked from marcotc/sidekiq_retry_time.csv
Sidekiq retry exponential backoff formula times
Retry count Retry Time Total Cumulative Time Total Cumulative Days
0 0:00:00 0:00:00 0.0
1 0:00:16 0:00:16 0.0
2 0:00:31 0:00:47 0.0
3 0:01:36 0:02:23 0.0
4 0:04:31 0:06:54 0.0
5 0:10:40 0:17:34 0.0
6 0:21:51 0:39:25 0.0
7 0:40:16 1:19:41 0.1
8 1:08:31 2:28:12 0.1
@bogn83
bogn83 / git-prune.md
Created November 30, 2020 09:59 — forked from dgoguerra/git-prune.md
Prune branches and tags deleted in the remote
# prune branches deleted in origin
git remote prune origin

# prune tags
# http://stackoverflow.com/questions/1841341/remove-local-tags-that-are-no-longer-on-the-remote-repository
git fetch --prune <remote> '+refs/tags/*:refs/tags/*'
@bogn83
bogn83 / gist:25e2dffde7bbab90cc43c287f31b3027
Created May 18, 2020 13:42 — forked from nodirt/gist:1469584
Find lost, unreachable commits
# retrieves commit relative date and message
humanify() {
while read hash; do
# echo to trim the new line
echo $( git log -n 1 ..$hash --format='%ci : %h : %s%n%b' )
done
}
# show the commits!
git fsck --unreachable | grep -oP '(?<=commit )\w+' | humanify | sort
@bogn83
bogn83 / add_user_id_to_sessions_devise.md
Created May 13, 2020 07:46 — forked from raderj89/add_user_id_to_sessions_devise.md
Make sessions queryable by user with ActiveRecord Session Store and Devise

Make sessions queryable by user with ActiveRecord Session Store and Devise

  1. Install the ActiveRecord Session Store gem and read the documentation for how to use it and create your sessions table.

  2. Create a migration to add user_id to the sessions table.

class AddUserIdToSessions < ActiveRecord::Migration
  disable_ddl_transaction!
@bogn83
bogn83 / flags.rb
Created March 19, 2020 17:30 — forked from wevtimoteo/flags.rb
Ruby Flags
# Flags Ruby
# Sentinel to check that the rbenv-vars plugin is in use.
RBENV_VARS_ENABLED=1
# Ruby 2.1 GC reading:
# http://tmm1.net/ruby21-rgengc/
# http://thorstenball.com/blog/2014/03/12/watching-understanding-ruby-2.1-garbage-collector/
# http://samsaffron.com/archive/2013/11/22/demystifying-the-ruby-gc
@bogn83
bogn83 / tmux-cheatsheet.markdown
Last active January 29, 2020 17:12 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new with session name:

tmux new -s myname

attach to named:

tmux a -t myname