Skip to content

Instantly share code, notes, and snippets.

@AngeloR
AngeloR / gist:860674
Created March 8, 2011 18:09
Url Shortening with Goo.gl
<?php
$longUrl = 'http://facebook.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'http://goo.gl/api/shorten');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'security_token=null&url='.$longUrl);
$content = curl_exec($ch);
curl_close($ch);
<?php
/**
* Created by Ryan J | ryanjayako@gmail.com
* Date:
* Version : v1.1
*/
include("config.ini.php");
@AngeloR
AngeloR / Step_1.php
Created April 11, 2011 15:24
Getting started with limonade-php
<?php
include('lib/limonade.php');
?>
@AngeloR
AngeloR / Step_2.php
Created April 11, 2011 15:30
Getting started with limonade-php
<?php
include('lib/limonade.php');
dispatch_get('/', function() {
return "Hello, World!";
});
run();
@AngeloR
AngeloR / Step_3.php
Created April 11, 2011 16:18
Lemondoo, a limonade-php tutorial
<?php
include('lib/limonade.php');
dispatch_get('/','get_todo_list');
dispatch_post('/','add_todo');
dispatch_get('/:id','get_todo');
dispatch_put('/:id','update_todo');
dispatch_delete('/:id','delete_todo');
@AngeloR
AngeloR / Step_4.php
Created April 12, 2011 04:54
Lemondoo, a limonade-php tutorial
<?php
function configure() {
$c = mysql_connect('localhost','root','');
$s = mysql_select_db('todo',$c);
}
?>
@AngeloR
AngeloR / lemon_mysql.php
Created April 14, 2011 15:20
Simple mysql wrapper for lemonade-php
<?php
/**
* A quick little function to interact with a MySQL database.
*
* When working with Limonade-php a full-fledged MySQL wrapper seems like
* overkill. This method instead accepts any mysql statement and if it works
* returns either the result or the number of rows affected. If neither worked,
* then it returns false
*
* @param string $sql the sql statement you want to execute
@AngeloR
AngeloR / dump mysql
Created April 18, 2011 20:11
dump mysql database
mysqldump --user=username --password=1234 --databases your_database --opt --quote-names --allow-keywords --complete-insert > your_database.sql.bz2
@AngeloR
AngeloR / datasource.php
Created April 19, 2011 20:48
Sample datasource for OPCDataGrid implementation
<?php
$data = array(
array(
'user_id' => 1,
'username' => 'skywalkl',
'email' => 'luke.skywalker@rebelalliance.ht'
),
array(
'user_id' => 2,
'username' => 'solohan',
@AngeloR
AngeloR / example_opcdatagrid.php
Created April 20, 2011 16:59
Example of OPCDataGrid usage
<?php
$res = db('select product_id,name,short_description from products order by name asc');
$dg = new OPCDataGrid($res);
$dg->fields(array(
'name' => 'Product Name',
'short_description' => 'Description'
));