Skip to content

Instantly share code, notes, and snippets.

@kocisov
kocisov / index.js
Created August 3, 2017 20:21
tp02l
// example
// don't overthink this too much
class X extends PureComponent {
// constructor equivalent for creating initial state
state = {
something: ''
}
// function that returns another function
changeReturn = () => e => {
@kocisov
kocisov / index.js
Created September 1, 2017 23:38
flook
function flookThis (input) {
console.log(input)
}
@kocisov
kocisov / meca.js
Created February 20, 2018 11:34
xd
export default 'http://play.typeracer.com/?rt=i5gfna57v'
@kocisov
kocisov / server.js
Created March 28, 2018 14:41
express or bust
// require your modules
var express = require('express')
var bodyParser = require('body-parser')
// create instance of express
var app = express()
// let app use body-parser
// this one is parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
@kocisov
kocisov / index.js
Created April 1, 2018 06:36
Recharts
import * as React from 'react'
import { render } from 'react-dom'
import { PieChart, Pie, Cell } from 'recharts'
const data = [
{
name: 'Low thing',
value: 3,
color: '#d0d0d0',
},
@kocisov
kocisov / download.js
Created June 9, 2018 16:00
Download in JavaScript
function download(filename, text) {
// create link element
const element = document.createElement('a')
// set link href to our text
element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`)
// set attribute download
element.setAttribute('download', filename)
@kocisov
kocisov / keybase.md
Created July 16, 2018 14:47
keybase.md

Keybase proof

I hereby claim:

  • I am kocisov on github.
  • I am koci (https://keybase.io/koci) on keybase.
  • I have a public key ASBXHD4BBI1gweZOkEPh2gPUVO0fvd9JkFJGrVmeYCcWlgo

To claim this, I am signing this object:

import * as React from 'react'
class Button extends React.PureComponent {
render() {
return (
<button onClick={this.props.onClick}>{this.props.text}</button>
}
}
}
@kocisov
kocisov / index.js
Created July 17, 2018 20:19
Sup #2
class App extends Component {
// return false = COMPONENT_SHOULD_NOT_UPDATE!
// return true = COMPONENT_SHOULD_UPDATE!
shouldComponentUpdate(nextProps, nextState) {
// PureComponent do this for you, not for everything tho
return this.props.value != nextProps.value;
}
render() {
return (
@kocisov
kocisov / Atom-Like.md
Created August 4, 2018 19:29
Atom like VSCode