Skip to content

Instantly share code, notes, and snippets.

View scaleflake's full-sized avatar
🏠
Working from home

scaleflake scaleflake

🏠
Working from home
View GitHub Profile
/// rpc.js
import { createAction } from 'redux-actions';
import { put, call, takeEvery } from 'redux-saga/effects';
export function buildRpcMethod(methodName, { customSelectors, customSagas }) {
const doRequest = (params) => {
const { data: { result, error } } = await axios.post('/rpc', {
jsonrpc: '2.0',
method: methodName,
params,
@scaleflake
scaleflake / FRONTEND_REACT.md
Created February 21, 2020 11:51
Frontend React

Web

http
rest
graphql

JavaScript

javascript
promise
async/await

React

react-router

Backend Node.js

Web

http
rest
graphql

Databases

mongodb
redis
postgresql
mysql

Math.getRandomInt = (min, max) => {
/* getRandomInt(11, 17) => output includes 11 and 17 */
return Math.floor(Math.random() * (max - min + 1)) + min;
};
// Vue.js Nurislam Node.js Artur Islam React_Na Artur
// books[0].authors[0].books[1].authors[1] === persons[2].books[0].authors[1];
function fetchBooks() {
return new Promise((resolve, reject) => {
/* jshint esversion: 6*/
/* jshint ignore:start */
let TIMES = 1000 * 1000 * 100;
console.time("(() => { }) instanceof Function");
for (let i = 0; i < TIMES; i++)
(() => {}) instanceof Function;
console.timeEnd("(() => { }) instanceof Function");
@scaleflake
scaleflake / redirectStdout.js
Last active September 22, 2018 16:21
Node.js stdout and stderr redirecting to file.
#!/usr/bin/env node
/* jshint esversion: 6*/
function redirectStdout(logFilePath) {
const fs = require('fs');
let access = fs.createWriteStream(logFilePath, {
'flags': 'a',
'encoding': null,