Skip to content

Instantly share code, notes, and snippets.

allybee / _contrast-color.scss
Last active Apr 21, 2016
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.
View _contrast-color.scss
// Returns either the $light or $dark color by deciding which contrasts more
// with $color using the YIQ color space (
// 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 / CanonicalUrls.php
Last active Jun 19, 2018
Redirect to canonical URLs and add the canonical tag in concrete5 v5.7 (including /index.php?cID=123 format)
View CanonicalUrls.php
<?php // application/src/Helpers/CanonicalUrls.php
namespace Application\Src\Helpers;
use Concrete\Core\Routing\Redirect;
use Config;
use Page;
* Class CanonicalUrls
allybee / Pretty Radios &
Last active Jan 21, 2016
Generated by
View Pretty Radios &
View .gitignore_global
### Archives ###
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
allybee / robots-staging.txt
Last active Jan 4, 2016
Disallow robots on Staging server
View robots-staging.txt
User-agent: *
Disallow: /
allybee / Grunt.applescript
Created Aug 28, 2014
AppleScript Service: Takes selected folder in Finder, opens the path in iTerm, and runs grunt.
View Grunt.applescript
-- 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"
set myterm to (make new terminal)
allybee / .htaccess.concrete5
Last active Dec 19, 2015
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.
View .htaccess.concrete5
# 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 / target_blank.js
Last active Oct 31, 2021
Add target="_blank" to external links with pure JavaScript.
View target_blank.js
function targetBlank() {
// remove subdomain of current site's url and setup regex
var internal ="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