Skip to content

Instantly share code, notes, and snippets.

View bogn83's full-sized avatar

Bogomir Engel bogn83

View GitHub Profile
@bogn83
bogn83 / docker-compose.yml
Created October 22, 2018 09:35 — forked from ajeetraina/docker-compose.yml
Docker Compose for ELK Stack
version: '2'
services:
elasticsearch:
build:
context: elasticsearch/
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
ports:
@bogn83
bogn83 / active_record_objects_autosave.md
Created December 3, 2018 18:14 — forked from demisx/active_record_objects_autosave.md
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@bogn83
bogn83 / grep-with-gpg.sh
Last active October 28, 2022 09:02 — forked from pachanka/search-with-gpg.sh
A simple bash script to grep within a bunch of GPG encrypted files.
#!/bin/bash
#
# Usage grep-with-gpg path/to/encrypted/files/*
#
if [ -z "$1" ]; then
echo "Usage: $0 'search string' [path/to/encrypted/files/*]";
exit 1;
else
SEARCH=$1;
@bogn83
bogn83 / gist:e83a5f62d897a968151798d19527cd82
Last active October 7, 2019 18:11 — forked from bmaupin/gist:1b59abbf30406ed1eb82
Parse installed packages from /var/log/apt/history.log
import re
history_snippet = '''Start-Date: 2014-08-25 12:52:37
Commandline: apt-get install -y openjdk-6-jdk openjdk-7-jdk icedtea-7-plugin
Install: openjdk-6-jre-lib:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), icedtea-netx-common:amd64 (1.5-1ubuntu1, automatic), openjdk-6-jdk:amd64 (6b32-1.13.4-4ubuntu0.14.04.1), libxcb1-dev:amd64 (1.10-2ubuntu1, automatic), ttf-dejavu-extra:amd64 (2.34-1ubuntu1, automatic), icedtea-6-jre-cacao:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), icedtea-7-plugin:amd64 (1.5-1ubuntu1), libxau-dev:amd64 (1.0.8-1, automatic), openjdk-6-jre-headless:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), x11proto-core-dev:amd64 (7.0.24-1, automatic), libxt-dev:amd64 (1.1.4-1, automatic), openjdk-7-jdk:amd64 (7u65-2.5.1-4ubuntu1~0.14.04.1), libx11-dev:amd64 (1.6.2-1ubuntu2, automatic), x11proto-kb-dev:amd64 (1.0.6-2, automatic), openjdk-6-jre:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), xtrans-dev:amd64 (1.3.2-1, automatic), libxdmcp-dev:amd64 (1.1.1-1, automatic), icedtea-netx:a
@bogn83
bogn83 / gitcheats.txt
Created October 8, 2019 17:21 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# print your list of commits this month for a repo
git log --since='last month' --author="$(git config user.name)" --oneline
# get a list of all commit messages for a repo
git log --pretty=format:'%s'
# pull all git repos to current version
@bogn83
bogn83 / delete_git_submodule.md
Created December 11, 2019 16:47 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@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
@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 / 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 / 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