This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import Rxjs from 'rxjs'; | |
import { ajax } from 'rxjs/observable/dom/ajax'; | |
const { Observable } = Rxjs; | |
const retryActionAfterDelaySeconds = (action, error, delaySeconds = 5) => { | |
const retryAction = { ...action, retry: (action.retry || 0) + 1 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import Rxjs from 'rxjs'; | |
import { ajax } from 'rxjs/observable/dom/ajax'; | |
const { Observable } = Rxjs; | |
const retryActionOnError = (action, error, retryCount = 0, delay = 5000) => { | |
if (retryCount && action.retry && action.retry >= retryCount) { | |
return Observable.of({ ...action, payload: error, error: true }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mocks for testing react-native with jest | |
// Add: | |
// "setupFiles": [ | |
// "./jest-setup.js" | |
// ], | |
// to your jest config. | |
import 'react-native'; | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// converts array of items into object of items with item.field as a key | |
export const byField = (field, list) => { | |
if (list && list.length > 0) { | |
return list.reduce((acc, item) => { | |
const keys = acc.keys || []; | |
return { | |
...acc, | |
keys: [...keys, item[field]], | |
[item[field]]: { ...item }, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getFacilityInfo = idList => async (dispatch, getState) => { | |
// 0 | |
const facilityById = selectors.getFacilityById(getState()); | |
const facilityIdList = idList || facilityById.keys; | |
if (facilityIdList.length === 0) { | |
return; | |
} | |
let data; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShortUrlModelMixin(models.Model): | |
TOKEN_LEN = 5 | |
short_url = models.CharField(max_length=TOKEN_LEN, db_index=True, unique=True, editable=False) | |
class Meta: | |
abstract = True | |
def save(self, *args, **kwargs): | |
if not self.pk: | |
while 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python3 | |
# coding: utf8 | |
from __future__ import generators | |
import unittest | |
def fn(iterator1, iterator2): | |
# may be a little bit faster but not DRY if get_next() function calls will be replaced by function code | |
def get_next(iterator): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats | |
# Change example.com (server_name) to your website url | |
# Change /path/to/your/root to the correct value | |
server { | |
listen 80; | |
server_name example.com; | |
root /path/to/your/root; | |
index index.html; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Usage: mt2 length [width=3] [needEmptyStash=true] | |
-- | |
local function refuel() | |
local fuelLevel = turtle.getFuelLevel() | |
if fuelLevel == "unlimited" or fuelLevel > 0 then | |
return | |
end | |
NewerOlder