Skip to content

Instantly share code, notes, and snippets.

View cobolfoo's full-sized avatar

Yanick Bourbeau cobolfoo

  • MRG Tech
  • Canada
View GitHub Profile
$pleaseRotate = 0;
if ($file["type"] == "image/jpeg") {
$exif = exif_read_data($file["tmp_name"]);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$pleaseRotate = 90;
break;
case 3:
$pleaserotate = 180;
@cobolfoo
cobolfoo / BitPacker.java
Created February 9, 2016 17:50
Bit packer for JAVA
package org.shadebob.netcode.tools;
import java.util.BitSet;
/**
* Bit packer utility class
*/
public class BitPacker {
private final static int MAX_SIZE = 32768;
@cobolfoo
cobolfoo / gist:294f76d85820a611cabf
Created February 9, 2016 17:49
Bit packer for JAVA
package org.shadebob.netcode.tools;
import java.util.BitSet;
/**
* Bit packer utility class
*/
public class BitPacker {
private final static int MAX_SIZE = 32768;
@cobolfoo
cobolfoo / gist:6868b0558f7f9c6be831
Created May 11, 2015 01:17
Converting XML data about health rate from Apple Watch to CSV
<?php
$xml = xml_parser_create();
xml_parse_into_struct($xml, file_get_contents("export.xml"),$values,$indexes);
print '"Date/Time","Average","Minimum","Maximum"'."\r\n";
foreach($values as $val) {
if (isset($val["attributes"]) == false) {
continue;
// Initialize the ray handler
RayHandler.setGammaCorrection(true);
RayHandler.useDiffuseLight(true);
rayHandler = new RayHandler(world);
rayHandler.setAmbientLight(0.1f, 0.1f, 0.1f, 0.5f);
rayHandler.setBlurNum(15);
// Set the point light of the player at the center of the screen initially. with 320 pixels of range (radius)
playerLight = new PointLight(rayHandler, 100, new Color(1,1,1,1), 320, Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
package org.shadebob.itsatrap.tools;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.OrderedMap;
/**
* A replacement class for ini4j, I don't like having too much dependencies. This class let you handle
* ini files.
*
public class DuplicateHashMap<K,V> extends HashMap<K, Array<V>> {
public void put(K key, V value) {
Array<V> current = get(key);
if (current == null) {
current = new Array<V>();
super.put(key, current);
}
current.add(value);
}
@cobolfoo
cobolfoo / gist:fe310b25f540e90fd703
Created September 17, 2014 17:17
Render between batches using scene2d actor
final Matrix4 camera = stage.getCamera().combined;
Actor customActor = new Actor() {
@Override
public void draw (Batch batch, float parentAlpha) {
batch.end();
shapeRenderer.setProjectionMatrix(camera);