background preloader

New folder

Facebook Twitter

Immutable types: understand their benefits and use them. There is a powerful and simple concept in programming that I think is really underused: Immutability Basically, an object is immutable if its state doesn’t change once the object has been created. Consequently, a class is immutable if its instances are immutable. There is one killer argument for using immutable objects: It dramatically simplifies concurrent programming. Think about it, why does writing proper multithreaded programming is a hard task?

Because it is hard to synchronize threads accesses to resources (objects or others OS things). Why it is hard to synchronize these accesses? Of course I simplify here so let’s dig a bit. A famous immutable class There is one famous immutable class: System.String. String str = “foofoo”; str.Replace(“foo”, “FOO”); …where we need to write instead: str = str.Replace(“foo”, “FOO”); Of course, doing so comes at the cost of creating multiple string objects in memory when doing some intensive string computation. String str1 = “foofoo”; Purity vs. Ruby Operators. Ruby supports a rich set of operators, as you'd expect from a modern language.

Most operators are actually method calls. For example, a + b is interpreted as a. +(b), where the + method in the object referred to by variable a is called with b as its argument. For each operator (+ - * / % ** & | ^ << >> && ||), there is a corresponding form of abbreviated assignment operator (+= -= etc.) Ruby Arithmetic Operators: Assume variable a holds 10 and variable b holds 20, then: Ruby Comparison Operators: Ruby Assignment Operators: Ruby Parallel Assignment: Ruby also supports the parallel assignment of variables. A = 10 b = 20 c = 30 may be more quickly declared using parallel assignment: a, b, c = 10, 20, 30 Parallel assignment is also useful for swapping the values held in two variables: a, b = b, c Ruby Bitwise Operators: Bitwise operator works on bits and perform bit by bit operation. Assume if a = 60; and b = 13; now in binary format they will be as follows: a = 0011 1100 b = 0000 1101 a&b = 0000 1100. A Quick (and Hopefully Painless) Ride Through Ruby (with Cartoon Foxes) :: Why's (Poignant) Guide to Ruby.

Yeah, these are the two. My asthma’s kickin’ in so I’ve got to go take a puff of medicated air just now. Be with you in a moment. I’m told that this chapter is best accompanied by a rag. Something you can mop your face with as the sweat pours off your face. Indeed, we’ll be racing through the whole language. Like striking every match in a box as quickly as can be done. 1. My conscience won’t let me call Ruby a computer language. But what do you call the language when your brain begins to think in that language? We can no longer truthfully call it a computer language. Read the following aloud to yourself. 5.times { print "Odelay! " In English sentences, punctuation (such as periods, exclamations, parentheses) are silent. Which is exactly what this small Ruby program does. Exit unless "restaurant".include? Here we’re doing a basic reality check.

Ever seen a programming language use question marks so effectively? ['toast', 'cheese', 'wine'].each { |food| print food.capitalize } 2. Variables 3. Atlassian Cloud. Atlassian Cloud. Underscore.js. Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. It’s the answer to the question: “If I sit down in front of a blank HTML page, and want to start being productive immediately, what do I need?” … and the tie to go along with jQuery's tux and Backbone's suspenders. Underscore provides over 100 functions that support both your favorite workaday functional helpers: map, filter, invoke — as well as more specialized goodies: function binding, javascript templating, creating quick indexes, deep equality testing, and so on.

The project is hosted on GitHub. You can report bugs and discuss features on the issues page, or on Freenode in the #documentcloud channel. Collection Functions (Arrays or Objects) _.each(list, iteratee, [context]) Alias: forEach Iterates over a list of elements, yielding each in turn to an iteratee function. If no match is found, or if list is empty, undefined will be returned. Build REST Resources with Laravel. In this part, we will begin to work with the REST interface. Creating a REST Api on Laravel isn’t very difficult.

All we need to keep in mind is that we’re dealing with EmberJS and that we don’t want to write a new adapter from scratch. As usual, you can find the source code for this part on github. Where to start? That is a hard question. Ember has its own workflow and logic. Let’s assume that we want to retrieve a user. If we want to retrieve a list of users, Ember would expect a json like this: The first one requires “user”, but the second one requires “users”. Ember.Inflector.inflector.irregular('formula', 'formulae'); EmberJs will make an assumption and request “formulas”. Before venturing deeper with Ember, a warning: Ember is difficult and powerful. If we complicate things a little bit and put some relations between the objects, for example we say that the user has some photos.

This is a one-to-many relation. I started with Ember to see how this framework wants the data. The Route. Chapter 7. JavaScript’s Syntax. Chapter 7. JavaScript’s Syntax An Overview of the Syntax This section gives you a quick impression of what JavaScript’s syntax looks like. The following are five fundamental kinds of values: Here are a few examples of basic syntax: // Two slashes start single-linecomments var x; // declaring a variable x = 3 + y; // assigning a value to the variable `x` foo(x, y); // calling function `foo` with parameters `x` and `y`obj.bar(3); // calling method `bar` of object `obj` // A conditional statementif (x === 0) { // Is `x` equal to zero? Note the two different uses of the equals sign: A single equals sign (=) is used to assign a value to a variable. Rules for Using Semicolons In this section, we examine how semicolons are used in JavaScript. Normally, statements are terminated by semicolons.

Semicolons are optional in JavaScript. No Semicolon After a Statement Ending with a Block The following statements are not terminated by semicolons if they end with a block: Note Tip Subsequent characters are: Atlassian Cloud. Atlassian Cloud. Mozilla's bind function question. Atlassian Cloud. JavaScript’s Apply, Call, and Bind Methods are Essential for JavaScript Professionals. Prerequisite: — Understand JavaScript’s “this” With Ease, and Master It. — JavaScript Objects — Understand JavaScript Closures (This is an intermediate to advanced topic) Duration: About 40 minutes.

Functions are objects in JavaScript, as you should know by now, if you have read any of the prerequisite articles. And as objects, functions have methods, including the powerful Apply, Call, and Bind methods. On the one hand, Apply and Call are nearly identical and are frequently used in JavaScript for borrowing methods and for setting the this value explicitly. On the other hand, we use Bind for setting the this value in methods and for currying functions. We will discuss every scenario in which we use these three methods in JavaScript. JavaScript’s Bind Method We use the Bind () method primarily to call a function with the this value set explicitly. Before we look at the code for this section, we should understand the this keyword in JavaScript. Bind () Allows us to Borrow Methods Final Words.

Top 50 - Product - Google Sheets. [JIRA] (CUS-1454) section width is not updated sometimes after number input - sunny - Hem.com Mail. Technology OKRs - Google Sheets. New Resource Allocation Gantt - Google Sheets. TalentPad.