Skip to content

Instantly share code, notes, and snippets.

@mordaha
mordaha / mt2
Last active August 29, 2015 14:24
turtles
--
-- Usage: mt2 length [width=3] [needEmptyStash=true]
--
local function refuel()
local fuelLevel = turtle.getFuelLevel()
if fuelLevel == "unlimited" or fuelLevel > 0 then
return
end
@mordaha
mordaha / nginx.conf
Created November 5, 2015 14:29 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
# 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;
#/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):
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:
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;
// 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 },
};
// mocks for testing react-native with jest
// Add:
// "setupFiles": [
// "./jest-setup.js"
// ],
// to your jest config.
import 'react-native';
//
@mordaha
mordaha / testEpic.js
Last active September 21, 2017 14:44
// @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 });
// @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 };
0x33a8035C9d940Ade14baA54A4028636108d52B5A