When unsing docker compose you can have a problem with the order of dependent linked containers
The solution is to start a script which tries to access a service and waits until it gets ready before loading your program
import pandas as pd | |
from boto3 import client | |
client = client(service_name='ec2') | |
prices = client.describe_spot_price_history(InstanceTypes=["m3.medium"], | |
AvailabilityZone="us-east-1a") | |
df = pd.DataFrame(prices['SpotPriceHistory']) | |
df.set_index("Timestamp", inplace=True) | |
df["SpotPrice"] = df.SpotPrice.astype(float) |
When unsing docker compose you can have a problem with the order of dependent linked containers
The solution is to start a script which tries to access a service and waits until it gets ready before loading your program
# Description: | |
# Get help from @yourorg/it for your information technology problems. Oh by the way.... Your Welcome. | |
# | |
# Commands: | |
# hubot it me <problem> - get help from @yourorg/it about your information technology <problem> | |
module.exports = (robot) -> | |
robot.respond /it(?: me)?(?: (.*))?/i, (msg) -> | |
problem = msg.match[1] |
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
eventInterval: 10000, | |
schedulePollEvent(event, interval) { | |
var eventInterval = interval || this.get('eventInterval'); | |
return Ember.run.later(()=>{ | |
event.apply(this); | |
this.set('timer', this.schedulePollEvent(event)); |
from cqlengine import columns | |
from cqlengine.models import Model | |
class Users(Model): | |
firstname = columns.Text() | |
age = columns.Integer() | |
city = columns.Text() | |
email = columns.Text() | |
lastname = columns.Text(primary_key=True) | |
def __repr__(self): |
from cassandra.cluster import Cluster | |
from cassandra.policies import (TokenAwarePolicy, DCAwareRoundRobinPolicy, RetryPolicy) | |
from cassandra.query import (PreparedStatement, BoundStatement) | |
cluster = Cluster( | |
contact_points=['127.0.0.1'], | |
load_balancing_policy= TokenAwarePolicy(DCAwareRoundRobinPolicy(local_dc='datacenter1')), | |
default_retry_policy = RetryPolicy() | |
) | |
session = cluster.connect('demo') |
The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
import time | |
import numpy as NP | |
from redis import StrictRedis as redis | |
# a 2D array to serialize | |
A = 10 * NP.random.randn(10000).reshape(1000, 10) | |
# flatten the 2D NumPy array and save it as a binary string | |
array_dtype = str(A.dtype) |
""" | |
This script was used to create the figures for http://jrsmith3.github.io/sample-logs-the-secret-to-managing-multi-person-projects.html from a PDF file containing some old CMU sample logs. | |
""" | |
import PyPDF2 | |
from wand.image import Image | |
import io | |
import os |