Skip to content

Instantly share code, notes, and snippets.

View KarlHeitmann's full-sized avatar
🕶️

Karl KarlHeitmann

🕶️
View GitHub Profile
@KarlHeitmann
KarlHeitmann / heatmap_hot_files_in_git_repo.md
Created May 20, 2024 15:18
Command to get hot files in git repository

Source: https://dev.to/augustohp/files-with-the-most-changes-on-git-repository-46l1

Command to get all files with counts on git log

git log --name-only --pretty="format:" | sed '/^\s*$/'d | sort | uniq -c | sort -nr
# get head files:
git log --name-only --pretty="format:" | sed '/^\s*$/'d | sort | uniq -c | sort -nr | head
# filter files, eg: by "controller" pattern
git log --name-only --pretty="format:" | sed '/^\s*$/'d | grep controller | sort | uniq -c | sort -nr | head
@KarlHeitmann
KarlHeitmann / spec_AFTER.rb
Last active May 10, 2024 03:25
RSpec::Support spec AFTER changes
# spec results AFTER changes in PR 596: https://github.com/rspec/rspec-support/pull/596
describe "fuzzy matcher anything" do
it "outputs only key value pair that triggered diff, anything_key should absorb actual value" do
actual = {
:fixed => "fixed",
:trigger => "trigger",
:anything_key => "bcdd0399-1cfe-4de1-a481-ca6b17d41ed8"
}
expected = {
:fixed => "fixed",
@KarlHeitmann
KarlHeitmann / spec_BEFORE.rb
Last active May 10, 2024 03:25
RSpec::Support spec BEFORE changes
# spec results BEFORE changes in PR 596: https://github.com/rspec/rspec-support/pull/596
describe "fuzzy matcher anything" do
it "outputs only key value pair that triggered diff, anything_key should absorb actual value" do
actual = {
:fixed => "fixed",
:trigger => "trigger",
:anything_key => "bcdd0399-1cfe-4de1-a481-ca6b17d41ed8"
}
expected = {
:fixed => "fixed",
@KarlHeitmann
KarlHeitmann / memory_profiling_ruby_on_rails.md
Last active August 18, 2023 15:41
Real time memory profiling Ruby on Rails application using: Rails.logger, tail, awk and asciigraph

1. Search a place in the code to put a logger line. It can be:

# home_controller
# ...
def index
  # ...
  Rails.logger.info "BEFORE_PRIMARY_LOCATION_RSS PID |#{$$}| is: " + `ps -o rss -p #{$$}`.chomp.split("\n").last
  # ...
end
@KarlHeitmann
KarlHeitmann / recursividad.js
Created January 4, 2023 01:51
Ejemplos fibonacci y recursividad, tareas e ideas para practicar recursividad
// Correrlo con:
// node recursividad.js
/* FIBONACCI
1, 1, 2, 3, 5, 8, 13, 21
1
1
1+1 = 2
2 + 1 = 3
3 + 2 = 5
@KarlHeitmann
KarlHeitmann / 00_MyContract.sol
Created April 6, 2020 19:29
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity 0.5.1;
contract MyContract {
enum State { Waiting, Ready, Active }
State public state;
constructor() public {
state = State.Waiting;
}
@KarlHeitmann
KarlHeitmann / 00_MyContract.sol
Created April 6, 2020 04:17
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity 0.5.1;
contract MyContract {
enum State { Waiting, Ready, Active }
State public state;
constructor() public {
state = State.Waiting;
}
@KarlHeitmann
KarlHeitmann / 1_Storage.sol
Created April 6, 2020 04:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Storage
* @dev Store & retreive value in a variable
*/
contract Storage {
uint256 number;
@KarlHeitmann
KarlHeitmann / # glibc - 2017-10-31_11-09-37.txt
Created October 31, 2017 14:19
glibc on "openSUSE Leap 42.3" - Homebrew build logs
Homebrew build logs for glibc on "openSUSE Leap 42.3"
Build date: 2017-10-31 11:09:37