There is a easy solution to remove all uncommitted changes from your working directory in GIT git fetch origin git reset –hard origin/master Note: After executing this command, all uncommitted changes will be removes from your working directory. If you want to save the current work before removing all uncommitted changes, you can do: git ..
Archives : May-2015
In Java there is a easy was to capture screenshots. The following captureScreenshot method will capture a screenshot of the display of your screen and save it to the disk. public void captureScreenshot(String filename) throws Exception { java.awt.Dimension size = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); java.awt.Rectangle rectangle = new java.awt.Rectangle(size); java.awt.Robot robot = new java.awt.Robot(); java.awt.image.BufferedImage image = robot.createScreenCapture(rectangle); ..
There is a simple solution, to get the name of the current method in Java. It uses the stack trace to get the name of the mehod. It works with different virtual machines like oracle, dalvik (Android), Open JDK, etc. String name = Thread.currentThread().getStackTrace()[1].getMethodName(); But don’t use this in time-critical code, because working with the ..
To generate random readable passwords you can combine words, letters and special chars. The words can come from a wordlist array. For example you can use the list of the 10,000 most common English words in order of frequency, as determined by n-gram frequency analysis of the Google’s Trillion Word Corpus. In the exmaple the ..
This is a simple Android background Service Template. You can use it to run updates in the background without blocking the UI. To start and stop the service use the following lines in your activity: // starting the service Intent intent = new Intent(this, UpdateService .class); startService(intent); // stopping the service Intent intent = new ..
For the IoT you can use a cheap esp8266 microcontroller with WiFi onboard. To connect the esp8266 to the wireless network you can use the following lua snippet that will work with the nodemcu..
To get the first 10 in descending order in sqlite SELECT * FROM table ORDER BY id DESC LIMIT 10 To get the first 10 in ascending order in sqlite SELECT * FROM table ORDER BY id ASC LIMIT 10 Note: If there are less than 10 entrys in the sqlite database, you will get ..
If you play around with height and width for a android device you often need to convert between real pixel (px) and device indipenden pixel (dp, dip). The following methods are a easy solution to convert between px to dp private float px2Dp(float px, Context ctx) { return px / ctx.getResources().getDisplayMetrics().density; } private float dp2Px(float ..
To remove objects from an array in Java you have to make a List out of the array with Arrays.asList(), and call remove(object) on all the appropriate elements. Then call toArray() on the ‘List’ to make back into an array again. This is not terribly performant, but if you use it in a properly way, ..
In some cases it makes sense to disable automatic wordpress updates. For example if you want to have a special release of a running wordpress installation to check plugins or themes with this release. Or if are not ready to update to the latest version of wordpress or you want to update manualy…. The wordpress ..