Skip to content

Instantly share code, notes, and snippets.

@acidChrist
acidChrist / new_task.py
Created December 7, 2016 19:26 — forked from quiver/new_task.py
rabbitmq : dead letter exchange example with python/pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@pimterry
pimterry / install-bats-libs.sh
Created December 3, 2016 17:34
Set up bats libraries for testing as git submodules in test/libs
mkdir -p test/libs
git submodule add https://github.com/sstephenson/bats test/libs/bats
git submodule add https://github.com/ztombol/bats-support test/libs/bats-support
git submodule add https://github.com/ztombol/bats-assert test/libs/bats-assert
# The following will split a CSV (file.csv) into multiple parts of 1 million lines each
# with each part having its own header.
#
# PREFIX denotes the filename to use for the parts. A number will be added to the end.
tail -n +2 file.csv |
split -d -l 1000000 - --filter='sh -c "{ head -n1 file.csv; cat; } > $FILE"' PREFIX
@matthewadams
matthewadams / git-scrum.sh
Last active June 6, 2017 20:28
git log for scrum across multiple repos
#!/usr/bin/env bash
SCRUM_TIME=${SCRUM_TIME-"08:45:00"}
BEFORE_DAY=${BEFORE_DAY-$(date +%Y-%m-%d)}
BEFORE_TIME=${BEFORE_TIME-$SCRUM_TIME}
AFTER_DAY=${AFTER_DAY-$(python -c "from datetime import datetime, timedelta; before = datetime.strptime('$BEFORE_DAY','%Y-%m-%d').date(); monday = before.strftime('%u') == '1'; days = -3 if monday else -1; after = before + timedelta(days=days); print after;")}
AFTER_TIME=${AFTER_TIME-$BEFORE_TIME}
TZ_OFFSET=$(date +%z)
AFTER="${AFTER_DAY}T${AFTER_TIME}${TZ_OFFSET}"
BEFORE="${BEFORE_DAY}T${BEFORE_TIME}${TZ_OFFSET}"
DIR="${DIR-$PWD}"
@armand1m
armand1m / Dockerfile
Last active March 2, 2026 16:31
Yarn cache compatible Dockerfile
FROM alpine
RUN apk add --update --no-cache nodejs
RUN npm i -g yarn
ADD package.json yarn.lock /tmp/
ADD .yarn-cache.tgz /
RUN cd /tmp && yarn
RUN mkdir -p /service && cd /service && ln -s /tmp/node_modules
# Usage: gh-clone lagom lagom to checkout lagom/lagom
function gh-clone() {
OWNERNAME=$1;
PROJNAME=$2;
cd $WORKDIR;
mkdir $PROJNAME;
cd $PROJNAME;
hub init -g
hub clone $OWNERNAME/$PROJNAME master;
cd master;
@josephspurrier
josephspurrier / etc-init.d-hello-world
Last active May 15, 2021 17:14
/etc/init.d Script for Go Application
#!/bin/bash
#
# chkconfig: 35 95 05
# description: Hello world application.
# Run at startup: sudo chkconfig hello-world on
# Load functions from library
. /etc/init.d/functions
@kwilczynski
kwilczynski / getStackOutputs.js
Last active April 1, 2024 10:25
Get outputs from a stack by name in CloudFormation.
'use strict';
function getStackOutputs(properties, callback) {
if (typeof properties.StackName === 'undefined') {
return callback(new Error('The StackName property was not specified.'));
}
let filter = [];
if (typeof properties.Filter !== 'undefined') {
if (!Array.isArray(properties.Filter)) {
@brwillis
brwillis / inbox2dated.scpt
Created July 8, 2016 23:40
Some applescript to move messages from an Outlook inbox to a dated folder in your On My Computer folder.
tell application "Microsoft Outlook"
activate
set folderName to "Inbox"
if name of selected folder is not equal to folderName then set selected folder to inbox
set selectedMessages to messages of selected folder
repeat with theMessages in selectedMessages
set {year:y, month:m, day:d} to time received of theMessages
set datedFolder to "" & y & "-" & m & ""
if not (exists mail folder datedFolder of on my computer) then
make new mail folder with properties {name:datedFolder} at on my computer
@bblincoe
bblincoe / client_throttle.py
Last active April 28, 2022 14:16
Amazon AWS Client Throttle in Python (boto3)
import boto3
import botocore
from random import randint
from time import sleep
def client_throttle(action, **kwargs):
while True:
try:
return action(**kwargs)
except botocore.exceptions.ClientError as e: