Skip to content

Instantly share code, notes, and snippets.

@rkoopmann
rkoopmann / transactions.pl
Last active April 7, 2016 03:19
Split the Mint.com "export all transactions" file into one file per account name
unlink glob("mint_*.csv"); # delete files from prior runs
open mint, "transactions.csv" or die $!; # open the mint export file for reading
while (my $transaction = <mint>) { # loop through each line
chomp $transaction; # remove trailing new line
@detail = split(/","/, $transaction); # values are quoted and comma separated
@rkoopmann
rkoopmann / appLink.py
Created May 15, 2013 02:14
For creating affiliate links for iTunes content with Pythonista for iOS.
@rkoopmann
rkoopmann / SAS_Syntax_Color.plist
Last active August 29, 2015 14:00
TextWrangler-SAS-Plugin: SAS Plugin for Bare Bones' BBEdit & TextWrangler, for SAS syntax highlighting
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.1.dtd">
<plist version="2.0.1">
<!-- 2014-04-30 -->
<!-- Forked as version 2.0.1 -->
<!-- Documentation at http://www.barebones.com/support/develop/clm.html -->
<!-- 2014.02.05 -->
@rkoopmann
rkoopmann / d.sas
Last active August 29, 2015 14:05
parsing SAS macro scripts
/*********************************************************************************\
PROGRAM INFORMATION
Project : Autocall utilities
Purpose : Returns DATE in the specified format.
Inputs :
Outputs :
Notes :
PROGRAM HISTORY
2008-04-14 RK Initial program developed.
%macro split(Value);
%if %index(&value,~) %then %do;
%let lower=%scan(&value,1,~);
%let upper=%scan(&value,2,~);
%end;
%else %do;
%let lower=0;
%let upper=&value;
%end;
%put lower value: &lower;
@rkoopmann
rkoopmann / cinema.scpt
Last active August 29, 2015 14:06 — forked from mcs07/cinema.scpt
-- Parse booking confirmation emails from Cinema and add Calendar event
-- Author: Matt Swain <m.swain@me.com>, Version 1.0, License: MIT
-- Triggered by Mail rule.
using terms from application "Mail"
on perform mail action with messages msgs for rule theRule
tell application "Mail"
repeat with msg in msgs
try
set msgcontent to content of msg
/*********************************************************************************\
PROGRAM INFORMATION
Project : Autocall Macros
Purpose : Import a sheet from an xls file via a SQL pass through query
Inputs : xls file
Outputs : SAS dataset
Notes : data - Dataset to be created.
path - Path to the xls worksheet to be imported.
sheet - Name of the worksheet to be imported.
where - optional where clause to limit data;
%macro expExcel(
data
, path=c:\temp\
, file=%scan(&DATA,1,'.')
, sheet=%scan(&DATA,2,'.')
);
proc export
data=&DATA.
outfile="&PATH.\&FILE..xls"
@rkoopmann
rkoopmann / dates.sas
Created February 28, 2015 01:46
Tests for getting date values from strings containing spanned dates.
data _null_;
d1='29-31 DEC 2009,04-05 JAN 2010'; *broken across month, year;
d2='04-05,08-09,11-12 FEB 2010'; *broken within month;
d3='01-03 MAR 2010'; *contiguous within month;
d4='31 MAR-01 APR 2010'; *contiguous across month;
d5='29 DEC 2009-01 JAN 2010'; *contiguous across year;
d6='01 FEB 2010'; *single day;
array d(*) d1-d6;
re_datesx=prxparse('/^\d{2} [A-Z]{3} \d{4}$/');
@rkoopmann
rkoopmann / iTunes.sas
Created February 28, 2015 01:50
miscellaneous explorations of iTunes metadata.
filename itunes 'iTunes Music Library.xml' encoding='utf-8';
data _null_;
infile itunes;
input;
if index(_infile_, '<key>Tracks</key>') then call symput('start', _n_);
if index(_infile_, '<key>Playlists</key>') then call symput('stop', _n_);
run;
data music( drop=_: kind play_date persistent_id--Composer sort_: );