Skip to content

Instantly share code, notes, and snippets.

@hmps
hmps / as-pomodoro-spotify.scpt
Created February 8, 2012 16:38
Applescript to control Spotify through Pomodoro
on ApplicationIsRunning(appName)
tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
return appNameIsRunning
end ApplicationIsRunning
if not ApplicationIsRunning("Spotify") then
open location "SPOTIFY-URI"
delay 10
end if
@hmps
hmps / Walker with parent recognition
Created August 16, 2012 14:57
Custom Walker_nav_menu to add class to all items with children
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$has_children = get_posts(array('post_type' => 'nav_menu_item', 'meta_key' => '_menu_item_menu_item_parent', 'meta_value' => $item->ID)); /* Does the current item have any children? */
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
@hmps
hmps / comment.py
Created October 19, 2012 09:24
The way the comment filter in Zen Coding for Sublime Text 2 was designed didn't really appeal to me. Removed starting block and put ending block in same line as end tag.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Comment important tags (with 'id' and 'class' attributes)
@author Sergey Chikuyonok ([email protected])
@link http://chikuyonok.ru
'''
import zencoding
@hmps
hmps / rwd-alternate-row.css
Created December 4, 2012 08:42
Alternate row coloring in a responsive table
.container .row:nth-child(odd) > div:nth-child(odd), .container .row:nth-child(even) > div:nth-child(even) {
background-color: rgba(0, 0, 0, 0.05);
}
@hmps
hmps / Latest_tweet.php
Created December 17, 2012 06:37
Get latest tweet from Twitter API, insert anchor tags and return the string.
$url = "https://api.twitter.com/1/statuses/user_timeline/$userid.xml?count=1&include_rts=1callback=?";
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$xml = simplexml_load_file($url) or die("could not connect");
foreach($xml->status as $status){
$tweet = $status->text;
}
if(preg_match($reg_exUrl, $tweet, $url)) {
return preg_replace($reg_exUrl, "<a href=\"{$url[0]}\">{$url[0]}</a>", $string);
@hmps
hmps / Contract Killer 3.md
Last active December 13, 2015 23:49
Svensk version av Andy Clarkes "Contract Killer", ursprungligen uppladdad 2008 på http://24ways.org/2008/contract-killer/

Kontrakt

Senast uppdaterad: 2013-02-20

Mellan mig, [MITT NAMN] och er [KUNDENS NAMN], [KUNDENS ADRESS]

Sammanfattning:

Jag kommer alltid att göra mitt absolut yttersta för att tillfredsställa era önskemål och behov, men det är ändå för allas bästa att ha några rader nedskrivna om vad som är vad, vem som ska göra vad och vad som händer om något inte skulle gå som planerat. I det här kontraktet finns inga komplicerade juridiska termer eller långa stycken av oläslig text och jag har ingen önskan att få er att skriva på något som ni kan komma att ångra i framtiden. Detta är helt enkelt för bägge parters säkerhet, nu och i framtiden.

@hmps
hmps / bash_profile
Last active December 14, 2015 21:19
My .bash_profile
export PATH=/usr/local/bin:/opt/subversion/bin/:$PATH
export PATH="/usr/local/mysql/bin:$PATH"
# Set style of command prompt
export PS1="\W:> "
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Aliases for GIT
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
@hmps
hmps / _mixins.scss
Last active December 19, 2015 22:08
Sassylicious: Sweet mixins for SASS
//**************************************************************************//
// Handy mixins for SASS
//
// @author: Hampus Persson
//
// Credit to HTML5 Boilerplate, Foundation by Zurb & Inuit.css
//**************************************************************************//
//**************************************************************************//
// HIDDEN
@hmps
hmps / is_blog.php
Last active December 19, 2015 22:28 — forked from wesbos/is_blog.php
Check to discover if a WP-page is a part of the blog or not.
<?php
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
?>
<?php
// Usage