Skip to content

Instantly share code, notes, and snippets.

@adenot
adenot / getConf.py
Created May 29, 2013 05:30
Getting a file from S3 and writing to the disk using authentication in python/boto
import sys, getopt
from boto.s3.connection import S3Connection
conn = S3Connection('YOURKEY', 'YOURSIGNATURE')
from boto.s3.key import Key
bucket = conn.get_bucket('proxy-templates')
k = Key(bucket)
k.key = 'web/lighttpd.conf'
k.get_contents_to_filename('lighttpd.conf')
"""
The portfolio rebalancing bot will buy and sell to maintain a
constant asset allocation ratio of exactly 50/50 = fiat/BTC
"""
import strategy
DISTANCE = 7 # percent price distance of next rebalancing orders
FIAT_COLD = 0 # Amount of Fiat stored at home but included in calculations
COIN_COLD = 0 # Amount of Coin stored at home but included in calculations
@adenot
adenot / gist:6418844
Created September 3, 2013 01:43
CloudFormation template validation using a proxy
<?php
include 'aws.phar';
use Aws\CloudFormation\CloudFormationClient;
$client = CloudFormationClient::factory(array(
'region' => 'ap-southeast-2',
'key' => '__redacted__',
'secret' => '__redacted __',
'curl.options' => array(
@adenot
adenot / apt.yml
Created January 19, 2014 08:07
Ansible playbook: Avoid apt module report changed when no packages actually changed.
- name: Ensure packages are installed
apt: pkg={{ item }} state=present
with_items:
- git
- python-keyczar
- php5-cli
- php5-sqlite
- php5-json
- php5-mcrypt
- php-gettext
@adenot
adenot / composer.yml
Created January 19, 2014 08:09
Ansible playbook: Installing php composer only once. The tasks checks if composer.phar exists before executing it for the second time.
- name: Installing composer.phar
shell: chdir=/app/bin creates=/app/bin/composer.phar php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
@adenot
adenot / locale.yml
Created January 19, 2014 08:10
Ansible playbook: Generates a new locale only if it was not generated before
- name: Check for pt_BR locale
shell: grep pt_BR /var/lib/locales/supported.d/local
register: locale_pt_BR
ignore_errors: true
changed_when: false
- name: Create pt_BR locale
shell: locale-gen pt_BR.UTF-8
when: locale_pt_BR.rc == 1
@adenot
adenot / composer-install.yml
Created January 19, 2014 08:11
Ansible playbook: Runs composer install in your app only if composer.lock doesn't exist. Runs it async because composer can take a long time to execute, resulting in a ssh timeout.
- name: Composer install
shell: chdir=/app/web creates=/app/web/composer.lock /app/bin/composer.phar install
async: 600
poll: 2
@adenot
adenot / find_ami
Created January 21, 2015 05:05
Ansible module find_ami - it returns image_id from an AMI name
#!/usr/bin/env python
# USAGE:
# Save this as: library/find_ami
# inside your ansible project folder
#
# chmod +x library/find_ami
#
# Playbook task:
# - find_ami:
@adenot
adenot / cloudfront_headers_https.json
Created June 19, 2016 03:29
Cloudfront headers passed to the origin from a CURL request. (with "Forward Headers: All" option)
{
"host": "staging.REDACTED",
"x-amz-cf-id": "TeSvfNKhljGl5v1Nldr0ApgX0LbmW25-sfTbOvU-kfSxjBAszhQNOQ==",
"connection": "Keep-Alive",
"user-agent": "curl/7.47.0",
"via": "1.1 74b217f6de96253e0ed5551fd50bc165.cloudfront.net (CloudFront)",
"x-forwarded-for": "52.62.49.205",
"cloudfront-is-mobile-viewer": "false",
"cloudfront-is-tablet-viewer": "false",
"cloudfront-is-smarttv-viewer": "false",
@adenot
adenot / kittycore.sol
Created December 7, 2017 03:05
KittyCore v0.4.18+commit.9cf6e910
pragma solidity ^0.4.11;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;