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.

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. Use functional programming techniques to write elegant JavaScript Introduction Functional programming languages have been in academia for quite some time, but historically they do not have extensive tools and libraries available. With the advent of Haskell in the .NET platform, functional programming is becoming more popular. Some traditional programming languages, such as C++ and JavaScript, import constructs and features from functional programming. In many cases, repetitive code in JavaScript leads to clumsy coding. Because functional programming encompasses a very different way of composing programs, programmers who are used to the imperative paradigm can find it difficult to learn. Functional programming concepts, including anonymous functions, different ways to call functions, and how to pass functions as arguments to other functions. Back to top Functional programming concepts Many developers know how to code in languages where you specify the method of solving a problem by describing "how." Listing 1. Listing 2. Anonymous functions Listing 3. Or

Azkaban | LinkedIn Data Team A batch job scheduler can be seen as a combination of the cron and make Unix utilities combined with a friendly UI. Batch jobs need to be scheduled to run periodically. They also typically have intricate dependency chains—for example, dependencies on various data extraction processes or previous steps. A good batch workflow system allows a program to be built out of small reusable pieces that need not know about one another. Why was it made? Schedulers are readily available (both open source and commercial), but tend to be extremely unfriendly to work with—they are basically bad graphical user interfaces grafted onto 20-year old command-line clients. State of the project We have been using Azkaban internally at LinkedIn for since early 2009, and have several hundred jobs running in it, mostly Hadoop jobs or ETL of some type. Any patches, bug reports, or feature ideas are quite welcome.

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

CoffeeScript Functional programming with JavaScript | Minko Gechev's blog This article is about the functional concepts of JavaScript. Some of them are built-in the languages, others extra implemented but all of them are very common for purely functional languages like Haskell. First I want to tell what I mean with the term purely functional language. Concurrency. I hope these arguments are enough for you to look at the next sections. Anonymous functions It seems that the functional programming becomes more and more popular. $(document).ready(function () { //do some stuff }); The function passed to $(document).ready is exactly an anonymous function. More about passing functions in the next section… High-order functions High-order functions are functions which accepts functions as arguments or returns functions. function animate(property, duration, endCallback) { //Animation here... if (typeof endCallback === 'function') { endCallback.apply(null); } } animate('background-color', 5000, function () { console.log('Animation finished'); }); Imagine we have this case:

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.

PHPUnit Support After you set up PHPUnit, Web IDE greatly helps you to run your tests. Namely, to quickly create test run configuration: Right-click the desired target: a directory or a PHP file in the Project view, or a test class/method name in the code editorChoose Run<name> to start or Create<name> to specify additional parameters That’s it! XML configuration file Advanced settings can be specified through PHPUnit configuration file. Test groups A test can be tagged as belonging to one or more groups using the @group annotation as shown below. The test is run if none of the specified groups is excluded and at least one group is included. Run/Debug Tests Before you execute tests, please set up PHP home directory (one that contains PHP executable) in Settings | PHP. Test results window You can easily navigate from tests results tree and stack trace to the corresponding source code location. When debugging your tests you get all the features, such as watches, expressions evaluation, etc. Test with pleasure!

Related: