Skip to content

Instantly share code, notes, and snippets.

View tomfun's full-sized avatar

Greg tomfun

View GitHub Profile
'use strict';
/*
If you are using docker, you must change CMD from
CMD node www-server.js
to
CMD ["node", "www-server.js"]
*/
require('http-shutdown').extend()
var http = require('http');
'use strict';
const signals = [
'SIGUSR1',
'SIGTERM',
'SIGINT',
'SIGPIPE',
'SIGHUP',
'SIGTERM',
'SIGINT',
@tomfun
tomfun / plural.js
Created August 23, 2016 12:31
JavaScript russian plural function
function getNoun(number, one, two, five) {
let n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) {
return five;
}
n %= 10;
if (n === 1) {
return one;
}
@tomfun
tomfun / 1.html
Created August 19, 2016 11:30
в случае еденичного (не кешируемого) запроса к дом, выигрывает одиночный вызов. такие ситуации на самом деле бывают очень часто, часто нужно сделать что-то единоразово в первую загрузку страницы. в остальном же, разумеется лучше использовать некий el для удобной работы.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<title>Test selectors</title>
<link href="style.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
@tomfun
tomfun / 1.js
Last active August 8, 2016 09:23
/*
```bash
npm i big-integer
```
*/
// const input = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,];
// const input = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,];
const input = [2, 3, 5, 7, 11, 13];
// const input = [2, 3, 5, 7, 11];
// const input = [2, 3, 5, 7];
@tomfun
tomfun / rfc.md
Last active July 7, 2016 12:16
how to be with frontend dependencies

Предложение к разработке новых продуктов внутри custom отдела

Глоссарий

bundle - пакет/библиотека содержащая в себе ресурсы и код для бекенда и фронтенда. у бандла обязательно есть версия, он ставится через пакетный менеджер.

бекенд - часть бизнес логики связанная с обработкой и хранением информации выполняемая на сервере.

фронтенд - часть бизнес логики завязанная на информацию предоставляющуся бекендом

@tomfun
tomfun / gen_new_client.sh
Last active June 7, 2023 14:38
how to: tls client nginx
#!/bin/sh
echo $1
echo "optional questions is: A challenge password, An optional company name, Enter Export Password, Enter Import Password"
mkdir -p client/$1
# Create the Client Key and CSR
# личный ключ клиента, только ему самому стоит его знать. если софт поддерживает пассфраз (как ниже), лучше его использовать.
openssl genrsa -des3 -out client/$1/key.key 2048
@tomfun
tomfun / nodejs-tcp-example.js
Last active February 25, 2016 18:01 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/**
env SERVER=1 node 3.js
http://joxi.ru/n2YYBPdcjnbK42
http://joxi.ru/DmB74bJFN8JoB2
*/
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
@tomfun
tomfun / geoFilterDiscretteCache.js
Last active February 22, 2016 14:04
rough location filter with same minimum/maximum lattitude/longitude range
"use strict";
const EARTH_RADIUS = 6371;
function degToRad(deg) {
return deg * Math.PI / 180;
}
/**
* @param {Number} distance km
* @returns {Number}
@tomfun
tomfun / visudo
Created September 14, 2015 09:53
allow sudo for user liberulo without password
liberulo ALL=NOPASSWD:ALL