Skip to content

Instantly share code, notes, and snippets.

@kof
kof / logo-without-noise.svg
Created October 8, 2022 13:42
Webstudio Logo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kof
kof / button-hooked.js
Last active November 23, 2021 08:13
Inject styles with custom hooks
const styles = {
button: {
color: 'red'
}
}
const Button = () => {
const {classes} = useStyles(styles)
return <button className={classes.button}>Test<Button>
}
@kof
kof / node-wipe.sh
Last active March 7, 2021 08:41
Complete wipe of all node related files for MacOS
#!/bin/bash
yarn cache clean
npm cache clean --force
sudo rm -rfv /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
sudo rm -rfv ~/.npm ~/.nvm ~/node_modules ~/.node-gyp ~/.npmrc ~/.yarnrc ~/.node_repl_history
sudo rm -rfv /usr/local/bin/npm /usr/local/bin/node-debug /usr/local/bin/node /usr/local/bin/node-gyp
sudo rm -rfv /usr/local/share/man/man1/node* /usr/local/share/man/man1/npm*
sudo rm -rfv /usr/local/include/node /usr/local/include/node_modules
sudo rm -rfv /usr/local/lib/node /usr/local/lib/node_modules /usr/local/lib/dtrace/node.d
sudo rm -rfv /opt/local/include/node /opt/local/bin/node /opt/local/lib/node
@kof
kof / Switch1.js
Last active January 27, 2020 01:23
Material-UI Switch using imaginary state machine
// Original implementation https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Switch/Switch.js
// An attempt to use state machines inside of styles declaration.
const useStyles = createUseStyles({
root: {
display: 'inline-flex',
overflow: 'hidden',
boxSizing: 'border-box',
position: 'relative',
flexShrink: 0,
@kof
kof / action-creator-vs-reducer.md
Last active January 18, 2020 09:06
Action creator vs. reducer

When should you use action creator and when reducer?

Action creator

  • you need to have side effects
  • you need to read from store to decide what to do
  • you need to dispatch more than one action
  • action produced by action creator needs to contain all the data reducer can need to shape the components state

Reducer

  • should not have any side effects
@kof
kof / example.js
Created July 11, 2018 17:38
static jss as a raw css string
// source js
const styles = {
static: {
color: 'green'
},
mixed: {
color: 'red',
margin: (props) => props.spacing
}
}
@kof
kof / structure.txt
Last active June 26, 2018 10:30
Redux app structure
- components
- utils
features
- feature-x
- action-types
- action-creators
- reducer
- containers
- renderers
- index.js
@kof
kof / react-component.js
Last active August 30, 2017 15:49
Reactive Component
class MyComponent extends Component {
componentWillMount() {
alert('will mount')
}
onClick = () => {
alert('Button Clicked')
// Forward click to the outer listeners.
this.props.onClick()
@kof
kof / weird.md
Last active July 17, 2017 19:36
weird linked-in conversation

Jul 5 LinkedIn Member sent the following message at 7:19 PM LinkedIn Member Hi Oleg

We are a 12 person team of young professionals building our own company in Berlin. We are looking for another Reactjs developer to cofound with us. Would you like to hear more about it?

Best regards, Josh

@kof
kof / confirm-linkedin-skills.js
Last active July 8, 2017 10:20
Confirm all skills at linkedin
var expander = document.querySelector('[data-control-name="skill_details"][aria-expanded="false"]')
if (expander) expander.click()
;[].slice.apply(document.querySelectorAll('button[data-control-name="endorse"]')).forEach((btn) => {
btn.click()
})