Skip to content

Instantly share code, notes, and snippets.

View yolabingo's full-sized avatar

Todd Jacobsen yolabingo

  • New Mexico, USA
View GitHub Profile
@chrisguitarguy
chrisguitarguy / xml.py
Created October 21, 2011 21:18
Parse an XML sitemap with Python, requests and BeautifulSoup
from __future__ import with_statement # we'll use this later, has to be here
from argparse import ArgumentParser
import requests
from BeautifulSoup import BeautifulStoneSoup as Soup
def parse_sitemap(url):
resp = requests.get(url)
# we didn't get a valid response, bail
@Mte90
Mte90 / snippet.php
Last active February 24, 2021 18:25
Custom WordPress Error Handler. Support Query Monitor and can be used as mu-plugin.
<?php
/*
* Plugin Name: Better errors
* Description: Better errors in log
* Author: Daniele Scasciafratte
* Version: 1.0
* Author URI: http://codeat.co
*/
function handleError($code, $description, $file = null, $line = null, $context = null) {
@boardstretcher
boardstretcher / docker.sh
Last active October 1, 2021 21:02
docker bash completion
# INSTALL BASH_COMPLETION PACKAGE FIRST!!!
# yum install bash-completion
#!bash
#
# bash completion file for core docker commands
#
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
@gkhays
gkhays / Java-Mail.md
Last active January 5, 2022 19:31
How to use JavaMail to send email via an SMTP server. I was recently working with a server component that allowed for scheduling reports, which included email notification. I wanted to isolate the email notification portion. Check. :)

JavaMail

SMTP test driver using JavaMail version 1.5.2.

# SSL/TLS port: 465
# Otherwise: 587
smtp.host=smtp.mail.yahoo.com
smtp.port=465
smtp.useSsl=true
@dmolesUC
dmolesUC / entrypoint.sh
Created October 21, 2020 18:12
Start and terminate multiple sevices
# ########################################
# Start server and manager in background
/start-server.sh &
SERVER_PID=$!
/start-manager.sh &
MANAGER_PID=$!
# ########################################
@rebeccacremona
rebeccacremona / .bash_profile
Created September 1, 2016 13:46
Eternal bash history
# No dupes
export HISTCONTROL=ignoreboth:erasedups
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="%F %T "
@poolski
poolski / postfix.grok
Last active April 16, 2022 03:54
Usefuk Logstash GROK patterns
# Syslog stuff
COMPONENT ([\w._\/%-]+)
COMPID postfix\/%{COMPONENT:component}(?:\[%{POSINT:pid}\])?
POSTFIX %{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST:hostname} %{COMPID}: %{QUEUEID:queueid}
# Milter
HELO (?:\[%{IP:helo}\]|%{HOST:helo}|%{DATA:helo})
MILTERCONNECT %{QUEUEID:qid}: milter-reject: CONNECT from %{RELAY:relay}: %{GREEDYDATA:milter_reason}; proto=%{WORD:proto}
MILTERUNKNOWN %{QUEUEID:qid}: milter-reject: UNKNOWN from %{RELAY:relay}: %{GREEDYDATA:milter_reason}; proto=%{WORD:proto}
@mnordhoff
mnordhoff / gist:2213179
Last active October 22, 2022 23:17
Python regular expressions for IPv4 and IPv6 addresses and URI-references, based on RFC 3986's ABNF.The URI-reference regular expression includes IPv6 address zone ID support (RFC 6874).
# Python regular expressions for IPv4 and IPv6 addresses and URI-references,
# based on RFC 3986's ABNF.
#
# ipv4_address and ipv6_address are self-explanatory.
# ipv6_addrz requires a zone ID (RFC 6874) follow the IPv6 address.
# ipv6_address_or_addrz allows an IPv6 address with optional zone ID.
# uri_reference is what you think of as a URI. (It uses ipv6_address_or_addrz.)
import re
DATA AND METADATA COHERENCE
Some modern cluster file systems provide perfect cache coherence among their clients. Perfect cache coherence among disparate NFS clients is expensive to achieve, especially on wide area networks. As such, NFS settles for weaker cache coherence that satisfies the requirements of most file sharing types.
Close-to-open cache consistency
Typically file sharing is completely sequential. First client A opens a file, writes something to it, then closes it. Then client B opens the same file, and reads the changes.
When an application opens a file stored on an NFS version 3 server, the NFS client checks that the file exists on the server and is permitted to the opener by sending a GETATTR or ACCESS request. The NFS client sends these requests regardless of the freshness of the file's cached attributes.
When the application closes the file, the NFS client writes back any pending changes to the file so that the next opener can view the changes. This al