Skip to content

Instantly share code, notes, and snippets.

View mattparlane's full-sized avatar

Matt Parlane mattparlane

View GitHub Profile
@mattparlane
mattparlane / add_containers_to_hosts.rb
Last active January 29, 2018 07:50
Add containers to host's /etc/hosts file
require 'json'
require 'hosts'
loop do
hosts = Hosts::File.read('/etc/hosts')
host_elements = hosts.elements
all_aliases = []
`docker ps`.split(/\n/).each do |line|
cols = line.split(/\s/)
next if cols[0] =~ /[^a-f0-9]/
Delivered-To: mimi@destinyrescue.org
Received: by 10.159.59.102 with SMTP id j38csp1430993uah;
Tue, 24 Oct 2017 23:29:25 -0700 (PDT)
X-Google-Smtp-Source: ABhQp+QXeby6to6gc7KuOOfTL3xnRFU/dnPmU6kdfV6HTU1/6a/56nnBe3gIz44fHgpl3s2S63nc
X-Received: by 10.200.27.163 with SMTP id z32mr29417253qtj.8.1508912965090;
Tue, 24 Oct 2017 23:29:25 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1508912965; cv=none;
d=google.com; s=arc-20160816;
b=mptnPShzIr27g4dh6SdbmdvYoUWkY+2G+ZqSlYxrTtjfKKgPZRtCkRfBAy1c026Y7r
k9j7v6AK4wcwcPXSOGiHcxH3ow9UJnws579ljituQHJZ9f0lcpy7ksuciljWjHSQ/AAz
dr@drvm1:/$ sudo grep -riF --exclude-dir={proc,sys} "52.0.0.0" /
/home/dr/data/projects/marketing-api/node_modules/ipaddr.js/test/ipaddr.test.coffee: test.equal(ipaddr.IPv4.parse('252.0.0.0').prefixLengthFromSubnetMask(), 6)
/home/dr/data/projects/marketing-api/node_modules/ipaddr.js/test/ipaddr.test.coffee: test.equal(ipaddr.IPv4.subnetMaskFromPrefixLength("6"), "252.0.0.0")
/home/dr/.bash_history:route del 52.0.0.0
/home/dr/.bash_history:sudo route del 52.0.0.0
/home/dr/.bash_history:sudo route del -net 52.0.0.0
/home/dr/.bash_history:sudo route del -net 52.0.0.0 gw 0.0.0.0 netmask 255.0.0.0 dev eth0
/home/dr/.bash_history:sudo grep -ri "52.0.0.0" / 2> /dev/null
/home/dr/.bash_history:sudo grep -riF "52.0.0.0" / 2> /dev/null
/home/dr/.bash_history:sudo grep -riF "52.0.0.0" /
h2o server (pid:3919) is ready to serve requests
old worker 3789 died, status:0
received HUP, spawning a new worker
starting new worker 4060
new worker is now running, sending TERM to old workers:3228,3919
killing old workers
received SIGTERM, gracefully shutting down
[INFO] raised RLIMIT_NOFILE to 1048576
h2o server (pid:4060) is ready to serve requests
old worker 3919 died, status:0
@mattparlane
mattparlane / cookie-storage.js
Last active August 25, 2017 04:25
localStorage-compatible store backed by cookies. Spans across multiple cookies if data is too big for one cookie.
@mattparlane
mattparlane / set-us-accounts-usd.apex
Created July 14, 2017 14:22
Set US/non-USD accounts to USD
Account[] accounts = [select Id from Account where Primary_Funding_Nation__r.Name = 'United States' and CurrencyIsoCode != 'USD' Limit 2000];
for (Account account : accounts)
account.CurrencyIsoCode = 'USD';
update accounts;
@mattparlane
mattparlane / non-hh-accounts.apex
Created July 14, 2017 13:57
Set all contacts with non-Household accounts to Household accounts
Contact[] contacts = [select Id, AccountId from Contact where Account.RecordType.DeveloperName != 'HH_Account'];
for (Contact contact : contacts)
contact.AccountId = null;
update contacts;
@mattparlane
mattparlane / add-affs.apex
Created July 14, 2017 13:55
Add affiliations for non-Household accounts
Contact[] contacts = [select Id, AccountId from Contact where AccountId != null and Account.RecordType.DeveloperName != 'HH_Account'];
List<Id> contactIds = new List<Id>();
for (Contact c : contacts) contactIds.add(c.Id);
npe5__Affiliation__c[] affs = [select npe5__Contact__c, npe5__Organization__c from npe5__Affiliation__c where npe5__Contact__c in :contactIds];
npe5__Affiliation__c[] inserts = new List<npe5__Affiliation__c>();
for (Contact c : contacts) {
Boolean hasAff = false;
for (npe5__Affiliation__c aff : affs) {
@mattparlane
mattparlane / randompadding.php
Created September 14, 2016 03:41
WordPress plugin to add random padding to pages as an added mitigation against the BREACH attack.
<?php
/*
Plugin Name: Add Random Padding
Description: Adds random padding to the end of pages as an added (but not complete) mitigation against BREACH et al.
*/
function add_random_padding() {
echo str_repeat(' ', mt_rand(0, 20));
}
add_action( 'wp_footer', 'add_random_padding', 100 );
@mattparlane
mattparlane / h2o.conf
Created July 15, 2016 01:58
h2o.conf
This file has been truncated, but you can view the full file.
---
hosts:
walnutblock.co.nz:
listen:
port: 443
ssl:
key-file: "/etc/ssl/walnutblock.co.nz.key"
certificate-file: "/etc/ssl/walnutblock.co.nz.crt"
cipher-suite: ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
cipher-preference: server