Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Kraus zbyte64

  • Kraus Dev House
  • Fresno, CA USA
View GitHub Profile
@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 / 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 / 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
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 / 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() {
@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 / admin.jsx
Created Jul 31, 2015
Montage Admin DSL
View admin.jsx
<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}>
View debug_middleware.py
from django.views.debug import technical_500_response
import sys
import webbrowser
import tempfile
class BrowserExceptionMiddleware(object):
def process_exception(self, request, exception):
response = technical_500_response(request, *sys.exc_info())
path = tempfile.mkstemp(suffix='html')[1]
open(path, 'w').write(response.content)
@zbyte64
zbyte64 / Google map.js
Last active Oct 23, 2015
Custom tag examples
View Google map.js
/*
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 / forms.py
Created Feb 2, 2013
Example of using Django forms to load CSVs
View forms.py
from simplecart.discounts.models import *
from simplecart.orders.models import SKU
from decimal import Decimal
import datetime
from django import forms
class r(str):
pass