Skip to content

Instantly share code, notes, and snippets.

View tonypiazza's full-sized avatar

Tony Piazza tonypiazza

View GitHub Profile

Keybase proof

I hereby claim:

  • I am tonypiazza on github.
  • I am tonypiazza (https://keybase.io/tonypiazza) on keybase.
  • I have a public key ASBN7ohW1c1MIoxEmvnxl4C_JQqzxkoLEpYTGQ1P1Gzl1Qo

To claim this, I am signing this object:

@tonypiazza
tonypiazza / reshape_jhu_data.py
Last active March 30, 2020 22:12
Reshape the JHU data files
import csv
import sys
import traceback
FIELD_NAMES = ['Province_State', 'Country_Region',
'Lat', 'Long', 'Date', 'Count']
if __name__ == '__main__':
count = 0
@tonypiazza
tonypiazza / sourcefiles.sh
Last active February 7, 2018 04:40
BASH script to download flight data from the U.S. Department of Transportation, decompress it and then upload to S3
#!/bin/bash
echo 'Creating a temporary directory...'
temp_dir=`mktemp -d -q`
if [[ ! "$temp_dir" || ! -d "$temp_dir" ]]; then
echo 'Could not create temp dir!'
exit 1
else
pushd "$temp_dir"
@tonypiazza
tonypiazza / CheckAndSet.java
Last active August 29, 2015 14:25
Implementation of CAS using AspectJ
/*
* Copyright 2015 Piazza Software Consulting, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tonypiazza
tonypiazza / findByUserName.java
Last active August 29, 2015 14:17
Here is an example of using RxJava via the Couchbase Java SDK.
public Iterable<Playlist> findByUserName(String userName) {
return getBucketFactory()
.getAsyncBucket(Playlist.class)
.flatMap(bucket -> bucket
.get(USER_PREFIX + userName)
.flatMap(doc ->
Observable.from(doc.content().getArray(PLAYLISTS_PROPERTY))
)
.flatMap(id -> bucket.get(id.toString()))
.map(doc -> fromJsonObject(doc.content(), Playlist.class))
@tonypiazza
tonypiazza / setup-couchbase-dev.sh
Last active September 5, 2016 11:33
A BASH script to setup everything we need for a Couchbase development machine with Xubuntu Desktop. You will need a machine with at least 4348 MB of RAM and 4 cores.
#!/bin/bash
# Script written by Tony Piazza (https://gist.github.com/tonypiazza)
# Privileges check
if [ $UID != 0 ]
then
echo -e "Insufficient privileges!"
exit 1
fi
@tonypiazza
tonypiazza / setup-cassandra-dev.sh
Last active December 16, 2015 04:59
A BASH script to setup everything we need for a Cassandra development machine with Ubuntu Desktop.
#!/bin/bash
# Script written by Tony Piazza (https://gist.github.com/tonypiazza)
# make sure we have sufficient privileges
if [ $UID != 0 ]
then
echo -e "Insufficient privileges!"
exit 1
fi
@tonypiazza
tonypiazza / LoggingAspect.aj
Created September 25, 2012 20:36
This aspect demonstrates how to implement logging of method and constructor entry/exit. This is something I created recently for a client to replace more than 10,000 lines of logging code.
package com.piazzaconsulting.aspect;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MemberSignature;
public aspect LoggingAspect {
private static final String POINTCUT =
@tonypiazza
tonypiazza / JunitSuiteExample.java
Last active September 27, 2015 10:28
Example usage of the org.junit.runner.RunWith and org.junit.runners.Suite.SuiteClasses annotations
@RunWith(Suite.class)
@Suite.SuiteClasses({AuctionTest.class, BidTest.class, UserTest.class})
public class CoreAuctionDomainSuite {
// empty class
}
@tonypiazza
tonypiazza / JunitAssertThatExample.java
Last active September 27, 2015 10:28
Example usage of the assertThat method of the org.junit.Assert class
@Test
public void canGetAuctionsForUsername() throws ServiceException {
String username = "tpiazza";
Auction[] auctions = new Auction[5 + new Random().nextInt(16)];
for(int i = 0; i < auctions.length; i++) {
Auction auction = createDummyAuction( username );
auctions[i] = auction;
service.saveAuction( auction );
}
assertThat( service.getAuctions(username), hasItems(auctions) );