Skip to content

Instantly share code, notes, and snippets.

// this bit is important
$w('a div p span img table thead td th tr tbody tfoot input').each(function(e) {
window['$' + e] = function() {
return new Element(e, arguments[0]);
}
});
function addLocation(partId) {
// create the element
newPart = $div({
<?php
error_reporting(E_ALL);
require_once('config.php');
// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it or make something more sophisticated.
/**********************************************************************
******* COMMENTED TO ENABLE THE INSTALL_DEV.PHP FILE TO BE USED *******
***********************************************************************
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
Options +FollowSymLinks +ExecCGI
AddDefaultCharset utf-8
<IfModule mod_authz_host.c>
<FilesMatch "\.(lock|conf)$">
Order deny,allow
Deny from all
</FilesMatch>
<?php
class Checks
{
public static function getRequired()
{
sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N'));
return array(
array(version_compare(phpversion(), '5.2.4', '>='),
@hamstar
hamstar / shellcommand.php
Created May 7, 2011 15:04
Nice wrapper for the exec command
<?php
class ShellCommand {
private $last_line;
private $cmd;
private $output = array();
private $return_value;
function __construct( $cmd, $escape=true ) {
@hamstar
hamstar / MY_Factory.php
Created August 3, 2011 22:53
Boilerplate structure for CI models
<?php
class MY_Factory extends CI_Model {
public static function create() {
}
public static function find( $id ) {
@hamstar
hamstar / gist:1127306
Created August 5, 2011 10:56
commands to install chiliproject on a dreamhost system
rm ~/.gem*
gem install bundler
PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
cd ~
git clone git://github.com/chiliproject/chiliproject.git
cd chiliproject
git checkout stable
@hamstar
hamstar / base.rhtml
Created August 20, 2011 21:47
My changes (read: hacks) to the chiliproject layout file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><%=h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'application', :media => 'all' %>
@hamstar
hamstar / modelshow.java
Created August 23, 2011 15:41
example of drying up code through inheritance, the facade pattern, and convention over configuration
// Get a model from the database, client says
Connection conn = DatabaseConnectionHelper.getConnection(); // make this static
DBFacade db = new DBFacade( conn );
ExampleModel exModel = ExampleModel.find( db, 15 );
exModel.setName('blah').save();
exModel.delete();
// classes
public class SuperModel {
@hamstar
hamstar / gist:1180273
Created August 30, 2011 05:51
UNTESTED simple Oracle SQL procedure that gets a products price, multiplies it by the quantity and adds it to the sales table
/* Add a sale */
CREATE OR REPLACE PROCEDURE add_sale(
v_cust_id customers.id%TYPE,
v_prod_id products.id%TYPE,
v_qty sales.qty%TYPE
)
IS
v_price_single products.price%TYPE;
v_price_total sales.price%TYPE;
BEGIN