Skip to content

Instantly share code, notes, and snippets.

Ben Brewer bbrewer97202

  • Portland, OR
Block or report user

Report or block bbrewer97202

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bbrewer97202
bbrewer97202 / index.js
Created Jan 4, 2017
validation of x-hub-signature header facebook
View index.js
const crypto = require('crypto');
const jsesc = require('jsesc');
//inside express route handler
const xHubSignature = req.headers['x-hub-signature'];
if (this.validateSignature(xHubSignature, req.body)) {
console.log('valid signature');
}
/**
@bbrewer97202
bbrewer97202 / index.js
Created Oct 20, 2016
Graphicsmagick gm convert svg string buffer to sized jpg with 300 DPI setting
View index.js
var gm = require('gm');
var source = '<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 2550 3300" enable-background="new 0 0 2550 3300" xml:space="preserve"><g><path fill="#53381A" stroke="#1C1308" d="M807.6,1092.5L527.3,1067c-636.9-25.5-509.5,0-458.6,509.5c51,203.8,0,331.2,254.8,331.2 L807.6,1092.5z"/><path fill="#8A5B28" stroke="#1C1308" d="M909.5,1143.5H629.2c-636.9-25.5-509.5,0-458.6,509.5c51,203.8,25.5,305.7,305.7,229.3 L909.5,1143.5z"/><path fill="#454F2E" stroke="#1C1308" d="M807.6,990.6c127.4-254.8,76.4-305.7,458.6-254.8c509.5,127.4,509.5,152.9,891.6,152.9 c254.8,25.5,509.5,101.9,254.8,407.6l-280.2,509.5H450.9L807.6,990.6z"/><path fill="#76894C" stroke="#1C1308" d="M323.5,1703.9v178.3l1146.4,458.6v-178.3L323.5,1703.9z M807.6,990.6 c127.4-254.8,76.4-305.7,382.1-203.8c509.5,152.9,254.8,152.9,789.7,152.9c254.8,25.5,458.6,101.9,254.8,407.6L1954,1856.8 L527.3,1627.5L807.6,990.6z"/
@bbrewer97202
bbrewer97202 / index.html
Last active May 19, 2016
15 puzzle in javascript
View index.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container" id="container"></div>
<style type="text/css">
@bbrewer97202
bbrewer97202 / Preferences.sublime-settings
Created Oct 29, 2015
Sample custom Sublime Text Settings
View Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"caret_extra_width": 2,
"color_scheme": "Packages/User/SublimeLinter/Hyrule (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Consolas",
"font_size": 15,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
@bbrewer97202
bbrewer97202 / child.html
Created Jan 7, 2015
Responsive Iframe demo
View child.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<style type="text/css">
body, html {
@bbrewer97202
bbrewer97202 / webpack.config.js
Last active Aug 29, 2015
webpack jshint-loader custom reporter example with filename and color formatting
View webpack.config.js
var chalk = require('chalk');
module.exports = {
module: {
preLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "jshint-loader"
}
@bbrewer97202
bbrewer97202 / q.js-promises-chain.html
Last active Aug 29, 2015
Chained promises with q.js
View q.js-promises-chain.html
<!doctype html>
<html>
<head>
<title></title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/q.js/1.0.1/q.min.js"></script>
</head>
<body>
<script type="text/javascript">
//watch browser console for notification of what is happening
@bbrewer97202
bbrewer97202 / index.html
Created Feb 20, 2014
Simple Facebook,Twitter and Google+ social sharing calls
View index.html
<!doctype html>
<html>
<head>
<title>Social share page title</title>
<meta name="description" content="Social share page description" />
<meta property="og:title" content="Social share og:title value" />
<meta property="og:description" content="Social share og:description value" />
<meta property="og:image" content = "http://www.thunderfarm.com/socialshare/socialshare.jpg" />
</head>
<body>
@bbrewer97202
bbrewer97202 / gist:7373750
Created Nov 8, 2013
Open a browser tab within a chrome extension using JavaScript
View gist:7373750
chrome.browserAction.onClicked.addListener(function (tab) {
chrome.tabs.create({
url: "index.html"
});
});
@bbrewer97202
bbrewer97202 / gist:7240988
Created Oct 30, 2013
Common Android emulator commands + keyboard shortcuts I am always trying to remember
View gist:7240988
### commands
#start the avd manager
$ ./android avd
#list available avds
$ ./android list avd
#Start an emulator with a target avd:
$ ./emulator -avd <avdname>
You can’t perform that action at this time.