Skip to content

Instantly share code, notes, and snippets.

View voronianski's full-sized avatar

Dmytro Voronianski voronianski

View GitHub Profile
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@voronianski
voronianski / render.js
Created August 19, 2013 09:30
Simple template rendering
var render = function (page, data) {
var rendered = page;
Object.keys(data).forEach(function(key) {
if (!data[key]) {
return;
}
rendered = rendered.replace(new RegExp('\\{'+key+'\\}', 'g'), data[key].replace(/</g, '&lt;').replace(/>/g, '&gt;'));
});
return rendered;
function interval(func, wait, times){
var interv = function(w, t){
return function(){
if(typeof t === "undefined" || t-- > 0){
setTimeout(interv, w);
try{
func.call(null);
}
catch(e){
t = 0;
@voronianski
voronianski / decodeURI.lua
Created December 7, 2013 18:13
decode uri function (similar to javascript decodeURI)
function decodeURI (str)
local function _ (hex)
return string.char(tonumber(hex, 16))
end
str = string.gsub(str, '%%(%x%x)', _)
return str
end
/**
* POST to create a new user.
*/
exports.create = function *(){
var body = yield parse(this);
// password
var pass = body.password;
assert(pass, 400, 'password is required');
@voronianski
voronianski / augment.js
Created March 9, 2014 14:09
Smallest and fastest classical JavaScript inheritance pattern.
(function (global, factory) {
if (typeof define === "function" && define.amd) define(factory);
else if (typeof module === "object") module.exports = factory();
else global.augment = factory();
}(this, function () {
"use strict";
var Factory = function () {};
var slice = Array.prototype.slice;
/*1397564784,180664133,JIT Construction: v1206444,en_US*/
/**
* Copyright Facebook Inc.
*
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
try {window.FB || (function(window) {
var self = window, document = window.document;
@voronianski
voronianski / content-length-size.md
Last active January 19, 2021 01:08
What happens if you serve content with a different length than the Content-Length header?

@jakearchibald done a bit of research around this:

###Loading a page with Content-Length < actual content length

  • Chrome: Truncated content - no indication of error
  • Firefox: Truncated content - no indication of error
  • Safari: Truncated content - no indication of error
  • IE: Truncated content - no indication of error

###Loading a page with Content-Length > actual content length

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.