Skip to content

Instantly share code, notes, and snippets.

View barbagrigia's full-sized avatar

Vlad Trukhin barbagrigia

View GitHub Profile
@barbagrigia
barbagrigia / nginx + node setup.md
Created August 6, 2018 00:38 — forked from joemccann/nginx + node setup.md
Set up nginx as a reverse proxy to node.js.

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@mixin spacing($type: 'xl', $property: 'margin-top') {
#{$property}: map-get($margins, $type);
#{$property}: var(--margin-#{$type});
}
@barbagrigia
barbagrigia / app.js
Created July 30, 2018 22:49 — forked from koush/app.js
Make node.js express respect x-forwarded-proto on res.redirect
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
// use this to let express know it is on a encrypted connection
app.use(function(req, res, next) {
var schema = req.headers["x-forwarded-proto"];
if (schema === "https") {
@barbagrigia
barbagrigia / form.html
Created July 20, 2018 02:01 — forked from runspired/form.html
How to turn off password and email/username autocomplete.
<!--
<form autocomplete="off"> will turn off autocomplete for the form in most browsers
except for username/email/password fields
-->
<form autocomplete="off">
<!-- fake fields are a workaround for chrome/opera autofill getting the wrong fields -->
<input id="username" style="display:none" type="text" name="fakeusernameremembered">
<input id="password" style="display:none" type="password" name="fakepasswordremembered">

Step 1

Create a new directory.

$ mkdir micro-api
$ cd micro-api

Step 2

@barbagrigia
barbagrigia / sublime_text_patch.md
Created July 9, 2018 10:50 — forked from deyixtan/sublime_text_patch.md
Sublime Text Patching Guide

Automated Patching

Download slt.py python script (supports multiple build) from this repository.

Usage

python slt.py <"sublime_text file path">


Manual Patching

@barbagrigia
barbagrigia / node.js
Created May 21, 2018 09:24 — forked from anonymous/node.js
GET tv-programme in NODE.js / Our style
"use strict"
const request = require('request')
const fs = require('fs');
const zlib = require('zlib');
const opts = {
url: "https://iptvx.one/epg/epg.xml.gz",
headers: {
"User-Agent": "request"
}
@barbagrigia
barbagrigia / .md
Created April 20, 2018 22:44 — forked from iAdramelk/.md
Длинная телега про Бутстрап

Английская версия: https://evilmartians.com/chronicles/bootstrap-an-intervention

Вводная часть

У CSS есть несколько базовых проблем, которые позволяют очень быстро отстрелить себе ногу при неправильном использовании:

  1. Глобальный неймспейс – в серверном программировании все что написано в файле, в файле и остается. Все же что написано в css и js засирает глобальное пространство имен со всеми вытекающими. В JS эту проблему сейчас побороли всякими модульными системами, а вот с css сложнее. В идеальном мире это должен починить Shadow DOM и настоящие Web Components, но пока их нет единственный способ с этим бороться – следовать какой-то системе именований селекторов, которая по возможности уменьшает и исключает возможные конфликты.

  2. Каскадность – если на один элемент может сработать несколько правил, то они все и сработают последовательно. Если есть элемент h1.title, на него сработают все правила для тегов h1 и все правила для класса .title. Так как весь html состоит из тегов, то правил которые п

@barbagrigia
barbagrigia / InstanceMapReducerEnhancers.ts
Created April 17, 2018 23:08 — forked from zivni/InstanceMapReducerEnhancers.ts
Redux reducer enhancer to store specific control instance state by key
/**
* Use this reducer enhancer to store specific control instance state by key.
* The key will be resolved using the controlInstanceKeyResolver function parmeter which defaults to use the controlInstanceKey member of the action's meta object (i.e action.meta.controlInstanceKey)
* If the key is not a string then the action will be ignored and will not pass to the enhanched reducer.
* @param {function} reducer - the reducer to enhance
* @param {function} controlInstanceKeyResolver - an optional function to get the instance key from the action
*/
export function instanceMapReducerEnhancer(
reducer: Redux.Reducer,
controlInstanceKeyResolver: ((action) => string) = defaultKeyResolver) {
// in reusable feature instance
import createActions from '../reusable-feature/actions';
import selectors from './selectors';
import { createAction } from 'redux-actions';
const actions = createActions('INSTANCE_1', selectors);
actions['additionalAction'] = createAction(...);