Skip to content

Instantly share code, notes, and snippets.

@zachberry
zachberry / webcam.js
Last active August 14, 2018 00:16
Webcam in the browser example - https://codepen.io/zachberry/pen/gjyajp
// 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 June 8, 2018 18:03
Get HTML from a React component and inject it into an iframe
class TestPage extends React.Component {
render() {
return (
<body>...</body>
)
}
}
class SomeComponent extends React.Component {
injectTestPage() {

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 August 29, 2015 14:09
Three ways to implement recursion in JS
// METHOD 1 - Helper function
getTextNodes = function(element)
{
var textNodes = [];
getTextNodesHelper(element, textNodes);
return textNodes;
}
@zachberry
zachberry / fill-stripe-form
Created November 17, 2014 01:43
Snippet to quickly fill out a Stripe iframe form in test mode
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 November 30, 2012 15:47
Fixes font smoothing in OS X (Sublime Text)
#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 October 30, 2012 02:33
Creates a new HTML5 project via command-line using initializr.com (OS X)
#!/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.