Thursday, March 23, 2017

Maven things

Install library

mvn install:install-file -DgroupId=com.humegatech -DartifactId=car2go-connector -Dversion=1.2.0-SNAPSHOT -Durl=file:./target/ -DupdateReleaseInfo=true -Dfile=./target/car2go-connector-1.2.0-SNAPSHOT.jar

Deploy to local repository
Add repo to pom.xml

...
  <repository>
    <id>local-maven-repo</id>
    <url>file:///${project.basedir}/lib</url>
  </repository>
</repositories>

Deploy
mvn deploy:deploy-file -DgroupId=com.humegatech -DartifactId=car2go-connector -Dversion=1.2.0-SNAPSHOT -Durl=file:./lib/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=./lib/car2go-connector-1.2.0-SNAPSHOT.jar

Release Deployment
http://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment

Thursday, February 4, 2016

Free(ish) tee shirts from tech companies

If you're reading this you've already missed the January 2016 sweatshirt Salesforce offered for earning five badges on Trailhead (https://developer.salesforce.com/trailhead/en), but there are still plenty of folks willing to turn you into a mobile advertising platform.

You will be asked for personal information, a social media connection and maybe even some of your time.

NewRelic http://newrelic.com/lp/datanerd
Just sign up

MuleSoft http://champions.mulesoft.com/
Complete an hour or two's worth tasks: reading, commenting, LinkedIn connection, Twitter following, etc. After a week you'll get a link to redeem your t-shirt: I had to turn of Ghostery and uBlock Origin to complete the redemption process.

CircleCI http://blog.circleci.com/new-stickers-and-circleci-tee-shirts/
Just sign up

SmartBear http://www2.smartbear.com/Yovia-Social-TShirt-Campaign_Yovia-Social-LP.html
Download LoadComplete

5nerdssoftware: http://5nerdssoftware.com/so-you-want-a-free-shirt/
Facebook like

Mixpanel https://mixpanel.com/tshirt
Sign up, be inactive for a week (not sure if this is necessary, but I didn't get an email about the shirt until being inactive after signup), then instrument your application with Mixpanel.  Or just go to your console:

m = Mixpanel::Tracker.new '<your_product_token>'
m.people.set('1', {'email':'first.last@gmail.com'})
m.track('1', 'first event')

Amazon https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/content/alexa-developer-skill-promotionPublish an Alexa skill before March 31, 2016

Rollout https://blog.rollout.io/2015/12/try-rollout-get-a-free-tshirt/
contact information

Wistia http://wistia.com/shirts
contact information

JIRA Service Desk https://www.atlassian.com/software/jira/service-desk
You have to set up an account and do some things in said account

Rollbar https://rollbar.com
Create a free account and then wait a while (2+ months?) before you instrument an application.  I got an email saying that if I instrumented an application with Rollbar they'd send me a shirt for free.

DataDog https://www.datadoghq.com/ts/nagios/
I started a free trial and continue to have free monitoring on a non-production PostgreSQL instance.


On hold
These free shirt offers seem to be over/on hold:

WhenIWork http://wheniwork.com/free-shirt

Codeship https://codeship.com/swag

Friday, May 10, 2013

jMock custom actions, doAll expectation and onConsecutiveCalls

I had an issue with a class that I've not encountered before with projects on which I use jMock: I have a mocked class whose method modifies an object it takes as a parameter.  I suspect this is due to poor coupling in the application, but I'll refactor at a later date -- for now I welcome the challenge as an opportunity to explore three aspects of jMock with which I'm unfamiliar: custom actions, doAll and onConsecutiveCalls.

Problem

public class WillBeMocked {
    public Object processBusinessObject businessObject) {
        ReturnObject returnObject = new ReturnObject(businessObject);

        // change state of input parameter
        businessObject.incrementCounter();

        return returnObject;
    }
}

Solution


create custom jmock.org.api.Action in my test class

private static class BusinessObjectIncrementCounterAction<T> implements org.jmock.api.Action
{
    private final BusinessObject businessObjectInstance;

    public BusinessObjectIncrementCounterAction(final BusinessObject businessObjectInstance)
    {
        this. businessObjectInstance = businessObjectInstance;
    }

    @Override
    public void describeTo(final Description description)
    {
        description.appendText("calls incrementCounter() on the businessObjectInstance");
    }

    @Override
    public Object invoke(final Invocation invocation) throws Throwable
    {
        businessObjectInstance.incrementCounter();
        return null;
    }
}


create static call to construct custom Action in my test class

private static <T> org.jmock.api.Action incrementCounter(final BusinessObject businessObjectInstance)
{
    return new BusinessObjectIncrementCounterAction <T>(businessObjectInstance);
}


use doAll to execute custom Action and mocked class's method call

                
context.checking(new Expectations() {
    {
        oneOf(willBeMockedInstance).process(businessObjectInstance);

        will(doAll(incrementCounter(businessObjectInstance), 
             returnValue(new ReturnObject("A"))));
    }
});



use onConsecutiveCall to 

context.checking(new Expectations() {
    {
        exactly(2).of(willBeMockedInstance).process(businessObjectInstance);

        will(onConsecutiveCalls(doAll(incrementCounter(businessObjectInstance), 
             returnValue(new ReturnObject("A")))),
             doAll(incrementCounter(businessObjectInstance), 
             returnValue(new ReturnObject("B")))));
    }
});

Wednesday, May 8, 2013

Return code is: 401, ReasonPhrase:Unauthorized. -> [Help 1]: Nexus error via Maven via Jenkins when using a slave node: Solved


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project project: Failed to deploy artifacts: Could not transfer artifact com.company:project:jar:build_id from/to dirname (http://server:port/nexus/content/repositories/snapshots): Failed to transfer file: http://server:port/nexus/content/repositories/snapshots/com/company/product/build_id/product-build_id.jar. Return code is: 401, ReasonPhrase:Unauthorized. -> [Help 1]

(Output modified to protect the innocent.)

I have Maven builds running on a Jenkins master with slave nodes.  The deploy goal attempts to push artifacts from the build out to our Nexus instance.

To address this issue I had to add settings.xml to the Jenkins slave owner's .m2 directory as this is used during the upload to Nexus, not the settings.xml in the .m2 directory on the Jenkins master box.

Monday, April 15, 2013

How to move a repo from GitHub to Bitbucket

Just collating two existing resources.  As with the first poster I like to store tutorial code, etc. in a private repo so that it doesn't clutter up my GitHub presence when I put something out there.

Import GitHub repo into Bitbucket

http://somatose.com/2011/10/from-github-to-bitbucket-in-60-seconds.html

Delete GitHub repo

https://help.github.com/articles/deleting-a-repository

Saturday, February 23, 2013

How to create an iso of an existing Windows system using Ubuntu: what worked and what didn't

I have a Windows XP Media Center laptop that is dying, but want to keep the image around.  I've created vms before but not from existing systems, just as fresh installs.  Searching around I stumbled upon Clonezilla which allowed me to create just such an image without purchasing software.  Unfortunately Clonezilla only almost worked (probably because of something I didn't do correctly).   disk2vhd (a Microsoft product) ended up getting the job done in the end.

I'm using Ubuntu 12.10 as my main machine.   Taking an image of a Windows XP Home Media edition with an 80G hard drive. 

The disk2vhd approach

disk2vhd didn't turn up as one of the many options that were presented as I started down this path, but it   ended up being the easiest and quickest of those I tried. I followed these instructions to create the vhd.  Then I used VirtualBox to open the image.  The only thing I had to modify in VirtualBox was this: in System -> Motherboard check the Enable IO APIC box in the Extended Features setting.


The Clonezilla approach

I had space on my system's hard drive that is sufficient but not any flash drives so I backed up using Clonezilla's ssh option to my main box.  This was convenient since I'd be creating the image of the system on the main box anyway.

Before you reference the steps below, understand that I was only able to get to the point where the vm could boot to the safe mode prompt screen, but then hung on any attempt to move forward.  I've got a hunch that trying this with cloning a Linux box would have gone better.

There are several distinct units of work: 
  • prep the source machine
  • create media
  • prepare a repository location for the backup
  • create the clone
  • create a VM from the clone

Prep the source machine

Issues with the source machine

I loaded Clonezilla on a USB drive and ran fine for two partitions (boot and D:/), but not for the main partition where the OS files were installed.  After experiencing issues with booting SpinRite6 from a USB drive that cleared up when using a DVD, I burned the Clonezilla ISO to a physical DVD.  

I then decided to try and make the source image as 'clean' as possible by doing the following:
  • Removing unused files/dirs manually, running disk clean and emptying the recycle bin on the source machine
  • Defragging the source machine
  • Updating BIOS to the latest version provided for my source machine by the manufacturer
  • Running SpinRite on the source machine

Create media

Create Clonezilla disk

Create bootable Clonezilla ISO using Tuxboot.

Create Windows boot disk

I relied upon http://support.microsoft.com/kb/305595 for instructions.  My machine didn't come with any physical media so I needed to harvest the files from C:\.  ntldr and ntdetect.com were in C:/WINDOWS/ServicePackFiles/i386.  boot.ini.backup was in C:\Windows\pss which was good since I used it to confirm the boot.ini name of my operating system.

Tried boot-repair first since screen was blank when I restarted.  After boot-repair I got Windows boot screen, but it just hung part way through the process no matter which option.

Prepare a repository location for the backup

For me the repository location is an Ubuntu 12.10 machine.  It has more space than any external drives I have and it is where I'll be creating and hosting the VM.
  • Install/confirm openssh
  • Create directory /home/partimag on the destination machine and give said directory the appropriate permissions

Create the clone

  • Boot source machine with Clonezilla media
  • When prompted, enter connect info for your destination box
  • Give yourself a few hours if you have an old 80G box you're attempting to clone :)

Create a VM from the clone

  • Create a vm with the same amount (or more) of space
  • Start the vm with the Clonezilla ISO.  Follow the prompts and select restoredisk



Tuesday, February 19, 2013

Solved: Amazon Instant Video won't play on Firefox on Ubuntu 12.10

http://helpx.adobe.com/x-productkb/multi/flash-player-11-problems-playing.html

To summarize:
  1. Install hal
  2. Remove directories from ~/.adobe/Flash_Player
  3. Restart Firefox and watch a video