Skip to content

Instantly share code, notes, and snippets.

View DenisIzmaylov's full-sized avatar
🎯
Focusing

Denis Izmaylov DenisIzmaylov

🎯
Focusing
View GitHub Profile
@DenisIzmaylov
DenisIzmaylov / INDEX.md
Last active February 23, 2017 13:48
JavaScript Best Practicies
@DenisIzmaylov
DenisIzmaylov / skydns.yml
Created August 28, 2016 13:53
SkyDNS in Kubernetes example
apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "KubeDNS"
spec:
@DenisIzmaylov
DenisIzmaylov / gist:fd0d39a3d0b86e913192
Created November 10, 2015 15:58
Deploy to dokku from codeship.com

After migrating from heroku to dokku, we had to also chance codeship so we deploy to dokku. I followed the following steps to successfully deploy to dokku.

  1. Save the public key of the codeship project. It is found in Project Settings > General Settings.
  2. Copy the public key to a file /tmp/codeship_projectname.pub.
  3. Make sure when pasting, all the contents are in a single line and not multiple lines.
  4. Add the public key to dokku using the following command in console. Reference.
cat /tmp/codeship_projectname.pub | ssh root@yourdokkuinstance "sudo sshcommand acl-add dokku [description]"
@DenisIzmaylov
DenisIzmaylov / circular-json-stringify.js
Last active February 3, 2019 17:27
Circular JSON Stringify
function circularJSONStringify(obj) {
const cache = [];
const result = JSON.stringify(obj, (key, value) => {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
@DenisIzmaylov
DenisIzmaylov / NOTES.md
Last active November 15, 2019 07:39
Step By Step Guide to Configure a CoreOS Cluster From Scratch

Step By Step Guide to Configure a CoreOS Cluster From Scratch

This guide describes how to bootstrap new Production Core OS Cluster as High Availability Service in a 15 minutes with using etcd2, Fleet, Flannel, Confd, Nginx Balancer and Docker.

Content

@DenisIzmaylov
DenisIzmaylov / case-1.js
Last active December 16, 2019 01:41
Clean Code?
// Bad
books.forEach(book => {
if (book[title]) {
if (book[author]) {
console.log(book)
}
}
})
// Good
@DenisIzmaylov
DenisIzmaylov / INSTALLATION.md
Last active February 5, 2021 07:47
DigitalOcean Dokku: fresh install with Node.js Environment

DigitalOcean Dokku / Node.js Cloud Environment

Custom recipe to get full Node.js Cloud Environment in DigitalOcean Dokku droplet running from scratch. Yes. Your own Heroku for $5 per month.

I use this gist to keep track of the important configuration steps required to have a functioning system after fresh install.

When you have executed that's all step by step you will get a new working and stable system which is ready to host & serve your Node.js application and databases.

@DenisIzmaylov
DenisIzmaylov / i18n-data.json
Last active May 3, 2021 21:12
Easy i18n translation in your ES6 apps
{
"ru": {
"Your original english text": "Твой оригинальный русский текст"
}
}
@DenisIzmaylov
DenisIzmaylov / offset.js
Created July 24, 2015 09:12
Offset (with limit) calculation / validation
function offset(count, offset, limit) {
const finalOffset = Math.max(Math.min(count, offset), 0);
const remainedCount = Math.min(count, count - finalOffset);
const finalCount = (typeof limit === 'number') ? Math.min(limit, remainedCount) : remainedCount;
return { offset: finalOffset, finalCount: finalCount };
}
console.log(offset(10, 0)); // {"offset":0,"finalCount":10}
console.log(offset(10, 4)); // {"offset":4,"finalCount":6}
console.log(offset(10, 10)); // {"offset":10,"finalCount":0}