LATEST ARTICLES

How to pass arguments to Gradle Run

To pass argument to gradle run task main class. Add the below task to build.gradle // For gradle run task run (type: JavaExec, dependsOn: classes){ if(project.hasProperty('arg')){ args(arg.split(',')) } main = "com.example.AddTwoNumber" classpath...

Gradle exec task for run a shell script

Here is an exec task set up in a pretty default way, something like: task myTask(type:Exec) { workingDir '.' commandLine './myscript.sh' ignoreExitValue true doLast { if(execResult == 0) { //one thing } else { //another thing } } } Use...

How to call main() method of a class using reflection in java

Java reflection code sample to call main method of a class. Class RandomClass { public static void main(String args[]) { for (String arg : args) { System.out.println(arg); } } } Reflection example try { final Class clazz =...

Show Line number in cat command

Using NL Use nl command to add line number to a file. For example [email protected] ~$cat readme.txt | nl 1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. 2 Aenean massa. Cum sociis natoque penatibus et...

How to install 7zip in ubuntu

To extract rar files with unrar: sudo apt-get install unrar-free unrar e file.rar To extract rar files with 7-zip: sudo apt-get install p7zip-full 7z x file.rar e and x mean extract obviously.

How to download an image using requests module in python

To download and save an image from the web using python's requests module. Here is the code for urllib2 import urllib2 img = urllib2.urlopen("http://www.google.com/images/errors/robot.png") with open(path, 'w') as f: f.write(img.read()) In...