Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
I will likely never set this status again.

Cody Peterson codyjames

🐢
I will likely never set this status again.
View GitHub Profile
View GetLinkitSchema.php
<?php
// yourmodule/src/listeners/GetLinkitSchema.php
namespace modules\hshelpers\listeners;
use fruitstudios\linkit\base\Link;
use fruitstudios\linkit\models\Entry;
use markhuot\CraftQL\Types\EntryInterface;
use fruitstudios\linkit\fields\LinkitField;
use markhuot\CraftQL\Events\GetFieldSchema;
@codyjames
codyjames / tag_slug_classes.php
Created Jan 14, 2014
Wordpress. Add the tags of a post to post_class();
View tag_slug_classes.php
// Add tags to post classes
function tag_slug_classes($classes) {
global $post;
$tags = get_the_tags();
if ($tags) {
foreach($tags as $tag) {
$classes[] = 'tag-'.$tag->slug;
}
}
return $classes;
@codyjames
codyjames / hs-responsive-images
Created Nov 26, 2013
Dumb idea for responsive images. Basically you would create a super tiny version of the image that's just a solid color or something. That would make it so the dimensions of the image would be correct without having to calculate them with JS or anything.
View hs-responsive-images
<img
src="/path/to/image/dimensions-only-solid-color-tiny-filesize.gif"
style="
@media only screen and (min-device-pixel-ratio: 2) { background-image: url('/path/to/image/high-res.jpg')}
@media screen and (max-device-pixel-ratio: 1.999) { background-image: url('/path/to/image/low-res.jpg')}
"
title="Image Title"
/>
@codyjames
codyjames / gist:2979464
Created Jun 23, 2012
CSS3 Animation Fix Glitch in Mobile Safari
View gist:2979464
// Assuming this
.foo {
-webkit-transition: -webkit-transform 1s ease-out;
}
.foo:hover {
-webkit-transform: translateX(20px);
}
@codyjames
codyjames / lastfmissue
Created Nov 8, 2011
Last.fm PHP cURL JSON
View lastfmissue
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=Josh+Harmony&api_key=d3fcabf421291d107802fce0fe2c2825&format=json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
$content = curl_exec($ch);
curl_close($ch);
$content = json_decode($content);
$events = $content->events;