Skip to content

Instantly share code, notes, and snippets.

View hex13's full-sized avatar
💭
slavic code master

Łukasz Lityński hex13

💭
slavic code master
  • JavaScript developer
  • Warsaw/Poland
View GitHub Profile
@hex13
hex13 / redux-oop.js
Last active September 27, 2017 04:29
redux OOP way
const reducers = {
add(state, {payload: [number]}) {
return state + number;
},
};
function reducer(state, action) {
if (reducers.hasOwnProperty(action.type))
return reducers[action.type](state, action);
return state;
def emit_point():
print "x", x, "y", y
while width > 0 and height > 0:
direction = 1
while direction >= -1:
for i in range(width - 1):
emit_point()
x += direction
for i in range(height - 1):
@hex13
hex13 / b.js
Last active November 23, 2016 12:43
const app = {
logo: new Image;
};
app.logo.onLoad = () => {
// do some stuff
}
app.logo.src = logoUrl;
@hex13
hex13 / a.js
Last active November 23, 2016 11:57
class Application {
constructor(logoUrl, onLoad) {
this.logo = new Image;
this.logo.src = logoUrl;
this.callback = onLoad;
this.logo.onLoad = this.run.bind(this);
}
run() {
// some other things
this.callback();
@hex13
hex13 / render-promise-in-react.js
Created November 3, 2016 12:33
how to render promises in React
//License CC0 1.0: https://creativecommons.org/publicdomain/zero/1.0/
class Deferred extends React.Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
}
componentDidMount() {
{
"name": "Bułka z masłem",
"price": 10,
"currency": "PLN",
"description": "Bardzo smaczna"
}
@hex13
hex13 / main.jsx
Last active January 9, 2016 12:51
stateless function identity in React.js
import React from 'react';
import * as ReactDOM from 'react-dom';
var root = {
name: 'World',
children: [
{name: 'Sun', id:1},
{
name: 'Earth', id:2,
@hex13
hex13 / main.js
Last active January 9, 2016 12:49 — forked from anonymous/main.js
React triggers remounting when we use function as react component ( <Renderer /> ). When we don't and run Renderer() it's okay
import React from 'react';
import * as ReactDOM from 'react-dom';
var root = {
name: 'World',
children: [
{name: 'Sun', id:1},
{
name: 'Earth', id:2,
function foo() {
return <div>{'{ss'}</div>;
}
console.log(1);
const speck = require('speckjs');
const fs = require('fs');
const name = './src/index.js';
speck.build({name: name, content: fs.readFileSync(name, 'utf8')}, {ecmaVersion: 6, sourceType: 'module'});