This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks to Sebastian Kreutzberger | |
# Source: http://www.lecloud.net/post/61401763496/install-update-to-python-2-7-and-latest-pip-on-ec2 | |
# install build tools | |
sudo yum install make automake gcc gcc-c++ kernel-devel git-core -y | |
# install python 2.7 and change default python symlink | |
sudo yum install python27-devel -y | |
sudo rm /usr/bin/python | |
sudo ln -s /usr/bin/python2.7 /usr/bin/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks to Sebastian Kreutzberger | |
# Source: http://www.lecloud.net/post/61401763496/install-update-to-python-2-7-and-latest-pip-on-ec2 | |
# install build tools | |
sudo yum install make automake gcc gcc-c++ kernel-devel git-core -y | |
# install python 2.7 and change default python symlink | |
sudo yum install python27-devel -y | |
sudo rm /usr/bin/python | |
sudo ln -s /usr/bin/python2.7 /usr/bin/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
PNAME="$(basename $0)" | |
USER="jgarner1" | |
PIDFILE="$HOME/messaging/celery.pid" | |
LOGFILE="$HOME/messaging/celery.log" | |
AUTOSCALE="1,1" | |
start() { | |
if [ $# -eq 1 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging | |
from math import sqrt | |
def generate_primes(number): | |
logger = logging.getLogger(str(os.getpid()) + ':logger') | |
for num in range(number + 1): | |
# prime numbers are greater than 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading, os, logging | |
from math import sqrt | |
class threadsafe_iterator: | |
def __init__(self, iterator): | |
self.iterator = iterator | |
self.lock = threading.Lock() | |
def __iter__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import log | |
def is_valid_number(number, base): | |
for i in reversed(range(int(log(number, 10)) + 1)): | |
digit = number / 10 ** i | |
number -= digit * 10 ** i | |
if digit >= base: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Just to get a random list of numbers | |
import random | |
id_list = range(1, 101) | |
find_list = random.sample(id_list, random.randint(1, len(id_list))) | |
find_list.sort() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import botocore | |
from boto3.s3.transfer import S3Transfer | |
def lookup(s3, bucket_name): | |
try: | |
s3.meta.client.head_bucket(Bucket=bucket_name) | |
except botocore.exceptions.ClientError as e: | |
error_code = int(e.response['Error']['Code']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import botocore | |
def key_exists(s3_client, bucket, key): | |
""" | |
Checks if an S3 key exists. | |
Args: | |
s3_client (S3.Client): The AWS S3 client. | |
bucket (str): The AWS S3 bucket name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Override by passing whatever you want | |
REPO_HOME=$HOME/Work | |
if [ $# -eq 1 ] | |
then | |
REPO_HOME=$1 | |
fi |
OlderNewer