function varTest() {
var x = 31;
if (true) {
var x = 71; // same variable!
console.log(x); // 71
}
console.log(x); // 71
}
// http://paqmind.com/posts/fluent-api-debunked/ | |
var R = require("ramda"); | |
var sales = [ | |
{id: 1, price: "500"}, | |
{id: 2, price: "1500"}, | |
{id: 3, price: "750"}, | |
{id: 4, price: "1750"}, | |
{id: 5, price: "150"}, |
exports.adjustBy = curry((pred, adjustFn, array) => { | |
let i = findIndex(pred, array); | |
if (i >= 0) { | |
return adjust(adjustFn, i, array); | |
} else { | |
return array; | |
} | |
}); | |
map(when(whereEq({id: "1"}), flip(merge)({name: "FOO"}))); |
import {filter, head, range} from "ramda"; | |
const TOWERS_COUNT = 3; | |
// Int -> Int -> Int | |
let getIntermidiateDest = (from, to) => head(range(0, TOWERS_COUNT).filter(i => i != from & i != to)); | |
// Int -> Int -> Int -> {a} | |
function *hanoi(n, from, to) { |
import Data.Char | |
-- Double the value of every second digit beginning from the right. | |
-- Add the digits of the doubled values and the undoubled digits from the original number | |
-- Calculate the remainder when the sum is divided by 10 | |
-- If the result equals 0, then the number is valid. | |
-- String -> [Int] |
var flatMatrix = matrix => matrix.reduce((a, b) => a.concat(b)); | |
var isListEmpty = list => list.filter(i => i === 1).length === 0; | |
var emptifyByIndexes = (list, indexes) => list.map((item, index) => indexes.indexOf(index) >=0 ? 0 : item); | |
var getFirstNonZeroElementIndex = list => { | |
for (var key in list) { | |
if (list[key] === 1) return Number(key); | |
} | |
}; |
// How it works: https://youtu.be/IbfsvI6dh4U | |
@textFontSize: 20px; | |
@lineHeight: 1.5rem; | |
// Set up font size and line-height | |
html { | |
font-size: @textFontSize; | |
} |
Based on https://msdn.microsoft.com/en-us/library/ee658094.aspx#Interoperability
Conceptual integrity defines the consistency and coherence of the overall design. This includes the way that components or modules are designed, as well as factors such as coding style and variable naming.
Can be achived by
- Design Style Guides
The book i'm reading is from 2010, so i want to keep only things that are important now, in 2015, and add some comments about the current situation with having ES2015 and modern libs in place.
Every time a <script>
tag is encountered, the page must stop and wait for the code to download (if external)
and execute before continuing to process the rest of the page.
JavaScript’s tendency to block browser processes, both HTTP requests and UI updates,
// handler for click event | |
var h1 = $("h6").bind("click", function () { | |
console.log('click handler'); | |
}); | |
// handler for click event with namespace | |
var h2 = $("h6").bind("click.namespace", function () { | |
console.log('click handler with namespace'); | |
}); | |
// click event result: |