Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / usb-phone-control.zsh
Created April 25, 2019 13:57
Control an Android phone over USB and toggle tethering
typeset -A keys
keys=(
power 26
home 3
up 19
down 20
left 21
right 22
enter 66
)
@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 / matrix-beta-instructions.md
Last active June 26, 2017 14:24
Mikedamage.info Matrix Server Beta Instructions

Mikedamage.info Matrix Chat Server Instructions

I've decided to change the communication protocol used by the mikedamage.info chat server from XMPP to Matrix.org. I just finished setting up a Matrix instance on the chat server, and it's ready for some intrepid guinea pigs to kick the tires! There's a long winded explanation of why I'm switching us over to Matrix, but I put it below the instructions in case you don't really care.

TL;DR Matrix is easier for me to manage, more secure for you, and everybody can access the server using same app, with the same awesome features, on pretty much any device or operating system in existence.

Coming Soon: Once I set the Matrix server up properly, we'll be able to do real-time, person to person voice and video calls in addition to text chat!

How to Connect

@mikedamage
mikedamage / authentication_controller.php
Created December 13, 2013 15:29
Authentication controller for WordPress JSON API plugin
<?php
/*
Controller name: Authentication
Controller description: Login and logout functionality exposed over AJAX
*/
class JSON_API_Authentication_Controller {
public function login() {
global $json_api;
<?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