Skip to content

Instantly share code, notes, and snippets.

View andrevinsky's full-sized avatar

Andrew Revinsky andrevinsky

View GitHub Profile
@andrevinsky
andrevinsky / index.js
Created November 15, 2016 16:56 — forked from wtfil/index.js
injection of redux's dispatch in react-router's onEnter hook
/*
* common react, redux staff here
*/
import {Router, createRoutes} from 'react-router';
import createBrowserHistory from 'history/lib/createBrowserHistory';
import rawRoutes from './routes';
import store from './store';
function mixStoreToRoutes(routes) {
return routes && routes.map(route => ({
const alphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
const factors = [[38,1,4,4], [9,2,2,5], [36,3,8], [0,7,14], [38,1,1]];
export default ЛСДУ3ЙФЯУ9 = (name) => {
// check
if(typeof name !== 'string') return console.error('name is not a string');
if(name.length > 19) return console.error('name is longer then possible');
@skevy
skevy / gist:8a4ffc3cfdaf5fd68739
Last active February 4, 2017 04:59
Redux with reduced boilerplate

Note

I would recommend @acdlite's redux-actions over the methods suggested in this Gist.

The methods below can break hot-reloading and don't support Promise-based actions.

Even though 'redux-actions' still uses constants, I've come to terms with the fact that constants can be good, especially in bigger projects. You can reduce boilerplate in different places, as described in the redux docs here: http://gaearon.github.io/redux/docs/recipes/ReducingBoilerplate.html


@gaearon
gaearon / combining.js
Created June 3, 2015 18:03
Combining Stateless Stores
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@you-think-you-are-special
you-think-you-are-special / Singleton.js
Created February 18, 2015 10:52
ES6 Singleton example. Use: import Singleton from 'Singleton'; let instance = Singleton.instance;
'use strict';
/**
* Created by Alexander Litvinov
* Email: alexander@codeordie.ru
* May be freely distributed under the MIT license
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@gene1wood
gene1wood / batch-delete-gmail-emails.js
Last active July 19, 2024 19:59
A Google Apps Script script to bulk delete large amounts of email in Gmail while avoiding the error #793 which Gmail encounters normally
/*
This script, when used with Google Apps Scripts, will delete 400 emails and
can be triggered to run every few minutes without user interaction enabling you
to bulk delete email in Gmail without getting the #793 error from Gmail.
Google returns a maximum of 500 email threads in a single API call.
This script fetches 400 threads in case 500 threads is causing timeouts
Configure the search query in the code below to match the type of emails
you want to delete
@niksumeiko
niksumeiko / webstorm.watchers.handlebars.xml
Last active September 8, 2017 17:21
Handlebars templates watcher for WebStorm 6. Watcher complies Handlebars template file to a JavaScript file on every change.
<?xml version="1.0" encoding="UTF-8"?>
<TaskOptions>
<TaskOptions>
/*
* Compiled .js files are saved into generated '/compiled' folder.
*/
<option name="arguments" value="$FileDir$/$FileName$ -f $FileDir$/compiled/$FileNameWithoutExtension$.js" />
<option name="checkSyntaxErrors" value="false" />
<option name="description" value="Compiles .handlebars, .hbs templates into .js files" />
<option name="exitCodeBehavior" value="ERROR" />