Oslove
Posted: July 26th, 2011 | Author: alexbech | Filed under: None | No Comments »
Just found an awesome vector graphics library for javascript.
“Paper.js is an open source vector graphics scripting framework that runs on top of the HTML5 Canvas. It offers a clean Scene Graph / Document Object Model and a lot of powerful functionality to create and work with vector graphics and bezier curves, all neatly wrapped up in a well designed, consistent and clean programming interface.”
This is a small project I worked on for Nidar Favoritter while at Jimmy Royal.
Nidar Favoritter is a series of products with “norways favorite chocolate pieces”.
The client wanted the customers to be able to create their own favorite piece, and the winners (selected by a jury) would end up in the actual bag. The campaign resulted in more than 53.000 favorite pieces submitted and 3,5 million pageviews.
This job gave me a lot of experience with BitmapData-manipulation, and was one of the first projects I did entirely without a .fla file (late to the party I know).
Design was done by Daniel Tveiten, back-end by Tommy Stomlien and flash development by me.
The campaign is no longer active, but you can see an archived version here.
Campaign for KiMs (potato chips) where the users where allowed to create a new flavor, design the bag and battle it out for a cash price of $18.000!
KiMs got more than 50.000 submissions and 44.000 registered users – generating more than
7 million page-views during the campaign period.
Due to the big cash price, security and cheating was a big concern. The whole team put a lot of effort into making the system as secure as possible. A user had to create an account and verify by email to enter the contest. Furthermore a users could only “battle” a bag one time a day, making cheating and boosting your own bag more difficult. Some users tried to create multiple accounts with disposable emails, but this was easily discovered in the excellent admin system that Tommy built.
Design was done by Daniel Tveiten, back-end by Tommy Stomlien while I did the flash programming.
The campaign is now in it’s final stage and is closed for new submissions, but you can view an archived version here.
Kuene Bestemmer is another fun project I got to work on, also for Litago while at Jimmy Royal.
After letting the consumers decide what the next taste would be through a series of campaigns, the client wanted to let the cows producing the milk decide for themselves.
The job turned out great, with live video-feeds from the farm and real-time tracking of the cows. I did the map, position-tracking and video-streaming in flash, while Tommy Stomlien did all the back-end and the rest of the site. Concept and idea by Dist Creative.
The site won the “Craftsmanship Of The Year” award at Gulltaggen 2011.
You can learn more about the project here or see the archived version of the site here.
I have recently started porting some of my most used Actionscript utility classes to javascript.
You can probably find most of this (and a whole lot more) in libraries such as Underscore.js, but what can I say – I like things my own way. Anyway, this is what I’ve got so far.
Javadoc-style documentation is available in the source files.
ArrayUtil methods:
left, right, copy, toggle, remove, contains, shuffle, validIndex, getRandom, swap, unique, insert, insertBefore, insertAfter
KeyUtil methods:
isEnter, isBackspace, isTab, isAlt, isCtrl, isShift, isSpace, isEsc, isHome, isEnd, isPageDown, isPageUp, isDelete, isLeft, isRight, isUp, isDown, isNumPlus, isNumMinus, isCopy, isCut, isPaste, isSave, isSelectAll, isPrint
NumberUtil methods:
ceilTo, degreesToRadians, delta, diff, floorTo, isBetween, isEven, isFloat, isInteger, isOdd, isPrime, limit, radiansToDegrees, randomFloat, randomInt, randomSign, roundTo, roundToDecimals
StringUtil methods:
contains, upperCaseFirst, upperCaseWords, upperCaseSentence, stripWhiteSpace, trim, trimLeft, trimRight, startsWith, endsWith, replace, remove, truncate, numberFormat
TypeUtil methods:
isNumeric, isInteger, isFloat, isString, isArray, isBoolean, isObject, isFunction, isDate, isDOMElement
ValidationUtil methods: (norwegian formats)
isEmail, isPhone, isMobile, isDate, isZip, isIpAddress, isUrl, isDomain, notEmpty, isNumericOnly, isAlphabeticOnly, noWhiteSpace, noSpecialCharacters
You can download the classes here.
Project done for SpareBank1 while at Jimmy Royal.
With the introduction of new pension scheme in Norway, SpareBank1 wanted a website to show and explain how this affects your future pension. My task was to implement the “industry standard for pension calculation”, a 20-page document with mathematical formulas and tables, as a visual calculator.
In collaboration with Petter Hansen at SpareBank1 I managed to port the entire pension calculation to Actionscript. This included among other things tables for life expectancy adjustment and index/value adjustment.
A lot of effort was put into making the user-interface and information easy to understand.
Click here to visit the site and try the pension calculator.
I’ve had the pleasure of working with Litago over several years while being employed at Jimmy Royal.
On this particular job, we wanted the public to design a 3d-model of the brands famous cow.
More than 40.000 cows where designed and submitted during the campaign period, and I’m proud to say that we won an “FWA Site of the day”.
I did the framework, php/mysql back-end and all the individual pages – while Håvard Stranden (my boss) did the actual drawing editor. The design was done by Sandro Kværnmo a former Jimmy Royal employee, now with Strømme Throndsen Design. Concept and idea was done by Dist Creative.
The campaign is no longer active, but you can see an archived version here.
A friend recently posted a question on twitter regarding lack of unicode support in php string functions. He was specifically after ucfirst, lcfirst and ucwords.
After doing some research I figured I would create a set of custom string functions with unicode support.
if (!function_exists('mb_ucfirst')){
function mb_ucfirst($str, $e='utf-8') {
return mb_strtoupper(mb_substr($str, 0, 1, $e), $e) . mb_substr($str, 1, mb_strlen($str, $e), $e);
}
}
if (!function_exists('mb_lcfirst')){
function mb_lcfirst($str, $e='utf-8') {
return mb_strtolower(mb_substr($str, 0, 1, $e), $e) . mb_substr($str, 1, mb_strlen($str, $e), $e);
}
}
if (!function_exists('mb_sentence')){
function mb_sentence($str, $e='utf-8') {
$string = '';
$sentences = preg_split('/([.?!]+)/', $str, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
foreach ($sentences as $key => $sentence) {
$string .= ($key & 1) == 0 ? mb_ucfirst(mb_strtolower(trim($sentence), $e)) : $sentence .' ';
}
return trim($string);
}
}
if (!function_exists('mb_ucwords')){
function mb_ucwords($str, $e='utf-8'){
return mb_convert_case($str, MB_CASE_TITLE, $e);
}
}
Please note that some of the code was taken from comments and suggestions on php.net.
All I have done is modify, rewrite and rename the functions to suit my needs.
Please note that use of mb string functions is heavy on the cpu compared to normal string functions.
Hope this might be helpful for others struggling with unicode strings in php.

After winning the KLIKK! 2009 competition we got to do a pro bono job for Amnesty International Norge.
The goal was to help people around the world who have been subject to network censorship by their own government through collecting “digital” signatures.
The idea was to create attention through gentle, continuous and perhaps a little different “nagging”. We created a series of banner-ads that kept track of how many times, where and when the user had been exposed to the banners. Based on the local users-statistic and signature statistic loaded from our servers, we presented a series of different customized messages.
To be able to collect and store the statistic about the user across different browsers and domains, I came up with the idea to load a small shim-swf from a feeding server. Because the shim always loaded from the same domain, we could read and write data (timestamp, host/domain, current screen etc.) to the same SharedObject, regardless of where the actual banner-ads were deployed.
All signatures were stored on our server, alongside geo-location of the user and what host the signature came from. These data were then in turn used to generate more statistics that were exported to the feeding server, and loaded into the banners.
The design was done by Sandro Kværnmo, while I did flash development and mysql/php. The feeding service was donated by Wox.
Check out the banners here!
(refresh the page to see different screens and stats)