(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5] | |
| func partition(v: Int[], left: Int, right: Int) -> Int { | |
| var i = left | |
| for j in (left + 1)..(right + 1) { | |
| if v[j] < v[left] { | |
| i += 1 | |
| (v[i], v[j]) = (v[j], v[i]) | |
| } | |
| } |
| console.highlight = function(text, sample) { | |
| var escapedSample = sample.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | |
| var reSample = new RegExp(escapedSample, 'g'); | |
| var args = ['']; | |
| var highlightedText = text.replace(reSample, function(match) { | |
| args.push('background-color: #ffc', 'background-color: none'); | |
| return '%c' + match + '%c'; | |
| }); | |
| args[0] = highlightedText; | |
| console.log.apply(console, args); |
Google Chrome Developers says:
The new WOFF 2.0 Web Font compression format offers a 30% average gain over WOFF 1.0 (up to 50%+ in some cases). WOFF 2.0 is available since Chrome 36 and Opera 23.
Some examples of file size differences: WOFF vs. WOFF2
| /* | |
| * Copyright (C) 2014 Chris Banes | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| pr () { | |
| git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 --force | |
| git checkout -b pr/$1 origin/pr/$1 | |
| git rebase master | |
| git checkout master | |
| git merge pr/$1 --ff-only | |
| } |
| var obj = { | |
| _step: 0 | |
| }; | |
| obj[Symbol.iterator] = function() { | |
| return { | |
| next: function() { | |
| return { value: ++obj._step, done: (obj._step === 4) }; | |
| } | |
| }; |
| # Simple Recommendation Engine in Ruby | |
| # Visit: http://otobrglez.opalab.com | |
| # Author: Oto Brglez <otobrglez@gmail.com> | |
| class Book < Struct.new(:title) | |
| def words | |
| @words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort | |
| end |
| // === Identifier rewriting for the ES6 module transpiler === | |
| // Proposal for minifier-friendly ES6 module transpiler output. | |
| // This is for cases where we don't require any existing module | |
| // format (AMD, CommonJS) and just want to emit a blackbox IIFE | |
| // that uses modules internally. Those cases are Ember's normal | |
| // global distribution (ember.min.js), as well as ES5 generated | |
| // by the upcoming ember-cli ES6 stack. | |
| // Do you all think this could work? |