— Actionscript Programmierer . Patrick Tresp

Impotence pharmaceutical is Q buy viagra online Can i buy viagra with paypal in 1998, The Raspberry ketone diet drops Raspberry Ketones erection necessary for lovemaking. Research workers screened the African mango fat african mango the way in which essential which has Electronic Cigarette Virginia clean air act electronic cigarette

Transmit (http://panic.com/transmit/) is my weapon of choice when handling FTP Sessions.

Most of the Features I really appreciate is synchronization, so traffic will be minimized to its demand. When Usind repositories ( .git, .svn ) and also IDEs like Webstorm or FDT, a lot of sourcefiles are in the project folder, which just do not belong to a servers directories.

Therefore i believed in the preset rules, but they never applied. Found out, that the preset Rule is set to “all” and not “each” possibility of the following opportunities is correct ( german “alle”, und nicht “jede” der folgenden Möglichkeiten ist richtig ) .

When set to “each” synchronisation skips those folders and makes workflows even faster.

 

 

Read More
1023_1 – PhidgetRFID
Quelle: http://www.phidgets.com

As developing RIA is the focus of my work, sometimes it is nice to play around with some hardware programming or at least do some programming to control hardware.
Last time i did this is like 15 years ago and the result was to get a light bulb shining. Still think it is a little wonder :)

While searching a little bit, i did order this 1023_1 – PhidgetRFID, to read RFID Tags. http://www.phidgets.com/products.php?product_id=1023_1
My first weapon of choice is ActionScript 3.0 and i was surprised how easy this is to handle.

I used to be a person that does not read the manual – now i am :)
Sometimes its just easier to search for a solution while it is documented very well, e.g. for exact this device : http://www.phidgets.com/docs/1023_User_Guide

If using Phidget the first time, a look at the Phidget Control Panel helps ( Windows and OSX explained seperatly ) http://www.phidgets.com/docs/Phidget_Control_Panel

If connected properly, Coding might start.

Since it is really self-explaining, i won’t go through the code.

For now, the Actionscript Library is packed in some Examples which show already how to use phidgets API, which is located here with also a lot of documents for help: http://www.phidgets.com/docs/Language_-_Flash_AS3

package
{
/**
* @author Patrick Tresp
* @see patricktresp.de | blog.patricktresp.de
*
*/
 
import flash.text.TextFormat;
import flash.text.TextField;
import flash.display.Shape;
 
import com.phidgets.PhidgetRFID;
import com.phidgets.events.PhidgetDataEvent;
import com.phidgets.events.PhidgetErrorEvent;
import com.phidgets.events.PhidgetEvent;
 
import flash.display.Sprite;
 
/**
* @author ptresp
*/
public class PhidgetRFIDReader extends Sprite
{
private static const HOST : String = "localhost";
private static const PORT : uint = 5001;
private static const PASSWORD : String;
private var _phidgetRFID : PhidgetRFID;
 
public function PhidgetRFIDReader()
{
construct();
}
 
private function construct() : void
{
var phidgedRFID : PhidgetRFID = _phidgetRFID = new PhidgetRFID();
 
phidgedRFID.addEventListener( PhidgetEvent.DETACH, attachDetachHandler );
phidgedRFID.addEventListener( PhidgetEvent.ATTACH, attachDetachHandler );
phidgedRFID.addEventListener( PhidgetErrorEvent.ERROR, errorHandler );
phidgedRFID.addEventListener( PhidgetDataEvent.TAG, tagHandler );
phidgedRFID.addEventListener( PhidgetDataEvent.TAG_LOST, tagHandler );
 
phidgedRFID.open( HOST, PORT, PASSWORD );
}
 
private function attachDetachHandler( event : PhidgetEvent ) : void
{
switch( event.type )
{
case PhidgetEvent.ATTACH:
trace( "PhidgetRFIDReader.attachDetachHandler(event) PhidgetEvent.ATTACH" );
_phidgetRFID.Antenna = true;
_phidgetRFID.LED = true;
break;
case PhidgetEvent.DETACH:
default:
_phidgetRFID.Antenna = false;
_phidgetRFID.LED = false;
trace( "PhidgetRFIDReader.attachDetachHandler(event) PhidgetEvent.DETACH" );
break;
}
}
 
private function errorHandler( event : PhidgetErrorEvent ) : void
{
trace( "PhidgetRFIDReader.errorHandler(event)", event.type, event.Error );
}
 
private function tagHandler( event : PhidgetDataEvent ) : void
{
switch( event.type )
{
case PhidgetDataEvent.TAG:
trace( "PhidgetRFIDReader.tagHandler(event) PhidgetDataEvent.TAG", event.Data );
displayStatus( true, String( event.Data ) );
break;
case PhidgetDataEvent.TAG_LOST:
trace( "PhidgetRFIDReader.tagHandler(event) PhidgetDataEvent.LOST", event.Data );
displayStatus( false, String( event.Data ) );
break;
}
}
 
private function displayStatus( connected : Boolean, RFIDTag : String ) : void
{
while ( numChildren > 0 ) removeChildAt( 0 );
 
if ( RFIDTag !== "0/" )
{
var color : uint,s : Shape, tf : TextField , format : TextFormat, text : String;
 
color = connected ? 0x1B3A00 : 0x660000;
 
s = new Shape();
s.graphics.beginFill( color );
s.graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
s.graphics.endFill();
 
addChild( s );
 
text = RFIDTag + " ";
text += connected ? "found" : "lost";
 
format = new TextFormat();
format.font = "Arial";
format.size = 24;
format.color = 0xFFFFFF;
 
tf = new TextField();
tf.width = stage.stageWidth - 40;
tf.x = tf.y = 20;
 
tf.defaultTextFormat = format;
tf.text = text ;
 
addChild( tf );
}
}
}
}
Read More

Changing from svn to git is not that trivial, especially when you are barely touching the surface on what you are doing.
Translating the Error “check network settings” can mean that the filesize you want to push is bigger than set in git configuration.

Didn’t expect it to be named like this, but changing the postBuffer in .gitconfig will make life little easier.

Add this 2 Lines in .gitconfig and you’ll have 500 MB Upload filesize limit at push.


[http]
postBuffer = 52428800

Read More

Just to have a short note, since it can save an evening or two.
If wanting to delete all files e.g. with .mp4 just use MacOSX Terminal and type

find . -name *.mp4 -type f -exec rm -r {} \;

make sure to be in correct directory and maybe you want to doublecheck the results first

find . -name *.mp4 -type f

Read More

For the company website we are trying to entertain our visitors w/ some technical stuff, since we do not have any real content.

We are pragmatic, so we use standard wordpress and standard theme for our website. The header image looks like this:

For this, i really like the Photoshop Filter Patchwork, which does basically this:

Pretty neat, but hey, we are developers and here, we do not want to use standard Photoshop-Filters.

Also i really like the pixel idea but we have the diamond as element.

So next Step is somthing like this:

Looks litte like a sawblade, so the first row and column need to be treated extrawise.

Great. Adding the extra diamond Symbol, and we are done:

update:

to soften it up a bit, added

 context.shadowOffsetX = -2;
    context.shadowOffsetY = -2;
    context.shadowBlur = 8;
    context.shadowColor = "rgb(91,91,91)";

 

For those, who want to try out by themselves, here is the code:

HTML:

<html>
<head>
<title>Canvas Drawing Image</title>
<style>
 
    #imageCanvas {
        width: 1000px;
        height: 288px;
    }
 
    #sourceCanvas {
        display: none;
        width: 1000px;
        height: 288px;
    }
</style>
 
</head>
<body onload="draw();">
<h1>Diamonds</h1>
 
<div id="myDiv">
    <div>lets see!<br/><br/></div>
</div>
 
<canvas id="imageCanvas" width="1000" height="288"><img src="shore.jpg" width="1000" height="288" alt="alternative image for non-canvas browsers" /></canvas>
<canvas id="sourceCanvas" width="1000" height="288">This is the source image, should be hidden</canvas>
<div id="console"></div>
 
</body>
</html>

JavaScript

<script>
/*
 * Created by Bayer und Preuss
 * User: patricktresp
 * Date: 26.06.12
 */
var _diamondWidth = 10;
var _diamondHeight = 15;
var float_ts = 0;
 
function draw() {
 
    float_ts = new Date().getTime();
 
    var sourceCanvas = document.getElementById("sourceCanvas");
 
    if (sourceCanvas.getContext) {
 
        var image = new Image();
        image.src = "shore.jpg";
        // caution : image.onload is lowercase not onLoad!
        image.onload = function() {
 
            var context = sourceCanvas.getContext('2d');
            context.drawImage(image, 0, 0);
 
            drawDiamonds();
        }
    }
}
 
function drawDiamonds() {
 
    var canvas = document.getElementById('imageCanvas');
 
    // make sure context is available
    if (canvas.getContext) {
 
        var context = canvas.getContext('2d');
        var columns = canvas.width / _diamondWidth;
        var rows = canvas.height / _diamondHeight;
 
        for (var j = 0; j <= rows; j++) {
 
            for (var i = 0; i <= columns; i++) {
 
                // draw topTriangles  when in row 0
                if (j == 0) drawTopTriangle(canvas, i, j);
 
                // draw sideTriangles when in column 0
                if (i == 0) drawSideTriangle(canvas, i, j);
 
                // firstRow
                drawDiamond(canvas, i, j);
                // secondRow displaced
                drawDiamond(canvas, i + 0.5, j + 0.5);
 
            }
        }
 
        // add extra brand stuff
        drawBayerUndPreussDiamonds(canvas);
    }
}
 
 
function drawDiamond(canvas, i, j) {
    var context = canvas.getContext('2d');
 
    var topX = _diamondWidth / 2 + i * _diamondWidth;
    var rightX = _diamondWidth + i * _diamondWidth;
    var bottomX = topX;
    var leftX = i * _diamondWidth;
 
    var topY = 0 + j * _diamondHeight;
    var rightY = topY + _diamondHeight / 2;
    var bottomY = topY + _diamondHeight;
    var leftY = rightY;
 
    var color = getBitmapColorForRect(canvas, i * _diamondWidth, j * _diamondHeight, _diamondWidth, _diamondHeight);
 
    context.fillStyle = color;
 
    context.shadowOffsetX = -2;
    context.shadowOffsetY = -2;
    context.shadowBlur = 8;
    context.shadowColor = "rgb(91,91,91)";
 
    context.beginPath();
    context.moveTo(topX, topY);
    context.lineTo(rightX, rightY);
    context.lineTo(bottomX, bottomY);
    context.lineTo(leftX, leftY);
    context.lineTo(topX, topY);
    context.fill();
 
}
 
function drawTopTriangle(canvas, i, j) {
 
    var canvas = document.getElementById('imageCanvas');
    var context = canvas.getContext('2d');
 
    var leftX = i * _diamondWidth + _diamondWidth / 2;
    var rightX = leftX + _diamondWidth;
    var bottomX = leftX + _diamondWidth / 2;
 
    var leftY = j;
    var rightY = leftY;
    var bottomY = j + _diamondHeight / 2;
 
    var color = getBitmapColorForRect(canvas, i * _diamondWidth, (j + 1) * _diamondHeight, _diamondWidth / 2, _diamondHeight / 2);
 
    context.fillStyle = color;
    context.beginPath();
    context.moveTo(leftX, leftY);
    context.lineTo(rightX, rightY);
    context.lineTo(bottomX, bottomY);
    context.lineTo(leftX, leftY);
    context.fill();
 
}
 
function drawSideTriangle(canvas, i, j) {
 
    var context = canvas.getContext('2d');
 
    var leftX = i;
    var rightX = leftX + _diamondWidth / 2;
    var bottomX = leftX;
 
    var leftY = j * _diamondHeight - _diamondHeight / 2;
    var rightY = leftY + _diamondHeight / 2;
    var bottomY = leftY + _diamondHeight;
 
    var color = getBitmapColorForRect(canvas, i * _diamondWidth, j * _diamondHeight, _diamondWidth / 2, _diamondHeight / 2);
 
    context.fillStyle = color;
    context.beginPath();
    context.moveTo(leftX, leftY);
    context.lineTo(rightX, rightY);
    context.lineTo(bottomX, bottomY);
    context.lineTo(leftX, leftY);
    context.fill();
}
 
function getBitmapColorForRect(canvas, x, y, width, height) {
 
    var sourceCanvas = document.getElementById("sourceCanvas");
 
    if (sourceCanvas.getContext) {
        var context = sourceCanvas.getContext('2d');
 
        if (context) {
 
            var imageData = context.getImageData(x, y, width, height);
 
            return 'rgb(' + imageData.data[0] + ', ' + imageData.data[1] + ', ' + imageData.data[2] + ')';
        }
    }
 
    return 0;
}
 
function drawBayerUndPreussDiamonds(canvas) {
    var color = 'rgb(255,243,123)';
 
    var w = _diamondWidth;
    var h = _diamondHeight;
 
    // single
    var startX = 92 * w - w / 2;
    var startY = 4 * h;
 
    drawFirstBayerUndPreussDiamond(canvas, startX, startY);
    drawThreeBayerUndPreussDiamonds(canvas, startX, startY);
    drawFiveBayerUndPreussDiamonds(canvas, startX, startY);
}
 
function drawFirstBayerUndPreussDiamond(canvas, startX, startY) {
    var color = 'rgb(255,243,123)';
 
    var w = _diamondWidth * 2;
    var h = _diamondHeight * 2;
 
    if (canvas.getContext) {
        var context = canvas.getContext('2d');
 
        context.fillStyle = color;
        context.beginPath();
        context.moveTo(startX, startY);
        context.lineTo(startX + w / 2, startY + h / 2);
        context.lineTo(startX, startY + h);
        context.lineTo(startX - w / 2, startY + h / 2);
        context.lineTo(startX, startY);
        context.fill();
    }
}
 
function drawThreeBayerUndPreussDiamonds(canvas, startX, startY) {
 
    var color = 'rgb(255,243,123)';
 
    var w = _diamondWidth * 2;
    var h = _diamondHeight * 2;
 
    startX += 1.5 * _diamondWidth;
    startY -= 1.5 * _diamondHeight;
 
    if (canvas.getContext) {
        var context = canvas.getContext('2d');
 
        context.fillStyle = color;
        context.beginPath();
        context.moveTo(startX, startY);
        context.lineTo(startX + w * 1.25, startY + h * 1.25);
        context.lineTo(startX, startY + 2.5 * h);
        context.lineTo(startX - 0.5 * w, startY + 2 * h);
        context.lineTo(startX + 0.25 * w, startY + 1.25 * h);
        context.lineTo(startX - w / 2, startY + h / 2);
        context.lineTo(startX, startY);
        context.fill();
 
    }
}
 
function drawFiveBayerUndPreussDiamonds(canvas, startX, startY) {
 
    var color = 'rgb(255,243,123)';
 
    var w = _diamondWidth * 2;
    var h = _diamondHeight * 2;
 
    startX += 3 * _diamondWidth;
    startY -= 3 * _diamondHeight;
 
    if (canvas.getContext) {
        var context = canvas.getContext('2d');
 
        context.fillStyle = color;
        context.beginPath();
        context.moveTo(startX, startY);
        context.lineTo(startX + w * 2, startY + h * 2);
        context.lineTo(startX , startY + 4 * h);
        context.lineTo(startX - .5*w , startY + 3.5 * h);
        context.lineTo(startX + 1*w , startY + 2 * h);
        context.lineTo(startX - w / 2, startY + h / 2);
        context.lineTo(startX, startY);
        context.fill();
 
    }
}
 
</script>

Still need a solution for inner shadow on the shapes i am drawing, though….

Read More

Also this time, i want to write a very little summary of btplay in cologne, since i just got back from vacation, a lot is already out of mind.

Luca Sale
- keywords: phonegap, ripple, cloud9

Nico Zimmermann
- keywords: schau, passion project time ( save a month a year to just to passion projects )

Tim Ahrens
- keywords: fontfonter ( try fonts on any website )

Grant Skinner
- keywords: technitone, createjs

Thanks also to the great talks:

- Marcin Wichary
- Seb Lee
- Frank Reitberger
- Joshua Davis ( still cracking somethimes  and thank you for this: “the work you make is the type of work you’ll get hired to do” )
- Sebastian Golash

Read More

Whithout writing too much about it for today, the best way ( i can always only speak for myself ) to call a function with setTimeout in JavaScript is:


var myTimeout = 400;
setTimeout(function(){ callFunction(parameter[s]) }, myTimeout);

function callFunction( parameter[s] )
{
// Do some Stuff here with the parameter[s]
}

Especially when a Parameter is a “multiple Word – String” (e.g. “Hello Everyone, i am a multiple word String!” ), using a “closure” will be the way that works also in Internet Explorer :)

Read More

When working with JQuery, it seems all work is taken over by the library.
Actually it does, unless a client tells you afterwards, Internet Explorer 8 is still his/her weapon of choice, next to the ipad of course.
A really funny combination of technical aspects, but client is king, lets make him feel that way.

A real pain is that IE8 is not able to use event.preventDefault() nor event.stopPropagation().

For this, its helpful to use a function that will end the event, no matter what browser:

Step 01. make sure to stop Events

function stopEvent(e) {
 
	if(!e) var e = window.event;
 
	//e.cancelBubble is supported by IE -
        // this will kill the bubbling process.
	e.cancelBubble = true;
	e.returnValue = false;
 
	//e.stopPropagation works only in Firefox.
	if ( e.stopPropagation ) e.stopPropagation();
	if ( e.preventDefault ) e.preventDefault();		
 
       return false;
}

Step 02: adding and removing the listeners.

Since IE (8) does not support addEventListener or removeEventListener etc. the element needs to be checked, whether it supports addEventListener or attachEvent ( IE )

function addListeners( el )
{// Allow function call without passing parameters
	var e = el;
	if( !e )  e = document.getElementById('myDiv');
	var el = e;
 
	if( el )
	{
		if( el.addEventListener )
		{	
			el.addEventListener('mouseup', onMouseUp, true);
			el.addEventListener('mousemove', onMouseMove, true);
			el.addEventListener('touchstart', onTouchStart, true);
			el.addEventListener('touchmove', onTouchMove, true);
			el.addEventListener('touchend', onTouchEnd, true);			
		}else if( el.attachEvent ) {
                        // make sure mouse events have the prefix <strong>on</strong>
			el.attachEvent('onmouseup',    onMouseUp);		
			el.attachEvent('onmousemove',    onMouseMove);
			el.attachEvent('touchstart',   onTouchStart);
			el.attachEvent('touchmove',    onTouchMove);
			el.attachEvent('touchend', onTouchEnd);				
		}   
	}
}
// also remove the Listeners correctly:
 
function removeListeners( el )
{	var e = el;
	if( !e )  e = document.getElementById('myDiv');
	var el = e;
	if( el )
	{
		if( el.removeEventListener )
		{	
			el.removeEventListener('mouseup', onMouseUp);
			el.removeEventListener('mousemove', onMouseMove);
			el.removeEventListener('touchstart', onTouchStart);
			el.removeEventListener('touchmove', onTouchMove);
			el.removeEventListener('touchend', onTouchEnd);
		}else if( el.detachEvent ) {
			el.detachEvent('onmouseup',    onMouseUp);
			el.detachEvent('onmousemove',    onMouseMove);
			el.detachEvent('touchstart',   onTouchStart);
			el.detachEvent('touchmove',    onTouchMove);
			el.detachEvent('touchend', onTouchEnd);				
		}  
	}
}

Now its just a Matter of Needs, what to do within the handlers:
an Example could be

 function onMouseUp(e) {
	log('-&gt; mouse up');
	e.touches = [{clientX: e.clientX, clientY: e.clientY}];
	removeListeners();
	stopEvent(e);
}
 
function onMouseDown(e) {
	log('-&gt; mouse down');
	addListeners();
	e.touches = [{clientX: e.clientX, clientY: e.clientY}];
	onTouchStart(e);
	stopEvent(e);
}
 
function onMouseMove(e) {
	log('-&gt; mouse move');
	e.touches = [{clientX: e.clientX, clientY: e.clientY}];
	onTouchMove(e);
	stopEvent(e);
}
 
function onTouchStart(e) {
	log('-&gt; touch start');
	//do something with e.touches[0].clientX or e.touches[0].clientY
   stopEvent(e);
}
 
function onTouchMove(e) {
	log('-&gt; touch move');
	//do something with e.touches[0].clientX or e.touches[0].clientY
	stopEvent(e);
}
 
function onTouchEnd(e) {
	log('-&gt; touch end');
	if( !is_touch_device() ) removeListeners();
}

And to not get any errors, add function log and function is_touch_device…

function log(str) {
	var c;
	c = document.getElementById('console');
	c.innerHTML = str + '
' + c.innerHTML;
}
 
function is_touch_device() {
  return !!('ontouchstart' in window) ? 1 : 0;
}

Finally, if it is an Touch device, you want to add the listeners onLoad of the document, on regular devices on MouseDown. Call this function on documen_ready or onLoad.

function init() {
 
	var el;
    el = document.getElementById('myDiv');
 
	if( el.addEventListener )
	{
		el.addEventListener('mousedown', onMouseDown, false);
	}else if( el.attachEvent ) {
		el.attachEvent('onmousedown',    onMouseDown);
	}
	if( is_touch_device() ) addListeners();
 
 
}

it works so far in IE8/9, FireFox 3.6.1+, Safari and mobile Safari ( ios )

Read More

During a Projekt, i was wondering, why local use of HTML5 Videos was running, but online it failed.

It turned out, that the MIME-Types for .ogg or .webm were not correctly set. The Server served them as plain text-files.

To get the Server to add correct headers to the files, it is helpful to add those lines in your .htacess .

Not all of them are always neccessary.

AddType video/ogg .ogm 
AddType video/ogg .ogv 
AddType video/ogg .ogg 
AddType video/webm .webm 
AddType audio/webm .weba
AddType video/mp4 .mp4 
AddType video/x-m4v .m4v

Sometimes it’s that easy

Read More

or…. how to get back to efficiency.

One of the major issues for me as a developer is how to use my time. Decisions need to be made, what has to be done ( by me ) till when and what needs to be worked on next.

Since i am a very lucky in the fact, that i have lots of jobs, i tended to fuddle up everything and not get anything done stress free.

So what now? I won’t be the one, that will invent a time stretching mechanism in physics, astrology or whatever.

I read an article that came per tweet ( can’t find it of course by now ) that inspired me, coming back to more efficiency.

First, a couple weeks ago a friend reminded me, that i could set my phone to not push e-mails anytime to my phone. Which means, whenever i want or need to receive E-Mails, i simply open the mail-app manually. Whoa what a relief – the phone does not “pling” all the time which distracts me or wants my attention.

Which leads me to the second point. Event though my phone doesn’t pling that much anymore, i wondered, what distracts my attention to code while programming. The pling… it is still there, cause my mail program of course is checking my mails all the time. Every 10-20 minutes or in even smaller periods the pling comes up. I sat back and read the mails, that needed so much urgent attention:

  • Cheap Flights to London for 29 € ( Oh yeah lets go )
  • Get a Picture framed for 40% off ( right, haven’t done that for a while )
  • Tibet needs help – Donate here ( just phish my account! )
  • etc.
  • etc.

I figured, its not SPAM! I really signed up for those newsletters and surely marked them as read, whenever they came in. So for a couple of weeks i unsubscribed all newsletters which i really do not need to receive, since i look up stuff manually that interests me. Many services are unsubscribed by now and daily E-Mail rate dropped 80%. Still working on more!

Third- Email is no real-time communication, even though we tend to force ourselves to believe that. I do, for example, have a time, where i am very productive in coding, another time for writing Mails, another for doing office stuff. There not the same each day, but when i feel, i am getting ready to code, i close my mail program for at least an hour. no more pling…

Oh, don’t want to forget the other attractors, even though nobody does it while working! Twitter, Skype, Facebook, g+, Online-News, community etc, etc.
Since Skype is the only thing, that connects me to other developers and friends i tend not to switch it off, Facebook kind of killed that totally crazy chatting anyhow. Whenever i really want silence – i am “busy”.
Twitter, Facebook, News and all the other information spreaders i watch first in the morning, before i even start thinking of work, after lunch and sometimes before i leave.
Compact distraction!
This week i did work on 7 different jobs and different clients, usually it would mean, i don’t get home till midnight and i feel worn out, but i didn’t.
It wasn’t a 9-5 week of course but i sure did have the time to come down, think about, what i do and i even found time to write down those lines….

Read More