Skip to content

Instantly share code, notes, and snippets.

View theKashey's full-sized avatar
🤔
what's happening?

Anton Korzunov theKashey

🤔
what's happening?
View GitHub Profile
@theKashey
theKashey / kill_john.js
Created March 29, 2018 21:45
rewiremock tests
import rewiremock from 'rewiremock';
import sinon from 'sinon';
rewiremock('./rocket-silo')
.with({ Launch: sinon.stub()});
rewiremock('./rockets')
.toBeUsed();
// ....
@theKashey
theKashey / dooms-day.test.js
Created March 29, 2018 21:50
advanced proxyquire
import rewiremock from 'rewiremock';
import sinon from 'sinon';
const Launch = sinon.stub()
const case = rewiremock.proxy('./dooms-day.js',{
'./rocket-silo': rewiremock.with({Launch}).toBeUsed(),
'doom-scheduler': rewiremock.by('mocked-doom-scheduler')
});
@theKashey
theKashey / import.js
Created March 29, 2018 21:56
advanced rewriremock
import rewiremock from 'rewiremock';
import sinon from 'sinon';
const Launch = sinon.stub()
// "require" module name
rewiremock(() => require('./rocket-silo')).with({
Launch: sinon.stub()
});
@theKashey
theKashey / Table.js
Created April 15, 2018 10:40
Table gDSFP
// base - https://github.com/reactjs/rfcs/pull/40#discussion_r180818891
import memoize from "lodash.memoize";
class Example {
getSortedData = memoize((list, sortFn) => list.slice().sort(sortFn))
getPagedData = memoize((list, page) => list.slice(page*10, (page+1)*10))
render() {
const sorted = this.getSortedData(this.props.data, this.props.sort);
const pages = this.getPagedData(sorted, this.props.page);
@theKashey
theKashey / TableFlow.js
Created April 15, 2018 11:02
Table gDSFP+flow
// base - https://github.com/reactjs/rfcs/pull/40#discussion_r180818891
import memoize from "lodash.memoize";
import flow from "lodash.flow";
class Example {
getSortedData = memoize((list, sortFn) => list.slice().sort(sortFn))
getPagedData = memoize((list, page) => list.slice(page*10, (page+1)*10))
render() {
const theFlow = flow(
@theKashey
theKashey / Table.js
Last active April 16, 2018 00:52
Table + MemoizedFlow
// base - https://github.com/reactjs/rfcs/pull/40#discussion_r180818891
import {MemoizedFlow} from "react-memoize";
class Example {
getSortedData = (list, sortFn) => list.slice().sort(sortFn)
getPagedData = (list, page) => list.slice(page*10, (page+1)*10))
render() {
return (
<MemoizedFlow
@theKashey
theKashey / Locky.js
Created May 7, 2018 04:17
Locky example
import Locky from 'react-locky';
import FocusLock from 'react-focus-lock';
const LockedModal = () => (
<Modal>
<Locky>
// it is important to manage focus, to not let "tab-out", as long you will be unable to "tab-in"
<FocusLock>
Hey! You can only click on this button!
<button> click me </button>
import Locky from 'react-locky';
const LockedModal = () => (
// lock only scroll
<Locky noDefault events={{scroll:true}}>
// we are locking scroll only. There is no need to focus lock
Hey! You can only scroll only here
<div> scroll me </div>
</Locky>
)
@theKashey
theKashey / 0_Unprocessed.c
Last active May 12, 2018 04:06
EDSS(Q.931 line), xState, 2005 year. C + Lua => C
#include "stdafx.h"
#include "l2_lapd.h"
@require "mpx.lua"
@include "../siglib/sys_signals.hh"
#include "../siglib/release_types.h"
//lua function RR(a)return a;end;
//lua function CL(a)return a;end;
#define CS_CALL_CLEAR 0
const lightMachine = Machine({
key: 'light',
initial: 'green',
states: {
green: {
on: {
TIMER: 'yellow',
}
},