Blending Features in Canvas HTML5

Reblogging this from Adobe website as a means to easily find the link again -

Summary of the post – Adobe has added some specs to the canvas api which will improve the way colors and backgrounds get blended. This is in addition to the blending capabilities provided by CSS(3)

For detailed understanding, click away -

http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/

Posted in How To..., linklog | Leave a comment

BookNotes – Chapter1 Using Memcached by Josef Finsel

Shring key takeaways from the first chapter of the Using memcached throu this blog post. Purpose is for me to recapitulate my learning and for you to get the highlights.

Before starting to read is book, I would recommend readin the following links – these will refresh the memory with the scope and context of words like  events and servers: -

http://blog.soemarko.com/post/1396596544/event-driven-approach

http://www.wangafu.net/~nickm/libevent-2.1/doxygen/html/

The key takeaways are -
1. Memcached is a NameValue Pair cache only and NOT a persistent data store of any sort.
2. The max size of Name/key is 250 chars, max size of values that can be stored is 1 MB.
3. Can be installed on both linux/unix and Windows servers.
Quote
Running the server under Windows as a service only allows one one instance. If you want to run multiple instances you will need to actually run memcached multiple times with different port addresses. This can be done by adding keys to the Registry or by using a tool such as AutoRuns[1] to do that for you.
Unquote
4. 4 commands for add, update and remove data, and a detailed statistics command
5. Works on a server client basis, so for raw interactions with a trial memcached sever use telnet as a client

That, in short, is the highlights of this chapter.

For detailed reading head to http://pragprog.com/book/memcd/using-memcached

Posted in BookNotes | Tagged | Leave a comment

What is Celery task queue, where do i use it and how do I use it?

As you start going beyond the landing page and the login/logout screen of the latest coolest app that you are building, you realize that the app needs to do a lot more set of things other than querying the database and building dandy HTML views around it. :)   And that is when you realize the need for an assistant of sorts, to whom you can throw all the extra load and continue working on your html views :)

This is where Celery the task queue comes into the picture. The Celery homepage and the associated Wikipedia page will only say this much -

Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.

But where the hell do I use it? What are typical usecases where Celery comes into the picture? So instead of writing a blogpost all over again, sharing this slide share link, that I found particularly useful in answering these questions that bogged me -

And this one with a little more technical details as to how the tasks are dealt with

So click through the above and get enlightened. And share your experience in the trenches with Celery.

Posted in library watch, What is.. | Tagged , | 2 Comments

Bridging the learning curve to Backbone.js

Sharing a URL which talks about how to move from JQuery programming to Backbone style. – i.e. converting an existing codebase into a Backbone based app - http://www.ofbrooklyn.com/2012/11/13/backbonification-migrating-javascript-to-backbone/

Posted in How To..., linklog | Tagged | Leave a comment

ClassNotes – What exactly is Functional Programming?

Sharing some notes and insights gained as part of attending Martin Odersky’s Functional Programming course on coursera.org

1) Programming usually taught in colleges (atleast indian ones) is the  imperative style which is strongly based on von neumann’s design of what a computer should be like. It means programs in this style are instruction sequences. And a good number of the popular languages are written around this philosophy  ”compute/execute instruction in processor,store data and results in memory and have a bus that serves as transportation between the two”

Functional programming is different from this. The approach of object oriented programming is orthogonal to both Functional or Imperative i.e. it is independent of the two and can be successfully combined with both the above discussed types of programming.

Martin Odersky says that imperative programming is limited by the “Von Neumann Bottleneck” which is that “One tends to visualize datastructures word-by-word” – I dint quite understand that in entirety – will update the post when i do so

 

Lets consider Mathematics. Every other topic in mathematics consists of laws that describe relationships between data and a set of operations that can be done on them. So Quote Martin ” If we want to implement  high-level concepts following their mathematical theories,then there’s no place for mutation”. So we want to be able to

  1. concentrate on defining theories for operators
  2. avoid mutations
  3. have powerful ways to abstarct and compose theories.

This is what functional programming  is all about. and this is the space that functional programming operates in.

Posted in Functional Programming | Tagged , , , | 1 Comment

Tech Notes : Introduction to Clojure by @ghoseb

Its been more than one month since I attended the “Introduction to Clojure” talk by Baishampayan Ghose (@ghoseb on twitter) as part of the Java Pune Meetup group’s monthly meetup. I had scribbled down some notes, that I promised to blog about, but other things just cannibalized my blogging time.

Anyway, better late than never, here are some of excerpts and salient features of clojure as described by “BG”.

  • Clojure is a variation of LISP, but is a JVM based language so gives interoperability with the JVM.
  • One can do functional programming with Clojure.
  • One of the interesting things about clojure is that you can bring the domain of your problem statement into this language, rather trying to adapt Clojure to the domain.
  • Clojure has profound state management capability.
  • Protips for Clojure, an LISP based language for that matter
  • 1) Everything, i.e every statement in LISP is perceived as a list of items.
  • 2) the first item in the list, is always considered to be a function.
  • As a consequence of the above, all LISP statement are read as “prefix expressions”.
  • Few interesting mentions about Datatypes in Clojure ->
  • 1) basic datatypes in Clojure start at Long and Double as against int and float for those from the C,C++,Java world
  • 2) there exists a dedicated datatype called “Ratio” that enables much higher levels of accuracy in computation when dealing with real numbers such as ‘Pi”(22/7)
  • 3)RegularExpression is a one of the built in datatypes
  • 4)There is also a datatype called ‘Keyword’
  • Some default datastructures built into Clojure ->
  • 1)List -  its a singly linked list that grows from the front
  • 2)Vector – its a collection of values indexed by contiguous integers that grows from the end.
  • 3)Map – its a standard key,value pair datastructure
  • 4)Sets – its a collection unique values (yes the same way we refer to sets in maths)
  • One key thing about Clojure is that all datastructures are immutable and when you code with them, you only perform transformations over them and copy them over to newer items while playing around with them
  • The other interesting aspect of this Clojure 101 talk was about sequences – where you can specify the first item of a sequence followed by instructions to recursively generate the next next elements of the sequence.
  • Namespaces are part of the language. You can create and switch in between namespaces even while you are playing around in the commandline.
  • And namespaces can be imported around as if they were packaged libraries.

These are the major things that BG spoke about. As BG mentioned at the beginning of the talk, the goal of the above points is to give Clojure aspirers a good springboard, from where they can easily jump into the world of Clojure programming.

Hope this helps someone looking for a headstart in Clojure.

Posted in Uncategorized | Leave a comment

Object Oriented Javascript – A prototype based language – a beginner’s notes

Here are some notes that I have discovered and would like to share with fellow beginners of OO JavaScript
Reference:http://msdn.microsoft.com/en-us/magazine/cc163419.aspx

Key Learnings : -
a. JavaScript’s support for OO is very different from that given by C++, Java
b. a JavaScript function is really an object with executable code associated with it. and hence every function in JavaScript gets a “this” operator which refers to itself
Example-

function displayQuote() {
    // the value of "this" will change; depends on
    // which object it is called through
    alert(this.memorableQuote);
}

var williamShakespeare = {
    "memorableQuote": "It is a wise father that knows his own child.",
    "sayIt" : displayQuote
};

var markTwain = {
    "memorableQuote": "Golf is a good walk spoiled.",
    "sayIt" : displayQuote
};

var oscarWilde = {
    "memorableQuote": "True friends stab you in the front."
    // we can call the function displayQuote
    // as a method of oscarWilde without assigning it
    // as oscarWilde’s method.
    //"sayIt" : displayQuote
};

williamShakespeare.sayIt(); // true, true
markTwain.sayIt(); // he didn’t know where to play golf

// watch this, each function has a method call()
// that allows the function to be called as a
// method of the object passed to call() as an
// argument.
// this line below is equivalent to assigning
// displayQuote to sayIt, and calling oscarWilde.sayIt().
displayQuote.call(oscarWilde); // ouch!

c. You declare and setup classes by setting up functions in their name
d. Every object in JavaScript is created as a copy of an existing example object, and every class definition, so to speak , has the keyword “prototype” associated with it giving us developers access to the prototype of the class that we are setting up.  ”Any properties and methods of this prototype object will appear as properties and methods of the objects created from that prototype’s constructor. You can say that these objects inherit their properties and methods from their prototype. “
e. Every “prototype” has a “constructor” property to it. and since the class declaration/definition itself is a function, this “constructor” property  simply refers back to this function. (some recursion this is).
f. “Every JavaScript object inherits a chain of prototypes, all of which terminate with Object.prototype, which is the ultimate base prototype for all prototypes. “
g.JavaScript supports closures. “Closure” when crudely translated to simpler english means anonymous functions. And a more specific meaning would be “A closure is a runtime phenomenon that comes about when an inner function (or an inner anonymous method) is bound to the local variables of its outer function.”

Inheritance works this way – http://javascript.crockford.com/prototypal.html

Posted in JavaScript | Tagged , , | 1 Comment