Skip to content

Instantly share code, notes, and snippets.

@kharandziuk
kharandziuk / main.tf
Created October 16, 2019 10:51
docker provider with terraform locally
provider "docker" {
host = "unix:///var/run/docker.sock"
}
resource "docker_image" "ubuntu" {
name = "ubuntu:precise"
}
resource "docker_image" "nginx" {
name = "nginx:latest"
$ pytest -s
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.7.4, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
Django settings: dproject.settings (from ini file)
rootdir: /Users/kharandziuk/Projects/django-long-query, inifile: pytest.ini
plugins: django-3.5.1, django-webtest-1.9.7
collected 2 items
users/tests.py ..
@kharandziuk
kharandziuk / pipe.js
Created September 4, 2019 10:35
all messages from one queue to another in amqp
const DLQ_NAME = 'DeadLetterQueue'
const EXCHANGE_NAME = 'MainExchange'
const delay = (ms) => new Promise((resolve) => {
setTimeout(resolve, ms)
})
const delayWithRefresh = (ms) => {
let flag = false
@kharandziuk
kharandziuk / index.js
Last active September 5, 2019 13:23
PM2 programmatically with logs
const pm2 = require('pm2')
const pino = require('pino')
const logger = pino()
pm2.connect(true, function(err) {
if (err) {
logger.fatal(err)
process.exit(2);
}
pm2.start([
@kharandziuk
kharandziuk / gulpfile.js
Created August 5, 2019 11:49
gulp4 and prompt example
const gulp = require('gulp');
const util = require('util')
const prompt = require('prompt')
const schema = {
properties: {
password: {
hidden: true
}
}
@kharandziuk
kharandziuk / sequence.js
Created July 5, 2019 15:41
a solution for a sequence of streams
const stream = require('stream');
const process = require('process')
const { promisify } = require('util')
const fromList = (lst) => new stream.Readable({
read() {
if (lst.length) {
this.push(String(lst.shift()))
} else {
this.push(null)
function isBalanced(str) {
const stack = str.split('')
const compare = []
while(stack.length) {
//console.log(stack, compare)
let current = stack.shift();
if(compare.length == 0) {
compare.push(current)
const streamAsPromise = (readable) => {
const result = []
const w = new Writable({
write(chunk, encoding, callback) {·
result.push(chunk)
callback()
}
})
readable.pipe(w)
return new Promise((resolve, reject) => {
@kharandziuk
kharandziuk / express-supertest-hello-world.js
Created November 28, 2018 14:11
express-supertest-hello-world gist
const S = require('supertest')
const { expect } = require('chai')
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
//app.listen(port, () => console.log(`Example app listening on port ${port}!`))
describe('server', () => {
@kharandziuk
kharandziuk / mixins.js
Created November 23, 2018 13:35
Show some properties of javascript mixins
let HiMixin = Base => class extends Base {
hi () {
console.log('hi')
}
}
let ByeMixin = Base => class extends Base {
bye () {
console.log('bye')
}