Skip to content

Instantly share code, notes, and snippets.

@tomfun
tomfun / classFunc.ts
Created Feb 25, 2020
Example of async generators with typescript
View classFunc.ts
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 Oct 24, 2019
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
View static-web-site-hosting.example.com--cloudformer.template.json
{
"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 Aug 6, 2019
TypeScript HTTP Hello world example with docker compose & Basic Auth
View docker-compose.test.yml
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 Apr 18, 2019
Simple bash status updater - preloader
View preloader.sh
#!/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 Apr 17, 2019
Gitlab CI docker registry cleaner
View .gitlab-ci.yml
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 Feb 7, 2018
Рецепт плова по-домашнему
View плов.md

Рецепт Плова

Ингридиенты

  • Казан (3л)
  • Мясо (600г)
  • Рис (300г)
  • Лук
  • Морковь
  • Масло подсолнечное
  • Чеснок
  • Приправы, соль
@tomfun
tomfun / abstract-class-and-methods-example.ts
Created Jan 16, 2018
Example of how to use decorators with typescript implementation to do pretty syntax abstract classes
View abstract-class-and-methods-example.ts
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 Jul 24, 2017
my colored .bashrc
View .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
View gracefully-shutdown-node-http-server.js
'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');