Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View zbyte64's full-sized avatar

Jason Kraus zbyte64

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / admin.jsx
Created July 31, 2015 20:25
Montage Admin DSL
<Route path="/" component={AdminPanel}>
<Route path="users" component={CrudList}>
<Route path="/add" component={CrudAdd}/>
<Route path="/:id" component={CrudDetail}/>
<Route path="/:id/delete" component={CrudDelete}/>
<Route path="/:id/transfer" component={TransferAccount}/>
</Route>
<Route path="industries" component={CrudList}>
@zbyte64
zbyte64 / Google map.js
Last active October 23, 2015 18:46
Custom tag examples
/*
Registers the following tags (use is property):
* x-googlemap (iframe with api-key & address properties)
be sure to enable polyfill: https://github.com/WebReflection/document-register-element
*/
(function() {
var GoogleMapProto = Object.create(HTMLElement.prototype);
@zbyte64
zbyte64 / tlsrethink.py
Created March 10, 2016 22:12
TLS authentication with rethinkdb python client
from rethinkdb.net import ConnectionInstance, SocketWrapper, Connection, decodeUTF
from rethinkdb.errors import *
import socket
import time
import ssl
class TLSConnectionInstance(ConnectionInstance):
def connect(self, timeout):
self._socket = TLSSocketWrapper(self, timeout)
@zbyte64
zbyte64 / SchemaBootstrapField.jsx
Created March 25, 2016 01:10
Bootstrap theme for react-jsonschema-form
import React, { PropTypes } from "react";
import { isMultiSelect, retrieveSchema } from "zbyte64/react-jsonschema-form/src/utils";
import ArrayField from "zbyte64/react-jsonschema-form/src/components/fields/ArrayField";
import BooleanField from "zbyte64/react-jsonschema-form/src/components/fields/BooleanField";
import NumberField from "zbyte64/react-jsonschema-form/src/components/fields/NumberField";
import ObjectField from "zbyte64/react-jsonschema-form/src/components/fields/ObjectField";
import StringField from "zbyte64/react-jsonschema-form/src/components/fields/StringField";
import UnsupportedField from "zbyte64/react-jsonschema-form/src/components/fields/UnsupportedField";
@zbyte64
zbyte64 / async_app.py
Created May 26, 2016 20:47
Asyncio Views With Django
import asyncio
from django import http
from django.core.urlresolvers import set_script_prefix
from django.utils.encoding import force_str
from django.core.handlers.wsgi import get_script_name
from django_wsgi.handler import DjangoApplication
import logging
import logging
import sys