Skip to content

Instantly share code, notes, and snippets.

View fndiaz's full-sized avatar
:octocat:

Fernando fndiaz

:octocat:
  • São Paulo
View GitHub Profile
@fndiaz
fndiaz / curl.md
Created July 13, 2018 22:32 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@fndiaz
fndiaz / auth.py
Last active May 23, 2017 19:15
requisições http
import urllib2
import urllib
from cookielib import CookieJar
from xml.dom.minidom import parseString
cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
response = opener.open("http://192.168.1.100/astmanager/asterisk/mxml?action=login&username=user&secret=senha")
var = response.read()
# -*- coding: utf-8 -*-
#########################################################################
## Database initialization
#########################################################################
from images import THUMB #use PIL to create the photo thumb
from widgets import Radio, Upload, Checkbox
from customvalidators import IS_EMPTY_OR_MASK_OR
auth.settings.hmac_key = G.auth.security_key # before define_tables()
#auth table
@fndiaz
fndiaz / xml_func.py
Last active December 19, 2015 03:08
manipulando xml com ajax jquery
def read_xml():
cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.open("http://192.168.1.100/astmanager/asterisk/mxml?action=login&username=admanager&secret=ad9898")
tree = ElementTree(file=opener.open('http://192.168.1.100/astmanager/asterisk/mxml?action=queuestatus'))
#print tree
r = tree.getroot()
#print r
@fndiaz
fndiaz / loop.js
Created June 28, 2013 19:39
loop ajax jquery
<script>
$(document).ready(function(){
function poll() {
$.ajax({
method: "get",
url: "initial/gera_zip",
dataType: "json",
success: function(lista){
for(var i=0, l=lista.length; i<l; i++){
@fndiaz
fndiaz / face_pictures.py
Created May 21, 2013 01:57
facebook get pictures perfil
import urllib2, requests, json, sys
reload(sys)
sys.setdefaultencoding("utf-8")
r=requests.get('https://graph.facebook.com/me/friends?access_token=CAAAAAITEghMBALwFqDAZBkD7ptrp00ZBoLVWavPBd736XH8bekkuv7y9UYjyoAQFVjIZB7cXkQbnC4uLrc8XjAZAHAonohN339yFTkA2QhkcTqhP9Br1d1HLbt4HXLclHAWyjqEinnLrJpDTTcXFhFZBZCftBzoTkZD')
users = r.json()
i=0
for user in users['data']:
print '############ User ############'
@fndiaz
fndiaz / face_client.py
Created May 21, 2013 01:47
xmpp facebook client
#!/usr/bin/python
# coding: utf-8
import sys, xmpp, os, signal, time, re, commands, requests, json
reload(sys)
sys.setdefaultencoding("utf-8")
def messageCB(conn,msg):
mess=str(msg.getBody())
rec=str(msg.getFrom())
rec0=rec.split('/')[0]
@fndiaz
fndiaz / snmp.py
Last active August 29, 2015 14:19
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
def gera_snmp(var):
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('localhost', 161)),
var
import iplib
ips = ["10.4.4.6", "10.4.4.250", "10.4.4.100", "10.4.4.5", "10.4.4.25"]
def ip_compare(x, y):
""" Compare two IP addresses. """
# Convert IP addresses to decimal for easy comparison
dec_x = int(iplib.convert(x, "dec"))
dec_y = int(iplib.convert(y, "dec"))
if dec_x > dec_y:
@fndiaz
fndiaz / gist:bc74a07b9585ae4feb24
Created March 30, 2015 13:32
Curl with parameters
curl --data "email=fndiaz@gmail.com&senha=1234" http://127.0.0.1:8000/admanager/crm/login_crm
curl --data "email=fndiaz@gmail.com&senha=1234" -X GET http://127.0.0.1:8000/admanager/crm/login_crm