Skip to content

Instantly share code, notes, and snippets.

View cpu's full-sized avatar
❄️

Daniel McCarney cpu

❄️
View GitHub Profile
DROP TABLE IF EXISTS ipd_users;
DROP TABLE IF EXISTS ipd_associations;
DROP TABLE IF EXISTS ipd_logins;
DROP TABLE IF EXISTS ipd_logouts;
-- The table of usernames and their unique ID
CREATE TABLE ipd_users (
`id` INT NOT NULL auto_increment,
`username` VARCHAR(13),
PRIMARY KEY(`id`),
DROP VIEW IF EXISTS ipd_ips;
DROP VIEW IF EXISTS ipd_dested_players;
DROP VIEW IF EXISTS ipd_timeout_events;
DROP VIEW IF EXISTS ipd_player_replace_events;
DROP VIEW IF EXISTS ipd_quit_events;
DROP VIEW IF EXISTS ipd_in_out;
DROP VIEW IF EXISTS ipd_user_logouts;
DROP VIEW IF EXISTS ipd_user_logins;
DROP VIEW IF EXISTS ipd_pretty_associations;
DROP VIEW IF EXISTS ipd_ip_popularity;
DROP PROCEDURE IF EXISTS log_disconnect;
DROP PROCEDURE IF EXISTS log_connection;
DELIMITER //
-- The log_connection() procedure is called when a user connects to the game.
-- It accepts the username that is connecting, and the ip they are connecting
-- from. It then adds the user if their username is new, associates the
-- username with the IP making sure to update the count of how many times
-- they've connected from that IP. Finally it adds a login for this user at
-- the present time/date.
-- Selecting IPs used by a username
SELECT username, ip FROM ipd_pretty_associations WHERE username = '%s' ORDER BY count DESC;
-- Selecting usernames that have used a specific IP
SELECT ip, username, count, countryCode FROM ipd_pretty_associations WHERE ip = '%s'
ORDER BY count DESC;
-- Selecting usernames that have used a wildcarded IP
SELECT ip, username, count, countryCode FROM ipd_pretty_associations WHERE ip LIKE '%s'
ORDER BY count DESC;
@cpu
cpu / stayOnTarget.sh
Created April 13, 2011 18:16
A quick bash script to keep me from procrastinating
###
## Stay On Target!
## Daniel McCarney 2011
## https://binaryparadox.net
##
## Using an interactive countdown function found on the unix.com forums
## I created a shell function/alias that allows me to avoid procrastinating
## (if I procrastinate by writing code to stop procrastinating it equals out
## right?).
##
@cpu
cpu / gist:1276006
Created October 10, 2011 18:00
Python Twitter Avatar Downloader
###############################################################################
# Quick & Dirty script to download the Avatars of your Twitter Followers
# Daniel McCarney -- 10/10/11
#
# Emphasis on the quick & dirty. There's no error handling, and bad things
# are liable to happen if you have Twitter followers with malicious avatars
#
# Requirements: Python 2.6, python-twitter, OAuth keys*
#
# *Twitter requires OAuth authentication for the API calls this script uses.
@cpu
cpu / pushoverbooted.conf
Created May 2, 2012 03:13
Simple Upstart Script to send a PushOver notification when the machine boots.
#
# pushoverbooted service
#
# Sends a PushOver notification when the box has finished booting. To
# install, place this file in /etc/init/ You can test the service by
# running 'start pushoverbooted'
#
# You will need to replace TOKEN with the value you get upon following the
# registration process for a pushover application detailed at:
# https://pushover.net/api#registration
@cpu
cpu / pushoverbooted.conf
Created May 2, 2012 14:21
Simple Upstart Script to send a PushOver notification when the machine boots.
#
# pushoverbooted service
#
# Sends a PushOver notification when the box has finished booting. To
# install, place this file in /etc/init/ You can test the service by
# running 'start pushoverbooted'
#
# You will need to replace TOKEN with the value you get upon following the
# registration process for a pushover application detailed at:
# https://pushover.net/api#registration
@cpu
cpu / pushover.pl
Created May 2, 2012 20:24
Irssi script to send DM's via Pushover API
use strict;
use vars qw($VERSION %IRSSI);
use LWP::UserAgent;
use Irssi;
$VERSION = '0.0.1';
%IRSSI = (
authors => 'Daniel McCarney',
contact => 'daniel@binaryparadox.net',
@cpu
cpu / post-commit.sh
Created May 2, 2012 21:27
SVN Post-commit hook for Pushover messages.
#!/bin/bash
#
# SVN Post-commit hook for the Pushover API
# Filters commits to only push when specific authors commit.
# Sends commit messages to one or more device KEYS.
# List of keys to push to
KEYS=( DEVICE_KEY_ONE DEVICE_KEY_TWO DEVICE_KEY_THREE )
# Which commit authors should generate push messages?