Skip to content

Instantly share code, notes, and snippets.

View speedmax's full-sized avatar

Taylor luk speedmax

View GitHub Profile
<?php
function openbet($class, $attrs = array()) {
$class = "Openbet_".ucwords($class);
return new $class;
}
class Openbet_Object {
function __construct($attrs = array()) {
# set object property
/*
Standarized Data API design in JSON object
we should also learn from google data API recommended attributes for
Events & activities
-http://base.google.com/base/api/itemTypeDocs?verticalName=events%20and%20activities&verticalLocale=en_US
Universal attributes
- http://base.google.com/base/api/universalAttributes?verticalLocale=en_US
specials:
title: Action all the time
country: [au]
url: http://centrebet.com/?GoSports
from: now
to: 02-09-2009
content: >
If the world of Sports and Racing has nothing to offer you, then
check out Centrebet’s Special & Entertainment Odds.
CREATE TABLE adrev_ad_types (
id int(11) NOT NULL auto_increment,
name varchar(64) NOT NULL default '',
template text,
PRIMARY KEY (id), KEY name (name))
CREATE TABLE adrev_ads (
id int(11) NOT NULL auto_increment,
userid int(11) NOT NULL default '0',
def index
@az_idols = ("a"..."z").reduce({}) do |result, letter|
res = Idol.find :all, :conditions=>["name LIKE ?", "#{letter}%"]
result[letter] = res unless res.empty?
result
end.sort
end
>> Product.find :all, :conditions => ["title LIKE ?", "c%"]
=> [#<Product id: 339768653, title: "Canon EOS 40D 10.1MP Digital SLR Camera", description: "This is an H1\r\n=============\r\n\r\n\r\n\r\nBuilding on the...", price: 1199.0, created_at: "2008-06-05 23:50:39", updated_at: "2008-09-05 12:31:06", quantity: 70, brand_id: 528229938, product_type_id: 985430838, price_min: #<BigDecimal:2483b98,'0.1199E4',4(8)>, price_max: #<BigDecimal:2483b5c,'0.1899E4',4(8)>, handle: "canon-eos-40d-101mp-digital-slr-camera", description_html: "<h1>This is an H1</h1>\n\n<p>Building on the success ...", filter: "markdown_filter">, #<Product id: 1024741415, title: "Casio Exilim EX-S10", description: "Casio has its finger in more pies than Billy Bunter...", price: 249.0, created_at: "2008-06-05 23:50:39", updated_at: "2008-06-05 23:50:39", quantity: 50, brand_id: 528229938, product_type_id: 425291712, price_min: #<BigDecimal:2483634,'0.249E3',4(8)>, price_max: #<BigDecimal:24835f8,'0.249E3',4(8)>, handle: "casio-exilim-ex-s1
@speedmax
speedmax / h2o works well.html
Created November 26, 2008 09:22
Beautiful template and data API
<div class="good-evans span-8 last" style="float:right">
{{ '/img/goodevans.png'|image_tag }}
<ul>
{% for article in site.articles_tagged.good-evans %}
<li>{{ article.title | links_to article.url }}</li>
{% endfor %}
</ul>
</div>
<div class="latest-buzz span-10">
<?php
h2o::addTag('load_sports_events');
class Load_sports_events_Tag extends H2o_Node {
function render($context, $stream) {
$cache = h2o_cache($context->options);
$cache_key = 'digg_xml_feed';
# try cached
if (! ($feed = $cache->read($cache_key))) {
$feed = file_get_contents('http://feeds.digg.com/digg/popular.rss');
// Option 1, flat tags
$page['tags'] = array('soccer', 'cricket betting', 'football');
// get keyword
<meta type="keyword" content="{{ page.tags|join }}"/>
// get list of tag links
{% for tag in page.tags %}
<a href="{{ tag|tag_url }} ">{{ tag }}</a>
{% endfor %}
<?php
/**
* Min
* ========================
* A lightweight framework to provide convient wrappers for PHP to improve
* grammers when programming
*
* @author Taylor luk
*/