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
How to restore kde klipper confirm dialog to defaults (KDE4)
I asked the same question from myself and it took some time to find a proper solution.
KDE config settings stored in ~/.share/config
and klippers' in ~/.share/config/klipperrc
In that file there is configuration group called Notification Messages in which all answers which were answered with "Do not ask again" checkbox ticked are stored.
[Notification Messages]
really_clear_history=false
In this case whenever user clicks on Clear Clipboard History it will always taken as if the user got the pop and answered no. If it...
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
Linux volume control from command line and mute/unmute
To Mute:
amixer -D pulse sset Master mute
To Unmute:
amixer -D pulse sset Master unmute
To turn volume up 5%:
amixer -D pulse sset Master 5%+
To turn volume down 5%:
amixer -D pulse sset Master 5%-
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 ...
Force Launcyh to use a specific browser even if running through ssh -X
If using zeus
in that terminal issue the command below:
export BROWSER='/usr/bin/konqueror'
than in another terminal run
zeus cucumber features/holly____.feature
BROWSER will take precedence over xdg-open
and - by using different browser - fix firefox's strange behaviour with X11 ssh forward https://bugzilla.mozilla.org/show_bug.cgi?id=378032
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
Opensuse docker certificate error
You see this 2013/11/28 14:00:24 Get https://index.docker.io/v1/images/ubuntu/ancestry: x509: certificate signed by unknown authorit
You say wtf????????
Then In this file /etc/ssl/ca-bundle.pem
there is a hint: /usr/lib/ca-certificates/update.d/certbundle.run
run it. Reboot. Voila no cert errors.
Opensuse VIM Konsole 256 colors
Try Settings -> Edit Current Profile... -> Environment: Edit... -> enter "TERM=xterm-256color" (without "").
To check how many colors terminal has use this script
TMUX HOME END not working
I had a problem under OpenSuSE 13.1 with tmux 1.8-2.1.2 the home and end buttons did not work. It took me so long to find a solution but finally here it is, original link attached.
There is a nice tool called tput
which can display the key sequence values that the system receives when a user hit a button, and another one bind
which can map key sequences to another. This way it easy to spot that under tmux the system receives different sequence.
Test it like this:
$ cat -v # pressing home, then end
^[[1~^[[4~
$ tput...
ActiveRecord chaining multiple union with Arel
It seems chain uinon with union is possible with newer versions of Arel. But i currently stucked with 3.0.2 so this is what i come up with:
beer = Beer.arel_table
union1 = Beer.where(name: "Oberon").union(Beer.where(name: "Two Hearted"))
table1 = Beer.select("two_beers.*").from(beer.create_table_alias(union1, :two_beers).to_sql)
union2 = table1.union(Beer.where(name: "Distilled"))
table2 = Beer.from(beer.create_table_alias(union2, :beers).to_sql)
The generated SQL is far from being nice but for me works.