Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / mongo-stats.sh
Created May 21, 2013 19:32
Mongo collection stats script
#!/bin/bash
#
# = Mongo Collection Stats Script
database=${1:-test}
mongo --quiet --eval '
var collections = db.getCollectionNames();
print("Collection Count Size StorageSize AvgObjSize nIndexes");
@mikedamage
mikedamage / email-ping.rb
Last active December 2, 2023 13:10
Ping an email address to see if it exists. This script resolves MX records to find the SMTP server responsible for delivering mail to the address, connects to it, and starts to send a message to the address. It disconnects before the message is sent.
#!/usr/bin/env ruby
#
# = Email Ping
#
# Check to see if an email address exists by looking up MX records and connecting
# to the address's home SMTP server. It then starts to send a message to the address
# but quits before the message is actually sent.
require 'resolv'
require 'net/smtp'
<?php
function dm_library_document_set_file_size($pieces, $is_new_item) {
$size_val = $pieces['fields']['size']['value'];
if (!$size_val) {
$attachment = $pieces['fields']['attachment']['value'];
$attachment_id = reset($attachment);
if ($attachment_id) {
$attachment_id = $attachment_id['id'];
$file_path = get_attached_file($attachment_id);
$file_size = filesize($file_path) / 1024; // get size in kilobytes
#= Main Puppet Manifest
# Update Apt Repo
exec {"update-apt":
command => "apt-get update",
cwd => "/",
path => ["/usr/bin", "/usr/local/bin", "/bin", "/usr/local/sbin", "/usr/sbin", "/sbin"],
}
# Install cURL
<p>
<?php
$tags = get_author_tags(get_the_author_meta('ID'));
$links = array();
foreach ($tags as $id => $tag) {
$url = get_tag_link($tag->term_id);
$links[] = "<a href=\"{$url}\">{$tag->name}</a>";
}
?>
My Topics: <?php echo implode(', ', $links); ?>
<?php
function get_author_tags($id) {
$user_tags = array();
$query = new WP_Query(array(
'posts_per_page' => -1,
'author' => $id,
));
while ($query->have_posts()) {
@mikedamage
mikedamage / gist:2838148
Created May 30, 2012 18:29
regexp for line break tags
\<br\s*\/?\>
preg_replace("/\<br\s*\/?\>/", " ", $str);
@mikedamage
mikedamage / xdebug.ini
Created April 20, 2012 15:27
INI file for XDebug - /etc/php5/conf.d/xdebug.ini
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=true
xdebug.remote_connect_back=true
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
@mikedamage
mikedamage / captcha.rb
Created January 21, 2012 22:51
Wolfram CAPTCHA Sinatra App
require 'rubygems'
require 'sinatra'
require 'nokogiri'
require 'digest'
require 'net/http'
require 'cgi'
configure do
set :config, YAML.load_file(File.join(File.dirname(__FILE__), 'config.yml'))
set :api_key, settings.config['api_key']
@mikedamage
mikedamage / result.xml
Created January 21, 2012 21:28
wolfram api result
<pod title='Result'
scanner='Identity'
id='Result'
position='200'
error='false'
numsubpods='1'
primary='true'>
<subpod title=''
primary='true'>
<plaintext>3.725×10^17 inches</plaintext>