Skip to content

Instantly share code, notes, and snippets.

View zbyte64's full-sized avatar

Jason Kraus zbyte64

View GitHub Profile
@zbyte64
zbyte64 / iframe.js
Created May 13, 2015 05:22
React iframe head
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 August 29, 2015 14:20 — forked from anonymous/sample.jsx
Custom React
/** @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() {
@zbyte64
zbyte64 / sample.jsx
Last active August 29, 2015 14:20 — forked from anonymous/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 August 29, 2015 14:19
MIT + Code of Conduct / Ethical Use Proposition
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 December 11, 2014 00:29
Render to an iframe using its own document model
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 June 21, 2014 01:13
Attempt to grab peer certificate when serving
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 18:17
Deep cloning of react components
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 September 15, 2016 09:32
React.js Component Guideline

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 March 5, 2014 20:52
Testosterone Driven Development [TDD]

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

image

@zbyte64
zbyte64 / alpaca-om.cljs
Created January 16, 2014 01:42
Render alpacajs form in OM (clojsurescript react.js library); AKA render raw html in OM
(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)))