Skip to content

Instantly share code, notes, and snippets.

View hyzhak's full-sized avatar
🤔
feel creative

Ievgenii Krevenets hyzhak

🤔
feel creative
View GitHub Profile
@hyzhak
hyzhak / component.js
Created January 15, 2019 22:45
track frequent component diff v0.1
/**
* try to track frequent component update without real neads of update
*/
//...
componentDidUpdate (prevProp) {
console.log('componentDidUpdate ',
this.props.collectionId,
'\ndiff:\n',
Object.entries(prevProp)
.filter(([key, value]) => value !== this.props[key])
@hyzhak
hyzhak / next-tick.js
Created November 30, 2018 23:45
next tick promise build which could be used when we need to wait before next portion of async calls
/**
* Create next trick promise which could be used:
*
* lazyAction()
* .then(nextTick())
* .then(doSomethingElse)
*
* @returns {Promise}
*/
module.exports = () => new Promise(resolve => process.nextTick(resolve))
@hyzhak
hyzhak / get-namespace.js
Created November 14, 2018 10:40
get current app redux namespace
import packageJSON from '../../package'
/**
* get current app namespace
*/
module.exports = function getReduxNamespace () {
return packageJSON.name
}
@hyzhak
hyzhak / perf.js
Created November 9, 2018 09:18
short but useful function to measure performance of function in node.js
function perf(fn) { console.time('x'); fn(); console.timeEnd('x');}
@hyzhak
hyzhak / show_samples.py
Last active November 8, 2018 10:08
Convert tensorflow dataset to pandas dataframe
import pandas as pd
import tensorflow as tf
def convert_tf_to_pd(ds, limit=32):
"""
Read data from Tensorflow dataset to Pandas dataframe
:param ds:
:param limit:
@hyzhak
hyzhak / binary.js
Last active September 13, 2018 22:57
limitations of binary operations in js
// Binary shifting
1 << 30
// 1073741824
1 << 31
// -2147483648
1 << 32
// 1
// Power
@hyzhak
hyzhak / Dockerfile
Created July 20, 2018 00:02
FoundationDB and Python3 together in the one Docker container
FROM foundationdb:ubuntu-18.04
# for the moment it is not published
# current version in preview here:
# https://github.com/apple/foundationdb/pull/355
ENV PATH /usr/local/bin:$PATH
# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
@hyzhak
hyzhak / links.md
Last active October 5, 2018 13:42
Awesome List of NASA Space Apps Challenge 2017
@hyzhak
hyzhak / my-form.ts
Last active December 14, 2016 13:54
enable/disable group of elements on input[radio] selected for angular 2 with reactive forms (ReactiveFormsModule)
//angular 2 (TypeScript, ReactiveFormsModule)
export class MyForm {
form: FormGroup;
constructor(fb: FormBuilder) {
this.form = fb.group({
radioInput: '',
group1: fb.group({
ctr0: '',
ctr1: '',
@hyzhak
hyzhak / async_stories.py
Last active September 3, 2016 23:02
architecture of stories - stateless and async
"""
v0.1.0
Bot asks user about destionation of space travelling.
- stateful story, it stores context of story (current question) in python interpreter
"""
@story.once('lets go!')
async def async_story(message):
dest = await ask_location(message['user'], text='Where do you go?')
store_destination(dest['location'])