Skip to content

Instantly share code, notes, and snippets.

View pibi's full-sized avatar
💭
I may be slow to respond.

pibi pibi

💭
I may be slow to respond.
View GitHub Profile
@pibi
pibi / clean_code.md
Created January 28, 2022 09:05 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

// let's see if the same happens using a common resolved promise
let promised = 42.1
// here we are promisify-ing the thenable
const staticPromise = (async () => {
return ++promised
})()
const asyncStatic = async () => {
return staticPromise
@pibi
pibi / child_process.js
Created May 11, 2016 14:33
Child Process survival test for node
setInterval(function () {
console.log(Date.now());
}, 1000);
c:\Web\senecatest>node api-gateway\api-gateway
2016-04-27T07:07:52.949Z lxb7br8lizf1/1461740872929/6208/- INFO hello Seneca/2
.0.1/lxb7br8lizf1/1461740872929/6208/-
2016-04-27T07:07:53.272Z lxb7br8lizf1/1461740872929/6208/- INFO client {type:am
qp,pin:role:*,cmd:*}
[ API-GW ] loading dw
[ API-GW ] loading pets
[ API-GW ] loading user
2016-04-27T07:08:02.339Z lxb7br8lizf1/1461740872929/6208/- INFO ready to start
Server running at: http://0.0.0.0:3000
Message: seneca: Action name:/home/architest/api-gateway/api/pets.js,plugin:define,role:seneca,seq:9,tag:undefined failed: [TIMEOUT:7xiawktwn82i/zspnz00obx9i:11111<1460985258575-1460985247174:undefined].
Code: act_execute
Details: { id: '7xiawktwn82i/zspnz00obx9i',
gate: true,
ungate: false,
desc: undefined,
cb: [Function: noop],
@pibi
pibi / index.html
Created April 23, 2015 18:48
Quantumui modal & slider
<!DOCTYPE html>
<html lang="en" ng-app="vtrack">
<head>
<!-- Bootstrap latest css[THIS IS REQUIRED IF YOU DON'T HAVE QUANTUMUI PRO SKIN]-->
<link rel="stylesheet" href="lib/bootstrap/bootstrap.min.css">
<!-- Light package of effect.css It is optional -->
<link rel="stylesheet" href="lib/quantumui/dist/css/addon/effect-light.min.css">
<!-- Latest compiled and minified CSS on head of your page -->
<link rel="stylesheet" href="lib/quantumui/dist/css/quantumui.min.css">
@pibi
pibi / Makefile
Last active December 15, 2015 17:38 — forked from utaal/Makefile
webserver: webserver.c libuv/uv.a http-parser/http_parser.o
gcc -I libuv/include \
-o webserver webserver.c \
libuv/libuv.a http-parser/http_parser.o \
    -lrt -lm -lpthread  
libuv/uv.a:
$(MAKE) -C libuv
@pibi
pibi / gist:1084298
Created July 15, 2011 08:10
GWAN C Servlet Pages Cache
$ curl http://192.168.11.150:8080/csp/httpdate
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html lang="en"><head><title>Benchmarking function calls (with CPU clock cycles)</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link href="imgs/style.css" rel="stylesheet" type="text/css"></head><body><h1>Benchmarking function calls (with CPU clock cycles)</h1><br>Linux clib calls: Fri, 15 Jul 2011 08:03:10 GMT<br><br><table class="clean" width=160px><tr><th>function</th><th>time</th></tr><tr class="d0"><td>Linux clib calls</td><td>1323</td></tr><tr class="d1"><td>Linux clib calls</td><td>1336</td></tr><tr class="d0"><td>Linux clib calls</td><td>1336</td></tr><tr class="d1"><td>Linux clib calls</td><td>1301</td></tr><tr class="d0"><td>Linux clib calls</td><td>1301</td></tr><tr class="d1"><td>Linux clib calls</td><td>1308</td></tr><tr class="d0"><td>Linux clib calls</td><td>1301</td></tr><tr class="d1"><td>Linux clib calls</td><td>1301</td></tr><tr class="d0"><td>Linux clib calls</td><td
@pibi
pibi / LICENSE
Created July 12, 2011 10:54
Embedding V8 on GWAN
Copyright (c) 2011 pibi, http://pianobit.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@pibi
pibi / bench.js
Created May 26, 2011 21:29
Zen vs Stack vs Stack2
var STACKSIZE=1;
var zen=require('zen');
var stack=require('stack');
var stack2=require('stack2');
var mod=function(a,b,next){next();}
var middles=[];
for (var i=0;i<STACKSIZE;i++){
middles.push(mod);