Skip to content

Instantly share code, notes, and snippets.

View roman01la's full-sized avatar
🇺🇦

Roman Liutikov roman01la

🇺🇦
View GitHub Profile
@roman01la
roman01la / fetch.js
Last active August 29, 2015 14:07
Fetch.js
var fetch = function (url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function() {
if (xhr.status === 200) {
resolve(xhr);
" Make Vim more useful
set nocompatible
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
set clipboard=unnamed
" Enhance command-line completion
set wildmenu
" Allow cursor keys in insert mode
set esckeys
" Allow backspace in insert mode
set backspace=indent,eol,start
@roman01la
roman01la / nginx.conf
Last active May 18, 2019 07:00
Node.js Express Nginx
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
}
location ~ ^/(images/|scripts/|styles/|robots.txt|humans.txt|favicon.ico) {
root /your/app/public/folder;
@roman01la
roman01la / DB-class.js
Created December 9, 2014 19:15
ES7 async/await
class DB {
constructor (name) {
this.name = name;
this.collections = {};
this.async = function (callback, timeout) {
return new Promise((resolve, reject) => {
if (!callback) { return reject('Error!'); }
@roman01la
roman01la / api-proxy.js
Created December 22, 2014 12:03
Calling REST API with ES6 Proxies
var EndPoint = function (baseUrl) {
var request = function (type, url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(type, url);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.responseType = 'json';
module.exports = {
watch: true,
entry: [
__dirname + '/src/app'
],
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loaders: ['6to5-loader?optional=coreAliasing'] }
]
@roman01la
roman01la / main.jsx
Created January 26, 2015 01:39
Reactive React components using Most
import React from 'react';
import most from 'most';
let push = ({source: {sink}}, event) => {
try {
sink.event(event.type, event);
} catch (err) {
sink.error(event.type, err);
}
@roman01la
roman01la / react-flux-store.jsx
Created January 26, 2015 12:14
How to avoid storing application data within controller-view.
import React from 'react';
import AppActions from './actions';
import ItemsStore from './items-store';
let List = React.createClass({
componentDidMount() {
ItemsStore.addChangeListener(this.forceUpdate.bind(this));
},
@roman01la
roman01la / button.jsx
Created January 26, 2015 14:06
Mixin for handling DOM events via React assignment style using Most
import React from 'react';
import ReactDOMMostify from 'react-dom-mostify';
let Button = React.createClass({
mixins: [ReactDOMMostify],
componentWillMount() {
@roman01la
roman01la / main.es6
Created February 18, 2015 00:41
Property with a custom getter to get merged Set objects as a single Set
let obj = {
a: new Set([1,2,3]),
b: new Set([4,2,6,7]),
c: new Set([6,2,1,0])
};
Object.defineProperties(obj, {
all: {