Here are some notes on the various ways to check disk space usage on linux:
Disk usage of all (non-hidden) files and folders
Using the du
command (disk use) with the -s
(summarize) and -h
(human-readable) options.
du -sh *
from io import BytesIO | |
import gzip | |
import shutil | |
def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'): | |
"""Compress and upload the contents from fp to S3. | |
If compressed_fp is None, the compression is performed in memory. | |
""" |
When calling a Lambda Function via Boto3, the returned object is something like:
{u'Payload': <botocore.response.StreamingBody object at 0x7f8d5b62ac50>,
'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '5bdbb3ca-3b35-11e7-9816-397b140c3bac', 'HTTPHeaders': {'x-amzn-requestid': '5bdbb3ca-3b35-11e7-9816-397b140c3bac', 'content-length': '1636', 'x-amzn-trace-id': 'root=1-591ca199-00d34d5474d16275ec2c8d10;sampled=0', 'x-amzn-remapped-content-length': '0', 'connection': 'keep-alive', 'date': 'Wed, 17 May 2017 19:16:41 GMT', 'content-type': 'application/json'}}, u'StatusCode': 200}
The Payload
parameter is <botocore.response.StreamingBody>
which is a data streaming object.
var _fetchedResultsController: NSFetchedResultsController<Entity>? = nil | |
var blockOperations: [BlockOperation] = [] | |
var fetchedResultController: NSFetchedResultsController<Entity> { | |
if _fetchedResultsController != nil { | |
return _fetchedResultsController! | |
} | |
let fetchRequest: NSFetchRequest<Entity> = Entity.fetchRequest() | |
let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).managedObjectContext! |
#!/usr/bin/env python3 | |
''' | |
`@beartype` decorator, implementing a rudimentary subset of PEP 484-style type | |
checking based on Python 3.x function annotations. | |
See Also | |
---------- | |
https://stackoverflow.com/a/37961120/2809027 | |
Stackoverflow answer introducing the `@beartype` decorator. |
import json | |
import boto3 | |
settings = { | |
"aws.cloudsearch.doc": | |
"<doc-ep>", | |
"aws.cloudsearch.search": | |
"<search-ep>" | |
} | |
from avail.aws.cloudsearch import get_cloudsearch_endpoint_from_settings | |
doc = get_cloudsearch_endpoint_from_settings("doc", settings) |
To remove a submodule you need to:
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \ | |
--header 'Accept: application/vnd.github.v3.raw' \ | |
--remote-name \ | |
--location https://api.github.com/repos/owner/repo/contents/path | |
# Example... | |
TOKEN="INSERTACCESSTOKENHERE" | |
OWNER="BBC-News" | |
REPO="responsive-news" |
Problem: When linking to the raw version of a gist, the link changes with each revision.
Solution:
To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/
To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]
#!/bin/bash | |
# bash generate random alphanumeric string | |
# | |
# bash generate random 32 character alphanumeric string (upper and lowercase) and | |
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
# bash generate random 32 character alphanumeric string (lowercase only) | |
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1 |