Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
@thinkphp
thinkphp / gist:2375706
Created April 13, 2012 10:41
basket.require Usage in mentors
basket.require('javascript/Request.JSONP.js')
.require('javascript/Request.YQL.min.js')
.require('javascript/overlay.js')
.require('javascript/MooDialog.js')
.require('javascript/MooDialog.Request.js').wait(function(){
basket.require('javascript/domready.js')
})
@thinkphp
thinkphp / gist:2375762
Created April 13, 2012 10:44
basket.js
(function(context, document) {
"use strict";
var storagePrefix = "basket-",
scripts = [],
scriptsExecuted = 0,
waitCount = 0,
waitCallbacks = [],
@thinkphp
thinkphp / gist:2415146
Created April 18, 2012 17:14
table generation using Reflection
<?php
class Grid {
public function build($datasource, $headers, $fields) {
$out = '<table border="1">';
$out .= $this->_make_header($headers);
@thinkphp
thinkphp / gist:2419980
Created April 19, 2012 09:39
JSON Rest Service
/**
* JSON Service for HTTP REST GET
*/
class JsonService {
private $instance;
public function __construct($instance) {
$this->instance = $instance;
@thinkphp
thinkphp / gist:2423708
Created April 19, 2012 19:50
Create Flickr Service using JsonService
<?php
//create a service Flickr photos
require_once('jsonservice.php');
class Flickr {
/**
* Photos who's title, description, tags contain the text will be returned.
* @param $text String - A free text search.
@thinkphp
thinkphp / gist:2427437
Created April 20, 2012 09:57
Create Twitter Service using JsonService
require_once('jsonservice.php');
class Twitter {
const endpoint = 'http://twitter.com/statuses/user_timeline/';
public function get( $username, $count = 10 ) {
//call private method _curl for retrieve the data from service API Twitter in format xml
$statuses = $this->_curl( $username, $count );
@thinkphp
thinkphp / gist:2427440
Created April 20, 2012 09:58
Usage Twitter Service
<?php
$endpoint = 'http://thinkphp.ro/apps/ishackday/jsonservice/twitter.php/get?username=thinkphp';
$json = json_decode(file_get_contents($endpoint));
$response = $json->response;
print_r($response);
?>
@thinkphp
thinkphp / gist:2427460
Created April 20, 2012 10:01
Usage Flickr Service
$endpoint = 'http://thinkphp.ro/apps/ishackday/jsonservice/flickr.php/get?text=beach';
$json = json_decode(get($endpoint));
$response = $json->response;
function get($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
@thinkphp
thinkphp / gist:2427787
Created April 20, 2012 11:02
complete example twitter service
<?php
//action: http://thinkphp.ro/apps/ishackday/jsonservice/getTweets.php
if(isset($_GET['user'])):
$user = $_GET['user'];
else:
$user = 'thinkphp';
endif;
$endpoint = 'http://thinkphp.ro/apps/ishackday/jsonservice/twitter.php/get?username=' . $user ;
@thinkphp
thinkphp / gist:2436249
Created April 21, 2012 09:46
Create Subsets Service
<?php
require_once('jsonservice.php');
class Subsets {
public function get( $n ) {
return$ret = $this->_generate($n);
}