Skip to content

Instantly share code, notes, and snippets.

View sergeysova's full-sized avatar
👋
Open to network

Sova sergeysova

👋
Open to network
View GitHub Profile
@sergeysova
sergeysova / Collection.js
Created November 7, 2015 00:03
JS ActiveRecord
import Dispatcher, {EventObject} from "Dispatcher";
/**
* Items collection
*/
export default class Collection {
static E_ADD = 'add';
static E_REMOVE = 'remove';
static E_CHANGE = 'change';
@sergeysova
sergeysova / random.js
Created November 17, 2015 15:07 — forked from kerimdzhanov/random.js
Javascript — random number in a specific range
// MIT License
// @return {float} a random number between min and max
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
// @return {integer} a random int between min and max
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
window.downloadFile = function (sUrl) {
//iOS devices do not support downloading. We have to inform user about this.
if (/(iP)/g.test(navigator.userAgent)) {
alert('Your device does not support files downloading. Please try again in desktop browser.');
return false;
}
//If in Chrome or Safari - download via virtual link click
if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
@sergeysova
sergeysova / index.html
Last active December 15, 2015 09:24
array: .native vs .forEach vs .map #jsbench #jsperf (http://jsbench.github.io/#6107e83d8fcfe0bbb37a) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>array: .native vs .forEach vs .map #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
var button = document.createElement('button');
button.onclick = function(e) { alert('clicked button', e); }
var clickEvent = new Event('click');
button.dispatchEvent(clickEvent);
@sergeysova
sergeysova / index.html
Last active December 16, 2015 13:26
Compare key value and sha1 #jsbench #jsperf (http://jsbench.github.io/#0e7bd7e5fef502f90cfa) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Compare key value and sha1 #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>

Nginx example configuration

HTTP

To create one host nginx for static site:

server {
  listen 80;
  server_name www.yourhost.com yourhost.com;
function getPath(el) {
var path = el.nodeName;
if (el.parentNode && el.parentNode.nodeName !== 'BODY') {
path = getPath(el.parentNode) + ' ' + path;
}
return path.toLowerCase();
}
/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wno-extra-tokens -Wtrigraphs -fdollars-in-identifiers -C file.js
@sergeysova
sergeysova / route-transition.js
Created March 3, 2016 11:13
React Router Transition
import React from 'react';
import {TransitionMotion, spring} from 'react-motion';
const willEnter = children => ({children, opacity: spring(0), translate: spring(999)});
const willLeave = (key, {children}) => ({children, opacity: spring(0), translate: spring(-999)});
const getStyles = (children, pathname) => ({[pathname]: {children, opacity: spring(1), translate: spring(0)}});
export default function RouteTransition({children, pathname}) {
return (
<TransitionMotion