Skip to content

Instantly share code, notes, and snippets.

View TheSirop's full-sized avatar
:octocat:
New Conky Project in GitHub

Sergei Anishchenko TheSirop

:octocat:
New Conky Project in GitHub
View GitHub Profile
@TheSirop
TheSirop / gist:04fd135eec8407c2127c72dcfedddfa9
Created November 2, 2016 14:24 — forked from learncodeacademy/gist:ebba574fc3f438c851ae
Nginx Node Frontend / Load Balancer / Static Assets Caching
upstream project {
server 22.22.22.2:3000;
server 22.22.22.3:3000;
server 22.22.22.5:3000;
}
server {
listen 80;
location / {
@TheSirop
TheSirop / webpack.config.js
Created November 2, 2016 14:25 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
module.exports = {
"parser": "babel-eslint",
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
@TheSirop
TheSirop / atom.config.txt
Last active October 20, 2017 10:29
Atom configuration
Atom packages:
- language-babel
- autocomplete-modules
- file-icons
- linter
- prettier-atom
- language-gitignore
- editorconfig
- pigments
- highlight-selected
function getUserAccount() {
return axios.get('/user/12345');
}
function getUserPermissions() {
return axios.get('/user/12345/permissions');
}
axios.all([getUserAccount(), getUserPermissions()])
.then(axios.spread(function (acct, perms) {
@TheSirop
TheSirop / axios_post_order.js
Last active March 24, 2017 15:13
Сохранение заказа и отправка данных в 1С через API
import config from 'config';
import Order from '../models/order';
import Cart from '../models/cart';
const axios = require('axios');
export async function postCheckout(req, res, next) {
if (!req.session.cart) {
return res.redirect('/cart');
@TheSirop
TheSirop / Task_1.js
Created March 24, 2017 14:51
Задача #1
// Имеем URL вида:
// http://127.0.0.1:3000/products/dalnomer_lazernyj_bosch_dle
// Данный урл является ключом в JSON который через POST отправляется в 1С
"cart": {
"totalPrice": 1900,
"totalQty": 1,
"items": {
"dalnomer_lazernyj_bosch_dle": {
"price": 1900,
@TheSirop
TheSirop / Task_2.js
Created March 24, 2017 15:06
Объединение одинаковых полей в коллекции MongoDB (ORM mongoose)
// Имеется коллекция Prices.
{
"slug": "0u-00000124",
"createdAt": "2017-03-23T14:05:11.934Z",
"price": 384
},
{
"slug": "0u-00000125",
"createdAt": "2017-03-23T14:06:11.934Z",
"price": 129
upstream project {
server 22.22.22.2:3000;
server 22.22.22.3:3000;
server 22.22.22.5:3000;
}
server {
listen 80;
location / {
@TheSirop
TheSirop / nodemailer_transport_sendgrid.js
Created October 13, 2017 00:01
Nodemailer SendGrid
const nodemailer = require('nodemailer');
// Run nodemailer
export function sendEmail(req, res) {
const output = `
<p>Вы получили заявку с сайта</p>
<h3>Контактные данные:</h3>
<ul>
<li>Имя: ${req.body.name}</li>
<li>Компания: ${req.body.company}</li>