Skip to content

Instantly share code, notes, and snippets.

@odyss009
odyss009 / indent.js
Created September 22, 2017 12:26
indent
//indent rule
return Promise.all(keys.map(key => scan(key)))
.then(result => [].concat(...result))
.then(expireKeys.bind(null, client));
//beauiful
return Promise.all(keys.map(key => scan(key)))
.then(result => [].concat(...result))
.then(expireKeys.bind(null, client));
@odyss009
odyss009 / function.js
Created March 1, 2017 15:56
filterReducer, mapReducer, composeReducers, transducer
// Count the iterations
let count = 0;
const isMultipleOf3Or5 = n => (n % 3 === 0 || n % 5 === 0);
// Reducer functions can be composed if we abstract the differences.
// The filter's predicate function will need to be abstracted
// and curried in for function composition:
const filterReducer = predicate => reducer => (
acc, item
@odyss009
odyss009 / ruby-io-multi.ruby
Last active December 13, 2016 09:00
ruby I/O multi test
# sinatra
require 'sinatra'
require 'json'
get '/' do
'Hello sinatra'
end
get '/api/v2/users/:user_id/subscriptions' do
user_id = params['user_id']
@odyss009
odyss009 / ruby-multi-test.ruby
Last active December 13, 2016 08:14
ruby multi thread 및 process test(cpu intensive job)
# test 대상 class
class Mailer
def self.deliver(&block)
mail = MailBuilder.new(&block).mail
mail.send_mail
end
Mail = Struct.new(:from, :to, :subject, :body) do
def send_mail
@odyss009
odyss009 / what-forces-layout.md
Last active September 21, 2015 05:50 — 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()
@odyss009
odyss009 / gist:fe3b9a6ad27863121f88
Created June 25, 2015 20:36
npm outdated check
npm outdated --depth=0 | grep -v Package | awk '{print $1}' | xargs -I% npm install %@latest --save-dev
/**
* Object descriptor
**/
var a = {
prop1 : 14
}
var descriptorObj1 = Object.getOwnPropertyDescriptor(a, 'prop1');

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@odyss009
odyss009 / 00.md
Created March 16, 2014 19:11 — forked from hayajo/00.md