Skip to content

Instantly share code, notes, and snippets.

View 1-react-reading.md

Super overview of React!

Key nuggest:

  • React takes a functional programming approach on view rendering.
    • Angular and many others hold on to your data as well and tend to conform more to an MVC type patter, React allows you to write your views as functions (with some caveats)
    • Basically react lets you define "given the state of my data, what does my view look like right now?" as functions. Views are therefore very testable (ie call my component with 5 users with these names, I should see 5 cards with names displayed in header).
  • React has two major ways to define "Components"
    • functions (the pure functional way to write views)
function UserCard({user}) {
@djoeman84
djoeman84 / add_flow.sh
Last active Aug 2, 2017 — forked from orta/add_flow.sh
Add flow to all your JS files
View add_flow.sh
#!/bin/bash
# Based on http://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files
find . -type f -iname "*.js" -print0 | while IFS= read -r -d $'\0' i;
do
if ! grep -q @flow $i
then
(echo "" & echo "/* @flow */") > flowificator
cat flowificator $i >$i.new && mv $i.new $i
rm flowificator
@djoeman84
djoeman84 / stylePage.js
Last active Apr 10, 2017
Quick CSS setter
View stylePage.js
function stylePage(d){
for (var selector in d) {
if (!d.hasOwnProperty(selector)) return;
var properties = d[selector];
for (var styleName in properties) {
if (!properties.hasOwnProperty(styleName)) return;
var style = properties[styleName];
var matching = document.querySelectorAll(selector);
for (var j = 0; j < matching.length; j++) {
matching[j].style[styleName] = style;
View keybase.md

Keybase proof

I hereby claim:

  • I am djoeman84 on github.
  • I am el_gato (https://keybase.io/el_gato) on keybase.
  • I have a public key whose fingerprint is 64D6 0F0F ECE3 35B0 C5A5 2B6B 4A5D 6A51 C7CE E24C

To claim this, I am signing this object:

View .bash_profile
COLOR_BLACK="\[\033[0;30m\]"
COLOR_RED="\[\033[0;31m\]"
COLOR_GREEN="\[\033[0;32m\]"
COLOR_YELLOW="\[\033[0;33m\]"
COLOR_BLUE="\[\033[0;34m\]"
COLOR_MAGENTA="\[\033[0;35m\]"
COLOR_CYAN="\[\033[0;36m\]"
COLOR_WHITE="\[\033[0;37m\]"
@djoeman84
djoeman84 / NoBackgroundScroll.js
Last active Jul 21, 2016
React Wrapper Component to disable scroll on child -no modern IE :(
View NoBackgroundScroll.js
import React, {Component} from 'react'
import $ from 'jquery'
export class NoBackgroundScroll extends Component {
componentDidMount() {
stopBackgrounScrollForEl(this.childElement);
}
componentWillUnmount() {
cleanupStopBackgroundScrollForEl(this.childElement);
}
@djoeman84
djoeman84 / json_ecma_compliance.py
Created May 25, 2016
Map Python object to ECMA-JSON compliant objects
View json_ecma_compliance.py
import math
class JSONECMACompliance(object):
@classmethod
def make_standards_compliant(cls, json_serializable_obj, inf_value='Infinity',
negative_inf_value='-Infinity', nan_value='NaN'):
"""
Python decided it wouldn't conform to ECMA JSON standard.
This converts illegal values (Infinity, -Infinity, NaN) to strings with the same values.
@djoeman84
djoeman84 / Enable Spellcheck
Created Oct 29, 2013
A little bit of js to turn on spell checking on annoying pages that turn it off.
View Enable Spellcheck
var tareas = document.getElementsByTagName('textarea');
for (var i = 0; i < tareas.length; i++) {
tareas[i].spellcheck = true;
}
View gist:7140185
javascript:alert('You can download this video by using the command \'mimms -c '+document.getElementById('WMPlayer').data+' [target directory]\'');