Skip to content

Instantly share code, notes, and snippets.

View flavianmissi's full-sized avatar

Flavian Missi flavianmissi

View GitHub Profile
@flavianmissi
flavianmissi / macosx.txt
Created September 8, 2013 02:56
output of building gevent with pypy on mac and ubuntu
$ python --version
Python 2.7.3 (480845e6b1dd, Jul 31 2013, 10:58:28)
[PyPy 2.1.0 with GCC 4.2.1 Compatible Clang Compiler]
$ uname -a
Darwin MAC185954.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
Unpacking /Users/flavia.carlette/projects/gevent
Running setup.py egg_info for package from file:///Users/flavia.carlette/projects/gevent
@flavianmissi
flavianmissi / lxml-pypy.md
Last active January 24, 2016 10:42
Building and installing lxml with pypy2.1.0 and python 2.7.3 (ubuntu 13.04)

Bootstrap

Follow Andrews' post to install PyPy: andrewsmedina.com/2013/07/28/introducao-ao-pypy/

Create a virtualenv (I'm using virtualenvwrapper) with pypy executable:

  $ mkvirtualenv lxml-pypy -p /path/to/bin/pypy
@flavianmissi
flavianmissi / backuper.py
Last active December 11, 2015 10:38
backuper structure for tsuru
class Backuper(object):
def __init__(access, secret):
pass
def backup(self, instances):
image_id = self.snapshot(instances)
self.remove_old()
self.save_current(image_id)
@flavianmissi
flavianmissi / describe_lbs.go
Last active December 10, 2015 05:48
DescribeLoadBalancers action
type DescribeLoadBalancerResp struct {
LoadBalancerDescriptions []LoadBalancerDescription
}
type LoadBalancerDescription struct {
AvailZones []string
BackendServerDescriptions []BackendServerDescriptions
CanonicalHostedZoneName string
CanonicalHostedZoneId string
CreatedTime time.Time //datetime
@flavianmissi
flavianmissi / create_lb.go
Last active December 10, 2015 04:18
sample load balancer creation using goamz with validation error (missing Listeners)
package main
import (
"fmt"
"launchpad.net/goamz/aws"
"launchpad.net/goamz/elb"
)
func main() {
auth := aws.Auth{"access", "secret"}
e := elb.New(auth, aws.Region{ELBEndpoint: "https://elasticloadbalancing.amazonaws.com"})
createLB := &elb.CreateLoadBalancer{Name: "testLB"}
@flavianmissi
flavianmissi / migration.js
Created September 27, 2012 20:28
mongodb "migration" script
// changes the data in db.collection[from] to
// db.collection[to] and deletes db.collection[from]
// how can I force the execution of the variables from and to?
function changeFieldKey(collection) {
var docs = db[collection].find({"from-key": {$exists: true}});
for (var i = 0; i < docs.length(); i++) {
print(docs[i])
docs[i]["to-key"] = docs[i]["from-key"];
delete docs[i]["from-key"];
print(docs[i])
@flavianmissi
flavianmissi / database_settings.py
Created August 22, 2012 22:10
Sample database config for Django. Possible via tsuru
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'MYSQL_DATABASE_NAME',
'USER': 'MYSQL_USER',
'PASSWORD': 'MYSQL_PASSWORD',
'HOST': 'MYSQL_HOST',
'PORT': 'MYSQL_PORT',
}
}
@flavianmissi
flavianmissi / keystone.log
Created July 10, 2012 13:04
Keystone log generated by a call to openstack ec2 api by goamz
2012-07-10 09:43:48 DEBUG [keystone.common.wsgi] ******************** RESPONSE BODY ********************
2012-07-10 09:43:48 DEBUG [keystone.common.wsgi] {"access": {"token": {"expires": "2012-07-11T12:43:48Z", "id": "1ed8531cf222422c9a77eb8319ff1df5", "tenant": {"description": null, "enabled": true, "id": "3358
4a4f9c624ccea054db3ae2f253db", "name": "paas"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://nova:8774/v2/33584a4f9c624ccea054db3ae2f253db", "region": "RegionOne", "publicURL": "
http://nova:8774/v2/33584a4f9c624ccea054db3ae2f253db", "internalURL": "http://nova:8774/v2/33584a4f9c624ccea054db3ae2f253db"}], "endpoints_links": [], "type": "compute
", "name": "Compute Service"}, {"endpoints": [{"adminURL": "http://swift:8080", "region": "RegionOne", "publicURL": "http://swift:8080", "internalURL": "http://swift.
:8080"}], "endpoints_links": [], "type": "s3", "name": "S3 Service"}, {"endpoints": [{"adminURL": "http://glance:9292/v1", "region": "RegionOne", "publicURL": "http://glance:9292/
@flavianmissi
flavianmissi / ec2_openstack.go
Created July 9, 2012 21:50
Testing goamz against openstack
package main
import (
"fmt"
"launchpad.net/goamz/aws"
"launchpad.net/goamz/ec2"
)
var auth aws.Auth
var region aws.Region
@flavianmissi
flavianmissi / rsyslog-install.sh
Created June 12, 2012 14:07
Rsyslog installation script (ubuntu 12.04)
#!/bin/bash
sudo apt-get update
sudo apt-get -y install make libmysqlclient-dev x11-apps
wget http://www.rsyslog.com/files/download/rsyslog/rsyslog-4.6.1.tar.gz
tar xvf rsyslog-4.6.1.tar.gz
cd rsyslog-4.6.1
sudo mkdir /var/log/rsyslog # replace by your $WorkDirectory value, if any