Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Kraus zbyte64

  • Kraus Dev House
  • Fresno, CA USA
View GitHub Profile
@zbyte64
zbyte64 / iframe.js
Created May 13, 2015
React iframe head
View iframe.js
function mergeElements(target, source) {
var seen = {};
if (target.tagName != source.tagName) {
console.log("tagname change:", target.tagName, source.tagName, source)
target.parentNode.replaceChild(source, target);
return;
}
_.each(source.attributes, function(att) {
seen[att.nodeName] = true;
if (att.nodeName === 'data-reactid') {
@zbyte64
zbyte64 / sample.jsx
Last active Aug 29, 2015 — forked from anonymous/sample.jsx
Custom React
View sample.jsx
/** @jsx this */
//classic callback
function clicker(props, children, render) {
var clicks = 0;
function clicked(event) {
event.preventDefault();
clicks += 1;
render(); //or render(clicks) to allow caching
}
return function() {
View sample.jsx
function siteDef(state) {
return <div>
function* () {
var state = "Your Site";
var resolve;
function render() {
return <h1 contentEditable={true} onInput={onInput}>{state}</h1>;
}
function rerender() {
@zbyte64
zbyte64 / LICENSE.txt
Last active Aug 29, 2015
MIT + Code of Conduct / Ethical Use Proposition
View LICENSE.txt
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR T
@zbyte64
zbyte64 / zomg.js
Created Dec 11, 2014
Render to an iframe using its own document model
View zomg.js
var IReact = require.bind(window.frames['layout'])('react');
IReact.renderComponent(IReact.DOM.div({}, "hello world"), window.frames['layout'].document.body);
@zbyte64
zbyte64 / sslauth.py
Created Jun 21, 2014
Attempt to grab peer certificate when serving
View sslauth.py
from OpenSSL import crypto, SSL
from socket import gethostname
import socket
import os
import re
from pprint import pprint
from time import gmtime, mktime
from os.path import exists, join
@zbyte64
zbyte64 / cloneComponent.js
Created May 30, 2014
Deep cloning of react components
View cloneComponent.js
var _ = require('lodash');
function isComponent(obj) {
//ghetto check because JS
return (obj && obj.setState)
}
function deepCloneComponent(tpl) {
if (!tpl) return;
if (_.isArray(tpl)) {
@zbyte64
zbyte64 / guideline.rst
Last active Sep 15, 2016
React.js Component Guideline
View guideline.rst

React.js Minimal Entropy Guide

DO's:

  • Use explicit contracts to pipe data & events between systems
  • Business rules should bubble towards the top, UI and semantics should sink towards the bottom

DONT's:

@zbyte64
zbyte64 / tdd.rst
Created Mar 5, 2014
Testosterone Driven Development [TDD]
View tdd.rst

A compilation of software development techniques using Steve Ballmer as a mentor. Feel free to fork & add.

http://www7.pcmag.com/media/images/238533-conference-speaker-steve-ballmer.jpg

@zbyte64
zbyte64 / alpaca-om.cljs
Created Jan 16, 2014
Render alpacajs form in OM (clojsurescript react.js library); AKA render raw html in OM
View alpaca-om.cljs
(defn show-form [data _]
(om/component
(let [schema (:current-form data)
alpaca-html (.html (.alpaca (js/jQuery. "<div/>") (clj->js {:schema schema})))
form-html (js/React.DOM.div (clj->js {:dangerouslySetInnerHTML {:__html alpaca-html}}))]
form-html)))