Skip to content

Instantly share code, notes, and snippets.

View shofetim's full-sized avatar

Jordan Schatz shofetim

View GitHub Profile
@shofetim
shofetim / .htaccess
Created October 14, 2011 23:20 — forked from mudge/.htaccess
Remove file extensions in URLs with mod_rewrite but preserve 404 errors.
# The following will allow you to use URLs such as the following:
#
# example.com/anything
# example.com/anything/
#
# Which will actually serve files such as the following:
#
# example.com/anything.html
# example.com/anything.php
#
@shofetim
shofetim / php
Created October 20, 2011 18:19
Possible bug with CakePHP pagination?
//From a forms_controller.php
if (!empty($this->passedArgs['query'])) {
$this->paginate =
array(
'conditions' => array(
'or' =>
array(
'Form.title LIKE ' => '%' . $this->passedArgs['query'] . '%',
'Tag.title LIKE ' => '%' . $this->passedArgs['query'] . '%',
)
SELECT COUNT(*) AS `count`
FROM `forms` AS `Form`
LEFT JOIN forms_tags AS `FormsTags` ON (`Form`.`id` = `FormsTags`.`form_id`)
LEFT JOIN tags AS `Tag` ON (`FormsTags`.`tag_id` = `Tag`.`id`)
LEFT JOIN `statuses` AS `Status` ON (`Form`.`status_id` = `Status`.`id`)
LEFT JOIN `form_types` AS `FormType` ON (`Form`.`form_type_id` = `FormType`.`id`)
LEFT JOIN `summaries` AS `Summary` ON (`Form`.`summary_id` = `Summary`.`id`)
WHERE ((`Form`.`title` LIKE '%titl%') OR (`Tag`.`title` LIKE '%titl%'))
GROUP BY `Form`.`id` ;
SELECT count(distinct(`Form`.`id`)) as numberof
FROM `forms` AS Form
LEFT JOIN forms_tags AS `FormsTags` ON (`Form`.`id` = `FormsTags`.`form_id`)
LEFT JOIN tags AS `Tag` ON (`FormsTags`.`tag_id` = `Tag`.`id`)
LEFT JOIN `statuses` AS `Status` ON (`Form`.`status_id` = `Status`.`id`)
LEFT JOIN `form_types` AS `FormType` ON (`Form`.`form_type_id` = `FormType`.`id`)
LEFT JOIN `summaries` AS `Summary` ON (`Form`.`summary_id` = `Summary`.`id`)
WHERE ((`Form`.`title` LIKE '%titl%') OR (`Tag`.`title` LIKE '%titl%')) ;
@shofetim
shofetim / gist:1684184
Created January 26, 2012 18:23
BT ORM
<?php
class transfer extends App_BT_Object_Db {
/**
* Which single default database table relates to this object
*/
protected $_sDefaultTable = 'indusoft_transfers';
public function getAllEnabled()
{
@shofetim
shofetim / rotational pools
Created June 15, 2012 22:47
Rotational Pools data
'RotationalPool' => array(
'id' => '',
'name' => '',
'description' => '',
'abbrev' => '',
'duration' => array(
(int) 0 => array(
'ShiftBasic' => array(
'id' => '3',
'name' => 'Test',
SELECT
meta.name AS "Product Name",
CONCAT('A', location.aisle, ' S', location.shelf, ' B', location.bin) AS "Location",
(
SELECT
SUM(line.unit_price_at_checkout_time * line.quantity_shipped)
FROM orders_orderline AS line
INNER JOIN orders_order AS orders
ON orders.id = line.order_id
INNER JOIN products_product AS products
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
}
http {
gzip on;
gzip_types
text/html
application/javascript
application/x-javascript
SELECT
o.id AS "Order Number",
o.order_date AS "Order Date",
o.invoice_date AS "Invoice Date",
o.cached_post_shipped_invoiced_total AS "Amount",
CASE o.order_status
WHEN 1 THEN 'In Cart'
WHEN 2 THEN 'Resumed'
WHEN 3 THEN 'Placed'
WHEN 4 THEN 'Queued'
SELECT
product.code AS itemcode,
floor(piece.cached_possible_stock_available_count) AS stock_available,
product.cached_name AS list_name,
product.cached_%s_price AS price,
barcode.barcode AS upc,
SUBSTRING(product.code, 0, 3) AS category,
CASE WHEN meta.is_organic THEN 'TRUE'
ELSE 'FALSE'
END AS organic,