Skip to content

Instantly share code, notes, and snippets.

View rhossi's full-sized avatar

Felipe Garcia rhossi

View GitHub Profile
HTTPD_CONFD = "/etc/httpd/conf.d/"
HTTPD_WWW = "/var/www/"
def create_vhost(site)
vhost = <<-eos
<VirtualHost *:80>
\tDocumentRoot /var/www/#{site}
\tServerName #{site}
</VirtualHost>
eos
@rhossi
rhossi / gist:615abafc602028ecbe01
Created June 29, 2014 23:55
Allow an IAM user access to one of your buckets
{
"Statement":[
{
"Effect":"Allow",
"Action":[
"s3:ListAllMyBuckets"
],
"Resource":"arn:aws:s3:::*"
},
{
@rhossi
rhossi / resultset
Last active August 29, 2015 14:03
Resultado Query exemplo IMDB
{
"status":{
"rid":"9Z+48u4oJQqVLio=",
"time-ms":15
},
"hits":{
"found":485,
"start":0,
"hit":[
{
@rhossi
rhossi / gist:3611a7729b26e0aad4d6
Created June 30, 2014 19:45
Query de exemplo
q=(or genres:'Action')&q.parser=structured&fq=(or genres:'Adventure' genres:'Fantasy')
@rhossi
rhossi / s3upload.sh
Created July 30, 2015 18:51
Uploading files to S3 validating ContentMD5 using AWS CLI
# (1) aws s3api put-object é padrão, tem a mesma sintaxe para Mac, Linux e Windows
# (2) openssl está disponível no Mac e no Linux, pode ser instalado no Windows com o cygwin
# (3) openssl dgst -md5 -binary demo-diebold.txt vai gerar o MD5 em binário do arquivo informado (ex: demo-diebold.txt)
# (4) openssl enc -base64 vai converter o valor informado para Base64
# (5) o | (pipe) faz a passagem do output da execução do comando 4 para o comando 5, e gera como ouput final o MD5 em Base64
# (6) a chamada $(openssl dgst -md5 -binary demo-diebold.txt | openssl enc -base64) que passamos para o --content-md5 é para primeiro gerar o hash MD5 em Base64 do arquivo, e então passar o output para o aws s3api put-object ser executado
aws s3api put-object --bucket megasenateste --key demo-diebold.txt --body ./demo-diebold.txt --content-md5 $(openssl dgst -md5 -binary demo-diebold.txt | openssl enc -base64)
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10', region: 'us-east-1'});
var params = {
TableName: 'Produtos',
ExpressionAttributeValues: {
':id' : { 'S' : '1' }
},
KeyConditionExpression: 'Id = :id'
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10', region: 'us-east-1'});
var params = {
TableName: 'Produtos',
KeyConditionExpression: 'Id = :id',
ExpressionAttributeValues: {
':id' : '1'
}
[ { [InvalidParameterType: Expected params.ExpressionAttributeValues[':id'] to be a structure]
message: 'Expected params.ExpressionAttributeValues[\':id\'] to be a structure',
code: 'InvalidParameterType',
time: Wed Aug 19 2015 09:49:42 GMT-0300 (BRT) },
{ [UnexpectedParameter: Unexpected key '0' found in params.ExpressionAttributeValues[':id']]
message: 'Unexpected key \'0\' found in params.ExpressionAttributeValues[\':id\']',
code: 'UnexpectedParameter',
time: Wed Aug 19 2015 09:49:42 GMT-0300 (BRT) } ]
{"message":"One or more parameter values were invalid: Condition parameter type does not match schema type","code":"ValidationException","time":"2015-08-19T12:50:48.382Z","statusCode":400,"retryable":false}
from __future__ import print_function
from datetime import datetime
from urllib2 import urlopen
SITES = ['http://produto.mercadolivre.com.br/MLB-726627332-mini-pc-intel-nuc-i5-16gb-ssd-250-samsung-evo-5i5ryh-_JM', 'http://produto.mercadolivre.com.br/MLB-726629981-surface-4-pro-i5-8gb-ram-256-hd-teclado-e-mouse-_JM', 'http://produto.mercadolivre.com.br/MLB-716571875-iphone-6-plus-com-128gb-na-cor-space-gray-_JM'] # URL of the site to check
def lambda_handler(event, context):
try:
for num in range(1,10):