Skip to content

Instantly share code, notes, and snippets.

View sankars's full-sized avatar

Sankar sankars

  • Dubai
View GitHub Profile
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Open Command Window Here as Administrator"
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
@sankars
sankars / hadoop.sh
Created April 18, 2014 17:07
Hadoop Shell Commands
# http://stackoverflow.com/questions/17079513/hdfs-replication-factor-change
hadoop fs -setrep -R 2 /
@sankars
sankars / subset.r
Created April 17, 2014 17:21
Subset operations in R
# http://stackoverflow.com/questions/9860090/in-r-why-is-better-than-subset
subset(airquality, Month == 8 & Temp > 90)
airquality[airquality$Month == 8 & airquality$Temp > 90, ]
# From http://stackoverflow.com/questions/7027288/error-could-not-find-function-in-r
help.search("some.function")
??some.function
RSiteSearch("some.function")
# From http://stackoverflow.com/questions/7004710/laply-is-part-of-what-package-in-r
install.packages("pkg")
library("pkg")
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());
// 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");
}
}
# 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' {} \;
@sankars
sankars / vector_operations.r
Created April 11, 2014 16:23
Vector operations
# 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)]
# http://stackoverflow.com/questions/4984725/how-to-test-cron-job
run-parts -v /etc/cron.weekly