Skip to content

Instantly share code, notes, and snippets.

View adamcbrewer's full-sized avatar

Adam Brewer adamcbrewer

View GitHub Profile
@adamcbrewer
adamcbrewer / clipboard.history.json
Last active September 11, 2020 08:54
Visual Studio Code Settings Sync Gist
{
"version": 2,
"clips": []
}
@adamcbrewer
adamcbrewer / actions.js
Last active September 13, 2022 20:18
JS: React & Redux Component Kit
export const ACTION_KEY = 'ACTION_KEY';
// If a component has this method defined in `bindActionCrators`
// then this method can be called via `this.props.actionsFunction()`
// within the component.
export function actionFunction(value) {
return {
type: ACTION_KEY,
payload: value
};
@adamcbrewer
adamcbrewer / entities.json
Created October 12, 2015 11:32
JSON: HTML Entity Reference
{
"ascii": [
{
"character": " ",
"entityName": " ",
"entityNumber": " ",
"description": "Space"
},
{
"character": "!",
@adamcbrewer
adamcbrewer / viewbox-trim.js
Last active February 5, 2021 09:06
JS: Trim SVG viewbox
/**
* Will trim the whitespace around the SVG's viewbox
*
*/
var svg = document.getElementsByTagName("svg")[0];
var bbox = svg.getBBox();
var viewBox = [bbox.x, bbox.y, bbox.width, bbox.height].join(" ");
svg.setAttribute("viewBox", viewBox);
@adamcbrewer
adamcbrewer / share-intents.md
Last active November 9, 2017 07:14
SOCIAL: Share intents on major platforms

Twitter

<a href="http://twitter.com/intent/tweet?url={url_encoded_url}&amp;text={url_encoded_text}&amp;hashtags={url_encoded_hashtags}">Tweet This</a>

Tumblr

<a href="http://www.tumblr.com/share/link?url={url_encoded_url}&amp;name={url_encoded_post_title}&amp;description={url_encoded_post_text}">Share on Tumblr</a>
@adamcbrewer
adamcbrewer / typo-transforms.css
Created May 22, 2014 09:19
CSS: Fixing Typography Inside of CSS 2D Transforms
/* This should hopefully fix crappy typography inside of rotated elements.
Taken from http://flippinawesome.org/2014/05/21/fixing-typography-inside-of-css-2-d-transforms/ */
.rotated-typography {
transform: perspective(1px) rotate(-10deg);
/* Using `translateZ(0)` forces GPU rendering (and only fixes -webkit), but `perspective(1px)` does the job nicely. */
/* Don't use -ms prefix, however, as Presto engine in IE9 lacks 3D transform support. */
}
@adamcbrewer
adamcbrewer / sortBy.onEdit.gs
Created February 1, 2014 14:43
GS: Automatically sorts the 1st column (not the header row) Ascending.
/**
* Automatically sorts the 1st column (not the header row) Ascending.
*/
function onEdit(event){
var sheet = event.source.getActiveSheet();
var editedCell = sheet.getActiveCell();
var columnToSortBy = 1;
var tableRange = "A4:Z99"; // What to sort.
@adamcbrewer
adamcbrewer / hd-media-query.css
Created January 18, 2014 15:34
CSS: HD Media Query Snippet
@media (-webkit-min-device-pixel-ratio: 2),
(min--moz-min-device-pixel-ratio: 2),
(min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
.logo {
background-image: url(../img/[email protected]);
}
}
@adamcbrewer
adamcbrewer / interval.js
Created November 21, 2013 12:50
JS: A better interval handler
/**
* setInterval has some issues:
* 1. Doesn't care whether the callback is still running or not
* 2. Ignores errors
*
* @source http://www.thecodeship.com/web-development/alternative-to-javascript-evil-setinterval/
* @param func The function to call
* @param wait The interval to wait
* @param times The total number of repititions, instead of infinite
*
@adamcbrewer
adamcbrewer / totype.js
Created November 21, 2013 12:42
JS: A Better typeof operator
/**
* A better, more reliable way to handle `typeof` checking.
*
* @source http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
*
*/
Object.toType = function(obj) {
return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
}