Skip to content

Instantly share code, notes, and snippets.

@jarpy
jarpy / requirements.txt
Last active June 30, 2022 06:28
Serverless Elasticsearch Curator for AWS Lambda
certifi==2016.8.8
elasticsearch-curator==4.0.6
PyYAML==3.11
@bluebycode
bluebycode / port_redirection_iptables
Last active October 5, 2020 09:50
Port forwarding from 443 to 22 using iptables #iptables #forward #redirection
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 22
@aws-scripting-guy
aws-scripting-guy / get_account_id_lambda.py
Created March 6, 2016 23:49
Get AWS account id inside Lambda function programmatically - python
def lambda_handler(event, context):
# Get Account Id from lambda function arn
print "lambda arn: " + context.invoked_function_arn
# Get Account ID from lambda function arn in the context
ACCOUNT_ID = context.invoked_function_arn.split(":")[4]
print "Account ID=" + ACCOUNT_ID
@mozillazg
mozillazg / supervisord.service
Last active December 1, 2023 12:59 — forked from tonyseek/supervisord.service
install and configure supervisord on centos 7.
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
@dbf256
dbf256 / event_timer.py
Last active October 21, 2016 02:30
Event timer - simple time tracing for Python
import datetime
class EventTimer:
def __init__(self, name):
self.events = []
self.timer = None
self.name = name
def reset(self):
@krigar
krigar / ansible.cfg
Last active February 28, 2023 20:46
Bastion Playbook
[ssh_connection]
ssh_args = -F ssh.cfg
control_path = ~/.ssh/mux-%r@%h:%p
user nobody;
worker_processes auto;
error_log logs/error.log notice;
worker_rlimit_nofile 65535;
pid /var/run/nginx.pid;
events {
accept_mutex off;
@TomAugspurger
TomAugspurger / to_redshift.py
Last active September 16, 2021 16:55
to_redshift.py
# see also https://github.com/wrobstory/pgshift
import gzip
from io import StringIO, BytesIO
from functools import wraps
import boto
from sqlalchemy import MetaData
from pandas import DataFrame
from pandas.io.sql import SQLTable, pandasSQL_builder
@arulrajnet
arulrajnet / TutsplusVideoDownloader.py
Created October 2, 2014 09:47
Script to download course videos from https://tutsplus.com
from bs4 import BeautifulSoup
from lxml import html
from urllib2 import urlopen, Request, HTTPError, URLError
import urllib2
import urllib
import urlparse
import json
import os
__author__ = 'arul'
@subelsky
subelsky / large_redshift_tables.sql
Created April 18, 2014 17:39
Quick SQL command to find large tables in redshift
-- based on http://stackoverflow.com/questions/21767780/how-to-find-size-of-database-schema-table-in-redshift
SELECT name AS table_name, ROUND((COUNT(*) / 1024.0),2) as "Size in Gigabytes"
FROM stv_blocklist
INNER JOIN
(SELECT DISTINCT id, name FROM stv_tbl_perm) names
ON names.id = stv_blocklist.tbl
GROUP BY name
ORDER BY "Size in Gigabytes" DESC