Skip to content

Instantly share code, notes, and snippets.

@wilhelser
wilhelser / gist:2650319
Created May 10, 2012 01:34
Mobile site re-direction
<?php
/**
* Check to see if the visitor is coming from the mobile site link
*
*/
$token = isset($_GET['token']) ? $_GET['token'] : null;
/**
* If they are coming from the mobile site, set a cookie that expires in 1 hour
namespace :load do
ZIP_CODE_DATA_URL = 'http://www.census.gov/tiger/tms/gazetteer/zips.txt'
# Swiped from ActiveRecord migrations.rb
def announce(message)
length = [0, 75 - message.length].max
puts "== %s %s" % [message, "=" * length]
end
@wilhelser
wilhelser / gist:3648960
Created September 6, 2012 00:42
Everything you can override in a refinerycms project with refinerycms-blog
When starting a project that includes refinerycms-blog:
$ rake refinery:override view=refinery/pages/*
$ rake refinery:override view=layouts/*
$ rake refinery:override view=refinery/blog/shared/*
$ rake refinery:override view=refinery/blog/posts/*
$ rake refinery:override view=refinery/*
$ rake refinery:override controller=refinery/blog/*
$ rake refinery:override controller=refinery/*
@wilhelser
wilhelser / ImageMagick Configure
Created September 8, 2012 01:58
Configuration for setting up ImageMagick to install RMagick gem
./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=$FONTS
@wilhelser
wilhelser / chef_solo_bootstrap.sh
Created October 23, 2012 22:26 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
mkdir ~/tmp && cd ~/tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p286.tar.gz
tar -xvzf ruby-1.9.3-p286.tar.gz
cd ruby-1.9.3-p286/
./configure --prefix=/usr/local
make
make install
@wilhelser
wilhelser / gist:4009892
Created November 4, 2012 02:38
Set up an Init Script for Nginx
Nginx is now installed in /opt/nginx, but there are no "init" scripts to control this process. Issue the following sequence of commands to download a script, move it to the proper directory, set the proper permissions and set system startup links:
cd /opt
wget -O init-deb.sh http://library.linode.com/assets/602-init-deb.sh
mv /opt/init-deb.sh /etc/init.d/nginx
chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults
<!-- ################## TEXTAREA FIELD ################## -->
<form action="">
<textarea name="test" id="test" cols="17" rows="5"></textarea>
</form>
<!-- ################ END TEXTAREA FIELD ################ -->
<!-- ################## ECHOING THE VALUE IN THE CALENDAR ################## -->
<?php echo nl2br($value); ?>
<!-- ################ END ECHOING THE VALUE IN THE CALENDAR ################ -->
@wilhelser
wilhelser / gist:4063881
Created November 13, 2012 04:10
Delete JS
<div id="zdpop" class="zpopup">
<img title="Edit" id="content_81850_editbutton" onclick="changediv(this,1,1);"
src="icons/edit_handle.jpg" style="cursor: pointer;"> <a class="delete" title="Delete"
onclick="ArticleSerialDel(this,'frontpage',19203,2504,1,81850,'frontpagelist_81850');"
href="javascript:void(0);"> <img src="icons/delete_handle.jpg">
</a> <img class="handle" src="icons/move_handle.jpg"
style="cursor: pointer;">
</div>
@wilhelser
wilhelser / calendar.css
Created November 27, 2012 23:39
Calendar Mods
.bigcalday {
height: 84px;
width: 84px;
background: #fcfaec;
font-size: 12pt;
overflow: hidden;
cursor: pointer;
}
.bigcalday:hover, .halfbigcalday:hover, .calcurrent {
background: #9DC9E0;
@wilhelser
wilhelser / states.rb
Last active December 10, 2015 11:58
Ruby helper for listing US states
def us_states
[
['AL', 'AL'],
['AK', 'AK'],
['AZ', 'AZ'],
['AR', 'AR'],
['CA', 'CA'],
['CO', 'CO'],
['CT', 'CT'],
['DE', 'DE'],