Skip to content

Instantly share code, notes, and snippets.

@SavvyGuard
SavvyGuard / ty_vs_fy_mortgage.py
Last active August 29, 2015 14:02
mortgage 15 vs 30 year
def total_saved(monthly_sum, total_years, ror):
year = 0
total_sum = 0
year_sum = monthly_sum*12
while year <= total_years:
year += 1
total_sum += year_sum
total_sum *= ror
return total_sum
@SavvyGuard
SavvyGuard / pricedecrypt.py
Created August 20, 2014 21:28
openx price decryption
# The incoming encrypted price is unpadded websafe base64 encoded of length 38
# This is obtained from base64 encoding the encrypted price, and *then*
# websafe base64 encoding the already encoded encrypted price.
encrypted_price_base64_wsbase64 = 'SjpvRwAB4kB7jEpgW5IA8p73ew9ic6VZpFsPnA'
# We first add padding
encrypted_price_base64_wsbase64_padded = 'SjpvRwAB4kB7jEpgW5IA8p73ew9ic6VZpFsPnA=='
@SavvyGuard
SavvyGuard / liverailtest.json
Last active August 29, 2015 14:07
LiveRail Test BidRequest
{
"id": "LR_544697890b8bb5.19955162",
"imp": [
{
"id": "1",
"video": {
"mimes": [
"video/mp4",
"video/x-flv",
"video/webm"
@SavvyGuard
SavvyGuard / dwq.py
Last active August 29, 2015 14:10
Makes requests to the data warehouse and returns results in json
# /usr/bin/python
import subprocess
import argparse
import json
import datetime
@SavvyGuard
SavvyGuard / liverailrequester.py
Created January 9, 2015 23:54
Makes a bench of requests to liverail test endpoint on bidder for profiling
import requests
import json
data = {
"bcat": [
"IAB25",
"IAB7-39",
"IAB8-18",
"IAB8-5",
"IAB9-9"
@SavvyGuard
SavvyGuard / createplacement.sh
Last active August 29, 2015 14:15
create placement in api
curl http://0.0.0.0:3005/placements/api/1.0/create?apikey=pyroturtle -X POST -d '{"impressions": 6000, "geo_region": ["US-CA"], "device__browser": ["Chrome"], "device_os": ["Windows 7", "Windows 8", "Windows 8.1"], "campaign": "54be9b9cdcfad93307ef8b99", "bid": 10}' -H "Content-Type: application/json"
curl http://0.0.0.0:3005/placements/api/1.1/54be9b9cdcfad93307ef8b99/pacing?apikey=pyroturtle -X POST
curl http://0.0.0.0:3005/placements/api/1.1/54be9b9cdcfad93307ef8b99/pacing?apikey=pyroturtle -X PUT -d '{"thursday":{"cap":3000,"0":{"hour_cap":600,"minutes_active":[[0,60]]},"1":{"hour_cap":600,"minutes_active":[[0,60]]},"2":{"hour_cap":600,"minutes_active":[[0,60]]},"3":{"hour_cap":600,"minutes_active":[[0,60]]},"4":{"hour_cap":600,"minutes_active":[[0,60]]},"5":{"hour_cap":600,"minutes_active":[[0,60]]},"6":{"hour_cap":600,"minutes_active":[[0,60]]},"7":{"hour_cap":600,"minutes_active":[[0,60]]},"8":{"hour_cap":600,"minutes_active":[[0,60]]}}}' -H "Cont
@SavvyGuard
SavvyGuard / samplebidrequest.json
Created February 12, 2015 23:43
sample bidrequest
{
"badv": [
"adjghajogh2iohwrgiofhjo.com"
],
"bcat": [
"Automotive",
"Gambling",
"Alcohol"
],
"id": "90f39442f6615a1e1f31e879771b9ef7",
@SavvyGuard
SavvyGuard / mopubvideoampsample
Last active August 29, 2015 14:16
sample app mopub videoamp test bidresponse
{
"ext": {
"vamp_uuid": "477ce014-c140-11e4-a189-123e43da4f5e"
},
"seatbid": [
{
"bid": [
{
"nurl": "http://vast.videoamp.com/vast/54f4eb6added912e45b3c9b2?price=${AUCTION_PRICE}&vamp_uuid=477ef9da-c140-11e4-a189-123e43da4f5e&ex=mpb&auction_id=${AUCTION_ID}",
"cid": "54f4eb6added912e45b3c9b2",
@SavvyGuard
SavvyGuard / simpleprogressbar.py
Created July 29, 2013 18:38
Simple Progress Bar for outputting to console
import sys
def _progressBar(state):
progress_bar = '=' * state
sys.stdout.write('\r'+progress_bar)
sys.stdout.flush()
@SavvyGuard
SavvyGuard / launchec2.py
Created July 29, 2013 22:23
Launch an ec2 instance and then wait until they're ready
import sys
import boto
import boto.ec2
def _launchAWSInstances():
connection = boto.ec2.connect_to_region(AWS_REGION, aws_access_key_id = AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_ACCESS_KEY_SECRET)
global reservation
reservation = connection.run_instances(AWS_AMI,
key_name=AWS_SSH_KEY_NAME,
instance_type=AWS_INSTANCE_SIZE,