Category Archives: Other

Developers Can’t Make Movie Apps Anymore

A few days ago I brainstormed an app idea to help users find movies they want to watch on Redbox and Netflix. A small app, nothing grandiose or too ambitious, but a simple app that would do a job.

In order for me to create these apps, I need to be able to pull (public) information from these services. Redbox inventory differs from location to location, and Netflix’s inventory changes as their movie rights expire and new titles are added.

I’m astonished at the lack of developer support from Netflix and Redbox. As of about a month ago, Netflix shut down its API service to developers.

This change means that developers can’t create an app that helps people find Netflix movies to watch. Even if you want to grab publicly digestible information like the list of movies on Netflix Instant.

Redbox has an API, but you have to apply… and wait… for them to approve of your “application” – basically you have to tell them what you’re building, your business model, etc. Considering I could probably count with one hand the number of Redbox apps out there, I am guessing that Redbox doesn’t quite see eye-to-eye with most developers’ API applications.

Hulu doesn’t even offer an official API and developers have to resort to reverse engineered libraries.  Amazon Instant does have an API, but it is stupidly wrapped under the overly complex Amazon’s Product Advertising API umbrella.

This is sad.

There is a problem in movie discovery, many people struggle to find movies they want to watch, and developers have their hands tied behind their back trying to fix this problem.

Custom Options Set Price to 0 in Magento 1.7 – The Fix

I’m working on a side project with Magento… There is a bug in 1.7 where when you use custom options, and your theme doesn’t include it’s own options.phtml file, the price will set to $0 (zero) when a user selects the price.

A bunch of forum posts have people talking about the problem. Basically it’s a silly bug in the javascript in options.phtml.

Basically, if your theme doesn’t have that options file in it’s theme directory, then magento looks like it defaults to the base‘s folder and includes the “default” options.phtml.

Here is the fix. I hope Magento includes it in the next Magento release!

Line 123 of options.phtml in
app/design/frontend/base/default/template/catalog/product/view/

Right now is

price += parseFloat(config[optionId][element.getValue()]);

Should be

price += parseFloat(config[optionId][element.getValue()].price);

Basically the code was trying to convert a javascript Object to a float… making the price 0.

Please share this page to others who experience the same issue.

Camera quality on iOS for Air

Having quality issues? Getting different dimensions from the camera than what you request? Read this note from Adobe:
https://bugbase.adobe.com/index.cfm?event=bug&id=2942275

cam = Camera.getCamera();
cam.setMode(320, 240, 20, false);
cam.setQuality(0, 100);
cameraVideo.attachCamera(cam);
cameraVideo.width = cam.width;
cameraVideo.height = cam.height;


//Actual Result:

cameraVideo's dimension are 320x240 when on IPhone emulator
cameraVideo's dimension are 192x144 when on IPhone

//Expected Result:
cameraVideo's dimension are 320x240 when on IPhone emulator
cameraVideo's dimension are 320x240 when on IPhone

This was Adobe’s response

When you call Setmode with some requested width and height, its not necessary that you will get the requested width and height.
The returned width and height depend on a number of factors –
1. Obviously, the values you passed in as width and height.
2. If you passed favorArea=true/false in the setmode API
3. And most importantly, the camera hardware – what are the possible resolutions (and fps) the hardware of camera on you device supports.

Since “3” can be different for different devices you can get different values on different devices (values can vary on WIN Desktop as well with different webcams)

In this case, iOS devices again support different set of possoble resolutions –
ios Camera Presets AVCaptureSessionPresetLow AVCaptureSessionPresetMedium AVCaptureSessionPreset640x40 AVCaptureSessionPreset1280x720 AVCaptureSessionPresetHigh
3G 400×304 400×304 NA NA 400×304
3GS 192×144 480×360 640×480 NA 640×480
4 front 192×144 480×360 640×480 NA 640×480
4 back 192×144 480×360 640×480 1280×720 1280×720

The logic to compute the width and height is somewhat like this (and happens in core, same for all platforms) –

1. core asks platform to provide a list of supported resolutions. (In ios we provide the list as mentioned above , and in the spec)
2. core selects one of these resolutions, the one closest to user’s requirement (basically comparing area using percentatges but is more involved to describe in words).
3. Say user asks for 320 x 240
4. core has now to select the native supported mode closest to this. SO it can either choose 192×144 or 480×360. Seems in this case core decides to use 192×144.
5. core also changes the resolution based on the aspect ratio of the requested resolution (doing any required cropping).
6. So, you will be getting 192 x 144.

Similarly when you choose 384 x 288, core selects 480 x 360 to be the closest native resolution. Camera captures at 480 x 360 and then a cropped part of it (384 x 288) is provided to you.

Also, on Android, you get the desired values because 320 x 240 is one of the supported values by most Android cameras, thus the requested and supported better match in case of Android.
Also as I have genrally observed, Android cameras have a large number of supported resolutions compared to just 4 on iOS. Thus Android camera has a better chance to match the requested resolution. But if you ask for weird numbers like 700 x 400, you will not get that on Android too (but something else based on the above described logic)

Also the same information is mentioned in implementation spec (and comments on the spec) – https://zerowing.corp.adobe.com/display/airlinux/Mobile+Camera+Implementation+spec

See my suggestion here:
https://bugbase.adobe.com/index.cfm?event=bug&id=2953037

Might shed some light on why your video from webcam is so bad. Try increase the setMode values and get the highest quality camera quality returned. Be mindful that the resolution may be different!

Birthday Paradox and Small Business Conflicts

I think I realized something today concerning workplace culture.

The birthday paradox is a cool mathematical phenomenon. If you take a group of people, the chances that there are two people that share the same birthday is much higher than one would expect. Here’s the Wikipedia article explaining the birthday paradox.

For example, in a group of 23 people, the chances that there are two people that share the same birthday is 50.7%. Pretty crazy? When you hear the problem you start thinking, “1/365” – but this question isn’t asking how many people will share the same birthday as you, it’s asking ANY two people will share the same birthday as each other. In a group of 30 people, the chances rise to 70%.

Now that you know this cool math trick, here’s what I was thinking in regards to work and conflicts.

I think the same paradox can be applied when you take a small business. I think in every workplace there is an incredible high chance that two people won’t get along. In fact, the chances that there is decent cohesion is incredibly small.

Imagine if you will, the nicest person you know. This person gets along with nearly everyone he or she meets. In fact, let’s say that person gets along with 99% of people they meet… Actually let’s be even more specific and say 99.7%.

Let’s say you are an employer and employee 30 people who are this nice. The chances that there will be a conflict is still 70%.

Obviously, people aren’t numbers – but consider people are in the workplace 8 hours a day… “Getting along” and being able to work together is imperative. Sports teams have the same issues with players. In a small group of players there is still a relatively high chance there will be a conflict between two.

So how can companies minimize this risk? Well instead of picking at random, I think recruiters and companies should incorporate chemistry as an atttribute in the job hiring. Instead of employing the person who can do the job, find the person who will be the right fit in your company.

My opinion on Steve Job’s Adobe Attack

So since some people have asked me about Steve Job’s letter against Flash, this is what I think.

I have always said that Apple doesn’t want to risk buggy system and battery life (valid reasons. and I think Apple has a right to refuse Flash until Adobe fixes problems and proves Flash Lite can work on mobile phones). But to call themselves “open” because of support for HTML5 is silly.

His last “sixth” reason is where I really disagree. Not allowing third party applications (like Adobe CS 5) to make IPhone applications because of fear of the quality is bullshit.

I ONLY use third party apps to make Flash content. Many people ONLY use third party apps to develop windows/java/android apps.

If I want to make a Flash app I can use Mac OR Windows and a bunch of programs. If I want to make an IPhone app Apple now requires me to buy a Mac and develop with their own Mac software.

Nice job encouraging competition Steve.

Faster Way to Get a Random Row MySQL

So doing order by RAND() limit 0,1 is pretty slow for big tables. So I came up with the following. Basically it uses the ID column to find a random id number between the lowest id in the table (usually it will be 1 since that’s where auto increment start; however, I lots of times delete these rows during testing and don’t reset my auto incrementer). The only stipulation is that your ID doesn’t have any “holes” – basically if you’ve deleted rows in the middle of your table so that the ID column has a set such as n,n+1, n+y,n+y+1, n+y+2… where y > 1. Example would be 1,2,3,5,6,7. Unfortunately, if you are actively deleting rows in the middle of your database you will have to resync a counter column (either the id or some or column) to fill up the holes… Unfortunately, that’s pretty expensive (sort of like reindexing an array to take off holes… same idea). But maybe you can find a balanced solution. Who knows.

Here’s the code:
SELECT *
FROM ptg_users
JOIN (

SELECT ROUND( (
MAX( ptg_users.id ) – MIN( ptg_users.id ) ) * RAND( )
) + MIN( ptg_users.id ) AS rid
FROM ptg_users
) AS x ON ptg_users.id >= x.rid
LIMIT 1

Replace ptg_users with the name of your table.

Turing Machine

I was asked by Ian Bogost to make a Turing Machine program. The Turing Machine is a device that basically uses conditions to create some type of program.

You can make your own here. I think it’s a great way to teach someone the basics of computer programming and logic.

Initial Tape: PIG

1,_,1,_,>

1,P,2,_,>

2,I,3,P,>

3,G,4,I,>

4,_,5,G,<

5,I,6,I,<

6,P,2,_,>

6,_,1,_,>

My New Game: Obechi!

Click here to play my new game Obechi.

Here’s the description of the game written by Tim Halbert (who wrote the music to the game):

From the creators of the Flash sensation Boomshine comes a devious new game where hand/eye co-ordination and a lightning-quick reaction time spell the difference between success and failure. Hundreds of colorful particles floating in the ether – and it’s your job to put them all together. Click and hold down the mouse button to make a ring around the dots, and watch them all gather in the center. With every ring you create you’ll get closer and closer to your target… but miss the target, even by one, and the nucleus is ruined. How quickly can you complete all fifteen levels without making a single mistake? The challenge is on

Special thanks: Tim Halbert, Tim van de Vall, Aneece K, Ajani T, Anna M, MochiMedia, and Kongregate.

New version of Picterizer

*Edit: Renamed app to Picterizer*
A new version of Picterizer has been uploaded. If you haven’t checked it out, this web application generates a picture of pictures (from flickr). Basically you upload your photo from your hard drive. The program uses Flickr to compile the picture. The new version now includes a “variance” factor as well as a new dimension choice (1728×1728) which will fit a 24×24 inch poster.

The new variance (built in) will not ALWAYS select the closest average color picture match of the sliced region. This way the picture won’t have so many repeated pictures on solid color sections.

The variance is 1% multiplied by the number of pictures in the pool. This means that if you select 500 Flickr results that means the program determines the 5 closest pictures to a color slice and chooses a random one. It’s hard to explain, but basically it means that more pictures from the pool of pictures found will be used (at the expense though of possibly losing recognition of the original picture).
picture_in_picture-smiley1
Here is a smiley face built with the result for the search “smiley” on Flickr. Even though the middle is solid white, it selects a random choice from the closest 5 white pictures (instead of the whitemost picture) in order to add some variance. You can also see I added a watermark (as I thought it’d be a good idea to get people spreading the application).

Click here to Picterize your own photo.

Remember, you can click “Save” on the bottom right to save it to your hard drive.

Pass it around and send me the photos you guys make with it! And let me know if you find any bugs (I’m sure it isn’t bug free) or have any suggestions.

EventManager 1.3

Dennin Dalke, a Brazillian Flash Developer emailed me a great method for the AS3 EventManager class (read the original post).

//adding multiple events at once.
EventManager.addEventListeners( loader.contentLoaderInfo, [
ProgressEvent.PROGRESS,    onSiteLoad_Progress,
Event.OPEN,                onSiteLoad_Open,
Event.COMPLETE,            onSiteLoad_Complete,
IOErrorEvent.IO_ERROR,    onSiteLoad_IOError
] );

It’s a great method to save retyping so many lines.

Get the updated class here. Also, if you have, are, or planning to use the class I would love to know how!