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 update | |
| sudo apt-get install openssh-server | |
| sudo ufw allow 22 |
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
| vector <- c(45, 5, 64, 80) | |
| tail(vector, 1) | |
| vector[length(vector)] | |
| last <- function(x) { tail(x, n = 1) } | |
| last(vector) |
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
| public enum Blah { | |
| A("text1"), | |
| B("text2"), | |
| C("text3"), | |
| D("text4"); | |
| private String text; | |
| Blah(String text) { | |
| this.text = text; |
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
| ## only print filename instead of full path | |
| find /dir1 -type f -printf "%f\n" | |
| find /dir1 -type f -exec basename {} \; |
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
| # http://stackoverflow.com/questions/4984725/how-to-test-cron-job | |
| run-parts -v /etc/cron.weekly |
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
| # http://stackoverflow.com/questions/7706876/r-script-removing-na-values-from-a-vector | |
| # Sort vectors that have 'NA' | |
| d <- c(1, 100, NA, 10) | |
| max(d, na.rm=TRUE) | |
| # Remove 'NA' in a vector | |
| d <- d[!is.na(d)] |
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
| # http://stackoverflow.com/questions/471183/linux-command-line-global-search-and-replace | |
| # not recursive. input the file name | |
| sed -i 's/foo/bar/g' * | |
| # recursive | |
| find -name '*.html' -print -exec sed -i.bak 's/foo/bar/g' {} \; |
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
| // http://stackoverflow.com/questions/22713652/can-an-interface-method-have-a-body | |
| // define static method | |
| interface Whoa { | |
| public static void doStuff() { | |
| System.out.println("This is not default implementation"); | |
| } | |
| } |
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
| public class Joda implements Directions | |
| { | |
| public static void main(String [] args) | |
| { | |
| // From http://stackoverflow.com/questions/1555262/calculating-the-difference-between-two-java-date-instances | |
| Interval interval = new Interval(oldTime, new Instant()); | |
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
| # From http://stackoverflow.com/questions/7004710/laply-is-part-of-what-package-in-r | |
| install.packages("pkg") | |
| library("pkg") | |