Install XGBoost with GPU support with conda

conda install py-xgboost-gpu

source: https://docs.anaconda.com/anaconda/user-guide/tasks/gpu-packages/

ModuleNotFoundError: No module named 'cv2' in jupyter notebook

Create a new environment with as of now python 3.7 since opencv not available in conda's python 3.8 packages

conda create --name opencv-cuda python=3.7
conda activate opencv-cuda
conda install pytorch torchvision cudatoolkit=10.2 opencv -c pytorch
python
import cv2

If the above is all fine, but in jupyter the "No module named 'cv2'" error still an issue. Make sure to install jupyter in that environment too.

If jupyter is intalled in the base environment but not in opencv-cud it will be started...

Delete all Sidekiq Pro Batches

https://github.com/mperham/sidekiq/wiki/Batches

bs = Sidekiq::BatchSet.new
bs.each do |batch|
  puts batch.bid
  batch.delete
end

Load TAGS file in emacs manually

M-x visit-tags-table

You need to point to the directory in which ETAGS file generated and it will be loaded.

Git reset author for last x commit

git rebase -i -x 'git ci --amend --reset-author -Chead' head~5

Etags for Emacs

ctags -e -R --exclude=.git

This is going to generate a TAGS file in project root

Memoization in ruby with nested methods

class Example
  def foo
    def foo
      @bar
    end
    bar = (1..10).inject(1, :*)
    puts "bar is #{bar}"
    @wibble = "wibble is #{bar / 30}"
    @bar = bar / 20
  end
end

example = Example.new
example.foo
bar is 3628800
=> 181440
example.foo 
=> 181440

The hard working method, the outer def foo is called only once, on the first invocation, afterward, the nested def foo overrides it and simply returning the @bar variable from the object. The nested def foo still accessing the same object.

Note ...

Emacs keybinding link collection

https://www.emacswiki.org/emacs/EmacsNewbieKeyReference#toc9

https://tuhdo.github.io/c-ide.html

Join previous line: M-^

Join next line: C-1 M-^

KDE Window Titlebar Missing

If KDE is crash for some reason and not able to restore window's titlebar type this into konsole:

This will restore window titles and redirect further error messages to /dev/null

kwin_x11 --replace & 2> /dev/null

gdiff vim other branch same file

Given you are on the development branch and have another branch my_topic
  And want to compare the same file on the two different branches
 When open a file in vim say, Gemfile
 Then type :Gdiff my_topic
  And Vim open Gemfile from my_topic branch in a new split

Elixir / Phoenix system packages install on opensuse 13.2

zypper ar http://download.opensuse.org/repositories/home:/Ledest:/erlang/openSUSE_13.2/home:Ledest:erlang.repo
# for inotify (live code reload)
zypper ar http://download.opensuse.org/repositories/filesystems/openSUSE_13.2/

zypper ref
zypper in inotify-tools
zypper in erlang-full
zypper in elixir
zypper in erts-devel

Devise email validation regexp

config.email_regexp = /\A(([\p{L}0-9]+_+)|([\p{L}0-9]+\-+)|([\p{L}0-9]+\.+)|([\p{L}0-9]+\++))*[\p{L}0-9]+@(([\p{L}0-9]+\-+)|([\p{L}0-9]+\.))*[\p{L}0-9]{1,63}\.[\p{L}]{2,6}\z/i

Add custom nested translation path to a rails engine

In your engine's engine.rb file add these line:

module MyEngine
  class MyEngine < Rails::Engine
    config.before_initialize do                                                      
      config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]
    end
  end
end

Nicely formatted colored git log

I was struggle to set up a nicely formatted git log for a while. What I wanted to achive is to be able to quickly overlook the history including the
branch structure, authors, time of commits, remote and local branches. Here is what I currently use

I used to use this config in the past, there is little problem with this - honestly not too big -, is that all the branches displayed with yellow:

alias]
  prlog = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --abbrev-commit ...

How to split up rails 3.x logger by unicorn workers

config/unicorn/staging.conf

worker_processes 4

after_fork do |server, worker|
  $worker_nr = worker.nr                                                                                                     
end

config/application.rb

module MyApp
  class Application < Rails::Application
    #... lots of config options
    config.logger = ActiveSupport::TaggedLogging.new(Logger.new(Rails.root.join("log", "#{Rails.env}_#{$worker_nr}.log").to_s))
  end
end

set user home inside a docker container

ENV HOME /home/dev
USER dev 
RUN curl -L https://get.rvm.io | bash -s stable