Multi-threaded Javascript using an interpreter

Posted: January 13th, 2015 | By | Filed under: Development | Tags: , , , , , | No Comments »

In this post I’m going to explore running multiple threads of javascript code in the browser, executing the javascript code through an interpreter which runs in the browser.

Each thread has its own sandbox, with a restricted access to runtime which executes code in the browser.

Demo: http://www.doboism.com/projects/JS-Interpreter/asyncDemo/asyncDemo.html

Source code on github:  https://github.com/amitayd/JS-Interpreter

A brief explanation of the different parts that make it run:

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Free online tools for testing mobile and desktop web applications

Posted: February 7th, 2014 | By | Filed under: Development, Technology, Uncategorized | Tags: , , , | No Comments »

So, you’ve written you state of the art web app. You wrote unit tests, functional tests, relied on browser features detection, validated and linted your code and markup, and researched browser compatability carefully.

(First of all, wow, I’m impressed)
But still..

What about the layout? And some obscure html5 APIs you’ve been using? Are you entirely confident it works and renders ok on the chaotic multitude of devices, operating systems and browsers?

Without going through the hassle of setting up browsers and virtual machines, you can check your browser using some online tools. Those tools can help you to:

  • Test manually as a user your site or application
  • Run tests in the browser, and look at their reported results manually
  • Run tests, and report their results to some server (browserscope might help)
  • Run selenium tests (and javascript test suits) fully automated

Whether you’re just after a tool for manual testing, or a way to run your tests on multiple platforms, the following list of free(ish) tools might help.

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

CoffeeScript Regex Golf

Posted: January 19th, 2014 | By | Filed under: Development, Fun | Tags: , , , | No Comments »

Like most geeks, i’ve was recently introduced to the new activity of Regex Golf.  What it means, is trying to find the shortest regular expression for all strings in a given set, that doesn’t match any strings in a different given set.
For example, for matching ‘one’, ‘two’ and ‘three’, but not matching ‘four’, ‘five’ and ‘six’, we can come up with the the regexp /t|ne/. 

XKCD had a brilliant comic strip about the subject, which led the great Peter Norvig to write about creating a solver for finding a short regex golf solution.

It got me interested enough to want improve a little on the solution, and I thought “why not try out a new language?” so i’ve decided to port Norvig’s python code to Coffeescript, and play around with both the language and the solution to the problem.

You can have a look and try what I came up with at https://github.com/amitayd/regexp-golf-coffeescript.

It even runs in the browser, in a ugly page I hacked (be careful, it can be slow for big sets):

I will describe some of my experiences in porting the code to CoffeeScript and extending the solution below.

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Web Audio API browser support

Posted: October 17th, 2013 | By | Filed under: Development, Technology | Tags: , , , | No Comments »

The Web Audio API enables web application to synthesize and process audio. It leverages the Browser optimized low-level sound processing, and exposes a rich and modular (and fun!) ways for the web application to access the lower level processing.
Originated as a WebKit only feature, it is starting to become a widely accepted standard in other browsers.

In this post I will cover the current state of support for browsers for the Web Audio API. For this purpose i’ve created a test to gather information about current browsers:

Use it yourself to test a specific browser, or view recorded results for other browsers.

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Cross developing for node.js and browsers using Browserify

Posted: May 17th, 2013 | By | Filed under: Development, Technology | Tags: , , , , , , | No Comments »

I have recently started writing a Javascript library. Trying to create an environment for continuous building and testing the environment, I found the node.js ecosystem, has a lot to off nice tools to offer, such as Grunt, and the npm package management was very nice to use.
So I’ve decided to target the library both to Node.js and browsers, why not?

It turned out that some of the issues were not so trivial to solve, so I’ve started working on an example project, to clear up some of the problems in a  more limited scope.

Code speaks louder than (natural language) words, so try this example at https://github.com/amitayd/grunt-browserify-jasmine-node-example .

The example tries to provide solutions for the following issues:

  • Writing code in CommonJS (node.js) modules, and running it in the browser
  • Having browser-specific code (such as DOM manipulation)
  • Having node-specific code (such as File system)
  • Providing different implementation according to the environment (node/browser)
  • Being able to use libraries not supported as node.js module in the browser
  • Writing tests shared for node and the browser, and running it in the two environments
  • Having node-specific and browser-specific tests
  • Fully automated continuous build and test (provided by grunt)

I have chosen grunt.js for the build runner, and Jasmine as the test framework. Those choices are pretty trivial to replace by any other setup, and the design concepts and the source code can remain the same.
However, the choice in Browserify as a solution for packaging for the browser dictates using CommonJS/node.js modules (see their docs). Further discussion below.

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Titularly – job title generator (made with processing.js)

Posted: June 25th, 2011 | By | Filed under: Development, Fun | Tags: , , , , | No Comments »

  • Founding a new company or hiring new people, but not sure what is everyone going to do?
  • In need of a creative title for a business card?
  • Simply like to stare at text rolling up and down?

Worry no more! We might just have a solution for you!

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Continuous Performance Testing Presentation

Posted: November 25th, 2010 | By | Filed under: Development | Tags: , , , , , , , , | No Comments »

I gave a talk at Alphageeks about Continuous performance testing, using various tools and libraries (written in Java).

The demo code and minimal presentation cover Hudson CI and various performance tracking plugins, Grinder, ContiPerf and Jmeter. I will try to write in a future post a guided tour of the demonstrated code project, and how to set up a continuous performance testing environment.

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

My C# and Mono talk at Alphageeks meetup

Posted: February 25th, 2010 | By | Filed under: Development, Technology | Tags: , | No Comments »

Last Wednesday an AlphaGeeks technological meet up was arranged  by the honorable Yuval Goldstein. Yuval asked me to give a talk about C#, which was getting bash (unjustifiably!)  on previous events. I used the opportunity to throw inside some Mono project too, and get to know it a little bit myself.

So after sweating a lot on code example, and getting back to C# from recent work with Java and Python, I came up with my first presentation. So if you want to watch me lose my presentational virginity lost on video, have a look at at the talk video (In hebrew, courtesy of The Tech Vibe crew).

The slides are available too, but quite honestly they are pretty useless by themselves, as most of the stuff was code examples.

The code examples

CsharpTalk.Mono – demonstration of Delegates, Lambda Expressions, Extensions methods and some LINQ. This one uses Nunit for Mono, and Moq, so you might need to re-arrange the references to compile it, since i didn’t include the libraries. This one targeted Mono and the project was created in MonoDevelop, but should work fine in Visual Studio (again, you might need to change some references and arrange the libraries).

CSharp4Talk – demonstration of some of the new language features in C# 4.0: Dynamic objects, Optional and Keyworded  parameters and variance/contravariance (the last one still twists my brain). This one was created on Visual Studio 2010 Beta 2, but you might get it to work on mono 2.6, if you configure it before build with C# 4 profile (–with-profile4=yes). Json.net is referenced but not included.

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Benchmarking: Testing a string against a single composite Regular Expressions, or an array of Regexps

Posted: December 21st, 2009 | By | Filed under: Development | Tags: , | No Comments »

Here.

Today I needed to recode a small part of  client side script to test against a regular expression instead testing it begins with a specific value (using substring).

The current code used an array of expressions the string can begin with, and tested a string by looping and testing for each substring.

Changing the code had me to face a question that haunts me for a long time: which  is more efficient – testing against a single regular expression, composed from different supplied expressions, or testing against an array of those expressions.  By testing i mean to check if at least one of the expression tests positive for the string (i.e. someRegexp.test(“Tested string”) ).

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Setting active monitors using xrandr

Posted: August 15th, 2009 | By | Filed under: Technology | Tags: , , , | No Comments »

This post is (or might be) relevant for people who are running X Server with xrandr (1.2 and up) enabled (meaning, linux users mostly).

I have 2 displays connected to computer: The primary computer monitor and a television I sometime use to watch movies. Ubuntu doesn’t recognize when I turn on and off a monitor, but provides a way of enabling and disabling a monitor. This can be accessed in Gnome through System/Preferences/Display, and there’s even a shortcut for it in the system tray (is that how it’s called on Gnome?)

However, it can be quite a nuisance to click/drag/click/click just for turning on a monitor, and more so when gnome doesn’t remember my exact display setup (i.e. which monitor is left of which monitor).

Xrandr to the rescue!

show the rest of the post…

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather