Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
@typhonius
typhonius / fingerprint_conversion.py
Last active December 17, 2015 15:09
Quick snippet to convert public key signatures from an authorized_keys file into their ssh fingerprint
# Quick snippet to convert public key signatures from an authorized_keys file into their ssh fingerprint
# Usage: python fingerprint_conversion.py authorized_keys
import base64,hashlib,sys
line = sys.argv[1]
f = open(line, 'r')
for key in f:
key = str(key.strip().split()[1])
<?php
function custom_import_import_files_batch_files(&$context) {
db_set_active('import');
// Build the total import count.
// need to query D5 db
// mysql> select nr.body from node_revisions nr join node n on n.nid = nr.nid where n.type = 'homepage' and nr.body like '%flipperpage%';
if (empty($context['sandbox'])) {
@typhonius
typhonius / node_export_i18n.module
Created July 4, 2013 15:34
node export i18n for PHP < 5.3
<?php
/**
* @file Node Export i18n module
*/
// Ensure this node type has multilingual support
/**
<?php
# Memcache
print "Memcache API\n";
$conf['cache_backends'][] = './sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
bench_it();
#Memcache Storage
print "Memcache Storage\n";
@typhonius
typhonius / badger_dns_update.pl
Created August 17, 2013 06:37
A small script that gets the current IP and updates a domain using the API for badger.com Currently the domain ID is hard coded although work will be done to allow iteration and ID lookup
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use Regexp::Common qw /net/;
use JSON;
my $email = 'FILLME';
my $password = 'FILLME';
my $badger = 'https://api.badger.com';
@typhonius
typhonius / pagespeed.php
Created August 18, 2013 03:58
A PHP script to look up and parse google pagespeed results.
<?php
$url = 'URL GOES HERE';
$key = 'KEY GOES HERE';
// View https://developers.google.com/speed/docs/insights/v1/getting_started#before_starting to get a key
$data = json_decode(file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$url&key=$key"));
$dat = $data->formattedResults->ruleResults;
foreach($dat as $d) {
$name = $d->localizedRuleName;
<?php
$adam = array(
'remote-host' => 'adammalone.net',
'root' => '/var/www/html/adammalone/docroot',
'uri' => 'adammalone.net',
'strict' => 0,
'path-aliases' => array(
'%dump-dir' => '/home/adammalone/.drush/dumps',
'%files' => 'sites/default/files',
<?php
$options['shell-aliases']['offline'] = 'variable-set -y --always-set maintenance_mode 1';
$options['shell-aliases']['online'] = 'variable-delete -y --exact maintenance_mode';
$options['shell-aliases']['sync-dbs'] = '!drush sql-sync --structure-tables-key=common --no-cache {{#prod}} {{@target}}';
$options['shell-aliases']['sync-files'] = '!drush rsync {{#prod}}:%files {{@target}}:%files';
$options['structure-tables']['common'] = array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog');
$options['shell-aliases']['sync-fsdb'] = '!drush sql-sync {{#prod}} {{@target}} && drush rsync {{#prod}}:%files {{@target}}:%files';
@typhonius
typhonius / lastfm.pl
Last active March 25, 2016 14:12
Real simple script to get my now playing from last.fm for chat
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use JSON;
use utf8;
binmode(STDOUT, ":utf8");
@typhonius
typhonius / hashy.sh
Created October 29, 2013 11:08
Super simple password hashing on the command line.
#!/bin/bash
SALT=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-10};echo;`
PW=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-18};echo;`
HASH=`openssl passwd -1 -salt $SALT $PW`
echo "Automatically generated password of $PW salted against $SALT gets hashed as $HASH"