Skip to content

Instantly share code, notes, and snippets.

View jacoby's full-sized avatar
🌮
I ❤️ Tacos

Dave Jacoby jacoby

🌮
I ❤️ Tacos
View GitHub Profile
@jacoby
jacoby / DB.pm
Created March 13, 2013 16:10
Interface module for abstracting DB access
package DB ;
=head1 NAME
MyDB - Module handling access to MySQL databases
=head2 DESCRIPTION
This is the interface to the databases, abstracting all the complexity of
DBI into just a few functions.
@jacoby
jacoby / kicking.myself.pl
Created March 19, 2013 20:56
Man, I'm stupid. I go through, line by line, explaining how tunnelvision made this code stupid.
### Triple-hash comments are my commentary
### Assume I define some SQL here.
my $data = db_arrayref( $sql ) ;
###so I go through 3000+ rows of DB returns
for my $line ( @$data ) {
my @array ;
push @array, $$line[ 2 ] ;
### I should have this query outside the loop, but that's the least of my troubles
@jacoby
jacoby / MyDB.t
Created March 20, 2013 20:22
Test for MyDB.pm Will start to put it together into a more real thing.
# Tests for MyDB
use Test::More ;
# Does the module even exist
BEGIN { use_ok( 'MyDB' ) ; }
require_ok( 'MyDB' ) ;
subtest "function exists" => sub {
can_ok 'MyDB', 'db_connect' ;
@jacoby
jacoby / API.pm
Last active January 30, 2017 01:37
Perl Module to handle export of hashrefs based upon requested format.
package API ;
use 5.010 ;
use strict ;
use warnings ;
use CGI ;
use Exporter 'import' ;
use Data::Dumper ;
use JSON ;
@jacoby
jacoby / fitbit.download.py
Created April 15, 2013 18:13
Using my DB and FitBit Python code to download the last five days of FitBit data (because I don't necessarily sync the thing every day)
#!/usr/bin/env python
# downloads last five days of fitbit info, not including the current day.
# the current day's info isn't finished, and I often don't have it sync
# during the weekend
import datetime
import httplib
import os
import simplejson as json
@jacoby
jacoby / hacker_olympics.pl
Created May 28, 2013 14:41
Solution to http://www.hacker-olympics.com/puzzle.html , written in Perl. The rules: The sequence works like this. Starting with 0 and 1, add the previous two numbers together to generate the next number in the sequence. So, the pattern looks similar to what’s below. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34... Your job, is to do the following. * Continue…
#!/usr/bin/perl
use 5.010 ;
use strict ;
use warnings ;
use Math::BigInt ;
my $max = 500 ;
my @fib1 ;
my @fiba ;
@jacoby
jacoby / cron_error.pl
Created June 6, 2013 18:55
Something broke on one of our servers, causing lots of errors in our crontabs (and other things). I have notifications off in Thunderbird, so I have to enter into that directory to make it update and tell me the large amount of errors. So, I modified something I wrote a while ago to tell me when the cron directory is full up. I need to make some…
#!/usr/bin/env perl
=begin comment
cron_error.pl
Program used to check the Cron folder of my Purdue inbox,
to alert me if large amounts of errors start to be generated
in the crontab-run programs. Alerts happen, in this case, via
XMPP, specifically in this case via Google Talk, soon to be
@jacoby
jacoby / .twitter.cnf
Created June 6, 2013 20:08
Sample .twitter.cnf for my twitter.pl
---
consumer_key: <CONSUMER_KEY, available from Twitter>
consumer_secret: <CONSUMER_SECRET, available from Twitter>
tokens:
<YOUR_TWITTER_HANDLE>:
access_token: <GENERATED FIRST TIME YOU USE THIS SCRIPT>
access_token_secret: <GENERATED FIRST TIME YOU USE THIS SCRIPT>
@jacoby
jacoby / hidr.js
Created June 27, 2013 20:52
hidr.js is a library to hide tables and rows (although it could be used to hide other things...)
/*
hidr.js -- hiding and displaying rows or columns
<fieldset class="hidr_buttons">
<label> <input type="checkbox" value="abc"> </label>
<label> <input type="checkbox" value="def"> </label>
</fieldset>
<table class="hidr">
<tr class="abc"><td class="def"> Foo </td></tr>
@jacoby
jacoby / Locked.pm
Created July 15, 2013 17:59
Some of my fave code. A little library that tells if xscreensaver is running. For me, this tells if the machine is locked or not, with the assumption that a locked machine means I'm not there. Yeah, having something using OpenCV doing face recognition to see if I'm at my desk would be cooler, but I say this is sufficiently cool and more than a l…
package Locked ;
use strict ;
use warnings ;
use Exporter qw(import) ;
our $VERSION = 0.0.1 ;
our %EXPORT_TAGS ;
our @EXPORT ;
my %prepared ;