Skip to content

Instantly share code, notes, and snippets.

View subnetmarco's full-sized avatar
🦍
Hiring, Thinking, Coding

Marco Palladino subnetmarco

🦍
Hiring, Thinking, Coding
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://mashape.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mashape.com http://mashape.com/schema/mashape-api-3.0.xsd">
<method name="Get User" http="GET">
<url><![CDATA[/users/{id}]]></url>
<parameters>
<parameter optional="false">id</parameter>
</parameters>
{
"name": "Mark",
"email": "[email protected]"
}
{
"code": 1,
"message": "The user does not exist"
}
@subnetmarco
subnetmarco / gist:1498896
Created December 19, 2011 21:12
New Spec
<api format="JSON">
<authentication type="header">
<description><![CDATA[This is a simple header authentication]]></description>
<authenticationParameters>
<authenticationParameter name="X-Pippo-Username">
<description><![CDATA[Please enter here your username]]></description>
</authenticationParameter>
<authenticationParameter name="X-Pippo-Password">
<description><![CDATA[Please enter here your password]]></description>
// Pseudo-code
HASH = BASE64(PUBLIC_KEY + ":" + HMAC_SHA1(UUID, PRIVATE_KEY) + UUID)
private void main() {
Long value = null;
if (value != null) {
printValue(value);
}
}
private void printValue(Long value) {
System.out.println(value.toString());
}
private void main() {
Long value = null;
printValue(value);
}
private void printValue(Long value) {
if (value != null) {
System.out.println(value.toString());
}
}
@subnetmarco
subnetmarco / gist:2939141
Created June 15, 2012 22:56
C# Mashape Authentication
// Put the "header" value into a "X-Mashape-Authorization" header before making the HTTP request
// Util functions to generate a HMAC_SHA1 hash and Base64 encode a value
private static String hmac_sha1(String publicKey, String privateKey) {
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] privateKeyBytes = encoding.GetBytes(privateKey);
byte[] publicKeyBytes = encoding.GetBytes(publicKey);
Iterable<Transaction> fetchAll = DAOFactory.getInstance().getTransactionDAO().fetchAll();
for (Iterator<Transaction> iterator = fetchAll.iterator(); iterator
.hasNext();) {
Transaction transaction = iterator.next();
LOG.info("Processing transaction: " + transaction.getId());
Subscription subscription = transaction.getSubscription();
if (subscription == null) {
LOG.error("Missing subscription for transaction: " + transaction.getId());
} else {
> db.subscriptions.find({"_id":ObjectId("4ed3f9b2d7fe63a70e1db113")}, {transactions:1})
{ "_id" : ObjectId("4ed3f9b2d7fe63a70e1db113"), "transactions" : [ {
"$ref" : "transactions",
"$id" : ObjectId("4f09ba1be4b0c4954881f4fc")
} ] }
> db.subscriptions.find({"_id":ObjectId("4ed3f9b2d7fe63a70e1db113")}, {transactions:1})
{ "_id" : ObjectId("4ed3f9b2d7fe63a70e1db113"), "transactions" : [ {
"$ref" : "transactions",
"$id" : ObjectId("4f09ba1be4b0c4954881f4fc")