Skip to content

Instantly share code, notes, and snippets.

View novln's full-sized avatar
💻
コンピューター

Thomas LE ROUX novln

💻
コンピューター
  • Paris
View GitHub Profile
@novln
novln / gist:5774668
Last active December 18, 2015 11:19 — forked from rlemon/gist:1780212
<?php
/* Gets individual core information */
function GetCoreInformation() {
$data = file('/proc/stat');
$cores = array();
foreach( $data as $line ) {
if( preg_match('/^cpu[0-9]/', $line) )
{
$info = explode(' ', $line );
$cores[] = array(
public void download(String url) {
BufferedReader reader = null;
try {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url);
HttpResponse response = client.execute(get);
package fr.umlv.poo.automate0.command;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.PriorityBlockingQueue;
@novln
novln / CommandFactory.java
Created November 15, 2012 10:52
CommandFactory - Example
package fr.umlv.poo.automate0.command;
import fr.umlv.poo.automate0.robot.Robot;
import fr.umlv.poo.automate0.robot.axis.AxisType;
/**
* Example:
* CommandFactory.create(robot, CommandFactory.AXIS_MOVE_COMMAND, AxisType.X, 120);
* CommandFactory.create(robot, CommandFactory.PLIERS_OPEN_COMMAND);
*/
-----
MotionEvent mEvent = context.pollMotion();
if(mEvent != null) {
Input event = new Input(mEvent);
event(event, lastEvent);
lastEvent = event;
}
@novln
novln / Semaphore.java
Created November 8, 2012 20:12
Simple Semaphore Java
package fr.november;
public final class Semaphore {
private final int capacity;
private final Object lock;
private volatile int acquired;
public Semaphore(int capacity) {
this.capacity = capacity;
wlock.lock();
rlock.lock();
try {
long cur_time = System.nanoTime();
if (cur_time > (lastUpdate + 1000000000L)) {
setVersion(getVersion() + 1);
setLastUpdate(cur_time);
}