Skip to content

Instantly share code, notes, and snippets.

@epicallan
epicallan / chai-expect.md
Created December 7, 2015 12:12 — forked from patocallaghan/chai-expect.md
Chai Expect Assertion library examples. From http://chaijs.com/api/bdd/ #chai #javascript #expect

##Chai Expect

##Language Chains

  • to
  • be
  • been
  • is
  • that
  • and
  • have
@epicallan
epicallan / RxJS-intro.js
Created June 3, 2016 18:23 — forked from ekantola/RxJS-intro.js
RxJS intro snippets
/*
* Observable
*/
var xs = Rx.Observable.range(0, 3)
xs.subscribe(log)
//=> 0
//=> 1
//=> 2
@epicallan
epicallan / _service.md
Created June 4, 2016 12:20 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@epicallan
epicallan / examples.md
Created June 5, 2016 08:35 — forked from mattpodwysocki/examples.md
RxJS Demos
@epicallan
epicallan / fp-notes.md
Last active June 28, 2016 06:38
Functional Programming Notes & concepts

First class functions

When we say functions are "first class", we mean they are just like everyone else. We can treat functions like any other data type and there is nothing particularly special about them - they may be stored in arrays, passed around, assigned to variables, what have you. (dr boolean)

PointFree Functions

Pointfree style means never having to say your data. Excuse me. It means functions that never mention the data upon which they operate.

Functor

@epicallan
epicallan / what-forces-layout.md
Created June 11, 2016 21:05 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@epicallan
epicallan / service-workers.md
Created August 24, 2016 16:58 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@epicallan
epicallan / accesslog2csv.pl
Created September 29, 2016 11:48 — forked from sepehr/accesslog2csv.pl
Perl: Convert Apache access log to CSV
#!/usr/bin/perl
#
# @file
# Converter tool, from Apache Common Log file to CSV.
#
# All code is released under the GNU General Public License.
# See COPYRIGHT.txt and LICENSE.txt.
#
@epicallan
epicallan / citrusB
Created April 4, 2017 14:17
Flatten nested array of n depth in Javascript, with tail recursion
// should be able to run in any ever green browser or nodejs version 5 and above
const flatten = (inputArray, accumulator) => {
inputArray.forEach((val) => {
if (Array.isArray(val)) {
flatten(val, accumulator); // tail recursion
} else {
accumulator.push(val);
}
});