Skip to content

Instantly share code, notes, and snippets.

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

Damon Davison allolex

🏠
Working from home
View GitHub Profile
@allolex
allolex / generate_strong_password.pl
Created March 21, 2012 17:25
A Perl script for generating a strong password using String::MkPasswd
#!/usr/bin/env perl
use String::MkPasswd qw/mkpasswd/;
print mkpasswd(
-length => 12,
-minnum => 4,
-minlower => 3,
-minupper => 4,
-minspecial => 1,
-distribute => 0,
@allolex
allolex / zencart_subscriber_export.pl
Created March 21, 2012 17:29
A simple Zen Cart export Perl script for PHPlist input
#!/usr/bin/env per
use strict;
use warnings;
use DBI;
my $username = 'USERNAME';
my $password = 'PASSWORD';
my $dsn = 'dbi:mysql:DATABASE_NAME;host=HOSTNAME;port=3306';
my $query = qq{
@allolex
allolex / get_abuse_contacts.pl
Created March 21, 2012 17:32
A Perl script to find out who to send abuse reports to for a given domain
#!/usr/bin/env perl
use strict;
use warnings;
use Net::DNS;
use Net::Abuse::Utils qw( :all );
my $input = shift or die "Domain must be specified at the command line!";
my $res = Net::DNS::Resolver->new;
my $query = $res->search("$input");
@allolex
allolex / ping-parse.rb
Created August 24, 2012 16:05
Parse ping output files in the format ping-YYYYMMDDhhmm.log and turn them into a huge JSON array
#!/usr/bin/env ruby
require 'json'
lines = DATA.readlines
stats = []sent = received = loss = time = minimum = average = maximum = deviation = 0files = Dir.glob "data/*.log"files.each do |log|
lines = File.open(log).readlines
log =~ /ping-(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/
@allolex
allolex / scrape.rb
Created September 11, 2012 08:09
An example of a tiny, modular and cleanly-written screen scraper
require 'mechanize'
module Scraper
class Tumblr
attr_accessor :fake_browser, :results
def initialize url
@fake_browser = Mechanize.new { |browser|
@allolex
allolex / gist:4564357
Last active December 11, 2015 07:09
Improved code for snapping photos when committing to a git repo
#!/bin/bash
function make_image_dir () {
TARGET_DIR=$1
if [ ! -d "${TARGET_DIR}" ]; then
mkdir "${TARGET_DIR}"
fi
}
function ignore_image_dir () {
@allolex
allolex / damons_mutt_configuration.md
Last active August 30, 2018 12:16
Mutt with multiple IMAP (Google Mail) accounts in the cloud. This is how I have my mutt installation set up and configured. I primarily use Google products for my mail these days, so the config here should be just fine for that. The principle shown here holds true for all mail accounts.

Mutt for multiple email accounts

This is an OS X-centric configuration.

My setup and configuration for Gmail/Google Apps

The idea here is to use environment variables, loaded via aliases to mutt, to control which account you're loading. Years ago I had all of my accounts configured to be accessible from a single mutt

@allolex
allolex / gist:5546591
Created May 9, 2013 09:42
Where's my vodka?
POST http://crystalheadvodka.com/site/where_map_ajax 404 (Not Found) jquery.min.js:140
c.extend.ajax jquery.min.js:140
onsubmit
@allolex
allolex / web-servers.md
Last active December 19, 2015 07:19 — forked from willurd/web-servers.md
Make copy and pastable without shell prompts

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

python -m SimpleHTTPServer 8000

Keybase proof

I hereby claim:

  • I am allolex on github.
  • I am curatur (https://keybase.io/curatur) on keybase.
  • I have a public key whose fingerprint is 989B 269F C757 96D9 5229 EF55 140D 40DF 74BB D7B3

To claim this, I am signing this object: