This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| - Rename / Delete Tag | |
| $ git tag new_tag_name old_tag_name | |
| $ git tag -d old_tag_name | |
| - Tag a git commit | |
| $ git checkout <commit id> | |
| $ git tag <tag name> | |
| $ git push origin <tag name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| - Detach tmux session | |
| Ctrl + B then press D | |
| - Attach tmux session | |
| tmux attach | |
| - Find the tmux version installed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| - Magic of '/r' as shown below: | |
| my @new = map { s/foo/bar/r } @old; | |
| Compared with the old way: | |
| my @new = map { (my $tmp = $_) =~ s/foo/bar/; $tmp } @old; | |
| - To find the full path of the installed module (Modern Perl 2014, page 148) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| - Simple regex to validate UK postcode | |
| /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/gi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Source: http://courseweb.sp.cs.cmu.edu/~cs200/lecture22/lecture22.html | |
| One common use of graphs is to find the shortest path from one place to another. You may have | |
| at some point used an online program to find driving directions, and you likely had to specify | |
| if you wanted the shortest route/fastest route. This involves finding the shortest path in a | |
| weighted graph, but we will make it simpler for now by sticking to an unweighted graph. | |
| In an unweighted graph, finding the shortest path involves something you already know about - | |
| breadth-first search. To find the shortest path from a starting vertex s to a vertex v, we see | |
| if we can get from s to v in one step. If we can, we've found the shortest path from s to v.If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Source: http://courseweb.sp.cs.cmu.edu/~cs200/lecture22/lecture22.html | |
| If the graph is weighted, the problem is a bit more complex, but we can still use the ideas we learned | |
| from the shortest path algorithm for unweighted graphs. | |
| We keep all of the same information as before. So each vertex is marked as either known or unknown. We | |
| keep the tentative distance Length for each vertex as in the unweighted case. We again record Path, which | |
| is the last vertex to cause a change to Length. | |
| The general algorithm to solve the shortest path problem is known as Dijkstra's Algorithm. Dijkstra's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| PostgreSQL HELP | |
| --------------- | |
| 1. Conditional constraint | |
| CREATE UNIQUE INDEX <name> ON <table>(<col 1>,<col 2>,...) WHERE <col 3> IS TRUE; | |
| 2. Check time overlaps | |
| SELECT <col 1>, <col 2>, ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| $ sudo apt-get install gettext | |
| $ wget https://www.kernel.org/pub/software/scm/git/git-2.3.0.tar.xz | |
| $ tar -xvf git-2.3.0.tar.xz | |
| $ cd git-2.3.0/ | |
| $ ./configure --prefix=/usr --with-gitconfig=/etc/gitconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; use warnings; | |
| my $n = $ARGV[0]; | |
| die "Sorry, must be a positive odd integer.\n" | |
| unless ((defined $n) && ($n % 2 == 1) && ($n > 0)); | |
| for(my $i=0; $i<$n; $i++) { | |
| for(my $j=0; $j<$n; $j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| - Adding 'predicate => 1' to an attribute, will create a method has_<attr_name> which | |
| would return 0 or 1 depending on whether the attribute has any value. In case the | |
| attribute starts with '_' then it would create _has_<attr_name>. In case we want | |
| completely different name then we can do so by 'predicate => "my_new_val_check"'. | |
| - Adding 'clearer => 1' to an attribute, will create a method clear_<attr_name> which | |
| would clear attribute value including any default assigned. Even if an attribute is | |
| marked as 'required', it can remove its value, because 'default' and 'required' only | |
| applies to the constructor. | |
OlderNewer