Skip to content

Instantly share code, notes, and snippets.

View andypearson's full-sized avatar

Andy Pearson andypearson

View GitHub Profile
var Interface = {
init : function()
{
this.append(new Interface.Button('Button 1', function() {
alert('Button 1 has been pressed!');
}));
this.append(new Interface.Button('Button 2', function() {
alert('Button 2 has been pressed!');
# In your view...
<%= render_navigation ['Home', 'Pages', { :text => 'Media', :url => '/admin/media_items' }, 'Users'], :admin => true %>
# In config/application.rb
config.autoload_paths += %W(#{Rails.root}/app/presenters)
@andypearson
andypearson / gist:282906
Created January 21, 2010 16:00
A bunch of useful Git workflows
# create an empty branch and pull from an alternate remote
$ git symbolic-ref HEAD refs/heads/<new-branch>
$ git rm --cached -r .
$ git clean -fdx
$ git pull <remote> <remote-branch>
# switch branch, cherry pick commits and push branch to different remote branch
$ git checkout <local-branch>
$ git cherry-pick <commit>
<?php
/*
Plugin Name: Twitter for Wordpress
Version: 1.9.7
Plugin URI: http://rick.jinlabs.com/code/twitter
Description: Displays your public Twitter messages for all to read. Based on <a href="http://cavemonkey50.com/code/pownce/">Pownce for Wordpress</a> by <a href="http://cavemonkey50.com/">Cavemonkey50</a>.
Author: Ricardo Gonz&aacute;lez
Author URI: http://rick.jinlabs.com/
*/
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>Ask UK</ShortName>
<Description>Ask UK Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" method="GET" template="http://uk.ask.com/web">
<Param name="q" value="{searchTerms}"/>
<Param name="search" value="search"/>
// Find a div
<div id="footer">([.\s\S]*?)</div>
# Service model
require 'nokogiri'
require 'open-uri'
class Service < ActiveRecord::Base
def self.download
items = []
pre {
clear:both;
margin-top:36px;
font-size:1.2em;
line-height:1.4;
color:#e2e1dc;
background-color:#232323;
border:3px solid #1c1c1c;
padding:15px;
overflow:auto;
<?php
$photos = array(
'one.jpg',
'two.jpg',
'three.jpg',
'four.jpg',
'five.jpg'
);
$photo = $photos[array_rand($photos)];
body {
font:62.5%/1.5 Helvetica, Arial, sans-serif;
}
/* ---- Clearfix */
.clearfix:after {
content:".";
display:block;
height:0;