Skip to content

Instantly share code, notes, and snippets.

# My version of an app template, modified by James Cox (imajes)
# SUPER DARING APP TEMPLATE 1.0 - By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/src/git/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
hazards = Hazard.find :all
states = State.find :all
for hazard in hazards
for state in states
sorted_mats = Array.new
total_storage = 0.0000
total_closed = 0.0000
total_open = 0.0000
for proj_mat in @project.project_materials
<?php
$my_post = get_post($my_id = 12);
echo $my_post->post_title;
echo $my_post->post_content;
?>
static e_STATE current_state;
void main_thread()
{
switch(current_state)
{
case STATE_A:
state_a();
break;
...
#include "sm.h"
static state_e current_state;
static void state_a_entry(void);
static void state_a_exit(void);
static void message_a_handler(void);
static void message_b_handler(void);
static void message_c_handler(void);
static const state_t state_list[] =
function sss_excerpt($string, $count, $string_tags = TRUE){
//it's blank, just return.
if ( '' == $string) return $string;
$string = str_replace(']]>', ']]&gt;', $string);
$string = strip_tags($string);
$words = explode(' ', $string, $count + 1);
if (count($words)> $count) {
array_pop($words);
$string = implode(' ', $words);
<?php
function get_image_from_content($content) {
// Define the pattern to search
$szSearchPattern = '~<img [^\>]*\ />~';
// Run preg_match_all to grab all the images and save the results in $aPics
preg_match_all( $szSearchPattern, $content, $aPics );
// Count the results
$iNumberOfPics = count($aPics[0]);
<?php
function convert_state($name, $to='name') {
$states = array(
array('name'=>'Alabama', 'abbrev'=>'AL'),
array('name'=>'Alaska', 'abbrev'=>'AK'),
array('name'=>'Arizona', 'abbrev'=>'AZ'),
array('name'=>'Arkansas', 'abbrev'=>'AR'),
array('name'=>'California', 'abbrev'=>'CA'),
array('name'=>'Colorado', 'abbrev'=>'CO'),
array('name'=>'Connecticut', 'abbrev'=>'CT'),
emails don't match
email already taken
email not valid
email and password don't match
you must accept terms
email not found
password too short
you have already bought this video
you have already rented this video
{
"album_order" = "{\"count\":3,\"album_order\":{\"36\":{\"zebra\":\"zebra\"},\"count\":3,\"album_order\":{\"35\":{\"album\":\"album\"},\"count\":\"1\",\"album_order\":{\"0\":{\"album_id\":\"34\",\"name\":\"from ios\",\"url_name\":\"from-ios\"}}}}}";
email = "wes.billman@gmail.com";
id = 2;
layout = tiled;
name = "Wes Billman";
"site_name" = wes;
"site_url" = wes;
theme = light;
}