Skip to content

Instantly share code, notes, and snippets.

View frederickding's full-sized avatar

Frederick Ding frederickding

View GitHub Profile
--- qemu-dm-wrapper.bak 2014-07-18 16:49:42.000000000 -0400
+++ qemu-dm-wrapper 2014-07-18 20:38:46.000000000 -0400
@@ -97,6 +97,11 @@
write_dm_pid(domid, os.getpid())
os.dup2(1, 2)
+
+ for i in range(len(qemu_args)):
+ if qemu_args[i].find('macaddr=') > 0:
+ qemu_args[i] = qemu_args[i].replace('rtl8139', 'e1000')
@frederickding
frederickding / gist:8d0c9e892160f07dbe03
Created December 5, 2014 00:30
MAJOR PENNNET OUTAGE 2014-12-04T19:22:05-05:00
Date: Thursday, December 4, 2014 EST
Start time: 4:00 pm
Duration: Unknown
Building(s) Affected: Entire Campus
Service(s) Affected: ALL

Keybase proof

I hereby claim:

  • I am frederickding on github.
  • I am frederickding (https://keybase.io/frederickding) on keybase.
  • I have a public key whose fingerprint is 9347 E154 320F 7CA0 6682 2EBC 1EEB BDF4 31D5 1E20

To claim this, I am signing this object:

@frederickding
frederickding / gist:8176453
Created December 30, 2013 00:33
What spambots post
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any
interesting article like yours. {It's|It is} pretty worth enough
for me. {In my opinion|Personally|In my view}, if
all {webmasters|site owners|website owners|web owners} and bloggers made good content as you did,
the {internet|net|web} will be {much more|a lot more} useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting.
{Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service.
@frederickding
frederickding / mail_helper.php.diff
Created December 7, 2013 05:51
mail_helper.php patch to use CodeIgniter email library
diff --git a/OpenVBX/helpers/mail_helper.php b/OpenVBX/helpers/mail_helper.php
index 9453556..50efff0 100644
--- a/OpenVBX/helpers/mail_helper.php
+++ b/OpenVBX/helpers/mail_helper.php
@@ -30,13 +30,17 @@ function openvbx_mail($recipient, $subject, $template, $maildata = array())
$from_email = "$from <do-not-reply@$domain>";
}
- $headers = 'From: '.$from_email."\r\n";
- $headers .= 'Reply-To: '.$from_email."\r\n";
@frederickding
frederickding / backup-full.sh
Last active December 20, 2015 10:39
Backs up full filesystem to an xz-compressed tarball.
#!/bin/bash
XZ_OPT=-9
DATE=$(date +'%Y%m%d')
FILENAME="/"`hostname -f`"-$DATE.tar.xz"
printf "FULL FILESYSTEM BACKUP SCRIPT\n"
printf '==============================='
printf "\n"
printf "Current date: %s\n" "$DATE"
printf "Archive will be stored at: %s\n" "$FILENAME"
@frederickding
frederickding / parse.php
Created July 16, 2013 20:27
Search for all <wp:post_type> in a WXR file
<?php
$input_file = '/path/to/wxr.wordpress.2013-07-16.xml';
$file = simplexml_load_file($input_file);
$output = fopen($input_file . '.txt', 'w');
// find all instances of <wp:post_type>
$matches = $file->xpath('//wp:post_type');
foreach($matches as $match) {
// write out the contents
@frederickding
frederickding / domu-hostname.sh
Last active May 21, 2018 09:11
Set a domU's hostname based on its Xen Cloud Platform or XenServer VM name
#!/bin/bash
# Based on https://github.com/krobertson/xenserver-automater/blob/master/usr/sbin/xe-set-hostname
# Adapted by Frederick Ding
# Detect if xenstore-read is available
XENSTOREREAD=`which xenstore-read`
if [ -e $XENSTOREREAD ]; then
# Filter the domU's name to a lowercase alphanumeric hyphenated hostname
NAME=`xenstore-read name | sed -e 's/[^[:alnum:]|-]/-/g' | tr '[:upper:]' '[:lower:]'`
@frederickding
frederickding / dm3-to-tif-png.ijm
Created July 27, 2012 19:02
ImageJ macro to convert DM3 digital micrograph files (e.g. transmission electron microscope) to TIF and PNG
/**
* ImageJ macro to convert DM3 digital micrograph files to TIF and PNG
*
* @author Frederick Ding
*/
/*
* Option switches
*
* debug: when set to true, some variables will be outputted to the log
@frederickding
frederickding / gist:1631446
Created January 18, 2012 06:29
JavaScript to remove SOPA banner from Wikipedia
javascript:jQuery("#mw-sopaOverlay").hide();jQuery("#content, #mw-page-base, #mw-head-base, #mw-head, #mw-panel, #footer").show();