Skip to content

Instantly share code, notes, and snippets.

View tomfun's full-sized avatar

Greg tomfun

  • itrdev
  • ukraine
View GitHub Profile
@tomfun
tomfun / docker-compose.test.yml
Created August 6, 2019 13:40
TypeScript HTTP Hello world example with docker compose & Basic Auth
version: '3.7'
services:
test-node:
image: node:10
environment:
NODE_ENV: ${NODE_ENV:-dev}
PORT: 8080
working_dir: /home/node/app
volumes:
@tomfun
tomfun / preloader.sh
Created April 18, 2019 07:32
Simple bash status updater - preloader
#!/usr/bin/env bash
i=0
sp='/-\|'
n=${#sp}
STATUS='Created'
while [[ $STATUS == 'InProgress' || $STATUS == 'Created' ]]
do
sleep 1
@tomfun
tomfun / .gitlab-ci.yml
Created April 17, 2019 06:51
Gitlab CI docker registry cleaner
stages:
- clean
- build
- check
variables:
## docker image names inside the YML file to use
CI_REGISTRY_IMAGE_c: $CI_REGISTRY_IMAGE/dev:${CI_COMMIT_SHORT_SHA}
CI_REGISTRY_IMAGE_l: $CI_REGISTRY_IMAGE/dev:latest
CI_REGISTRY_IMAGE_i: services_${CI_BUILD_ID}_api_v2
@tomfun
tomfun / плов.md
Created February 7, 2018 20:12
Рецепт плова по-домашнему

Рецепт Плова

Ингридиенты

  • Казан (3л)
  • Мясо (600г)
  • Рис (300г)
  • Лук
  • Морковь
  • Масло подсолнечное
  • Чеснок
  • Приправы, соль
@tomfun
tomfun / abstract-class-and-methods-example.ts
Created January 16, 2018 16:51
Example of how to use decorators with typescript implementation to do pretty syntax abstract classes
function abstractMethod() {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
console.log("am(): called");
function abstractMethod() {
throw new TypeError('It is abstract method, this error should never be thrown')
}
abstractMethod.__abstractMethod = true;
descriptor.value = abstractMethod;
}
}
@tomfun
tomfun / .bashrc
Created July 24, 2017 20:02
my colored .bashrc
alias grep='grep --color=auto'
alias ls='ls --color=auto'
#PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '
git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; }
BRANCH='\033[00;33m$(git_branch)\033[0m'
PSC() { echo -ne "\[\033[${1:-0;38}m\]"; }
PR="1;36" # default color used in prompt is green
if [ "$(id -u)" = 0 ]; then
'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]>