bld-live.dk saving the environment, I think…

15Aug/100

Webcams

I have had these camera's up for some time, and have had them online for some time, and then took them off again. This was mostly because I used my ASRock ION330HT to make it all work, and after I decided to no longer have it running 24/7, I had no computer to bring the images online.

Now I finally took the time to make it work again, this time with everything running over my QNAP TS-219P nas instead of the ASRock.

Check them out, you can find them in the top under "Webcams"

I have posted this in multiple categories because I am going to update this with more info about how it all works.

28Jul/100

CURL with image

This is the snippet I use for showing images from internally on my network. The idea is that only the web server is exposed to the internet, so it isn't possible to directly change anything on the picture server.

<?php
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"http://10.0.0.50:8080/camera.jpg");
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($buffer))
	{
		print "Picture unavalible";
	}
	else
	{
		header('Content-Type: image/jpeg');
		print $buffer;
	}
?>
Filed under: PHP No Comments
28Jul/100

Check IP range

I needed a little something to check if one of my files was called from an internal IP, and for this I made this little function.

<?php
function validIp($IP)
	{
		$IP = ip2long($IP);
		$StartIP = ip2long("10.0.0.100");
		$EndIP   = ip2long("10.0.0.150");
		if ($IP >= $StartIP && $IP <= $EndIP)
		{
			return TRUE;
			break;
		}
		return FALSE;
	}

$ip = $_SERVER['REMOTE_ADDR'];

if (validIp($ip))
	{
		echo "Granted";
	}
	else
	{
		echo "Denied";
	}
?>
Filed under: PHP No Comments
12Jul/100

Build in x86 on a x64 with Visual C# 2010 Express

I am running Windows 7 x64 (64 bit), but want to compile my programs in x86 (32 bit).

When Microsoft Visual C# 2010 Express is installed, it will as default compile to the same as the platform it is running on, which in my case would be x64.

Filed under: Software Continue reading
7Jul/100

Multi platform map function

Description

Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.

Example
If you had an input range from 0 to 1023, and wanted an output from 0 to 255, based on the input, it would look like this.

map(val, 0, 1023, 0, 255)

If the input was 511 it would then return 127, because 511 is the half of 1023, and 127 the half of 255 (Rounded both down)

Arduino + C#

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
	return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

ASP

<%
function map(x, in_min, in_max, out_min, out_max)
	map = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
end function
%>

PHP

<?php
function map($x, $in_min, $in_max, $out_min, $out_max)
{
	$total= (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
	return $total;
}
?>

LSL

float map(integer x, integer in_min, integer in_max, integer out_min, integer out_max)
{
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Filed under: Software No Comments