Skip to content

Instantly share code, notes, and snippets.

View webysther's full-sized avatar
👨‍🔬
Can you solve the 3n + 1 problem?

Webysther Sperandio webysther

👨‍🔬
Can you solve the 3n + 1 problem?
View GitHub Profile
@uhho
uhho / pandas_s3_streaming.py
Last active December 2, 2022 18:57
Streaming pandas DataFrame to/from S3 with on-the-fly processing and GZIP compression
def s3_to_pandas(client, bucket, key, header=None):
# get key using boto3 client
obj = client.get_object(Bucket=bucket, Key=key)
gz = gzip.GzipFile(fileobj=obj['Body'])
# load stream directly to DF
return pd.read_csv(gz, header=header, dtype=str)
def s3_to_pandas_with_processing(client, bucket, key, header=None):

Getting Started With Superset: Airbnb’s data exploration platform

These instructions are for Amazon Linux Version 2

Update Python and PIP versions on EC2 (Amazon AMI)

sudo yum update -y
sudo yum install python3 -y
@mrshu
mrshu / aws_glue_python_shell_installed_packages.txt
Created February 1, 2019 09:22
AWS Glue Python Shell -- pre-installed packages
awscli==1.14.45
boto3==1.5.35
botocore==1.8.49
colorama==0.3.7
docutils==0.14
futures==3.2.0
jmespath==0.9.3
numpy==1.14.0
pandas==0.22.0
pip==9.0.1
@mrshu
mrshu / list_available_packages.py
Created February 4, 2019 15:49
Python list available packages
import pkg_resources
installed_packages = pkg_resources.working_set
for package in sorted(installed_packages, lambda x: x.key):
print "{}=={}".format(package.key, package.version)
@christopherhan
christopherhan / createSecureString.yaml
Last active August 25, 2022 18:35
Custom Lambda-backed CloudFormation resource to create a SecureString in ParameterStore
AWSTemplateFormatVersion: "2010-09-09"
Description: Put a SecureString parameter in SSM Parameter Store
Parameters:
KmsKeyId:
Type: String
Description: The KMS Key you want to use to encrypt the string.
SSMParameterKey:
Type: String
Description: The Parameter Store Key
SSMParameterValue:
@snixon
snixon / security-group-cleanup.py
Last active August 25, 2022 18:08 — forked from TomRyan-321/security-group-cleanup.py
Fancy Security Group Cleanup
#!/usr/bin/env python
import os
import boto3
import argparse
import json
# `pip install -U PTable` will get you the right fork of PrettyTable
from prettytable import PrettyTable
from botocore.exceptions import ClientError
@m4tthumphrey
m4tthumphrey / CronSchedule.php
Last active May 23, 2022 11:29
CronSchedule.php - Allows one to parse a cron expression into human readable text.
<?php
/*
* Plugin: StreamlineFoundation
*
* Class: Schedule
*
* Description: Provides scheduling mechanics including creating a schedule, testing if a specific moment is part of the schedule, moving back
* and forth between scheduled moments in time and translating the created schedule back to a human readable form.
*
* Usage: ::fromCronString() creates a new Schedule class and requires a string in the cron ('* * * * *', $language) format.
@pofider
pofider / 01-ebs.config
Created September 10, 2015 15:14
Attach EBS volume to amazon elastic beanstalk
# .ebextensions/01-ebs.config
commands:
01clear-if-unmounted:
command: if ! mount | grep /media/ebs_volume > /dev/nul; then rm -rf /media/ebs_volume; fi
02attach-volume:
command: aws ec2 attach-volume --region eu-central-1 --volume-id vol-ddb08e34 --instance-id $(curl -s http://169.254.169.254/latest/meta-data/instance-id) --device /dev/sdh
ignoreErrors: true
03wait:
command: sleep 10
04trymount:
@simecek
simecek / rmagic_example.ipynb
Last active January 16, 2021 13:29
How to add R code to your (IPython) Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ozanturksever
ozanturksever / get_uncompressed_size.py
Last active August 25, 2020 14:10
python get uncompressed size of a .gz file
def get_uncompressed_size(self, file):
fileobj = open(file, 'r')
fileobj.seek(-8, 2)
crc32 = gzip.read32(fileobj)
isize = gzip.read32(fileobj) # may exceed 2GB
fileobj.close()
return isize