Skip to content

Instantly share code, notes, and snippets.

@doppiomacchiatto
doppiomacchiatto / gist:33e662bf2d7a72abc827defd09cfb670
Last active August 15, 2017 21:06 — forked from griggheo/gist:2698152
dynamodb batchwriteitem in boto
import os
import sys
import subprocess
import re
import optparse
import boto
dynamodb_conn = boto.connect_dynamodb(aws_access_key_id='MY_ACCESS_KEY_ID', aws_secret_access_key='MY_SECRET_ACCESS_KEY')
table_name = 'mytable'
dynamodb_table = dynamodb_conn.get_table(table_name)
@doppiomacchiatto
doppiomacchiatto / sample_sns_event.json
Created August 3, 2017 21:04 — forked from yyolk/sample_sns_event.json
AWS Lambda SNS Sample Event
{
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:EXAMPLE",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "1970-01-01T00:00:00.000Z",
"Signature": "EXAMPLE",
@doppiomacchiatto
doppiomacchiatto / sqs.js
Created August 9, 2017 00:48 — forked from riston/sqs.js
SQS recursive polling
var aws = require('aws-sdk');
var util = require('util');
var SQS = new aws.SQS({
accessKeyId: 'xxxx',
secretAccessKey: 'xxx',
region: 'xxx',
sslEnabled: false,
paramValidation: true,
convertResponseTypes: true,
@doppiomacchiatto
doppiomacchiatto / gist:5af36f334c5cfe9f310db84282928224
Created August 14, 2017 22:34 — forked from tjcorr/gist:3baf86051471062b2fb7
CloudFormation to demo etcd-aws-cluster
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "An etcd cluster based off an auto scaling group",
"Mappings" : {
"RegionMap" : {
"eu-central-1" : {
"AMI" : "ami-840a0899"
},
"ap-northeast-1" : {
"AMI" : "ami-6c5ac56c"
@doppiomacchiatto
doppiomacchiatto / deregister.sh
Created August 17, 2017 06:45 — forked from bpholt/deregister.sh
Stop tasks on ECS Container Instance and Deregister it from ECS Cluster
#!/bin/bash
cluster=default
container_instance= # container instance guid
tasks=$(aws --region us-west-2 ecs list-tasks --container-instance $container_instance --cluster $cluster | jq -r '.taskArns | map(.[40:]) | reduce .[] as $item (""; . + $item + " ")')
for task in $tasks; do
aws --region us-west-2 ecs stop-task --task $task --cluster $cluster
done
aws --region us-west-2 ecs deregister-container-instance --cluster $cluster --container-instance $container_instance
@doppiomacchiatto
doppiomacchiatto / gist:bcf879b09761fc4871bd623839b4cd52
Created August 27, 2017 18:29 — forked from dpapathanasiou/gist:2790864
Using lxml to parse the Microsoft API translation result from the xml
#!/usr/bin/python
from lxml import etree
def get_text_from_msmt_xml (xml):
"""Parse the xml string returned by the MS machine translation API, and return just the text"""
text = []
doc = etree.fromstring(xml)
for elem in doc.xpath('/foo:string', namespaces={'foo': 'http://schemas.microsoft.com/2003/10/Serialization/'}):
@doppiomacchiatto
doppiomacchiatto / Vagrantfile
Created October 21, 2017 17:05 — forked from bergantine/Vagrantfile
Vagrant config for basic Python development
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
@doppiomacchiatto
doppiomacchiatto / README.md
Created October 30, 2017 00:40 — forked from dergachev/README.md
Vagrant tutorial

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

@doppiomacchiatto
doppiomacchiatto / 1_kubernetes_on_macOS.md
Created December 21, 2017 01:15 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@doppiomacchiatto
doppiomacchiatto / add.sh
Created January 2, 2018 18:09 — forked from ArseniyShestakov/add.sh
My compiler alternatives
# Cleanup old alternatives
update-alternatives --remove-all cc
update-alternatives --remove-all c++
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --remove-all clang
update-alternatives --remove-all clang++
update-alternatives --remove-all icc
update-alternatives --remove-all icc++