Skip to content

Instantly share code, notes, and snippets.

@phawk
phawk / spotify.coffee
Last active Aug 28, 2015
Hubot spotify-mac-api client
View spotify.coffee
module.exports = (robot) ->
api_url = process.env.HUBOT_SPOTIFY_MAC_API_URL
api_secret = process.env.HUBOT_SPOTIFY_MAC_API_SECRET
options = {}
options.commands = [
"play (track|artist|album) <name> - Play a given track, artist or album",
"play queue <1,2,3> - Play a given search result",
"pause - Pause the current song",
"toggle - Play/pause the current song",
View Gruntfile.js
/*global module:false*/
module.exports = function(grunt) {
var WEB_SERVER_PORT = 8000,
LIVERELOAD_PORT = 35729;
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
@phawk
phawk / config.ru
Created Sep 1, 2014
Middleman config.ru for usage with pow/anvil for mac
View config.ru
# From: https://github.com/middleman/middleman/pull/560
require "rubygems"
require "middleman-core/load_paths"
Middleman.setup_load_paths
require "middleman-core"
require "middleman-core/preview_server"
@phawk
phawk / html5
Created Mar 18, 2011
shortcut that doesn't rely on .js
View html5
// you need js if you want to reference:
header{
color: 'pink';
}
// but without the need for js you can have:
<header id="header">
and do
#header{
color: 'pink';
View gist:892064
public function add_facebook( $id, $fb_access_token )
{
$data = array('fb_access_token' => $fb_access_token);
$this->db->where('id', $id);
if( $this->db->update( $this->db_table, $data ) )
{
return TRUE;
}
else
{
View peteyswitch
<?php
$start = microtime();
$x = 1;
do{
$x++;
$result = null;
$i = 0;
View gist:925170
<?php
$start = microtime();
$x = 1;
do{
$x++;
$result = null;
$i = 0;
View gist:966534
<script type="text/javascript">
/*
* Basic reusable form validation
*
* @author Pete Hawkins <pete@craftydevil.co.uk>
* @created 2011-05-11
* @requires jQuery
*
* Setup:
* Add your fields as objects in an array to the validatorConfig.fields object.
View gist:1259458
# custom prompt
# pman, open man in preview
pman() { man -t "$@" | open -f -a Preview; }
# aliases
alias planzaivps="ssh -p 1892 batman@planzai.com"
# open files in coda
alias coda="open -a Coda"
@phawk
phawk / php-recursive-closure
Created Jan 4, 2012
php recursive closure
View php-recursive-closure
public function save()
{
//
// Find the root ID of the category to make selecting much easier
//
// Get all categories
$all_categories = $this->all_categories();
$parent_id = $this->get_parent_id();