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.js
Created June 14, 2015 14:28
My React routes implementation by Oct '14
var Router = require('director').Router;
var Dispatcher = require('flux2/dispatcher');
var React = require('react');
var Content = require('./components/content');
var routes = require('./routes');
React.render(
React.createElement(Content, null),
document.getElementById('content')
);
@DenisIzmaylov
DenisIzmaylov / INSTALLATION.md
Last active April 27, 2023 15:44
OS X 10.11 El Capitan: fresh install with Node.js (io.js) Developer Environment

OS X 10.11 (El Capitan) / Node.js and io.js Developer Environment

Custom recipe to get OS X 10.11 El Capitan running from scratch with useful applications and Node.js Developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after fresh install.

Content

@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}
@DenisIzmaylov
DenisIzmaylov / INSTALLATION.md
Last active November 9, 2024 13:39
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 / INDEX.md
Last active February 23, 2017 13:48
JavaScript Best Practicies
@DenisIzmaylov
DenisIzmaylov / RECIPE.md
Last active September 12, 2016 22:39
How to update io.js to Node 4 and npm 3

How to update io.js to Node 4 and npm 3

The recipe described below works fine in OS X El Capitan and Homebrew tool.

Fine tested with [email protected] and [email protected].

io.js -> Node.js 4

brew unlink iojs
@DenisIzmaylov
DenisIzmaylov / es-code-style.md
Last active June 10, 2016 22:38
ES Code Style

Code Style

Use Airbnb Code Style as Basic rules. This document only override some given rules.

TODO:

  • Make it as shareable cards (Twitter, FB, LinkedIn, VK)
  • Explain the reasons
  • Allow to discuss for every rule
@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 / 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 / OOP-and-FP.md
Last active November 6, 2016 12:08
Key difference between OOP and FP in JavaScript

Key difference between OOP and FP in JavaScript

In OOP we have mixed instance data and class functions:

class Animal { 
  constructor(name) {
    this.name = name;
  }
 speak() {