Skip to content

Instantly share code, notes, and snippets.

View mrevjd's full-sized avatar
🏠
Working from home

Evan Davies mrevjd

🏠
Working from home
View GitHub Profile
@mrevjd
mrevjd / emailparser.py
Last active January 12, 2022 07:16 — forked from slomo/mailprint.py
A script to print a mail delivered on stdin
#!/usr/bin/env python
import sys
import email
msg = email.message_from_file(sys.stdin)
to = msg['to']
fromwho = msg['from']
subject = msg['subject']
@mrevjd
mrevjd / gtk.css
Created September 19, 2021 01:31 — forked from imitablerabbit/gtk.css
Gnome terminal padding. ~/.config/gtk-3.0/gtk.css
VteTerminal,
TerminalScreen,
vte-terminal {
padding: 10px 10px 10px 10px;
-VteTerminal-inner-border: 10px 10px 10px 10px;
}
@mrevjd
mrevjd / generate_random_key.php
Created March 8, 2021 01:47 — forked from inda5th/generate_random_key.php
Generate a random key to be used based on a specified hashing algorithm.
<?php
/**
* Generate a random key
*
* Generate a random key based on the specified hashing algorithm and given length.
* The algorithm defaults to "sha256" and the length defaults to 1024.
* See PHP's hash_algos() function for a list of supported hashing algorithms.
*
* @param string $algo The hashing algorithm to use
* @param int $length Length of desired string of bytes to create the hash
@mrevjd
mrevjd / discover-chromecast.sh
Created August 26, 2020 01:29 — forked from ThomasRooney/discover-chromecast.sh
Discover Chromecast with devicename via mDNS
#! /bin/sh
if ! which dns-sd > /dev/null
then
echo "Requires dns-sd"
exit
fi
if (( $# < 1 )) ; then
echo "Requires devicename as an argument"
@mrevjd
mrevjd / _usage.md
Created April 23, 2020 21:11 — forked from tbranyen/_usage.md
OpenWeatherMap / Weather Icons integration
  1. Include Weather Icons in your app: https://github.com/erikflowers/weather-icons

  2. Include the below JSON in your application, for example purposes, lets assume it's a global named weatherIcons.

  3. Make a request to OpenWeatherMap:

req = $.getJSON('http://api.openweathermap.org/data/2.5/weather?q=London,uk&callback=?');
@mrevjd
mrevjd / CIDR.php
Last active October 29, 2019 03:59 — forked from jonavon/CIDR.php
CIDR class for IPv4
<?php
/**
* CIDR.php
*
* Utility Functions for IPv4 ip addresses.
* Supports PHP 5.3+ (32 & 64 bit)
* @author Jonavon Wilcox <[email protected]>
* @revision Carlos Guimarães <[email protected]>
* @version Wed Mar 12 13:00:00 EDT 2014
* @revision Evan Davies <[email protected]>
@mrevjd
mrevjd / openssl_encrypt_decrypt.php
Created October 16, 2019 03:50 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@mrevjd
mrevjd / hfsc-shape.sh
Created June 30, 2018 10:05 — forked from eqhmcow/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.