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
s3_resource = boto3.resource('s3') | |
zip_obj = s3_resource.Object(bucket_name="bucket_name_here", key=zip_key) | |
buffer = BytesIO(zip_obj.get()["Body"].read()) | |
z = zipfile.ZipFile(buffer) | |
for filename in z.namelist(): | |
file_info = z.getinfo(filename) | |
s3_resource.meta.client.upload_fileobj( | |
z.open(filename), | |
Bucket=bucket, |
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
{ | |
"description": "<h2>A CHILDHOOD CLASSIC</h2><p>This is children's bedroom furniture at its very best. The Huckleberry Cabin Bed is wonderfully sturdy and combines storage with a cool place to snuggle down - it's a real childhood classic.</p><img src=\"https://www.gltc.co.uk/pws/client/images/catalogue/products/l2427/original/l2427_1.jpg\" alt=\"\">|<h2>KEY FEATURES</h2><p>Made from a solid beech frame, with MDF panels and a solid pine slatted base; it's painted in Ivory, so it coordinates well with our <a href=\"/category/dept/bedroom-furniture\">Islander Bedroom Furniture</a> range. Features deep drawers and large cupboards that extend the full width of the bed, and a practical ambidextrous ladder/safety rail attachment, to suit your space. Tested to BS: 8509; suitable for 4yrs+. Assembly service available (£100), includes <a href=\"/content/bed-mattress-guarantee\">10 Year GLTC Guarantee</a>.</p><img src=\"https://www.gltc.co.uk/pws/client/images/catalogue/products/l2427/original/l2427_2.jpg\" |
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 collections import defaultdict | |
table = [{"name": "a", "value": 10}, {"name": "b", "value": 110}, {"name": "b", "value": 10}] | |
c = defaultdict(int) | |
for d in table: | |
c[d['name']] += d['value'] | |
print c |
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
function thousdansSeparater(nStr) { | |
nStr += ''; | |
x = nStr.split('.'); | |
x1 = x[0]; | |
x2 = x.length > 1 ? '.' + x[1] : ''; | |
var rgx = /(\d+)(\d{3})/; | |
while (rgx.test(x1)) { | |
x1 = x1.replace(rgx, '$1' + ',' + '$2'); | |
} |
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
Sub Splitter() | |
Dim Mask As String | |
Dim Letters As Long | |
Dim Counter As Long | |
Dim DocName As String | |
Dim oDoc As Document | |
Dim oNewDoc As Document | |
Set oDoc = ActiveDocument | |
oDoc.Save |
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
dicts_with_values = [{"value": 30}, {"value": 20}, {"value": 1}] | |
""" Horrible! """ | |
result = reduce(lambda x, y: x + y, [i["value"] for i in dicts_with_values]) | |
""" Nice, Pythonic """ | |
result = sum([i["value"] for i in dicts_with_values]) |
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
# -*- coding: utf-8 -*- | |
import urllib | |
import xlrd | |
class ExchangeRates(): | |
""" | |
Class to fetch exchange rate information from the Central Bank of Ireland | |
Example: | |
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 email | |
import imaplib | |
import os | |
class PortalEmail(): | |
""" | |
Interface to downloading attachments from | |
an email address and save them to a folder. | |
TODO: Implement the with context protocol |
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
""" | |
Requirements: | |
AWS Account | |
Valid Access key and secret | |
A valid bucket setup | |
""" | |
from boto.s3.connection import S3Connection | |
from boto.s3.key import Key | |
import sys |
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
sudo apt-get update | |
sudo apt-get install -y libssl1.0.0 openssl | |
# Confirm Build Date is at least Aril 7th 2014 | |
openssl version -a | |
# Restart all services listed by this command: | |
sudo lsof -n | grep ssl | grep DEL |
NewerOlder