Skip to content

Instantly share code, notes, and snippets.

View joshbeckman's full-sized avatar
👍

Josh Beckman joshbeckman

👍
View GitHub Profile
@joshbeckman
joshbeckman / classy.js
Created October 12, 2015 14:19
An example showing the difference between prototypal inheritance and raw object usage in JavaScript
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,who);
@joshbeckman
joshbeckman / fbevents.js
Created May 27, 2016 21:31
Facebook's new Audience ad tracking script
/*1464382852,,JIT Construction: v2361294,en_US*/
/**
* Copyright Facebook Inc.
*
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
try {
(function(a, b, c, d) {
@joshbeckman
joshbeckman / faux-fountain.css
Created June 2, 2016 18:39
Transmute some hacky HTML markup conventions into screenplay display, inspired by http://fountain.io/_css/scrippets.css
body {
font-family: monospace;
max-width: 35rem;
margin: 0 auto;
display: block;
text-align: left !important;
}
h1,h2,h3,h4 {
/* used for characters */
text-align: center;
https://jvns.ca/atom.xml
http://sonniesedge.co.uk/feed.xml
https://eev.ee/feeds/blog.atom.xml
http://feeds.feedburner.com/turkeltaub
https://marco.org/rss2
https://daringfireball.net/feeds/main
http://www.evanmiller.org/news.xml
http://feeds.feedburner.com/codinghorror
http://feeds.feedburner.com/HighScalability
http://www.overcomingbias.com/feed
@joshbeckman
joshbeckman / fbds.js
Created May 27, 2016 21:30
Facebook deprecated/ing (supposedly) adds script
/*1464382085,,JIT Construction: v2361294,en_US*/
/**
* Copyright Facebook Inc.
*
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
try {
(function(a, b, c, d) {
@joshbeckman
joshbeckman / animatedScrollTo.js
Created September 30, 2013 14:51
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
@joshbeckman
joshbeckman / gist:7867934
Created December 9, 2013 06:00
Handle drag-n-drop JSON file upload and parsing with javascript.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success!
function handleJSONDrop(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files;
// Loop through the FileList and read
for (var i = 0, f; f = files[i]; i++) {
// Only process json files.
@joshbeckman
joshbeckman / index.js
Created October 10, 2015 17:37
An example Node.js server that can verify a Shopify webhook's integrity. Run with `node index.js`.
const PORT = 3000;
const SECRET = 'APP_SHARED_SECRET';
var http = require('http'),
crypto = require('crypto'),
server;
function verifyShopifyHook(req) {
var digest = crypto.createHmac('SHA256', SECRET)
.update(new Buffer(req.body, 'utf8'))
var fs = require('fs');
var child_process = require('child_process');
var main = () => {
var excludedFileNames = /\| Hacker News/;
var journal = 'worklog';
fs.readdirSync('.')
.filter(f => f.match(/\.md$/))
.map(f => {
return Object.assign(fs.statSync(f), {
@joshbeckman
joshbeckman / tags.html
Created January 22, 2014 13:31
Meta/link tags necessary to make mobile devices correctly display responsive and mobile-optimized sites.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-type" /><!-- speak the same language -->
<meta content="width=device-width, initial-scale=1" name="viewport" /><!-- correctly relate screen size to CSS -->
<meta name="HandheldFriendly" content="true" /><!-- BlackBerry, please don't f*** with my page -->
<meta name="apple-mobile-web-app-capable" content="yes"><!-- iPhone save-to-home-screen-able -->
<link rel="icon" href="/images/favicon.png"><!-- bookmarking/favoriting image -->
<meta name="msapplication-TileColor" content="#ffffff"/><!-- Windows 8/Windows phone -->
<meta name="msapplication-TileImage" content="/images/favicon.png"/><!-- Windows 8/Windows phone -->