Skip to content

Instantly share code, notes, and snippets.

View porcelani's full-sized avatar

Porcelani porcelani

View GitHub Profile
@porcelani
porcelani / gist:ba8534bea3264d76442628b57a85e0b8
Created June 12, 2019 13:43
Re-run failed JUnit tests immediately
//https://stackoverflow.com/questions/8295100/how-to-re-run-failed-junit-tests-immediately
public class RetryTest {
public class Retry implements TestRule {
private int retryCount;
public Retry(int retryCount) {
this.retryCount = retryCount;
}
@porcelani
porcelani / package.json
Created December 19, 2017 09:17 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@porcelani
porcelani / add_intellij_launcer
Created April 3, 2017 20:20 — forked from rob-murray/add_intellij_launcer
Add Intellij launcher shortcut and icon for ubuntu
// create file:
sudo vim /usr/share/applications/intellij.desktop
// add the following
[Desktop Entry]
Version=13.0
Type=Application
Terminal=false
Icon[en_US]=/home/rob/.intellij-13/bin/idea.png
Name[en_US]=IntelliJ
List all variables in git:
git config --list
To save the output of a command as variable in bash, use command substitution $():
GIT_NAME="$(git config --global user.name)"
GIT_PASSWORD="$(git config --global user.password)"
GIT_EMAIL="$(git config --global user.email)"
@porcelani
porcelani / gist:187896bc20f71b27ad7be925cd73538f
Created December 29, 2016 20:00
redis-cli - List count conected ips
redis-cli -h localhost CLIENT LIST | awk {'print $2'} | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | sort | uniq -c | sort
#Output
1 10.11.0.62
1 192.168.171.9
2 192.168.170.28
5 192.168.170.109
9 192.168.171.7
10 10.11.0.220
@porcelani
porcelani / setPrivateFields
Last active May 3, 2016 16:22
Set value in private fields
import java.lang.reflect.Field;
public static boolean setPrivateFields(Object object, String fieldName, Object fieldValue) {
Class<?> clazz = object.getClass();
while (clazz != null) {
try {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(object, fieldValue);
return true;
//<dependency>
// <groupId>commons-io</groupId>
// <artifactId>commons-io</artifactId>
// <version>2.4</version>
//</dependency>
import org.apache.commons.io.IOUtils;
import java.io.InputStream;
public String getContentString(String fileName) throws IOException {