Skip to content

Instantly share code, notes, and snippets.

// Find parent category for related posts
global $post;
$category = get_the_category();
$cat_tree = get_category_parents($category[0]->term_id, FALSE, ':', TRUE);
$top_cat = split(':',$cat_tree);
$parent = $top_cat[0];
@shortcircuit3
shortcircuit3 / gist:3277760
Created August 6, 2012 19:23
Accessing the Lat Lng in the results object - Google Maps Geocoder
// Problem - The variables in the location object change frequently
var lat = results[0].geometry.location.Xx;
var lng = results[0].geometry.location.Xx;
// Solution - Use the lat() and lng() methods instead
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
@shortcircuit3
shortcircuit3 / gist:4161382
Created November 28, 2012 13:43
Randomize string on hover
var random_interval = 0;
var textArray = ['home','office','school','hotel','gym','daycare', "doctor's office"];
$(".random").hover(
function () {
random_interval = setInterval(function(){
var randomIndex = Math.floor(Math.random() * textArray.length);
var randomElement = textArray[randomIndex];
$('.random').text(randomElement);
}, 300);
@shortcircuit3
shortcircuit3 / gist:4169039
Created November 29, 2012 13:24
UserAgent detector
var userAgent = navigator.userAgent,
uaCheck = {
ios: userAgent.match(/(iPhone|iPod|iPad)/),
ipad: userAgent.match(/(iPad)/),
iphone: userAgent.match(/(iPhone)/),
blackberry: userAgent.match(/BlackBerry/),
android: userAgent.match(/Android/)
};
// Example
@shortcircuit3
shortcircuit3 / gist:4196114
Created December 3, 2012 16:31
A simple tooltip
var timeout;
function hide() {
timeout = setTimeout(function () {
$(".tooltip").css('margin-bottom', '-160px');
});
}
$(".button").mouseover(function () {
clearTimeout(timeout);

SoundCloud Design Challenge

Imagine you could rebuild SoundCloud. But you’d be restricted to only three actions a user could do. Which actions would you choose and how would you design that very simple SoundCloud app. (App could mean a native app for iOS or Android or a web app for Desktop or Mobile.)

As a deliverable we would expect a concept that is outlining your choices and your thoughts for the simplified app. We want to get an idea of how you think.

Your ideas should be illustrated with screens that go beyond wireframes. We should be able to get a good idea of your interaction and visual skills. As a plus you’d build a prototype.

@shortcircuit3
shortcircuit3 / middleman inline style.erb
Created February 22, 2013 10:29
Use this to output your stylesheet inline with middleman
<% css_path = sitemap.resources.select { |p| p.source_file.match(/all[.]css$/) }.first %>
<style type="text/css">
<%= css_path.render %>
</style>

Things that are nice to see in the design world

Rethinking conventions

Teehan + Lax's new website — They decided to exclude their portfolio and services page for a good reason. Read more about it on their blog

Hessian by Ben Pieratt — An interesting approach to corporate identity design. The inverse has been taught for years and it is refreshing to see someone question the status quo.

Things that are painful to see in the design world

@shortcircuit3
shortcircuit3 / sassroute.rb
Created March 21, 2013 10:57
Basic sinatra route for sass file
get '/style.css' do
content_type 'text/css', :charset => 'utf-8'
scss :style
end
var i = 0;
var f = 'F',
u = 'U',
c = 'C',
k = 'K';
setInterval(function(){
console.log(f + u + c + k);