Skip to content

Instantly share code, notes, and snippets.

@s3u
s3u / gist:1867773
Created February 20, 2012 04:06
Example (PHP)
<?php
function curl_get($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
@s3u
s3u / conf.ql
Created February 20, 2012 04:08
Example (ql.io)
ids = select itemId from ebay.finding.itemsbykeywords where keywords = '{q}' limit 5;
items = select ItemID, Location, GalleryURL from ebay.shopping.singleitem
where itemId = '{ids}';
bestOffers = select GetBestOffersResponse.BestOfferArray from ebay.trading.bestoffers
where itemId = '{ids}';
bidders = select GetAllBiddersResponse.BidArray from ebay.trading.getallbidders
where itemId = '{ids}';
return {
"user" : "{user}",
"item" : "{items}",
@s3u
s3u / gist:1883435
Created February 22, 2012 08:32
ql.io: Making Peace with Bad HTTP APIs

Step 1: Create a table

create table aws.swf
  on insert post to 'http://swf.us-east-1.amazonaws.com/'
  using headers 'X-Amz-Target' = 'com.amazonaws.swf.service.model.SimpleWorkflowService.RegisterDomain',
            'X-Amx-Encoding' = 'amz-1.0',
            'X-Amzn-Authorization' = '...'
  using bodyTemplate 'foo.json.mu' type 'application/json';       

Step 2: Describe the shape of the request body

@s3u
s3u / gist:1886983
Created February 22, 2012 20:20
Making Peace - table.ql
create table ebay.trading.placeoffer
on insert post to "https://api.ebay.com/ws/api.dll"
using headers "Content-Type" = "application/xml; charset=UTF-8",
"X-EBAY-API-DEV-NAME" = "your developer ID",
"X-EBAY-API-APP-NAME" = "your app name",
"X-EBAY-API-CERT-NAME" = "your cert name",
"X-EBAY-SIDEBAR-VERSION" = "747",
"X-EBAY-API-CALL-NAME" = "PlaceOffer",
"X-EBAY-API-SITEID" = "{siteId}",
"X-EBAY-API-COMPATIBILITY-LEVEL" = "747",
@s3u
s3u / gist:1886988
Created February 22, 2012 20:21
Making Peace - body
<?xml version="1.0" encoding="utf-8"?>
<PlaceOfferRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>en_US</ErrorLanguage>
{{#params}}
<ItemID>{{itemId}}</ItemID>
{{/params}}
{{#params}}
<EndUserIP>{{remoteAddress}}</EndUserIP>
{{/params}}
<Offer>
@s3u
s3u / gist:1886996
Created February 22, 2012 20:22
Making Peace - route
resp = insert into ebay.trading.placeoffer (siteId, itemId, offer, action, quantity)
values ("{siteId}", "{itemId}", "{offer}", "{action}", "{quantity}");
return resp via route
"/offers" using method post;
@s3u
s3u / io-fork-join
Created March 13, 2012 20:14
Fork/Join IO
var _ = require('underscore'),
http = require('http'),
URI = require('uri'),
async = require('async');
var sendReq = function (s, cb) {
// send a HTTP req, and pass error or result to the function arg
// content omitted for brevity
};
@s3u
s3u / io-fork-join2.js
Created March 13, 2012 20:28
IO fork/join more
var _ = require('underscore'),
http = require('http'),
URI = require('uri'),
async = require('async');
var sendReq = function (s, cb) {
// send a HTTP req, and pass error or result to the function arg
// content omitted for brevity
};
@s3u
s3u / gist:2031587
Created March 13, 2012 21:05
io-fork-join-orch-algo
repeat while pending > 0
for each statement
if task represented by the statement has no dependencies
pending++;
execute the task
on completion
pending--;
notify dependencies to update met dependencies
repeat this algo
end
@s3u
s3u / gist:2147268
Created March 21, 2012 14:19
Options to disable
var options = {
cluster: false,
port: process.env.VCAP_APP_PORT || 3000,
monPort: 3001,
config: cwd + '/config/dev.json',
tables: cwd + '/tables',
routes: cwd + '/routes',
xformers: cwd + '/config/xformers.json',
disableConsole: true,
disableQ: true,