Skip to content

Instantly share code, notes, and snippets.

View prichodko's full-sized avatar
:octocat:
hacking

Pavel prichodko

:octocat:
hacking
View GitHub Profile
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&family=Raleway:wght@800&display=swap");
:root {
--font-family: "Open Sans", sans-serif;
--border-radius: 0;
--form-element-spacing-vertical: 1rem;
--form-element-spacing-horizontal: 1.25rem;
}
body {
@prichodko
prichodko / decrypt-private-key.test.ts
Created May 27, 2022 15:10
Decrypt Public Key from Keystore File
import { decrypt } from 'ethereum-cryptography/aes'
import { keccak256 } from 'ethereum-cryptography/keccak'
import { scrypt } from 'ethereum-cryptography/scrypt'
import { getPublicKey } from 'ethereum-cryptography/secp256k1'
import {
bytesToHex,
concatBytes,
hexToBytes,
utf8ToBytes,
} from 'ethereum-cryptography/utils'
@prichodko
prichodko / mdx-image.js
Created April 6, 2021 16:35
MDX with next/image and zoom
import Image from 'next/image';
import Zoom from 'react-medium-image-zoom'
const MyImage = (props) => {
return (
<Zoom>
<Image
src={props.src}
alt={props.alt}
width={props.width}
@prichodko
prichodko / example.js
Created February 3, 2020 15:34
Array of children refs
const Parent = () => {
const refs = React.useRef([])
return React.Children.map(this.props.children, child => {
return React.cloneElement(child, {
ref: ref => refs.current.push(ref)
})
})
}
import styled from 'styled-components' // using upcoming `as` prop in v4
import { Link } from 'react-router-dom'
const Button = styled.button`
// styles
`
export default props => {
if (props.href) {
<Button as="a" {...props} rel="noreferrer noopener" target="_blank" />
@prichodko
prichodko / custom-git-completion.sh
Last active April 17, 2018 09:17
How to use git-completion.bash for custom commands (e.g. git-friendly)
if type __git_complete &> /dev/null; then
_branch () {
delete="${words[1]}"
if [ "$delete" == "-d" ] || [ "$delete" == "-D" ]; then
_git_branch
else
_git_checkout
fi
}
[user]
name = "Name"
email = "Email"
[core]
pager = less -r
editor = /usr/bin/vim
[alias]
a = add .
b = branch
bb = branch -vv
@prichodko
prichodko / index.js
Last active March 26, 2018 09:57
mapDispatchToProps shortcut
// this
const mapDispatchToProps = dispatch => ({
showHoverCart: () => dispatch(hoverCartActions.showHoverCart()),
hideHoverCart: () => dispatch(hoverCartActions.hideHoverCart()),
changeTab: index => dispatch(productActions.changeTab({ index })),
zoomIn: isZoomedIn => dispatch(productActions.zoomIn({ isZoomedIn })),
toggleNav: navState => dispatch(navActions.toggleNav({ navState })),
addToRecentlyViewed: product =>
dispatch(recentlyViewedActions.addToRecentlyViewed(product)),
})
@prichodko
prichodko / hoc.js
Last active March 23, 2018 15:23
How to write higher-order components
import hoistNonReactStatics from 'hoist-non-react-statics'
const withSomething = Component => {
const C = props => {
const { } = props // work with props if needed
return (
// render logic
<Component {...props} />
)
}
@prichodko
prichodko / setup.sh
Created January 13, 2016 10:40
Set working directory for new project
#!/bin/sh
NEW_PROJECT="/Users/Felicio/Documents/Developer/Resources/New\ Project"
TARGET_DIR="$1"
if [[ "$TARGET_DIR" == 0 ]]; then
printf "%s\n" "Specify targed directory."
exit 1
fi