Skip to content

Instantly share code, notes, and snippets.

View burdiuz's full-sized avatar
💭
isotope muffin

Oleg Galaburda burdiuz

💭
isotope muffin
View GitHub Profile
@burdiuz
burdiuz / intercept-calls-to.js
Last active June 1, 2021 04:54
logAccessTo() returns proxy of an object that logs out access to its members
const interceptCallsTo = (() => {
const pad = (value) => String(value).padStart(2, '0');
const getTime = (date = new Date()) =>
`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(
date.getSeconds(),
)}.${pad(date.getMilliseconds())}`;
return (obj, props = []) => {
const filtered = props && props.length;
@burdiuz
burdiuz / commandline.html
Last active June 6, 2020 05:39
Universal debug console for embedded HTML/JavaScript applications
<!--
This conains an input field for a JS command and output area to displaying whatever your command returns.
To execute command press Enter key or push "Execute" button on the right(if Enter key is being captured).
-->
<div style="width: 100%; display: flex; flex-direction: column; align-items: stretch;">
<div style="display: flex; margin: 5px; align-items: center;">
<input id="console-input" style="font-family: monospace; margin-right: 5px; flex: 1;">
<button id="console-exec">Execute</button>
</div>
<div id="console-output" style="white-space: pre-line; font-family: monospace; margin: 5px; border: 1px solid #000; padding: 5px;">
@burdiuz
burdiuz / README.md
Last active January 31, 2020 18:28
JavaScript Promise.all() and Promise.race() implementation in Go for Go's channels

promiselike.All(input ...<-chan interface{}) <-chan []interface{}

All works just like Promise.all() in Javascript and waits for all channels to return a value. After returning a list of values output channel is closed.

type IntValue struct {
  Value int
}

func main() {
  values := <-All(
@burdiuz
burdiuz / time.go
Created January 21, 2020 10:29
Learning concurrency in go
package main
import (
"fmt"
"time"
)
func seconds(done <-chan int) <-chan time.Time {
out := make(chan time.Time)
@burdiuz
burdiuz / Offline.js
Last active December 29, 2019 19:23
@actualwave/react-native-net-connected -- React Native components to use NetInfo declarative way.
import PropTypes from 'prop-types';
import callIfFunction from '@actualwave/call-if-function';
import withConnected from './withConnected';
const Offline = ({ connected, children, onlineRenderer }) => {
if (connected) {
return callIfFunction(onlineRenderer);
}
@burdiuz
burdiuz / Layout.js
Last active December 29, 2019 19:17
@actualwave/react-native-props-layout -- Provide style to component with it's props
import { View } from 'react-native';
import withLayoutProps from './withLayoutProps';
export const Layout = withLayoutProps(View, true, true, 'Layout');
@burdiuz
burdiuz / README.md
Last active December 29, 2019 21:00
@actualwave/react-native-swipeable-x-container -- React Native component for displaying swipeable panels

@actualwave/react-native-swipeable-x-container

React Native component for displaying swipeable panels

@burdiuz
burdiuz / README.md
Last active December 29, 2019 19:07
@actualwave/react-native-with-style -- HoC to provide base style for a component that merges with style provided via props

@actualwave/react-native-with-style

withStyle() HoC to provide base style for a component that merges with style provided via props

@burdiuz
burdiuz / README.md
Last active December 29, 2019 19:03
@actualwave/call-if-function -- calls function and returns everything else

@actualwave/call-if-function

callIfFunction accepts multiple arguments and checks first one. If it is a function, it will be called with other arguments passed to it(just like for Function.call()) If it is not a function, then value from first argument wil be returned.

I use it in react components, to check if component children are react nodes or a renderer function.

@burdiuz
burdiuz / README.md
Last active December 29, 2019 19:01
@actualwave/react-component-name -- function to get component name

@actualwave/react-component-name

Function that returns

  1. Component display name if defined
  2. Function name
  3. Predefined value, "Component" by default