Skip to content

Instantly share code, notes, and snippets.

View cameronjacobson's full-sized avatar

Cameron Jacobson cameronjacobson

View GitHub Profile
@cameronjacobson
cameronjacobson / utfdecode.php
Last active August 29, 2015 14:17
utf8 decode a unicode code point
<?php
// convert utf8 character to its unicode code point
function utf8decode($chr){
switch(strlen($chr)){
case 1:
$x = unpack('c',$chr);
$dec = $x[1] & 127;
break;
case 2:
$x = unpack('c*',$chr);
@cameronjacobson
cameronjacobson / yuy2conversion.php
Last active August 29, 2015 14:25
Convert YUY2 image format to RGB (.ppm) file via tcp connection
<?php
// 160x120 image pixel dimensions
// PPM Header
echo "P3\n";
echo "160 120\n";
echo "255\n";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);