Skip to content

Instantly share code, notes, and snippets.

@jpastuszek
jpastuszek / EC2 RI prices from pricing API.sql
Created December 8, 2016 11:49
Process EC2 price list csv with SQLite to get RI prices
-- curl https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.csv | tail -n +6 > ec2.csv.no_head
-- sqlite> .mode csv
-- sqlite> .import ec2.csv.no_head ec2
-- sqlite> .save ec2.sqlite
WITH prices AS (
WITH
loc AS (
SELECT "Asia Pacific (Sydney)" AS Location, "ap-southeast-2" AS Region
@stefzki
stefzki / resize-mongodb-oplog.sh
Last active January 2, 2018 12:10
MongoDB Replica Set Oplog Resize Helper Script
#!/bin/sh
function usage() {
echo
echo "Resizing the local MongoDB RS Oplog"
echo
echo "Usage:"
echo "mongodb_resize_oplog <mongodb local port> <mongodb data path> <new oplog size in gb> <user:group for data dir>"
echo
echo "Example:"
@ogavrisevs
ogavrisevs / aws-temp-token.sh
Created July 29, 2015 16:36
Script to generate AWS STS token
#!/bin/bash
#
# Sample for getting temp session token from AWS STS
#
# aws --profile youriamuser sts get-session-token --duration 3600 \
# --serial-number arn:aws:iam::012345678901:mfa/user --token-code 012345
#
# Based on : https://github.com/EvidentSecurity/MFAonCLI/blob/master/aws-temp-token.sh
#
@leommoore
leommoore / mongodb_indexes.md
Last active May 31, 2018 06:59
MongoDB Indexes

#MongoDB Indexes There are 5 different index types supported in MongoDB.

  1. Regular (B-Tree) - supports indexes on a single or multiple fields
  2. Geo - supports indexing on a geographical location (useful for finding locations nearby)
  3. Text - Allows for search engine like full text searching
  4. Hashed - This is used primarily used for sharding as it evenly distributes the hashes rather than clustering them.
  5. Time to Life - This supports expiring based on a document date field

##Create Index

@chronossc
chronossc / devpi-server-article.md
Created November 25, 2013 04:00
Article/how to about how install devpy-server (not finished yet)

dev-pi install howto

This guide follow instructions in the devpi quickstart server guide. We will install in own user home using virtualenvs, than, will setup a nginx instance. Server used here is Ubuntu Server 12.04 LTS in one virtualbox instance.

Create devpi user

root ~ # useradd -m -U -s /bin/bash devpi
root ~ # passwd devpi
@joeyAghion
joeyAghion / mongodb_collection_sizes.js
Last active February 9, 2024 22:37
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
@m14t
m14t / fix_github_https_repo.sh
Created July 5, 2012 21:57
Convert HTTPS github clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi