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 / cv_here.py
Created May 26, 2017 15:16
Program using Python, OpenCV, and your webcam to determine if you're at your desk (or if anyone is)
#!/usr/bin/python
import cv2
# pass either device id (0 usually for webcam) or path to a video file
cam = cv2.VideoCapture(0)
# a list of installed haar cascades. The upperbody and mcs_upperbody cascades
# are best for me, as the glasses block face detection
cascades = [
@jacoby
jacoby / coffee.R
Created May 8, 2017 15:51
R program that generates a calendar heatmap of my coffee intake over several years
#!/usr/bin/Rscript
# Cairo - for creating images outside of X
# ggplot2 - the MAGIC
# RMySQL - for interacting with the MySQL database
# yaml - for storing database credentials
suppressPackageStartupMessages( require( "Cairo" , quietly=TRUE ) )
suppressPackageStartupMessages( require( "ggplot2" , quietly=TRUE ) )
suppressPackageStartupMessages( require( "RMySQL" , quietly=TRUE ) )
@jacoby
jacoby / count
Last active May 5, 2017 17:02
given a list of entries, it counts identical entries and gives the count of that entry. Like uniq but different.
#!/usr/bin/env perl
use feature qw{ say state } ;
use strict ;
use warnings ;
my %hash ;
my @list = @ARGV ;
if ( !scalar @list ) {
while (<STDIN>) {
@jacoby
jacoby / dither.sh
Created April 6, 2017 19:13
Makes images look like dithered monochrome images from 1980s Macs..
#!/bin/bash
input=$1
output=$2
if [ -f $input ]
then
/usr/bin/convert "$input" -colors 2 -colorspace gray -normalize $output
else
#!/bin/bash
for z in *.zip
do
echo "$z"
mkdir "${z%%.*}"
mv "$z" "${z%%.*}"
cd "${z%%.*}"
unzip "$z"
cd ..
@jacoby
jacoby / get_temp.pl
Last active September 24, 2023 21:09
store_temp.pl pulls the current temperature from darksky.net (formerly forecast.io) and stores it in Redis. get_temp.pl retrieves it.
#!/usr/bin/env perl
# retrieves the current temperature from REDIS to be used in the bash prompt
# I should also get curr_time and, if the difference is too big, prints nothing
# but not implemented yet.
use feature qw{ say state unicode_eval unicode_strings } ;
use strict ;
use warnings ;
use utf8 ;
@jacoby
jacoby / parsing_log_file_question.R
Created February 28, 2017 17:54
I'm hitting the point in my R knowledge where I need to learn flow control and need guidance. Help?
# I'm reading in a logfile that holds hourly load averages from several hosts
logfile = read.table('.uptime.log')
# these log entries run hourly and take the form
# 2017/01/01 00:02:01 genomics-test : 0.36 0.09 0.03
# 2017/01/01 00:02:02 genomics : 0.04 0.03 0.04
# 2017/01/01 00:02:02 genomics-db : 0.12 0.05 0.01
# 2017/01/01 00:02:04 genomics-apps : 1.87 1.24 0.79
@jacoby
jacoby / qubit_archive.pl
Created February 15, 2017 16:24
Archives CSV files once a day
#!/usr/bin/env perl
# the program that cleans up the QuBit directory, copying the CSVs to directories
# corresponding to the day they were created
use strict ;
use warnings ;
use feature qw'say state signatures' ;
no warnings qw{experimental::signatures} ;
use utf8 ;
@jacoby
jacoby / this_query.sql
Created February 10, 2017 16:37
Forgive me, oh Codd, for I have sinned
SELECT wr.request_num req
, COUNT( ws.id ) count
, (
SELECT MAX(submission)
FROM wideseq_status st
WHERE wr.id = st.request_id
) scount
, (
SELECT MAX(status)
FROM wideseq_status ss
@jacoby
jacoby / coffee.pl
Created January 23, 2017 16:05
Magic you can do with 'use lib'
#!/usr/bin/env perl
use feature qw{ say state } ;
use strict ;
use warnings ;
use Data::Dumper ;
use lib join '/', $ENV{HOME}, 'lib' ;
use Coffee ;