Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@djoeman84
djoeman84 / 1-react-reading.md
Last active January 30, 2018 03:36
Learning React

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 August 2, 2017 06:54 — forked from orta/add_flow.sh
Add flow to all your JS files
#!/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 April 10, 2017 16:28
Quick CSS setter
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;

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:

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 July 21, 2016 00:56
React Wrapper Component to disable scroll on child -no modern IE :(
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 19:01
Map Python object to ECMA-JSON compliant objects
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 October 29, 2013 16:45
A little bit of js to turn on spell checking on annoying pages that turn it off.
var tareas = document.getElementsByTagName('textarea');
for (var i = 0; i < tareas.length; i++) {
tareas[i].spellcheck = true;
}
javascript:alert('You can download this video by using the command \'mimms -c '+document.getElementById('WMPlayer').data+' [target directory]\'');