Skip to content

Instantly share code, notes, and snippets.

View fatmatto's full-sized avatar
🎯
Focusing

Mattia Alfieri fatmatto

🎯
Focusing
View GitHub Profile
@fatmatto
fatmatto / MultipleInheritant.php
Created April 26, 2011 14:52
Pretending multiple inheritance in php5
<?php
namespace qoo\core;
/**
@fatmatto
fatmatto / MultipleInheritantUsage.php
Created April 26, 2011 14:53
Pretending multiple inheritance in php5 Part2 Usage
<?php
class Pirate
{
public function doPirateStuff()
{
echo "YARRRRRRRR I SINK SHIPS!";
}
}
class Cyborg
@fatmatto
fatmatto / emitToSomeone.js
Last active December 10, 2015 04:08
How to emit to a specific user using socket.io and session.socket.io
//Usual express config
var SessionSockets = require('session.socket.io'),
sessionSockets = new SessionSockets(io, sessionStore, cookieParser); //sessionStore and cookieParser are from connect/express
sessionSockets.on("connection",function(err,socket,session) {
if (err)
console.log(err);
else {
console.log("Joining channel "+session.username);
socket.join(session.username); //This creates a socket.io room with a single socket.
@fatmatto
fatmatto / gist:3b2c51ea3ca28ea52d38
Created July 16, 2015 07:03
Marketcloud Get Products
{
"method": "GET",
"url": "http://api.marketcloud.it/v0/products/22",
"httpVersion": "HTTP/1.1",
"cookies": [],
"headers": [
{ "name": "Accept", "value": "application/json" },
{ "name": "Content-Type", "value": "application/json" },
{ "name": "X-Auth-Token", "value": "YOUR_TOKEN_HERE" }
],
@fatmatto
fatmatto / gist:ec395133d8ad98280a39
Created July 17, 2015 09:17
Marketcloud GET /brands HAR
{
"method": "GET",
"url": "http://api.marketcloud.it/v0/brands",
"httpVersion": "HTTP/1.1",
"cookies": [],
"headers": [
{ "name": "X-Auth-Token", "value": "YOUR_TOKEN_HERE" }
],
"queryString" : []
}
@fatmatto
fatmatto / marketcloud.json
Created August 22, 2015 16:20
Marketcloud apis.json
{}
@fatmatto
fatmatto / marketcloud-token.js
Last active September 8, 2015 15:38
Get a token marketcloud
var superagent = require('superagent'),
crypto = require('crypto');
var current_time = Date.now(),
public_key = "YOUR-PUBLIC-KEY",
secret_key = "YOUR-SECRET-KEY",
hash = crypto.createHash('sha256')
.update(secret_key+current_time)
.digest('base64');
@fatmatto
fatmatto / marketcloud-token.sh
Last active February 29, 2016 14:07
Generate a marketcloud token with curl
#!/bin/bash
timestamp=$(date +%s)
hashedSecret=$(echo -n "YOUR_SECRET_KEY$timestamp" | openssl sha256 -binary | base64)
curl -XPOST -H "Content-Type: application/json" -d "{\"publicKey\" : \"YOUR_PUBLIC_KEY\",\"secretKey\" : \"${hashedSecret}\",\"timestamp\" : ${timestamp}}" http://api.marketcloud.it/v0/tokens
@fatmatto
fatmatto / marketcloud_file_upload.js
Last active December 13, 2016 23:15
Reading a file and uploading it with Marketcloud and the Javascript SDK
// Creating a new instance of the Marketcloud client
var client = new Marketcloud.Client({
public_key: 'your-public-key'
})
// File uploads requires at least user authentication
client.users.authenticate('example@mail.com', 'somepassword')
.then(function(response) {
// Auth was successful the client stored the user's auth token
@fatmatto
fatmatto / marketcloud_razorpay.php
Last active January 20, 2017 13:51
How to receive a razorpay event and update a Marketcloud order
<?php
// You need to install the Marketcloud SDK, you will find information on GitHub
// https://www.marketcloud.it/documentation/reference/php
/*
* Here you can find the data structure sent as a POST request
* The reference event is order.paid
https://docs.razorpay.com/v1/page/webhooks
*
*/