Pages in Article
Docker Cheatsheet
Container vs Image Image is immutable, container is a box running starting from an image. docker ps -as # list all containers with sizes docker images # list all images docker run [options] <image> # best to use image id or image:tag # -p hostPort:containerPort expose port, -P publish all exposed ports. 8888 for jupyter notebook # -t terminal pseudo-TTY # -i Keep STDIN open even if not attached # -v /host/dir:/<container-path> # –name Assign a name to the container docker start -ai <container> # can user container id or name # -a Attach STDOUT/STDERR and forward signals # -i Attach container’s STDIN jupyter notebook –ip 0.
Internet FAQ
Internet Protocol (IP) IPV4 vs IPv6 IPV4 uses 32 bits, 4 8 bit numbers, 2^32 distinct IP addresses. Example 202.2.1.10. IPV6 uses 128 bits, 8 16 bit numbers, 2^128 distinct IP addresses. Actual number is slightly smaller since multiple ranges are reserved for special use or completely excluded from use. Example 3ffe:1900:4545:3:200:f8ff:fe21:67cf. Refs: webopedia article IPV6 wikipedia
Mac Cheatsheet
Keboard Shortcuts Switching tabs: Safari, [shift]+ctrl+tab, cmd+number, shift+cmd+left/right. Chrome, [shift]+ctrl+tab, cmd+number, alt+cmd+left/right. macvim, shift+cmd+{/}. Editing: Delete to end of line, ctrl+k, same as on command line Delete to beginning of line, cmd+shift+left, then delete
Algorithm Question Substring Search KMP
Question LeetCode has this question Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Tags: Two Pointers, String. Let’s denote haystack length N, needle length M, character table size R (256 for extended ASCII). Java’s String class method indexOf() uses brute force algorithm O(MN). Examples: haystacsflksdjflkshhaystackneeneeneedle needle naslkfjskjlhhhh needle Method 1 2D DFA KMP Knuth Morris Pratt O(N) time complexity.
Sorting Algorithm Summary
The following table summarizes common characteristics of popular sorting algorithms, not including string sort algorithms (I may add those later here or write another separate post). algorithm In Place? Stable? parallel? worst average best remarks selection y n n N2/2 N2/2 N2/2 N exchanges insertion y y n N2/2 N2/4 N use for small N or partially ordered shell y n n ?
Git Cheatsheet
Basic Snapshotting git-mv - Move or rename a file, a directory, or a symlink git mv [-v] [-f] [-n] [-k] <source> <destination> rename git mv [-v] [-f] [-n] [-k] <source> … <destination directory> move into existing directory git mv <source> <destination> # rename a directory Branch Related git branch [options] <branchname> git branch # show all branches with current marked with * git branch -vv # show all local and tracked remote branches git checkout dev git branch jesse # creates branch named "jesse" off from "dev" branch git checkout -b jesse # creates and switch to branch "jesse" Merge git merge [options] [<commit>.
Virtualbox Tips for Ubuntu Guest in Windows Host
For Ubuntu tips, see http://jessezhuang.github.io/ article/ubuntu/. How to Get Shared Folder Write Access When used as a virtual machine guest (Ubuntu 14.04LTS in Windows 10 host with Oracle VirtualBox), to get access to shared folder, run the following command in shell, replace username with your ubuntu username.
replace username with your actual ubuntu username $ sudo usermod -a -G vboxsf username After that, reboot the VM and you should have write access to the shared folder.
Vim Cheatsheet
For Ubuntu Linux, Terms: C-x stands for ctrl-x. Generally, use :help <cmd>" for quick ref, e.g.:help undo`. Configuration Configuration file default ~/.vimrc. Can use source <another file> and put the actual vimrc in cloud like dropbox.
to reload an edited vimrc :so $MYVIMRC File operations # to rename a file :E or :Explorer :Te or :Texplorer to open explorer in new tab then :bd to close the new tab R # rename at bottom :bp # go back previous buffer # save the current session including buffers, tabs, and settings :mksession ~/vimSessions/session1.
How to Install Latest Version Vim in Ubuntu 14.04 LTS
Ubuntu comes with Vim-Tiny First of all, Ubuntu 14.04 LTS comes with Vim.Tiny with the version 2:7.4.052-1ubuntu3 which is Vim 7.4.052, already fairly new. Unfortunately I was looking specifically for markdown editing and syntax highlighting and I found that starting from 7.4.480 vim can pick up *.md files as markdown files by default. So I wanted to find a newer version of Vim to install. Install Vim with PPA I have tried to install Vim with debian packages listed on Vim.
Mongodb Tutorial 6 - Application Engineering
Durability of Writes Write Concern How to make sure the writes persistent? Assume application talking to a database server in the scheme below. The settings of two parameters affect the write concern: w(wait for acknowledgement) j(journal) effect comment 1 false fast, small window of vulnerability default setting 1 true slow, no vulnerability can be done inside driver at collection, database, or client level 0 - unacknowledged write do not recommend 2 - wait for 2 nodes in replica set to acknowledge write w can be 0-3 for a set with 3 nodes majority - wait for majority to acknowledge, avoid rollback on failover - tag values - set tags on nodes - If the journal has been written to disk and the server crashes, on recovery the server can look in the journal and recreate all the writes that were not yet persisted to the pages.