background preloader

Functional Javascript

Functional Javascript
var Functional; Functional is the namespace for higher-order functions. Functional.install = function(except) This function copies all the public functions in Functional except itself into the global namespace. Higher-order functions Functional.compose = function(fn...) Type: (a2 → a1) (a3 -> a2)… (a… -> an) -> a… -> a1 Returns a function that applies the last argument of this function to its input, and the penultimate argument to the result of the application, and so on. (1, 2, 3…, )() =def 1(2(3(…((…))))) compose('1+', '2*')(2)→ 5 Functional.sequence = function(fn...) Type: (a… → a1) (a1 -> a2) (a2 -> a3)… (an-1 -> an) -> a… -> an Same as compose, except applies the functions in argument-list order. (1, 2, 3…, )(…) =def (…(3(2(1(…))))) sequence('1+', '2*')(2)→ 6 Functional.map = function(fn, sequence, object) Type: (a ix → boolean) [a] -> [a] Applies fn to each element of sequence. map('1+', [1,2,3])→ [2, 3, 4] If object is supplied, it is the object of the call. The fusion rule: A synonym for select. Related:  Java Script

InMusic This page is divided in three sections: Music software written in Python, Music programming in Python, and Music software supporting Python Bluemindo - Bluemindo is a really simple but powerful audio player in Python/PyGTK, using Gstreamer. Bluemindo is a free (as in freedom) software, released under GPLv3, only. cplay - a curses front-end for various audio players edna - an MP3 server, edna allows you to access your MP3 collection from any networked computer. The web pages are dynamically constructed, adjusting to directory structure and the files in those directories. Yeoman : que tous ceux qui sont dans la vibe disent “Yo” 01 décembre 2014 La Tendance à la standardisation des développements issue du back-end se diffuse de plus en plus dans l’univers front-end. De nouveaux outils font leur apparition pour accompagner cette mutation. C’est de l’un d’eux, Yeoman, que je souhaite vous entretenir aujourd’hui. Yeoman, c’est un peu l’assistant qui va accompagner le développeur front-end dès le début du processus de développement. Qu’est ce que Yeoman Le projet Yeoman Yeoman est un projet open-source distribué sous licence BSD et soutenu par Google. Node.js Avant d’aller plus loin, une précision quant à NodejJs qui sera plusieurs fois évoqué dans cet article. Toutes les fois qu’on souhaitera développer en Javascript un outil destiné à tourner hors du navigateur, on va s’orienter naturellement vers Node.js. Node.js mériterait toute une série d’articles à lui seul, aussi si vous n’êtes pas familier avec ce framework, je vous conseille cet excellent tutoriel. Périmètre fonctionnel Génération du squelette de l’application

JS.Class - Ruby-style JavaScript In Ruby, modules and classes are just another type of object; they are objects that are responsible for storing methods and making new objects. Class methods are methods attached to (and called on) an individual class object, rather than its instances. They are really just a special case of singleton methods. To add class methods when defining a class, wrap them up in an extend block: We could equally add the methods after the class was created: These two syntaxes apply equally to creating and extending Modules. var james = User.create('James'); james.username // -> 'James' james.klass // -> User When you create a subclass, it will inherit any class methods of its parent, and you can use callSuper() too: Note how this, even in callSuper methods, always refers to the same thing as in the original method call. Note that class methods are not the same as Java’s static methods. User.define('copy', function() { return this.klass.create(this.username);});

Mongoose Add Update: Mongoose 1.0 has been released, and we recommend going to our dedicated website for the most up-to-date information and code At LearnBoost, we like to consider ourselves hackers. We look to implement the best technical solutions for our needs then tell people how we did it and hope they fork our code, contribute and make it even better. To make a kick-ass solution for schools , we needed a data store that was scalable, fast and able to keep up with constant iterations of features. The team is very proud to release Mongoose and we hope you like it! What is Mongoose? Mongoose is a javascript library that makes working with MongoDB a breeze. Why MongoDB? While looking into storage solutions we decided that using a NoSQL engine was the best fit for our needs. MongoDB We ended up choosing Mongo for a variety of reasons: commercial support leaders in the industry (founder was CTO at doubleclick ) VMM mapping is a good idea fast javascript (a great fit with Nodejs) Quick Intro to Mongoose

Scope isolé dans les directives AngularJS Second sujet que j'ai traité au Meetup chez Google, il s'agit des scopes isolés dans les directives. Les slides se trouvent ici, et une vidéo a été mise en ligne là ; mon intervention commence par un sujet sur l'usage des services, et celui-ci est à la suite. Le scope isolé est un outil bien pratique mis à notre disposition par AngularJS pour faciliter la création de widgets. L'arbre des scopes Les scopes d'AngularJS sont des objets qui servent de contexte d'évaluation des expressions contenues dans les templates. Ils forment un arbre, dont la racine est le seul scope de l'application qui est aussi publié comme un service, sous le nom $rootScope. La structure arborescente des scopes est calquée sur celle des éléments de la page HTML. Quand une directive crée un scope sur un élément HTML, ce scope aura pour parent le premier scope rencontré en remontant les éléments HTML. Scope d'un élément Quand et pourquoi un scope isolé ? Bindings des propriétés du scope isolé @ : attribut texte et attrs.

The best way to load external JavaScript Posted at July 28, 2009 09:00 am by Nicholas C. Zakas Tags: Blocking, JavaScript, Performance Not too long ago, I wrote about loading JavaScript without blocking by creating a dynamic <script> tag. When <script> tags are in the flow of an HTML document, the browser must stop rendering and wait for the script file to download and execute before continuing (example). The best technique Steve Souders has explored several different ways to load JavaScript without blocking both on his blog and in his books. Create two JavaScript files. That’s it! function loadScript(url, callback){ var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }

Experimenting with Node.js If you see extra mouse cursors moving around: don’t worry, they’re part of the demo. You can always disable them if you want. I’ve written a follow-up on this article, in which I improved a lot of the code. If you’re using a browser that supports web sockets, you might see some extra mouse cursors moving around. This is an experiment I did to play around with Node.js and web sockets. Web socket server Using @miksago‘s node-websocket-server made it extremely easy to send and receive messages from a web socket. After including the node-websocket-server library and creating the server, I add some listeners to know when clients disconnect or send a message and make sure messages get sent to the other clients. I saved it as server.js, so starting the server is as simple as running node server.js. Receiving messages Now, in a regular javascript file — with some jQuery — I included into this page, I connect to the web socket like this: As you can see, this connects to the server we just started.

Scopes Loading... Scope is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in hierarchical structure which mimic the DOM structure of the application. Scopes can watch expressions and propagate events. Scope characteristics Scopes provide APIs ($watch) to observe model mutations.Scopes provide APIs ($apply) to propagate any model changes through the system into the view from outside of the "Angular realm" (controllers, services, Angular event handlers).Scopes can be nested to limit access to the properties of application components while providing access to shared model properties. Scope as Data-Model Scope is the glue between application controller and the view. Both controllers and directives have reference to the scope, but not to each other. Edit in Plunker <div ng-controller="MyController"> Your name: <input type="text" ng-model="username"><button ng-click='sayHello()'>greet</button><hr> {{greeting}} </div> Scope Hierarchies

Related: