Skip to content

Instantly share code, notes, and snippets.

@adaam
adaam / cloudwatch_s3_size.py
Last active October 21, 2023 22:43
Query S3 bucket size by cloudwatch get-metric-data
#!/usr/bin/env python3
# inspire by https://www.slsmk.com/getting-the-size-of-an-s3-bucket-using-boto3-for-aws/
import boto3
import datetime
def main():
# Get all regions
ec2 = boto3.setup_default_session(region_name='us-east-1')
ec2 = boto3.client('ec2')
desc_regions = ec2.describe_regions()
@reecestart
reecestart / set-intelligent-lifecycle.py
Created December 3, 2018 05:08
Gets all S3 Buckets and creates an Intelligent Tiering Lifecycle Rule on all of them.
import boto3
from datetime import date
from datetime import datetime
today = date.today()
today = datetime.combine(today, datetime.min.time())
client = boto3.client('s3')
# Get all buckets
response = client.list_buckets()
@davideicardi
davideicardi / uuidHelpers.js
Created November 16, 2017 15:52
Mongodb uuid helpers
// Javascript helper functions for parsing and displaying UUIDs in the MongoDB shell.
// This is a temporary solution until SERVER-3153 is implemented.
// To create BinData values corresponding to the various driver encodings use:
// var s = "{00112233-4455-6677-8899-aabbccddeeff}";
// var uuid = UUID(s); // new Standard encoding
// var juuid = JUUID(s); // JavaLegacy encoding
// var csuuid = CSUUID(s); // CSharpLegacy encoding
// var pyuuid = PYUUID(s); // PythonLegacy encoding
// To convert the various BinData values back to human readable UUIDs use:
// uuid.toUUID() => 'UUID("00112233-4455-6677-8899-aabbccddeeff")'
@xaphod
xaphod / RXTimer.h
Last active January 5, 2023 08:57 — forked from couchdeveloper/RXTimer.h
A timer based on dispatch_source_create()Objective-C
//
// RXTimer.h
//
// Copyright 2013 Andreas Grosam
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@FrancesCoronel
FrancesCoronel / sampleREADME.md
Last active March 26, 2024 01:21
A sample README for all your GitHub projects.

Repository Title Goes Here

Frances Coronel

INSERT GRAPHIC HERE (include hyperlink in image)

Subtitle or Short Description Goes Here

ideally one sentence >

@jeffjohnson9046
jeffjohnson9046 / git-ignore.sh
Created August 11, 2015 21:02
Remove unwanted files from a git repo AFTER adding a .gitignore. The files will remain on disk.
## I just ran into this after initializing a Visual Studio project _before_ adding a .gitignore file (like an idiot).
## I felt real dumb commiting a bunch of files I didn't need to, so the commands below should do the trick. The first two commands
## came from the second answer on this post: http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files
# See the unwanted files:
git ls-files -ci --exclude-standard
# Remove the unwanted files:
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
@montanaflynn
montanaflynn / streamer.js
Created January 27, 2015 19:38
Streaming a response with Express.js
var express = require('express')
var app = express()
app.listen(1337)
app.all('/stream/:chunks', function (req, res, next) {
res.writeHead(200, {
'Content-Type': 'text/plain',
@wrobstory
wrobstory / redshift.sql
Created November 5, 2014 16:53
Redshift debugging queries
-- Gets all queries for a given date range
select starttime, endtime, trim(querytxt) as query
from stl_query
where starttime between '2014-11-04' and '2014-11-05'
order by starttime desc;
-- Gets all queries that have been aborted for a given date range
select starttime, endtime, trim(querytxt) as query, aborted
from stl_query
where aborted=1
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@gitaarik
gitaarik / git_submodules.md
Last active May 25, 2024 06:48
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.