Skip to content

Instantly share code, notes, and snippets.

View allybee's full-sized avatar

Allyson Beckers allybee

  • Principal Software Engineer @thenerdery
  • MN
  • 06:07 (UTC -05:00)
View GitHub Profile
@allybee
allybee / _contrast-color.scss
Last active April 21, 2016 16:25
A Sass and JavaScript function which returns either a light or dark color by deciding which contrasts more with the color using the YIQ color space.
// Returns either the $light or $dark color by deciding which contrasts more
// with $color using the YIQ color space (https://en.wikipedia.org/wiki/YIQ).
// This can be used to get a readable font color for a given background color.
//
// When $color is null, this function returns null.
@function contrast-color($color, $dark: 'black', $light: 'white') {
@if $color == null {
@return null;
}
@allybee
allybee / CanonicalUrls.php
Last active June 19, 2018 10:42
Redirect to canonical URLs and add the canonical tag in concrete5 v5.7 (including /index.php?cID=123 format)
<?php // application/src/Helpers/CanonicalUrls.php
namespace Application\Src\Helpers;
use Concrete\Core\Routing\Redirect;
use Config;
use Page;
/**
* Class CanonicalUrls
@allybee
allybee / Pretty Radios & Checkboxes.md
Last active January 21, 2016 19:49
Generated by SassMeister.com.
### Archives ###
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
*.7z
*.jar
*.rar
*.zip
*.gz
*.bzip
*.bz2
@allybee
allybee / robots-staging.txt
Last active January 4, 2016 17:11
Disallow robots on Staging server
User-agent: *
Disallow: /
@allybee
allybee / Grunt.applescript
Created August 28, 2014 16:17
AppleScript Service: Takes selected folder in Finder, opens the path in iTerm, and runs grunt.
-- create new Service in Automator
-- set input to "folders" in "Finder"
-- add new task: Run AppleScript
on run {input, parameters}
set _path to POSIX path of item 1 of input
tell application "iTerm"
activate
set myterm to (make new terminal)
@allybee
allybee / .htaccess.concrete5
Last active December 19, 2015 14:39
Placed in wherever your media is uploaded, this will check your local media directory for a requested file and, if it doesn’t exist, attempt to load it from production. This makes it easier to work on a local copy of a production site since you won’t need your own copy of the media directory.
# concrete5
# files/.htaccess
# NOTE: This doesn't work for images that are created with concrete5's getThumbnail()
# Attempt to load files from production if they're not in our local version
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteBase /
@allybee
allybee / target_blank.js
Last active November 7, 2023 22:40
Add target="_blank" to external links with pure JavaScript.
function targetBlank() {
// remove subdomain of current site's url and setup regex
var internal = location.host.replace("www.", "");
internal = new RegExp(internal, "i");
var a = document.getElementsByTagName('a'); // then, grab every link on the page
for (var i = 0; i < a.length; i++) {
var href = a[i].host; // set the host of each link
if( !internal.test(href) ) { // make sure the href doesn't contain current site's host
a[i].setAttribute('target', '_blank'); // if it doesn't, set attributes