Skip to content

Instantly share code, notes, and snippets.

View isavch's full-sized avatar

Ivan Savchenko isavch

View GitHub Profile
chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=Inversion%20of%20Control%20Containers%20and%20the%20Dependency%20Injection%20pattern&pos=1208&uri=https://www.martinfowler.com/articles/injection.html
chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=LEARNING%20PATH%3A%20iPhone%20Programming%20with%20iOS%2011%20and%20Swift%204%20%7C%20Learning%20Paths&pos=0&uri=https://www.safaribooksonline.com/learning-paths/learning-path-iphone/9781789611588/
chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=Are%20pointers%20and%20arrays%20equivalent%20in%20C%3F%20-%20Eli%20Bendersky's%20website&pos=4035&uri=https://eli.thegreenplace.net/2009/10/21/are-pointers-and-arrays-equivalent-in-c
chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#ttl=Professional%20C%20Programming%20LiveLessons%20(Video%20Training)%2C%20Part%20I%3A%20Writing%20Robust%2C%20Secure%2C%20and%20Reliable%20Code&pos=0&uri=https://learning.oreilly.com/videos/professional-c-pr
1) https://leetcode.com/problems/two-sum/
sum([1, 2, 5, 3, 4], 9) -> [2, 4]
find closest sum
sum([1, 8, 5, 6, 4], 15) -> [1, 3]
2) rotateMatrix([
[1, 2],
[3, 4]
]);
Result
@isavch
isavch / c.js
Last active March 28, 2018 12:53
certona
class GlassCertonaWithOverlap extends Component {
state = {
deviceSize: 0,
cardSize: 0,
style: {}
}
getCardImage = card => {
const { clientWidth } = card.querySelector('img')
@isavch
isavch / replay.md
Last active January 17, 2018 15:58
Replay

Replay flow

Which actions should be replayed? I guess only those are modyfying data on backend like:

  • POST
  • PUT
  • DELETE

When request failed we should save it somewhere in store, I think store should look like this

There are basicly 2 scenarious for create:

  • Online and everything is successful
  • Offline, request failed

First case

@isavch
isavch / p.js
Last active December 19, 2017 15:17
promise
class MyPromise {
constructor(handler) {
this.status = 'pending';
if (!handler) {
throw new TypeError('Promise resolver is undefined');
}
handler(value => {
this.value = value;
@isavch
isavch / API2.js
Last active December 15, 2017 14:08
api2
/* API usage */
import initApi from 'redux-wp';
initApi(store);
/* Somewhere in the user code */
import getPost from 'wp-redux'
getPost(2, 'posts')
.then(post => console.log(post));
@isavch
isavch / api.js
Created December 15, 2017 13:49
SS API
/* API usage */
import makeApi from 'redux-wp';
const api = makeApi(store);
api.getPost(2, 'posts')
.then(post => console.log(post));
/* Implementation */
  1. Collection GET /wp/v2/posts Response [{id: 1, name: 'post'}, {id: 2, name: 'post2'}]

  2. Signle entity GET /wp/v2/posts/1 Response {id: 1, name: 'test'}

  3. Object collection GET /wp/v2/taxonomies Response { testA: { name: 'test a' }, testB: {name: 'test b'}, testC: { name: 'test c' }}

How will look store for different actions, READ, READ_FAIL, READ_SUCCESS ?

@isavch
isavch / store
Last active December 12, 2017 12:25
{
posts: {
1: {
data: {
id: 1,
title: test
},
ststus: 'success'
}
}