Skip to content

Instantly share code, notes, and snippets.

View lucacesari's full-sized avatar
🎯
Focusing

Luca Cesari lucacesari

🎯
Focusing
  • RCP Vision
  • Florence (Italy)
View GitHub Profile
@lucacesari
lucacesari / WorkingProcessWaitFor.java
Created August 27, 2015 14:26
Java Process hanging waitFor() fix
Process p = Runtime.getRuntime().exec("my-long-command");
BufferedInputStream in = new BufferedInputStream(process.getInputStream());
byte[] bytes = new byte[4096];
while (in.read(bytes) != -1) {}
process.waitFor();
@lucacesari
lucacesari / UsbTetheringUtil.java
Created August 7, 2015 14:53
Open Android USB Tethering Configuration
/*
* This content is released under the MIT License (http://opensource.org/licenses/MIT).
* Copyright (c) 2015 Luca Cesari <luc@cesari.me>
*/
package lucacesari.gists;
import android.app.Activity;
import android.content.Intent;
@lucacesari
lucacesari / swtDependencies.gradle
Created August 3, 2015 07:34
SWT Dependecies for non-osgi projects
...
repositories {
maven {url "https://raw.githubusercontent.com/maven-eclipse/swt-repo/master/"}
}
...
dependencies {
...
compile "org.eclipse.swt:org.eclipse.swt.win32.win32.x86:4.4"
}
....
@lucacesari
lucacesari / emfDependencies.gradle
Created August 3, 2015 07:30
EMF Framework dependencies for non-osgi projects
...
dependencies {
compile "org.eclipse.emf:org.eclipse.emf.ecore:2.9.0-v20130528-0742"
compile "org.eclipse.emf:org.eclipse.emf.common:2.9.0-v20130528-0742"
compile "org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.9.0-v20130528-0742"
}
...
@lucacesari
lucacesari / CliUtils.java
Created October 15, 2014 08:13
Get Eclipse application arguments
/*
* This content is released under the MIT License (http://opensource.org/licenses/MIT).
* Copyright (c) 2014 Luca Cesari <luc@cesari.me>
*/
package lucacesari.gists;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@lucacesari
lucacesari / CommandBuilder.java
Created October 15, 2014 07:39
Eclipse parameterized Command builder
/*
* This content is released under the MIT License (http://opensource.org/licenses/MIT).
* Copyright (c) 2014 Luca Cesari <luc@cesari.me>
*/
package lucacesari.gists;
import java.util.ArrayList;
import java.util.List;
@lucacesari
lucacesari / obfuscate.gradle
Created September 19, 2014 06:55
Obfuscate a jar with Gradle
ext {
mainClassName = "foo.bar.buz.mainClass"
basename = "fooBar"
version = "42.0"
}
task obfuscate(type: proguard.gradle.ProGuardTask) {
injars "./build/libs/${basename}-${version}.jar"
outjars "./build/libs/${basename}-${version}-obf.jar"
@lucacesari
lucacesari / fatjar.gradle
Created September 19, 2014 06:45
Create a fat jar with Gradle
ext {
vendor = "vendor"
version = "42.0"
basename = "foo"
mainClassName = "bar.foo.mainClass"
}
dependencies {
compile project(':my_other_project')
compile 'ch.qos.logback:logback-classic:1.1.1'
@lucacesari
lucacesari / test_path.bat
Created September 16, 2014 15:11
Test if a command is in the Windows %Path%
@echo off
REM Usage: test_path.bat cmd_to_test
for %%x in (%1) do (
if not [%%~$PATH:x]==[] (
echo "Command %1 found"
goto :eof
)
)
echo "Command %1 NOT found"
@lucacesari
lucacesari / add_env_var.bat
Created September 16, 2014 14:26
Add a system enviroment variable in Windows
@echo off
REM Usage: add_env_var.bat NEW_ENV_VAR "my_path"
REM If the inserted path contains spaces remember to quote it
REG ADD "HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v %1 /t REG_SZ /d %2