Skip to content

Instantly share code, notes, and snippets.

View webcam.js
// Copy this code and paste it in a dev tools console - Must be on an HTTPS site (or localhost)
document.write("<video></video>");
navigator.getUserMedia(
{ video: true }, // Ask for video
onGetUserMediaSuccess,
onError
);
@zachberry
zachberry / react-component-to-iframe-html.jsx
Last active Jun 8, 2018
Get HTML from a React component and inject it into an iframe
View react-component-to-iframe-html.jsx
class TestPage extends React.Component {
render() {
return (
<body>...</body>
)
}
}
class SomeComponent extends React.Component {
injectTestPage() {
View keybase.md

Keybase proof

I hereby claim:

  • I am zachberry on github.
  • I am zachberry (https://keybase.io/zachberry) on keybase.
  • I have a public key whose fingerprint is E68F F858 352E CC35 8FE8 9FA3 05EC 950D BF17 DE30

To claim this, I am signing this object:

@zachberry
zachberry / gist:1f102070b8e480bf9bbc
Last active Aug 29, 2015
Three ways to implement recursion in JS
View gist:1f102070b8e480bf9bbc
// METHOD 1 - Helper function
getTextNodes = function(element)
{
var textNodes = [];
getTextNodesHelper(element, textNodes);
return textNodes;
}
@zachberry
zachberry / fill-stripe-form
Created Nov 17, 2014
Snippet to quickly fill out a Stripe iframe form in test mode
View fill-stripe-form
document.getElementById('shipping-name').value = 'Jimbo Jones';
document.getElementById('shipping-street').value = '123 Fake St.';
document.getElementById('shipping-zip').value = '12345';
document.getElementById('shipping-city').value = 'Anytown';
document.getElementById('submitButton').click();
setTimeout(function() {
document.getElementById('card_number').value = '4242 4242 4242 4242';
document.getElementById('cc-exp').value = '01 / 22';
document.getElementById('cc-csc').value = '222';
document.getElementById('submitButton').click();
@zachberry
zachberry / gist:4176540
Created Nov 30, 2012
Fixes font smoothing in OS X (Sublime Text)
View gist:4176540
#http://chrissilich.com/blog/sublime-text-font-smoothing-anti-aliasing-issues-in-mountain-lion/
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
@zachberry
zachberry / init-html.sh
Created Oct 30, 2012
Creates a new HTML5 project via command-line using initializr.com (OS X)
View init-html.sh
#!/bin/sh
# Replace this with your desired options (visit http://www.initializr.com/):
U="http://www.initializr.com/builder?h5bp-content&modernizr&jquerymin&h5bp-css&h5bp-csshelpers&h5bp-mediaqueryprint&h5bp-mediaqueries&simplehtmltag&izr-emptyscript"
# Usage: init-html [my-new-project-name]
#
# This will extract the initializr bootstrap files into the my-new-project-name
# folder (first creating the folder if it doesn't exist already) and start a
# new git repo. If no directory is given it will install into the current directory.