Thursday, December 13, 2018

From: https://jekyllrb.com/docs/usage/

Command Line Usage
The Jekyll gem makes a jekyll executable available to you in your terminal.
You can use this command in a number of ways:
jekyll new - Creates a new Jekyll site with default gem-based theme
jekyll new --blank - Creates a new blank Jekyll site scaffold
jekyll build or jekyll b - Performs a one off build your site to ./_site (by default)
jekyll serve or jekyll s - Builds your site any time a source file changes and serves it locally
jekyll doctor - Outputs any deprecation or configuration issues
jekyll new-theme - Creates a new Jekyll theme scaffold
jekyll clean - Removes the generated site and metadata file
jekyll help - Shows help, optionally for a given subcommand, e.g. jekyll help build
Typically you’ll use jekyll serve while developing locally and jekyll build when you need to generate the site for production.
To change Jekyll’s default build behavior have a look through the configuration options.

Configure Atom for Jekyll

https://atom.io/packages/jekyll

  • The Build Command will most likely need changing due to some weirdness with $PATH in Atom.
    • Go into the packages settings (Settings -> Packages -> Jekyll).
    • Change Build Command to /path/to/jekyll, build.
    • You can get your /path/to/jekyll by using which jekyll in your terminal.
Test on the Mac with shift-option-T
Test on a Windows machine with shift-alt-T

Wednesday, November 28, 2018

Github pages, Atom, and Jekyll

https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/

https://atom.io/packages/jekyll

https://jekyll.github.io/jekyll-seo-tag/

Start Atom

Install the necessary packages



Start and stop the server with shift-option-t on MacOSX



If you run into the above error then do the following:

https://github.com/jekyll/jekyll/issues/4268

Add this to the _config.yml




Grepping for non-ascii-chars

https://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters#comment18815407_9395552

  • @BastiaanVanDeWeerd is correct, grep on OSX 10.8 no longer supports PCRE ("Perl-compatible regular expressions") as Darwin now uses BSD grep instead of GNU grep. An alternative to installing the dupeslibrary is to install pcre instead: brew install pcre... as part of this, you will get the pcregreputility, which you can use as follows: pcregrep --color='auto' -n "[\x80-\xFF]" file.xml – pvandenberk Dec 4 '12 at 11:24 

Sunday, November 25, 2018

How to upgrade OpenSSL (macOS) using HomeBrew

https://medium.com/@katopz/how-to-upgrade-openssl-8d005554401

brew remove openssl
brew install openssl
ls -l /usr/local/opt/openssl

MacOSX Ruby installation, GitHub.io and Jekyll

Under construction. Do not use.

Ruby installation on MacOSX is not clean...these are the steps I had to take to get it to work. There are all sorts of paths in packages such as Anaconda which conflict with the paths to packages installed by Brew which are required for the installation of Ruby. Thanks to the GitHub, stack overflow, and superuser posts I was able to install Ruby in the end.

$ xcode-select --install

https://github.com/rbenv/ruby-build/wiki#updating-ruby-build

Check the installation

https://github.com/rbenv/rbenv-installer#rbenv-doctor

gem pristine gem-wrappers --version 1.4.0
rbenv install 2.5.1

https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/

gem install bundler

brew install rbenv
  echo $PATH
add eval "$(rbenv init -)" to ~/.bash_profile or what ever your startup script is
  source ~/.bash_profile
  which ruby-build
 3705  ls "$(rbenv root)"/plugins
 3706  ls "$(rbenv root)"/
 3707  rbenv init
 3708  eval "$(rbenv init -)"
 3709  curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
 3710  brew upgrade rbenv ruby-build
 3711  rbenv install -l
 3712  gem pristine gem-wrappers --version 1.4.0
 3713  rbenv install 2.5.1
 3715  cd .github.io/
 3716  gem install bundler

 3719  more Gemfile
 3720  bundle install

==============================================

brew uninstall perl
brew install perl
brew link --force openssl
brew link --force gettext
brew install gpg2
$ curl -sSL https://rvm.io/mpapis.asc | gpg --import -
gpg: key 3804BB82D39DC0E3: 47 signatures not checked due to missing keys
gpg: key 3804BB82D39DC0E3: public key "Michal Papis (RVM signing) " imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no ultimately trusted keys found

 \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enabled

eval "$(rbenv init -)

add to ~/.bash_profile 
export PATH="/usr/local/opt/openssl/bin:$PATH"
  1. brew unlink openssl
  2. brew uninstall --ignore-dependencies openssl
  3. Repeat number 2 until all deps are gone
  4. brew install openssl
  5. Follow post install instructions:
If you need to have this software first in your PATH run:
      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc


        For compilers to find this software you may need to set:
              LDFLAGS:  -L/usr/local/opt/openssl/lib
                CPPFLAGS: -I/usr/local/opt/openssl/include
              For pkg-config to find this software you may need to set:
                    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

                $ export LDFLAGS=" -L/usr/local/opt/openssl/lib"
                $ export CPPFLAGS="-I/usr/local/opt/openssl/include"
                $ export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"


                https://www.codementor.io/akabiru/3-steps-set-up-ruby-environment-macos-6mavm7jrl

                brew install ruby

                brew install ruby

                $ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
                Checking for `rbenv' in PATH: /usr/local/bin/rbenv
                Checking for rbenv shims in PATH: OK
                Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20181019)
                Counting installed Ruby versions: none
                  There aren't any Ruby versions installed under `/Users/depappas/.rbenv/versions'.
                  You can install Ruby versions like so: rbenv install 2.2.4
                Checking RubyGems settings: OK
                Auditing installed plugins: OK

                 rbenv install 2.3.1
                /usr/local/bin/ruby-build: /usr/local/bin/shasum: /usr/local/opt/perl/bin/perl: bad interpreter: No such file or directory
                ruby-build: use openssl from homebrew
                Downloading ruby-2.3.1.tar.bz2...
                -> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
                Installing ruby-2.3.1...
                ruby-build: use readline from homebrew

                BUILD FAILED (OS X 10.13.6 using ruby-build 20181019)

                Inspect or clean up the working tree at /var/folders/wx/88s0zlc92wvd9hczwkly7qqh0000gp/T/ruby-build.20181125184727.32663
                Results logged to /var/folders/wx/88s0zlc92wvd9hczwkly7qqh0000gp/T/ruby-build.20181125184727.32663.log

                Last 10 log lines:
                checking for long long... yes
                checking for off_t... yes
                checking char bit... 8
                checking size of int... 0
                checking size of short... 0
                checking size of long... 0
                checking size of long long... configure: error: in `/var/folders/wx/88s0zlc92wvd9hczwkly7qqh0000gp/T/ruby-build.20181125184727.32663/ruby-2.3.1':
                configure: error: cannot compute sizeof (long long)
                See `config.log' for more details
                make: *** No targets specified and no makefile found.  Stop.

                https://github.com/rbenv/rbenv/issues/1059

                https://superuser.com/questions/1296016/rvm-error-running-configure

                "I faced the same issue after migrating my Mac too (both MacOS High Sierra).  After running"
                $ sudo mv /usr/local/include /usr/local/include_old
                "and then"
                $ rvm install 2.5.0 --with-openssl-dir=/usr/local/opt/openssl/bin/openssl


                More ruby build solutions:
                https://github.com/rbenv/ruby-build/wiki#updating-ruby-build


                https://medium.com/@vovakuzmenkov/get-a-website-with-github-pages-9151ed636446

                https://jekyllrb.com/docs/installation/macos/

                ================================================

                Some of the problems I ran into. Solutions above.

                https://gist.github.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3

                ==> Installing rbenv dependency: ruby-build
                Error: An exception occurred within a child process:
                  RuntimeError: /usr/local/opt/openssl not present or broken
                Please reinstall openssl. Sorry :(

                $ brew remove openssl
                $ brew install openssl
                $ ls -l /usr/local/opt/openssl

                https://gist.githubusercontent.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3/raw/fbc736fa1b50bd637929a315e6803df306c8bc8e/setup-rbenv.sh

                You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory #938

                https://github.com/rbenv/rbenv-installer#rbenv-doctor


                https://github.com/rbenv/rbenv/issues/938

                "I'm not sure I installed rbenv and a ruby version correctly"
                Yep, sure it can be tricky.
                1. sudo xcode-select --install
                2. Install rbenv with brew install rbenv
                3. Add eval "$(rbenv init -)" to the end of ~/.zshrc or ~/.bash_profile
                4. Install a ruby version rbenv install 2.3.0
                5. Select a ruby version by rbenv rbenv global 2.3.0
                6. Open a new terminal window
                7. Verify that the right gem folder is being used with gem env home (should report something in your user folder not system wide)
                "I want to use bundler and rbenv together"
                Perfect match!
                1. Make sure you installed rbenv correctly ☝️
                2. Select a ruby version locally for the folder you are located in e.g. rbenv local 2.3.0 (this creates a file called .ruby-version in the directory)
                3. Verify that the right gem folder is being used with gem env home (should report something in your user folder not system wide)
                4. Run gem install bundler
                5. Run bundle install
                6. Run on of your favorite gems defined in the Gemfile by bundle exec ... e.g. bundle exec fastlane


                set -ex
                brew update
                brew install rbenv ruby-build
                rbenv install 2.5.3
                rbenv global 2.5.3
                ruby -v
                gem install jekyll bundler
                rbenv rehash
                
                if ! type rbenv | grep function; then
                  echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
                fi
                
                set +x
                echo "Done! Close and reopen your terminal"


                https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/

                https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/


                Wednesday, May 2, 2018

                Python dbg

                import pdb
                pdb.set_trace()

                Emacs ELPY config

                Create a virtualenv with the ELPY dependencies

                mkvirtualenv -p python3 kafka

                workon kafka pip install flask kafka opencv-python

                For an ELPY Emacs init.el see


                Start Emacs

                 M-x elpy-config

                Read the instructions in the ELPY config window about which Python packages to install using your virtualenv.

                 Install the Jedi server M-x jedi:install-server

                Updated ELPY emacs installation and general emacs config


                mkvirtualenv -p /Users//anaconda3/bin/python3 elpy pip install rope_py3k rope jedi flake8 ~/.emacs.init.el ;; global variables (setq inhibit-startup-screen t create-lockfiles nil make-backup-files nil column-number-mode t scroll-error-top-bottom t show-paren-delay 0.5 use-package-always-ensure t sentence-end-double-space nil) ;; buffer local variables (setq-default indent-tabs-mode nil tab-width 2 c-basic-offset 2) ;; modes (electric-indent-mode 0) ;; global keybindings (global-unset-key (kbd "C-z")) ;; load key bindings (load "~/.emacs.d/key-bindings.el") ;; the package manager (require 'package) (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") ("org" . "http://orgmode.org/elpa/") ;("melpa" . "http://melpa.org/packages/") ("melpa-stable" . "http://stable.melpa.org/packages/")) package-archive-priorities '(("melpa-stable" . 1))) (package-initialize) (when (not package-archive-contents) (package-refresh-contents) (package-install 'use-package)) (require 'use-package) (use-package scala-mode :interpreter ("scala" . scala-mode)) (unless (package-installed-p 'virtualenvwrapper) (package-refresh-contents) (package-install 'virtualenvwrapper)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Google Protobuf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (unless (package-installed-p 'protobuf-mode) (package-refresh-contents) (package-install 'protobuf-mode)) (use-package protobuf-mode :ensure protobuf-mode :interpreter ("protobuf" . protobuf-mode)) (defconst my-protobuf-style '((c-basic-offset . 2) (indent-tabs-mode . nil))) (add-hook 'protobuf-mode-hook (lambda () (c-add-style "my-style" my-protobuf-style t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; For SBT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'exec-path "/usr/local/bin") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Scala ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (unless (package-installed-p 'scala-mode) (package-refresh-contents) (package-install 'scala-mode)) (use-package scala-mode :interpreter ("scala" . scala-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Ensime ;; http://ensime.github.io/editors/emacs/install/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;(unless (package-installed-p 'ensime) ;(package-refresh-contents) (package-install 'ensime)) (use-package ensime :ensure t :pin melpa-stable) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Install Theme ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (use-package dracula-theme :ensure t :pin melpa-stable) (load-theme 'dracula t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Packages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar myPackages '(better-defaults elpy jedi flycheck material-theme py-autopep8)) ;; add the autopep8 package ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Install packages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (mapc #'(lambda (package) (unless (package-installed-p package) (package-install package))) myPackages) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Elpy ;; https://github.com/jorgenschaefer/elpy/wiki/Configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (unless (package-installed-p 'elpy) (package-refresh-contents) (package-install 'elpy)) (use-package elpy :interpreter ("elpy" . elpy)) (when (require 'elpy nil t) (elpy-enable)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Elpy ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Python side ;; For syntax checking, you need the flake8 tool: ;; ;; pip install flake8 ;; For auto-completion features you need to decide on whether you want to use 'rope' or 'jedi', and install either one: ;; (installation of jedi is preferred based on this issue) ;; ;; pip install jedi ;; or if you are using Python 2.x and have reasons to prefer rope ;; ;; pip install rope ;; If you are using Python 3 and want to use Rope, install the rope_py3k package, not rope. ;; ;; pip install rope_py3k ;; ;; mkvirtualenv -p /Users//anaconda3/bin/python3 elpy ;; workon elpy ;; pip install rope_py3k rope jedi flake8 (package-initialize) (elpy-enable) (setq elpy-rpc-backend "jedi") (setq gud-pdb-command-name "python -m pdb") ;; M-x pdb ;; http://programmingmatrix.blogspot.com/2017/09/emacs-installing-jedi.html (require 'pyvenv) (pyvenv-activate "~/python_venv/elpy/") (venv-initialize-interactive-shells) ;; if you want interactive shell support (venv-initialize-eshell) ;; if you want eshell support ;; note that setting `venv-location` is not necessary if you ;; use the default location (`~/.virtualenvs`), or if the ;; the environment variable `WORKON_HOME` points to the right place (setq venv-location "~/python_venv") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; elpy Company code completion ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq company-minimum-prefix-length 1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Python ;; minimal example to setup Jedi.el via package.el + MELPA: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Standard package.el + MELPA setup ;; (See also: https://github.com/milkypostman/melpa#usage) (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) (package-initialize) ;; Standard Jedi.el setting (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t) ;; Type: ;; M-x package-install RET jedi RET ;; M-x jedi:install-server RET ;; Then open Python file. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Flycheck - Python syntax checking ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (when (require 'flycheck nil t) (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) (add-hook 'elpy-mode-hook 'flycheck-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PEP8 - Python Lint ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'py-autopep8) (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Python settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;(add-hook 'python-mode-hook ;; (lambda () ;; (setq-default indent-tabs-mode t) ;; (setq-default tab-width 2) ;; (setq-default py-indent-tabs-mode t) ;; (add-to-list 'write-file-functions 'delete-trailing-whitespace))) (eval-after-load "python" `(progn (add-hook 'python-mode-hook #'(lambda () (setq tab-width 2) (setq python-indent-offset 2) (setq python-indent-guess-indent-offset nil))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (require 'command-log-mode) ;; (add-hook 'LaTeX-mode-hook 'command-log-mode) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ctags ;; Run "M-x create-tags" to create the TAGS file ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq path-to-ctags "/usr/bin/ctags") (setq tags-table-list '("")) (defun create-tags (dir-name) "Create tags file." (interactive "DDirectory: ") (shell-command (format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name))) ) ;;(setq tags-file-name "") (put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Custom ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages (quote (exec-path-from-shell exec-path-from-shell-initialize virtualenvwrapper command-log-mode jedi-direx protobuf-mode ensime scala-mode use-package)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) (put 'downcase-region 'disabled nil) (put 'upcase-region 'disabled nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; exec-path-from-shell-initialize ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (use-package exec-path-from-shell :ensure t :pin melpa-stable) ;; https://github.com/purcell/exec-path-from-shell (when (memq window-system '(mac ns x)) (exec-path-from-shell-initialize))

                Mac OSX virtualenv instructions

                http://roundhere.net/journal/virtualenv-ubuntu-12-10/ Install pip sudo apt-get install python-pip Install virtualenv sudo pip install virtualenv Create a dir to store your virtualenvs (I use ~/.virtualenvs) mkdir ~/.virtualenvs At this point you are all set to use virtualenv with the standard commands. However, I prefer to use the extra commands included in virtualenvwrapper. Lets set that up. Install virtualenvwrapper sudo pip install virtualenvwrapper Set WORKON_HOME to your virtualenv dir export WORKON_HOME=~/.virtualenvs Add virtualenvwrapper.sh to .bashrc ○ → which virtualenvwrapper.sh /Users//anaconda3/bin/virtualenvwrapper.sh Add this line to the end of ~/.bashrc so that the virtualenvwrapper commands are loaded. . /Users//anaconda3/bin/virtualenvwrapper.sh Exit and re-open your shell, or reload .bashrc with the command . .bashrc and you’re ready to go. Create a new virtualenv mkvirtualenv myawesomeproject to exit your new virtualenv, use deactivate. Switch between enviornments with workon To load or switch between virtualenvs, use the workon command: workon myawesomeproject You can read more about virtualenv here and virtualenvwrapper here. You might also want to look at this very similar (and probably better) python guide post.

                Thursday, February 1, 2018

                Building Darknet

                First install cuda

                https://gist.github.com/derek-pappas/c5a73efe4b5748a034c6a0a9b76b67c7

                Then install Darknet
                The install script does not work for everyone. Try this if it fails.


                cp -r $HOME/DockerDarknet /opt
                chown $USER:$USER -R DockerDarknet/
                
                cd /opt/DockerDarknet/
                
                git pull
                
                make
                


                https://github.com/cracker0dks/DockerDarknet/blob/master/README.md 

                Forked from:

                https://github.com/Guanghan/darknet

                Debugging

                : /opt/DockerDarknet
                $ make
                nvcc --gpu-architecture=compute_20 --gpu-code=compute_20  -DGPU -I/usr/local/cuda/include/ --compiler-options "-Wall -Wfatal-errors  -Ofast -DGPU" -c ./src/convolutional_kernels.cu -o obj/convolutional_kernels.o
                nvcc fatal   : Value 'compute_20' is not defined for option 'gpu-architecture'
                Makefile:54: recipe for target 'obj/convolutional_kernels.o' failed
                make: *** [obj/convolutional_kernels.o] Error 1
                
                
                Options for steering GPU code generation.
                =========================================
                
                --gpu-architecture <arch>                  (-arch)                          
                        Specify the name of the class of NVIDIA 'virtual' GPU architecture for which
                        the CUDA input files must be compiled.
                        With the exception as described for the shorthand below, the architecture
                        specified with this option must be a 'virtual' architecture (such as compute_50).
                        Normally, this option alone does not trigger assembly of the generated PTX
                        for a 'real' architecture (that is the role of nvcc option '--gpu-code',
                        see below); rather, its purpose is to control preprocessing and compilation
                        of the input to PTX.
                        For convenience, in case of simple nvcc compilations, the following shorthand
                        is supported.  If no value for option '--gpu-code' is specified, then the
                        value of this option defaults to the value of '--gpu-architecture'.  In this
                        situation, as only exception to the description above, the value specified
                        for '--gpu-architecture' may be a 'real' architecture (such as a sm_50),
                        in which case nvcc uses the specified 'real' architecture and its closest
                        'virtual' architecture as effective architecture values.  For example, 'nvcc
                        --gpu-architecture=sm_50' is equivalent to 'nvcc --gpu-architecture=compute_50
                        --gpu-code=sm_50,compute_50'.
                        Allowed values for this option:  'compute_30','compute_32','compute_35',
                        'compute_37','compute_50','compute_52','compute_53','compute_60','compute_61',
                        'compute_62','compute_70','compute_72','sm_30','sm_32','sm_35','sm_37','sm_50',
                        'sm_52','sm_53','sm_60','sm_61','sm_62','sm_70','sm_72'.
                


                /opt/DockerDarknet
                $ grep -r compute_20 *
                Makefile:ARCH= --gpu-architecture=compute_20 --gpu-code=compute_20
                

                How to use the standard Darknet


                docker exec -it darknet /bin/bash
                

                Now you can use Darknet yolo with the standard documentation:

                http://pjreddie.com/darknet/yolo/

                cd training
                
                wget https://pjreddie.com/media/files/yolo.weights
                

                ./darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg
                

                Tuesday, January 16, 2018

                Handling Permissions with Docker Volumes -reference

                https://denibertovic.com/posts/handling-permissions-with-docker-volumes/

                The expression between the back ticks gets interpolated

                $ id -u $USER
                1000

                Avatar




                Thanks for the very useful article.
                If one wants to bake-in the new user at build time then --build-args can leveraged.
                Assuming current user (who's building the docker image) is 'bob' having UID=103
                Goal is to create docker image having user 'jdoe' with same UID=103
                ================================================================
                 $ cat Dockerfile
                FROM centos:7 #OR whatever
                ARG USER_ID
                RUN useradd --shell /bin/bash -o --create-home --user-group -u $USER_ID  jdoe
                ================================================================
                Build
                ------
                $ docker build -t my-base-image --build-arg USER_ID=`id -u $USER` .
                ================================================================
                Run
                -----
                $ docker run -it -u jdoe my-base-image
                [jdoe@a1b2c3f4 /]$ id -u jdoe
                103
                ================================================================

                Avatar




                Hi Deni,
                I think this can (now) be solved without any additional scripts. Just mount your /etc/group and /etc/passwd readonly to your container like:
                docker run -ti \
                -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro \
                -u $( id -u $USER ):$( id -g $USER ) \
                some-image:lastest bash
                Notice also the usage of "id -g" and "id -u" which will also solve the group issue. This method has only one drawback: If any script or application tries to write-access /etc/group or /etc/passwd it will fail due to permissions. But at least for my use-cases I never ran into issues here.
                Best regards and thanks for your ideas on that.
                Basti.

                Sunday, January 14, 2018

                Ubuntu 16.04 stuck in login loop

                https://askubuntu.com/questions/223501/ubuntu-gets-stuck-in-a-login-loop

                My Ubuntu is stuck in a login loop when trying to enter my desktop. When I login, the screen gets black and soon after that the login screen comes back.



                I encountered this exact problem and non of the suggested fixes above worked for me. After almost giving up I looked at the .xsession-errors and noticed I had a typo in my .profile (I had an extra } in the file after I edited it earlier in the day).
                That was causing the login loop. It might be another place to look if the other suggested fixes don't work for you.


                https://askubuntu.com/questions/801440/login-loop-badvalue-integer-parameter-out-of-range-for-operation-16-04

                Adding +iglx to xserver-command in /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf.
                [SeatDefaults] 
                # Dump core 
                xserver-command=X -core +iglx
                
                After which you either reboot or Ctrl-Alt-F1, login, and sudo service lightdm restart.
                more .xsession-errors
                openConnection: connect: No such file or directory
                cannot connect to brltty at :0
                ...


                $ grep NVRM /var/log/kern.log
                Jan 14 08:37:31 berlin kernel: [1351327.884905] NVRM: API mismatch: the client has the version 384.111, but
                Jan 14 08:37:31 berlin kernel: [1351327.884905] NVRM: this kernel module has the version 384.98.  Please
                Jan 14 08:37:31 berlin kernel: [1351327.884905] NVRM: make sure that this kernel module and all NVIDIA driver
                Jan 14 08:37:31 berlin kernel: [1351327.884905] NVRM: components have the same version.
                Jan 14 09:17:26 berlin kernel: [1353722.487659] NVRM: API mismatch: the client has the version 384.111, but
                Jan 14 09:17:26 berlin kernel: [1353722.487659] NVRM: this kernel module has the version 384.98.  Please
                Jan 14 09:17:26 berlin kernel: [1353722.487659] NVRM: make sure that this kernel module and all NVIDIA driver
                Jan 14 09:17:26 berlin kernel: [1353722.487659] NVRM: components have the same version.

                CHANGE THE DRIVER VERSION TO MATCH THE VERSION YOU INSTALLED 

                I was able to resolve my issue by performing the following steps:

                1. First reinstall the nvidia-375 repository graphic driver.
                sudo apt-get install nvidia-375
                During the installation, I noticed that nvidia-375.26 driver was being installed.

                2. I moved the entire /lib/modules/4.4.0-64-generic/updates/dkms folder to my home directory backup folder. This was to make sure all old .ko files were removed.
                cp -R /lib/modules/4.4.0-64-generic/updates/dkms ~/backup

                3. I regenerated the .ko files for the installed driver using 
                sudo dpkg-reconfigure nvidia-375
                It created a new dkms folder with the relevant nvidia kernel modules. I also checked their version using command:
                sudo modinfo nvidia_375.ko
                sudo modinfo nvidia_375_drm.ko
                sudo modinfo nvidia_375_modeset.ko
                sudo modinfo nvidia_375_uvm.ko
                Their output showed that they were for version 375.26.

                4. I rebooted the system with 
                sudo reboot

                Adapted from https://devtalk.nvidia.com/default/topic/525877/linux/api-mismatch-means-ubuntu-can-39-t-boot-i-can-39-t-fix-i-please-help-/1

                $ sudo dpkg-reconfigure nvidia-384
                Removing all DKMS Modules
                Done.
                update-initramfs: deferring update (trigger activated)

                A modprobe blacklist file has been created at /etc/modprobe.d to prevent Nouveau from loading. This can be reverted by deleting /etc/modprobe.d/nvidia-graphics-drivers.conf.
                A new initrd image has also been created. To revert, please replace /boot/initrd-4.13.0-26-generic with /boot/initrd-$(uname -r)-backup.

                *****************************************************************************
                *** Reboot your computer and verify that the NVIDIA graphics driver can   ***
                *** be loaded.                                                            ***
                *****************************************************************************

                INFO:Enable nvidia-384
                DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
                DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
                DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
                Loading new nvidia-384-384.111 DKMS files...
                Building only for 4.13.0-26-generic
                Building for architecture x86_64
                Building initial module for 4.13.0-26-generic
                Done.

                nvidia_384:
                Running module version sanity check.
                 - Original module
                   - No original module exists within this kernel
                 - Installation
                   - Installing to /lib/modules/4.13.0-26-generic/updates/dkms/

                nvidia_384_modeset.ko:
                Running module version sanity check.
                 - Original module
                   - No original module exists within this kernel
                 - Installation
                   - Installing to /lib/modules/4.13.0-26-generic/updates/dkms/

                nvidia_384_drm.ko:
                Running module version sanity check.
                 - Original module
                   - No original module exists within this kernel
                 - Installation
                   - Installing to /lib/modules/4.13.0-26-generic/updates/dkms/

                nvidia_384_uvm.ko:
                Running module version sanity check.
                 - Original module
                   - No original module exists within this kernel
                 - Installation
                   - Installing to /lib/modules/4.13.0-26-generic/updates/dkms/

                depmod....

                DKMS: install completed.
                Processing triggers for initramfs-tools (0.122ubuntu8.10) ...
                update-initramfs: Generating /boot/initrd.img-4.13.0-26-generic

                $ sudo modinfo nvidia_384
                filename:       /lib/modules/4.13.0-26-generic/updates/dkms/nvidia_384.ko
                alias:          char-major-195-*
                version:        384.111
                supported:      external
                license:        NVIDIA
                srcversion:     EB07FB20BD3656BF1198872
                alias:          pci:v000010DEd00000E00sv*sd*bc04sc80i00*
                alias:          pci:v000010DEd*sv*sd*bc03sc02i00*
                alias:          pci:v000010DEd*sv*sd*bc03sc00i00*
                depends:        
                name:           nvidia
                vermagic:       4.13.0-26-generic SMP mod_unload 
                parm:           NVreg_Mobile:int
                parm:           NVreg_ResmanDebugLevel:int
                parm:           NVreg_RmLogonRC:int
                parm:           NVreg_ModifyDeviceFiles:int
                parm:           NVreg_DeviceFileUID:int
                parm:           NVreg_DeviceFileGID:int
                parm:           NVreg_DeviceFileMode:int
                parm:           NVreg_UpdateMemoryTypes:int
                parm:           NVreg_InitializeSystemMemoryAllocations:int
                parm:           NVreg_UsePageAttributeTable:int
                parm:           NVreg_MapRegistersEarly:int
                parm:           NVreg_RegisterForACPIEvents:int
                parm:           NVreg_CheckPCIConfigSpace:int
                parm:           NVreg_EnablePCIeGen3:int
                parm:           NVreg_EnableMSI:int
                parm:           NVreg_TCEBypassMode:int
                parm:           NVreg_UseThreadedInterrupts:int
                parm:           NVreg_EnableStreamMemOPs:int
                parm:           NVreg_MemoryPoolSize:int
                parm:           NVreg_RegistryDwords:charp
                parm:           NVreg_RegistryDwordsPerDevice:charp
                parm:           NVreg_RmMsg:charp
                parm:           NVreg_AssignGpus:charp