Skip to content

Instantly share code, notes, and snippets.

View mdippery's full-sized avatar
💭
Have you seen an older me go by in a time machine?

Michael Dippery mdippery

💭
Have you seen an older me go by in a time machine?
View GitHub Profile
@clintel
clintel / gist:1155906
Created August 19, 2011 02:40
Fenced code in bullet lists with GitHub-flavoured MarkDown??

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@DemmyDemon
DemmyDemon / mark.pl
Created May 17, 2013 21:06
Just a little irssi script to add a marker line to the chat.
#!/usr/bin/perl
use strict;
use warnings;
use Irssi;
our $VERSION = 0.1;
our %IRSSI = (
authors => 'Fredrik "Demonen" Vold',
contact => 'fredrik@webkonsept.com',
name => 'mark',
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
# Mirror from http://s3.jspenguin.org/ssltest.py
import sys
import struct
import socket
import time
@hensing
hensing / python_logging.c
Last active May 20, 2024 06:55
Python: Use 'logging' module from C extension
#include <Python.h>
/***********************************************************/
/* define logging function and logtypes for python.logging */
/* by H.Dickten 2014 */
/***********************************************************/
enum logtypes {info, warning, error, debug};
static void log_msg(int type, char *msg)
{
@sorbits
sorbits / every
Last active February 22, 2024 03:58
Run «command» only every «number» time invoked
#!/usr/bin/env bash
progname=$(basename $0)
version="1.0 (2014-08-17)"
step=2
function create_hash {
openssl dgst -sha1 -binary <<< "$1" | xxd -p
}
@Spindel
Spindel / watchdog.md
Last active May 24, 2023 09:48
Showing off the systemd watchdog in Python

Watchdogged

Place the service file (or a link to it) in /etc/systemd/system/ Place the watchdogged.py file somewhere ( and change the ExecStart portion in the .service to point at the file )

then do systemctl daemon-reload followed by systemctl start watchdogged.service

After this you can watch the progress using journalctl --follow -u watchdogged.service change the PROBABILITY variable to something else to watch it faster/later or succeed.

@pythonhacker
pythonhacker / state.py
Last active June 22, 2022 07:01
Example of State Pattern in Python implementing showing a minimal State Machine
"""
The State design pattern.
In Python this is done dynamically by changing the __class__ attribute.
Author : Anand B Pillai <anandpillai@letterboxes.org>
License: Public Domain
Ref: http://harkablog.com/dynamic-state-machines.html
@danvaida
danvaida / cloudwatch_events.yml
Last active September 7, 2022 20:35
Ansible Playbook for Creating CloudWatch Events Rules with Lambda Targets
# For creating the lambda functions, see instructions here: https://github.com/pjodouin/ansible-lambda
# Run this playbook with:
# ansible-playbook cloudwatch_events.yml --extra-vars debug=True
# Ansible CloudWatch Event module PR: https://github.com/ansible/ansible-modules-extras/pull/2101
# Ansible Lambda modules PR: https://github.com/ansible/ansible-modules-extras/pull/1890
---
- name: CloudWatch Events
hosts: localhost
connection: local
gather_facts: False
@alexcasalboni
alexcasalboni / aws-lambda-static-type-checker.md
Last active May 22, 2023 07:31
AWS Lambda Static Type Checker Example (Python3)

How to use Python3 Type Hints in AWS Lambda

TL;DR

Static Type Checkers help you find simple (but subtle) bugs in your Python code. Check out lambda_types.py and incrementally improve your code base and development/debugging experience with type hints.

Your Lambda Function code will go from this: