Skip to content

Instantly share code, notes, and snippets.

View tomfun's full-sized avatar

Greg tomfun

  • itrdev
  • ukraine
View GitHub Profile
@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
@tomfun
tomfun / classFunc.ts
Created February 25, 2020 11:41
Example of async generators with typescript
import { generateSequence } form './simple'
class NumberTransfrormer {
transform = async function*(gen: AsyncGenerator<number>) {
for await (const n of gen) {
yield n * 2;
}
}
}
@tomfun
tomfun / static-web-site-hosting.example.com--cloudformer.template.json
Created October 24, 2019 10:59
Cloudformation template for AWS S3 Bucket, CloudFront, private access for static hosting of angular frontend project (with client side routing). Every 403 request replies with index.html. For some reason it takes a lot of time after end to start work well
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters" : {
"MainDomainName": {
"Description": "public pretty FQDN for cloudfront",
"Type": "String",
"Default": "example.com"
},
"AcmCertificateArn": {
"Description": "AWS certificate ID for cloudfront",
@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 / 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;
}
}
'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',