Skip to content

Instantly share code, notes, and snippets.

View spac3unit's full-sized avatar

Denis spac3unit

View GitHub Profile
@spac3unit
spac3unit / 0. intro.md
Created October 20, 2017 19:24 — forked from jquense/0. intro.md
Alternative ways to define react Components

The 0.13.0 improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The main thing of note in 0.13 is that React Components are no longer special objects that need to be created using a specific method (createClass()). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!

Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component for setState(), but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props and context to the component instance otherwise the component will be static. The reason is

@spac3unit
spac3unit / WebGL-frameworks-libraries.md
Created November 6, 2017 17:57 — forked from dmnsgn/WebGL-WebGPU-frameworks-libraries.md
A collection of WebGL frameworks and libraries

A non-exhaustive list of WebGL frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are outdated/not maintained anymore.

Engines and libraries

  • three.js: JavaScript 3D library
  • stack.gl: an open software ecosystem for WebGL, built on top of browserify and npm.
  • PixiJS: Super fast HTML 5 2D rendering engine that uses webGL with canvas fallback
  • Pex: Pex is a javascript 3d library / engine allowing for seamless development between Plask and WebGL in the browser.
  • Babylon.js: a complete JavaScript framework for building 3D games with HTML 5 and WebGL
  • SceneJS: An extensible WebGL-based engine for high-detail 3D visualisation
  • Blend4Web: a tool for interactive 3D visualization on the Internet
@spac3unit
spac3unit / README.md
Created November 16, 2017 16:23 — forked from metasean/README.md
How to share a webpack config between next.js and Storybook
@spac3unit
spac3unit / index.html
Created April 11, 2018 17:43 — forked from JasonAGross/index.html
The multi-toggle is basically just nested accordions. The user taps on the parent category to reveal children categories underneath. Once enough screen real estate becomes available, they convert to the usual multi-level dropdown we’re used to seeing.
<!--Pattern HTML-->
<div id="pattern" class="pattern">
<!--Begin Pattern HTML-->
<button class="menu-link">Menu <span>&#9660;</span></button>
<nav id="menu" class="menu" role="navigation">
<ul class="level-1">
<!--Parent #1-->
<li class="has-subnav">
<a href="#">Parent #1</a>
<ul class="level-2">
@spac3unit
spac3unit / .eslintrc
Created May 15, 2018 01:46 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@spac3unit
spac3unit / cli_progress.py
Created June 20, 2018 01:07 — forked from 89465127/cli_progress.py
Simple example of how to get a python progress bar in your program.
import time
from progress.bar import Bar # sudo pip install progress
bar = Bar('Processing', max=20, suffix='%(index)d/%(max)d - %(percent).1f%% - %(eta)ds')
for i in range(20):
time.sleep(.05) # Do some work
bar.next()
bar.finish()
@spac3unit
spac3unit / filter_dict.py
Created June 20, 2018 02:12 — forked from 89465127/filter_dict.py
python filter a dictionary by keys or values
d = {1:11, 2:22, 3:33}
# filter by key
d2 = {k : v for k,v in filter(lambda t: t[0] in [1, 3], d.iteritems())}
# filter by value
d3 = {k : v for k,v in d.iteritems() if k in [2,3]}
@spac3unit
spac3unit / github-store.js
Created July 18, 2018 19:04 — forked from alexvcasillas/github-store.js
Async Fetching with MobX Actions
import fetch from 'node-fetch';
import { observable, action, runInAction } from 'mobx';
export default class GithubStore {
@observable searchName;
@observable user;
@observable repos;
@observable fetchingData;
constructor() {
@spac3unit
spac3unit / App.js
Created August 23, 2018 01:04 — forked from rogeliog/App.js
Composition and filters in React
/*
This is a minimal working example
*/
import React, { Component } from 'react';
import Filters from './Filters';
import InputFilter from './InputFilter';
import allMovies from './movies';
class App extends Component {