Skip to content

Instantly share code, notes, and snippets.

@mathieubolla
mathieubolla / Main.java
Created June 30, 2015 10:08
Reads data from thermoduino USB thermometer, and pushes to a StatsD deamon sitting on port 8125 at somehost.net
import java.io.*;
import java.net.*;
public class Main {
public static void main(String... args) throws IOException {
try (
BufferedReader controller = new BufferedReader(new FileReader("/dev/cu.usbserial-A601EQIH"))) {
controller
@mathieubolla
mathieubolla / site.config
Last active August 29, 2015 13:57
Hidden feature of StatiCMS: Host your website on S3, and get CDN + Gzip content negotiation on StatiCMS!
/ source("http://s3-eu-west-1.amazonaws.com/your.bucket.name/index.html")
/{+path} source("http://s3-eu-west-1.amazonaws.com/your.bucket.name/{+path}")
@mathieubolla
mathieubolla / GZIPOutputStream.java
Created December 11, 2013 10:55
Set maximum compression on a GZIPOutputStream
GZIPOutputStream zip = new GZIPOutputStream(outputStream){{def.setLevel(Deflater.BEST_COMPRESSION);}};
# On branch master
# Your branch is ahead of 'origin/master' by 4 commits.
# (use "git push" to publish your local commits)
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: "e\314\201tude de marche\314\201.md"
# deleted: "\303\251tude de march\303\251.md"
// Reads temperature from TMP36 sensor (from SparkFun electronics) on Arduino Pro Mini 3.3V 8MHz
// Reports the readings to serial port
// Plug Vcc of sensor to digital 12
// Plug Gnd of sensor to gnd of the board
// Plug Vout of sensor to analog 0
// Monitoring diode (digital 13) blinks while sensor is being read
const int power = 12;
const int monitor = 13;
const int analog = A0;
const int serialRate = 9600 * 4;
let a := "My cool, brand new, bootstrap 2.1 based website",
let b := "Some nastyness when resizing lower or over the usual dimensions",
let c := "The GitHub repository holding all of my new website related stuff",
led d := "A nice pull request to fix all of " + a + b " on " + c",
led e := "A super reward for the man who submit " + d
@mathieubolla
mathieubolla / WTF.java
Created January 19, 2012 15:36
What the fuck does this method do? Java puzzle #2 at work
/**
* Retrieves all descendants in breadth-first enumeration.
* Ordering for a particular level is undetermined.
*/
public List<Folder> getDescendants() {
List<Folder> folders = new ArrayList<Folder>(getChildren());
int i = 0;
while(i < folders.size()) {
Folder folder = folders.get(i);
folders.addAll(folder.getChildren());
@mathieubolla
mathieubolla / ChuckNorris.java
Created December 22, 2011 14:16
ChuckNorrisException Java Puzzle
/*
ChuckNorrisException Java Puzzle
You should be able to say which of the two proposition below is true:
a) The program prints "Norris caught the exception"
b) The program prints "Chuck Norris only can catch ChuckNorrisExceptions"
If you can't, run the program, and try to be ChuckNorris: Catch the exception for yourself
*/
import java.util.Map;
import java.util.HashMap;
@mathieubolla
mathieubolla / EC2Starter.java
Created October 19, 2010 16:22
Launches an EC2 micro instance, running a script, which stops it by default. Requires Amazon Java SDK and Apache Commons Codec.
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.RunInstancesRequest;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.codec.binary.Base64;
/**