Skip to content

Instantly share code, notes, and snippets.

@doughamlin
doughamlin / .editorconfig
Created March 4, 2020 22:39
.editorconfig
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space

Keybase proof

I hereby claim:

  • I am doughamlin on github.
  • I am doughamlin (https://keybase.io/doughamlin) on keybase.
  • I have a public key ASCoOgQvYFKaBC407xmvm0rDe2MouOOUjcSbG2bo3IU-Two

To claim this, I am signing this object:

@doughamlin
doughamlin / convertSVGPoints.js
Last active August 29, 2015 14:11
Converts a list of SVG polygon points to fractions/bounding box units
/**
* Converts a list of SVG polygon points to fractions/bounding box units
*
* @param {string} points Space separated list of points from Illustrator/Sketch/etc. export (each point is a comma separated X,Y pair)
* @param {number} width Bounding box width
* @param {number} height Bouding box height
*/
function convertSVGPoints(points, width, height) {
var convertedPoints = [];
points = points.split(' ');
@doughamlin
doughamlin / Mixins
Last active August 29, 2015 14:11
Random Sass mixins I've made for myself.
@mixin bg($url, $color: transparent, $repeat: no-repeat, $position: center center, $size: contain) {
background: $color url($url) $repeat $position;
background-size: $size;
}
@mixin size($width, $height: $width) {
width: $width;
height: $height;
}
@doughamlin
doughamlin / rem-mixins.scss
Last active January 23, 2024 08:37
SCSS mixins for sizing fonts, paddings and margins with rem units and px unit fallbacks.Width mixin not included because you should use percentages for that (although you should arguably do the same for padding and margin too).
@mixin font-size($size) {
font-size: $size + px;
font-size: ($size/10) + rem;
}
@mixin height($size) {
height: $size + px;
height: ($size/10) + rem;
}
@mixin min-height($size) {
min-height: $size + px;
@doughamlin
doughamlin / SassMeister-input.scss
Created October 21, 2013 19:26
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.7)
// ----
@mixin margin($margin) {
@if length($margin) == 1 {
margin: $margin+px;
margin: $margin/10+rem;
}
@doughamlin
doughamlin / SassMeister-input.scss
Last active December 26, 2015 03:39
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.7)
// ----
@mixin padding($padding) {
padding: @each $value in $padding { $value + px };
padding: @each $value in $padding { ($value / 10) + rem };
}
.test1 {
@doughamlin
doughamlin / spoiler-alert.scss
Last active December 22, 2015 11:19
A simple SCSS proposal for spoiler alerts on the web.
$background: #fff;
$text: #444;
.spoiler {
color: $background;
background: $background;
&:hover { color: $text; }
&:before {
content: '(Spoiler alert. Hover to reveal.): ';
color: darken($text, %10);
@doughamlin
doughamlin / gist:5084154
Created March 4, 2013 18:02
A better Javascript rounding function: Round X to the Nth digit
function roundTo(x,n) {
if(!n) { n = 2; }
var result = x * Math.pow(10,n);
var result = Math.round(result);
var result = result / Math.pow(10,n);
return result;
}
@doughamlin
doughamlin / gist:5033709
Last active December 14, 2015 05:09
Register a new content type in WordPress
add_action('init', 'CONTENTTYPE_register');
function CONTENTTYPE_register() {
$labels = array(
'name' => _x('CONTENTTYPE NAME', 'post type general name'),
'singular_name' => _x('CONTENTTYPE NAME', 'post type singular name'),
'add_new' => _x('Add New', 'CONTENTTYPE NAME'),
'add_new_item' => __('Add New CONTENTTYPE NAME'),
'edit_item' => __('Edit CONTENTTYPE NAME'),
'new_item' => __('New CONTENTTYPE NAME'),