Skip to content

Instantly share code, notes, and snippets.

@daniepetrov
daniepetrov / commands.md
Last active October 9, 2018 18:55
Several useful commands

On Windows

  • choco upgrade all - обновить все программы, установленные через chocolatey
  • choco list -lai - вывести все программы, установленные через chocolatey

On Mac

  • brew update - обновить homebrew
  • brew upgrade -  обновить пакеты homebrew
  • brew cask upgrade - обновить пакеты homebrew cask
@daniepetrov
daniepetrov / gist:8b40e3ea17c386b05791ae10e9236da1
Created July 4, 2018 07:41
Функции вспомогательные
// Функция полчения рандомного значения из интервала
const randomInteger = function (min, max) {
/*Пусть функция приняла аргументы 3 и 9, тогда
0.00001 * 3 <= minRandom <= 0.99999 * 3 = 0.00003 <= minRandom <= 2.99999
0.00001 * 9 <= maxRandom <= 0.99999 * 9 = 0.00009 <= maxRandom <= 8.9999
result = (8.99999 - 2.99999) = 6 + 3 = 9 - все ок
result = (0.00009 - 0.00003) = 0.00006 + 3 = 3.00006 - все ок
result = (8.99999 - 0.00003) = 8.99994 + 3 = 11.99994 (!) Ошибка, потому что Math.random() для обоих чисел одинаковый.
result = (0.00009 - 2.99999) = -2.99990 + 3 = 0.00001 (!) Ошибка, потому что Math.random() для обоих чисел одинаковый.
toggleSubMenu = menuItem => e => {
this.setState((state, props) => {
return {
...state,
[menuItem]: true
}
});
}
@daniepetrov
daniepetrov / gist:e312e0f63547675326b53433dafeaa01
Created August 19, 2018 20:24 — forked from vargeorge/gist:8b20488b7d7b6c101b4b
Show full path on OS X terminal / iTerm before the $ prompt
1. Edit ~/.bash_profile and add the following line to show full path before the $ prompt.
For example, as user@hostname:path/to/directory$
# show path before the $ prompt
export PS1='\u@\H:\w$ '
2. Save file and restart terminal or run source command
$ source ~/.bash_profile
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"baseUrl": ".",
"paths": {
"common/*": ["./src/common/*"],
"core/*": ["./src/core/*"]
}
},

The apt-get version of node is incredibly old, and installing a new copy is a bit of a runaround.

So here's how you can use NVM to quickly get a fresh copy of Node on your new Bash on Windows install

$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
// restart bash
$ nvm install node
function importAll(r) {
const images = {}
r.keys().map(item => {
images[item.replace('./', '')] = r(item)
return null
})
return images
}
const images = importAll(require.context('./images', false, /\.(png|jpe?g|svg)$/))
@daniepetrov
daniepetrov / package.json
Created July 8, 2019 15:41
Custom next.js server using Express
"scripts": {
"dev": "node server.js",
"start": "NODE_ENV=production node server.js",
"build": "next build",
}
const envConfig = {
development: {
SITE_URL: 'http://localhost:3000',
API_URL: 'http://localhost:3000/api'
},
testing: {
SITE_URL: 'https://test.site.com',
API_URL: 'https://api.test.site.com'
},
production: {
@daniepetrov
daniepetrov / .npmrc
Created November 1, 2019 12:52 — forked from ikaruce/.npmrc
.npmrc( proxy and strict-ssl setting )
proxy http://{proxy_server}:{proxy_port}
https-proxy http://{proxy_server}:{proxy_port}
strict-ssl=false