Skip to content

Instantly share code, notes, and snippets.

View adamcbrewer's full-sized avatar

Adam Brewer adamcbrewer

View GitHub Profile
@adamcbrewer
adamcbrewer / webkit-css-mask.css
Created June 25, 2013 16:04
CSS: overflow/border-radius mask bug-thingy
/*
* There's a bug in Chrome/Safari using overflow:hidden with border-radius. This mask fixes it.
* Solution: http://stackoverflow.com/questions/5736503/how-to-make-css3-rounded-corners-hide-overflow-in-chrome-opera/10296258#10296258
*/
.masked {
position: absolute;
border-radius: 10px;
overflow: hidden;
/* this fixes the overflow:hidden in Chrome */
-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
@adamcbrewer
adamcbrewer / css-sass-helpers.scss
Last active August 23, 2023 23:04
SASS: Helpers and mixins for using with SASS
//============================================================
// Typography
//============================================================
// An rem font-size mixin providing fallback to px
@mixin font-size($sizeValue: 1.4) {
$remValue: $sizeValue;
$pxValue: ($sizeValue * 10);
font-size: #{$pxValue}px;
font-size: #{$remValue}rem;
@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 / queryToObject.js
Created March 20, 2013 11:25
JS: Query string to object
/**
* Converts a URL query string to a javascript object
*
* @author Adam Brewer - @adamcbrewer - adamcbrewer.com
*
* Usage: "?test=true&something=false".queryToObj(?);
*
* Output: {test: true, something: false}
*
*/
@adamcbrewer
adamcbrewer / clickEventType.js
Last active October 22, 2021 20:29
JS: Detect for supported 'touchstart' events.
/**
* Using default click events in touch-supported devices
* incurs a delay (in order to determine if the user is performing a gesture).
*
* Detecting for touchstart events using the foloowing, we can replace the default 'clicks'
* for touch events, making a snappier experience for mobile/touch devices.
* Use wisely as this could prevent some gestures from happening. If there are scrolling
* issues try swap out 'touchstart' for 'touchend'
*
*/
@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 / getRotationDegrees.js
Created December 4, 2012 09:42
JS: CSS transform-martrix to rotation in degrees
/**
* Returns rotation in degrees when obtaining transform-styles using javascript
* http://stackoverflow.com/questions/8270612/get-element-moz-transformrotate-value-in-jquery
*/
function getRotationDegrees(obj) {
var matrix = obj.css("-webkit-transform") ||
obj.css("-moz-transform") ||
obj.css("-ms-transform") ||
obj.css("-o-transform") ||
obj.css("transform");
@adamcbrewer
adamcbrewer / clipboard.history.json
Last active September 11, 2020 08:54
Visual Studio Code Settings Sync Gist
{
"version": 2,
"clips": []
}
@adamcbrewer
adamcbrewer / node.sh
Created July 23, 2013 08:38
NODE: Run a daemon node.js server and create virtualhost to forward all site traffic to the specified port.
# This command will make sure the process persists
# even after you log out of a session
node server.js >/dev/null 2>&1 &
@adamcbrewer
adamcbrewer / custom_shortcodes.php
Created March 14, 2012 17:55
WP: Adding Shortcodes To Use When Posting
<?php
/**
* Adding shortcodes to the post-editing section: functions.php
* http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/
*
**/
/**