Skip to content

Instantly share code, notes, and snippets.

View tonypiazza's full-sized avatar

Tony Piazza tonypiazza

View GitHub Profile
@kathawala
kathawala / datetime_to_cron.py
Created April 21, 2020 22:23
Converts a python datetime to a crontab expression which fires once (at the date+time specified in the python datetime object)
from datetime import datetime
def datetime_to_cron(dt):
# FYI: not all cron implementations accept the final parameter (year)
return f"cron({dt.minute} {dt.hour} {dt.day} {dt.month} ? {dt.year})"
@mechcozmo
mechcozmo / IAM Permissions List.md
Last active August 1, 2024 09:50
A list of IAM permissions you can use in policy documents. Collected from the myriad of places Amazon hides them. (incomplete)
@daschl
daschl / gist:db9fcc9d2b932115b679
Last active August 26, 2020 23:17
Draft: Writing Code for Production

Writing Resilient Reactive Applications

This guide is a first draft (that will end up in the official docs) on writing resilient code for production with the Couchbase Java SDK. At the end, the reader will be able to write code that withstands bugs, latency issues or anything else that can make their application fail.

Note that lots of concepts can be applied for both synchronous and asynchronous access. When necessary, both patterns are discussed separately. Also, the focus is on database interaction, but if you are using RxJava as part of your stack you can apply most of the principles there as well (and should!).

RxJava 101 Recap: Cold and Hot Observables

When working with Observables, it is important to understand the difference between cold and hot. Cold Observables will start to emit events once a Observer subscribes, and will do it "fresh" for each Observer. Hot Observables instead are starting to emit data as soon as it becomes available, and will return the same (or parts of the same)

@JohnArchieMckown
JohnArchieMckown / pathmunge
Created October 16, 2014 12:29
pathmunge is a shell function to add a directory to the PATH. It will add the specified directory only if: (1) it currently exists and (2) it is not already on the PATH. It can add the directory either at the beginning of the PATH (defautl) or at the end of the PATH.
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if [ -e $1 ]; then
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
@tingletech
tingletech / cloud-init.bash
Last active May 24, 2017 04:08
install Gate One on an EC2/Amazon Linux AMI
set -eu
yum -y update
yum -y install git
yum -y groupinstall "Development Tools"
yum -y install python-devel
yum -y install ncurses-devel
yum -y install dialog
yum -y install openssl-devel
yum -y install libjpeg-devel
yum -y install freetype-devel
@chuangbo
chuangbo / cidr.py
Created August 13, 2012 09:45
Check if ip in cidr
#-*- coding:utf-8 -*-
# Author: @chuangbo
# For: @likexian
import socket
import struct
class CIDR:
'''Check if ip in cidr