Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dominykas's full-sized avatar

Dominykas Blyžė dominykas

View GitHub Profile
function processOneStuff(whateverFunction) {
return function (oneStuff, cb) {
whateverFunction(oneStuff, function (err, res) {
cb(err, res);
})
}
}
module.exports = function processManyStuffs(manyStuffs, someFunction, cb) {
function processOneVideo(video, cb) {
if(doesVariableHaveNoValue(video.videotitle)){
video.videotitle="Product video";
}
/* -----+++++-----+++++----- ZALGO TERRITORY -----+++++-----+++++----- */
if(doesVariableHaveNoValue(video.videothumb)){
video.videothumb= urlCorrector.convertUrl(video.videourl,function(err,res){
video.videourl=res;
cb(err);
});
@dominykas
dominykas / test.js
Created July 17, 2015 13:46
hapijs/h2o2 issue #13
var Hapi = require("hapi");
var server = new Hapi.Server();
server.connection({port:23232});
server.route({
method: "GET",
path: "/",
handler: {
proxy: {
@dominykas
dominykas / keybase.md
Created April 2, 2015 09:18
keybase.md

Keybase proof

I hereby claim:

  • I am dominykas on github.
  • I am dominykas (https://keybase.io/dominykas) on keybase.
  • I have a public key whose fingerprint is 1ABD BCEC 5DE0 28E2 207A C34B F8B9 F899 13C1 6B12

To claim this, I am signing this object:

@dominykas
dominykas / error.sh
Last active August 29, 2015 14:18
shelljs exec (sync) problems
#!/usr/bin/env bash
cd /tmp
git init tmp
cd tmp
git rev-parse --abbrev-ref HEAD
exit 1

The problem I've been facing lately is decisions. There is too little time to make good decisions. And working a startup, there's too few team mates that can help you make these decisions.

It is impossible to understand the tradeoffs completely. It is also hard to understand them objectively. Hunches and wants get lots of help from confirmation bias. I'm not even sure that choosing node, choosing 12factors, choosing microservices-ish things are objectively good. I sure as hell have wondered if node is the right decision: https://speakerdeck.com/dymonaz/node-dot-js-the-smallprint - as with everything else, I guess.

I want a set of decisions, a starter kit, if you will, that will not hinder your progress in the future. This probably boils down to being able to reverse your decisions. Some might be easy - CentOS or Debian. VM or container. But Mongo vs MySQL? Is there an easy way out of it? The typical advice is to go with what you already know. But if you do - you will not get out of your comfort zone and you

@dominykas
dominykas / crawler-parser-proxy.js
Last active August 29, 2015 14:10
Parsing crawler proxy with Hapi
var _ = require("lodash"),
Hapi = require("hapi"),
Nipple = require("nipple"),
jsdom = require("jsdom"),
Url = require("url");
var parsers = {
"default": function (url, document, cb) {
cb(null, {
title: document.title,
describe('route specificity', function () {
var server = new Hapi.Server();
var reflectRoutePath = function (request, reply) {
reply(request.route.path)
};
server.route({ method: 'GET', path: '/products1/search', config: { handler: reflectRoutePath } });
server.route({ method: 'GET', path: '/products1/search/{path*}', config: { handler: reflectRoutePath } });
server.route({
@dominykas
dominykas / pattern1.js
Last active August 29, 2015 14:05
You need the value of the first promise at the end of the chain - what do you do?
var p1value;
var final = promise1
.then(function (r) {
p1value = r;
return getPromise2(r);
})
.then(function (p2value) {
return finalResult(p1Value, p2Value)
});