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 / add_to_path.bat
Created September 16, 2014 14:22
Add path to Windows %PATH% variable
@echo off
REM If your path contains spaces remember to quote it
setx /m Path "%~1;%PATH%"
echo "%~1 has been added to the Path"
echo "Restart any application that needs to use the modified Path"
@lucacesari
lucacesari / Watermark.java
Last active August 29, 2015 14:06
(Buffered)Image watermarking
private static BufferedImage watermark(BufferedImage image, String text) {
final FontMetrics fm = graphics.getFontMetrics();
// center text string
final int x = (image.getWidth() / 2) - fm.stringWidth(text);
final int y = (image.getHeight() / 2) - fm.getHeight();
final Graphics2D graphics = image.createGraphics();
graphics.setPaint(Color.white);
graphics.setFont(new Font("SansSerif", Font.BOLD, 10));
graphics.drawString(text, x, y);
@lucacesari
lucacesari / gist:542615a4a241ac630544
Created September 14, 2014 15:00
Call external process in Java7
ProcessBuilder builder = new ProcessBuilder();
builder.command("command1");
builder.inheritIO(); // if you need to see the sysout and syserr
Process p = builder.start();
p.waitFor()
@lucacesari
lucacesari / Rakefile
Created September 14, 2014 10:30
Fabulous testing with Rake and Minitest
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = "test/**/*_test.rb"
t.warning = true
t.verbose = true
end