Skip to content

Instantly share code, notes, and snippets.

View vzaidman's full-sized avatar

Vitali Zaidman vzaidman

View GitHub Profile
@vzaidman
vzaidman / jquery-ajax-blob-arraybuffer.js
Last active August 29, 2015 14:23 — forked from SaneMethod/jquery-ajax-blob-arraybuffer.js
The branch supports headers and fixed stack overflows in aborting and creating response.
/**
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
*
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
* ajax transport, preventing the standard transport from hogging the request), and the * indicates that
* potentially any request with any dataType might want to use the transports provided herein.
*
* Remember to specify 'processData:false' in the ajax options when attempting to send a blob or arraybuffer -
@vzaidman
vzaidman / currencyFormatList.json
Created November 23, 2015 13:52
LCID-to-currency-format-mapping as appears in sharepoint currency field
{
"1164": "؋123,456.00 (Afghanistan)",
"1052": "123,456.00 Lek (Albania)",
"5121": "د.ج.‏ 123,456.00 (Algeria)",
"11274": "$ 123,456.00 (Argentina)",
"1067": "123,456.00 ֏ (Armenia)",
"3081": "$123,456.00 (Australia)",
"3079": "123,456.00 € (Austria)",
"1068": "123,456.00 man. (Azerbaijan)",
"2092": "123,456.00 ман. (Azerbaijan)",
@vzaidman
vzaidman / 0_consts.js
Last active October 7, 2017 18:40
The Vanilla Redux Way
const INCREASE_BY = 'INCREASE_BY'
@vzaidman
vzaidman / 0_actions.js
Last active October 7, 2017 18:51
Equivalent Code
import { makeActionCreator } from 'redux-toolbelt'
export const increaseBy = makeActionCreator('INCREASE_BY')
@vzaidman
vzaidman / 0_constants.js
Last active October 7, 2017 18:41
Actions in Vanilla Redux
const INCREASE_BY = 'INCREASE_BY'
const DECREASE_BY = 'DECREASE_BY'
@vzaidman
vzaidman / actions.js
Last active October 7, 2017 18:36
Actions in redux toolbelt
import { makeActionCreator } from 'redux-toolbelt'
export const increaseBy = makeActionCreator('INCREASE_BY')
export const decreaseBy = makeActionCreator('DECREASE_BY')
@vzaidman
vzaidman / actions-execution.js
Last active October 7, 2017 18:44
Action Creators Execution
import { increaseBy } from './actions'
// The redux toolbelt action creator "increaseBy"
// contains TYPE- the type of the action it creates.
increaseBy.TYPE
// ⇒ 'INCREASE_BY'
increaseBy(10)
// ⇒ {
// The action creator increaseBy is imported
// instead of the action's name from consts.js
import { increaseBy, decreaseBy } from './actions'
const deafaultCount = 100
export default countReducer = (count = deafaultCount, { payload, type }) => {
switch(type){
// an action creator is used inside the reducer to get it's type
case increaseBy.TYPE: {
@vzaidman
vzaidman / reducers.js
Created October 7, 2017 18:52
test code for danni
import { makeReducer } from 'redux-toolbelt'
import { increaseBy, decreaseBy } from 'actions'
export const countReducer = makeReducer(
increaseBy, (count, { payload }) => count + payload,
decreaseBy, (count, { payload }) => count - payload,
{defaultState: 100}
)
@vzaidman
vzaidman / 0_actions.js
Last active October 7, 2017 19:15
Creation of an Async Action Creator
export const fetchTodos = makeAsyncActionCreator('FETCH_TODOS')