Skip to content

Instantly share code, notes, and snippets.

View bbrewer97202's full-sized avatar

Ben Brewer bbrewer97202

View GitHub Profile
@bbrewer97202
bbrewer97202 / DockerFile
Last active April 9, 2024 22:34
Boilerplate for node app Dockerfile
# create .dockerignore with node_modules, dist, etc
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json /app
RUN npm install
COPY . /app
RUN npm run build
FROM node:18.20.1-bullseye-slim AS production
@bbrewer97202
bbrewer97202 / heroku-htaccess.md
Created August 10, 2012 18:20
Simple htaccess authentication on Heroku with cedar/php

Create an .htaccess file in the webroot:

AuthUserFile /app/www/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user

Create a .htpasswd file:

htpasswd -c /app/www/.htpasswd [username]

@bbrewer97202
bbrewer97202 / css3pulsingcirle
Created September 18, 2012 18:06
Simple CSS3 pulsing circle animation
<html>
<head>
<title></title>
</head>
<body>
<div id="pulser">
<div class="pulse pulse1"></div>
<div class="pulse pulse2"></div>
<div class="pulse pulse3"></div>
@bbrewer97202
bbrewer97202 / index.js
Created October 20, 2016 17:15
Graphicsmagick gm convert svg string buffer to sized jpg with 300 DPI setting
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.js
Created January 4, 2017 16:50
validation of x-hub-signature header facebook
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.html
Last active May 19, 2016 17:40
15 puzzle in javascript
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container" id="container"></div>
<style type="text/css">
@bbrewer97202
bbrewer97202 / gist:7373750
Created November 8, 2013 16:35
Open a browser tab within a chrome extension using JavaScript
chrome.browserAction.onClicked.addListener(function (tab) {
chrome.tabs.create({
url: "index.html"
});
});
@bbrewer97202
bbrewer97202 / gist:7240988
Created October 30, 2013 21:52
Common Android emulator commands + keyboard shortcuts I am always trying to remember
### commands
#start the avd manager
$ ./android avd
#list available avds
$ ./android list avd
#Start an emulator with a target avd:
$ ./emulator -avd <avdname>
@bbrewer97202
bbrewer97202 / gist:7161113
Created October 25, 2013 20:11
Add/Update a hosts file on Android SDK emulator
$ adb remount
$ adb pull /system/etc/hosts tmp/hosts
$ vi tmp/hosts
$ adb push tmp/hosts /system/etc
@bbrewer97202
bbrewer97202 / index.html
Last active December 26, 2015 04:19
Icon font implementation with MSHPIconsRegular web font
<!doctype html>
<html>
<head>
<title>MSHPIconsRegular</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="//i.s-microsoft.com/fonts/segoe-ui/west-european/normal/latest.css" />
</head>
<body>
<style type="text/css">