Skip to content

Instantly share code, notes, and snippets.

View nicolaiarocci's full-sized avatar

Nicola Iarocci nicolaiarocci

View GitHub Profile
@nicolaiarocci
nicolaiarocci / stefano.py
Last active March 31, 2018 17:24
questo server accetta una query tipo ?pin=P03&cmd=1 ed estrae i valori di pin e cmd che puoi testare per fare tutto quel che ti serve.
from flask import Flask, request
app = Flask(__name__)
def parse_request():
commands = {0:'L', 1:'H', 2:'U', 3:'K', 4:'W'}
cmd = commands.get(request.args.get("cmd", type=int))
pin = request.args.get("pin")
if pin:
var committente = new CessionarioCommittente();
committente.IdentificativiFiscali.CodiceFiscale = "01180680397";
committente.AltriDatiIdentificativi.Denominazione = "CIR 2000";
committente.AltriDatiIdentificativi.Sede.Indirizzo = "Via Sansovino 45";
committente.AltriDatiIdentificativi.Sede.CAP = "48124";
committente.AltriDatiIdentificativi.Sede.Comune = "Ravenna";
var fattura = new DatiFatturaBody();
fattura.DatiGenerali.Data = DateTime.Now;
fattura.DatiGenerali.TipoDocumento = "TD01";
@nicolaiarocci
nicolaiarocci / validate_objects.py
Created January 5, 2015 10:09
Validating complex user objects with Cerberus
import copy
from cerberus import Validator
from cerberus import errors
from collections import Mapping, Sequence
class ObjectValidator(Validator):
def __init__(self, *args, **kwargs):
@nicolaiarocci
nicolaiarocci / Microsoft .NET Framework 4.0 KB2468871 (x64).prq
Created September 8, 2014 08:22
.NET Framework 4.0 InstallShield KB2468871 Custom Prerequisites
<?xml version="1.0" encoding="UTF-8"?>
<SetupPrereq>
<conditions>
<condition Type="16" Comparison="2" Path="[WindowsFolder]Microsoft.NET\Framework\v4.0.30319" FileName="mscorlib.dll" ReturnValue="4.0.30319.233"></condition>
<condition Type="1" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\Microsoft\Updates\Microsoft .NET Framework 4 Extended\KB2468871\" FileName="" ReturnValue=""></condition>
<condition Type="1" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\Microsoft\Updates\Microsoft .NET Framework 4 Client Profile\KB2468871\" FileName="" ReturnValue=""></condition>
</conditions>
<operatingsystemconditions>
<operatingsystemcondition MajorVersion="5" MinorVersion="2" PlatformId="2" CSDVersion="" Bits="4" ProductType="1" ServicePackMajorMin="3"></operatingsystemcondition>
<operatingsystemcondition MajorVersion="5" MinorVersion="2" PlatformId="2" CSDVersion="" Bits="4" ProductType="2|3" ServicePackMajorMin="2"></operatingsystemcondition>

Keybase proof

I hereby claim:

  • I am nicolaiarocci on github.
  • I am nicolaiarocci (https://keybase.io/nicolaiarocci) on keybase.
  • I have a public key whose fingerprint is 3E83 939B 0635 B124 805A EB07 3CE7 F44C 719B 8FC6

To claim this, I am signing this object:

@nicolaiarocci
nicolaiarocci / sha1-mac.py
Last active December 13, 2015 22:28
Securing an Eve-powered API with SHA1+HMAC
# -*- coding: utf-8 -*-
"""
Auth-SHA1/HMAC
~~~~~~~~~~~~~~
Securing an Eve-powered API with Basic Authentication (RFC2617).
This script assumes that user accounts are stored in a MongoDB collection
('accounts'), and that passwords are stored as SHA1/HMAC hashes. All API
@nicolaiarocci
nicolaiarocci / bcrypt.py
Last active December 13, 2015 21:38
Securing a Eve-powered REST API, bcrypt-style
# -*- coding: utf-8 -*-
"""
Auth-BCrypt
~~~~~~~~~~~
Securing an Eve-powered API with Basic Authentication (RFC2617).
This script assumes that user accounts are stored in a MongoDB collection
('accounts'), and that passwords are stored as BCrypt hashes. All API
@nicolaiarocci
nicolaiarocci / mapping.py
Created February 3, 2012 14:02
Let's apply the @mimerender decorator to our function
@mimerender(
default = 'html',
html = render_html,
xml = render_xml,
json = render_json,
txt = render_txt
)
def index():
if request.method == 'GET':
return {'message': 'Hello, World!'}
render_xml = lambda message: '<message>%s</message>' % message
render_json = jsonify
render_html = lambda message: '<html><body>%s</body></html>' % message
render_txt = lambda message: message
@nicolaiarocci
nicolaiarocci / mimerender_flask_test
Created February 3, 2012 10:31
Test for Mimerender Flask
$ curl -H "Accept: application/html" localhost:5000/
<html><body>Hello, World!</body></html>
$ curl -H "Accept: application/xml" localhost:5000/
<message>Hello, World!</message>
$ curl -H "Accept: application/json" localhost:5000/
{'message':'Hello, World!'}
$ curl -H "Accept: text/plain" localhost:5000/