Skip to content

Instantly share code, notes, and snippets.

View zmts's full-sized avatar
🇺🇦
russian warship go f*uck yourself

Sasha Zmts 🇺🇦 zmts

🇺🇦
russian warship go f*uck yourself
View GitHub Profile
@zmts
zmts / json.md
Last active April 30, 2021 08:59
macOS quicklook-json
@zmts
zmts / reduce.md
Last active November 23, 2020 22:25
Reduce

Reduce

Objects array to object

const someObjectsArr = [{id: 1, name: 'alex'}, {id: 2, name: 'bob'}]
const objectsById = someObjectsArr.reduce((result, item) => {
  result[item.id] = item
  return result
}, {})
@zmts
zmts / auto indent in Webstorm Vue files.md
Created December 12, 2018 12:26
Remove auto indent in Webstorm Vue files

Remove auto indent in Webstorm Vue files

  • Settings -> Editor -> Code style -> HTML -> Other
  • Do not indent child of
  • Add 'script', 'style', 'template'
@zmts
zmts / bluebird.md
Created December 8, 2018 20:19
Issues with Bluebird.js debug mode in Express.js

Issues with Bluebird.js debug mode in Express.js(development mode)

http://bluebirdjs.com/docs/api/environment-variables.html

(node:48913) Warning: a promise was created in a handler at /Volumes/DATA/dev/supra-api-nodejs/node_modules/express/lib/router/index.js:317:13 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (/Volumes/DATA/dev/supra-api-nodejs/node_modules/bluebird/js/release/promise.js:79:10)

To disable this warnings add this to .env

@zmts
zmts / A Nuxt.js VPS production deployment.md
Created December 6, 2018 15:19 — forked from DreaMinder/A Nuxt.js VPS production deployment.md
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger then a landing page.

UPD: This manual now compatible with [email protected]. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

@zmts
zmts / start_end.md
Created December 4, 2018 16:02
Start/End day. Native JavaScript

Start/End day. Native JavaScript

new Date(new Date().setHours(0,0,0,0)).toISOString()
new Date(new Date().setHours(23,59,59,999)).toISOString()

How to Stop Nik Collection from crashing in Photoshop CC 2018

  1. Open some Nik Collection plug-in
  2. Open plug-in setting
  3. Click on 'AFTER CLICK OK' button
  4. Select 'Apply the filtered effect to the current layer'
@zmts
zmts / gist:b922a2719b6685da05ab4ecb90f290ad
Created October 30, 2018 15:37 — forked from samnang/gist:1759336
Install Bash version 4 on MacOS X
# Install Bash 4 using homebrew
brew install bash
# Or build it from source...
curl -O http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
tar xzf bash-4.2.tar.gz
cd bash-4.2
./configure --prefix=/usr/local/bin && make && sudo make install
# Add the new shell to the list of legit shells
@zmts
zmts / dom_nodejs.md
Last active November 24, 2018 13:59
Work with DOM in Node.js

Work with DOM in Node.js

const { JSDOM } = require('jsdom')

const htmlFragment = '<ul><li>one</li><li>two</li></ul>'
const jsDomFragment = JSDOM.fragment(htmlFragment)

jsDomFragment.querySelectorAll('li').forEach(li => {
 // make some operatons with DOM element, for example add some class
@zmts
zmts / base64-image-upload.js
Created October 25, 2018 12:33 — forked from madhums/base64-image-upload.js
save base64 encoded image
/*
* Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674
*/
var fs = require('fs');
// string generated by canvas.toDataURL()
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0"
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO"
+ "3gAAAABJRU5ErkJggg==";
// strip off the data: url prefix to get just the base64-encoded bytes