Simplicity in development or syntactic sugar

Computing is a pretty big field so it is not always possible to stay on top of every little (or big) framework or enhancement that comes down the line.  I am happy to be involved in software development so I can get a quick heads up when something really cool comes down the line.

Unfortunately I found out about a new thing (for me) in the worst possible way.  I had just joined a new project and was coming up to speed on some of the technologies that was different from my last project.

  • Java (that isn’t end of life)
  • Git
  • Spring Toolset
  • Hibernate
  • New data model
  • Different business area

In short there were no limit to things that I needed to spend my time coming up to speed on when I did the fateful command.

git pull

Yup, all I did was to refresh my workspace with the most recent code from our server.

Oh, sure, the code compiled once I installed the tool Lombok into my IDE and added it to my classpath.  The surprise was that the code that compiled no longer ran.

The culprit

What does Lombok do?  It is actually a really interesting use of the annotations that were added all those years ago in java 1.5. The purpose of Lombok it to reduce the amount of boilerplate code that needs to be manually entered that is added to all (well a lot) of projects by virtually everyone.  Not only that, it is possible to use the methods that Lombok creates even though they are not physically stored in the source code file.

Basically, this allows you to see and focus on the really interesting parts of your code that add value and not be distracted by some of the less interesting boilerplate code that you also added.

I am not going to cover everything that Lombok supports as that is all nicely documented.  I will just focus on a few of the annotations.

  • @Getter
  • @Setter
  • @Data

The first two actually do pretty much what they sound like.  If you add this annotation before your variable then Lombok will automatically generate the getter and setter for you.  Not only that but it will add these methods to the outline tab in your editor.

On the left is my own code and on the right is the outline showing the methods and variables for that class.  If you look closely enough you can see that no “get” method has been created for the iq or age variables and no “get” or “set” have been created for the internalvalue variable.

This code is obviously much smaller and would allow the programmer to be more focused on the real logic.   So this new project actually does add value.

If the Java object is really just an abstract object then there is an easier way than adding all of these “@Setter” and “@Getter” annotations it is possible to add a single @Data annotation.

@NoArgsConstructor
public <strong>@Data</strong> class ComplicatedObject 
{
	private String First;
	private String Last;
	private int age;
	private String Address;
	private String City;
	private String State;
	private int zipcode;
	private int iq;
	private int internalvalue;

	public static void main(String[] args) 
	{
		ComplicatedObject person = new ComplicatedObject();
		
		person.setFirst("Max");
		person.setLast("Musterman");
		person.setAddress("123 Main street");
		person.setCity("Smalltown");
		person.setState("IA");
		person.setZipcode(12345);
		person.setIq(125);
		
		System.out.println(person.toString());
	}
}

Installation

The installation process is actually super simple.  Simply run the lombok.jar file and it will open up a small installer.  First it searches for all installed IDE’s and presents them as a list of locations to install lombok.

Once the IDE has been selected it takes hardly a second to finish the setup of lombok.  In order to use it you simply need to restart the IDE and add the lombok.jar file to any projects that you wish to use this new functionality.

 

The good

The software both installs very simply and is limited to a single jar file. This makes it really easy to add to a project and to later remove if necessary.

 

The bad

I don’t really have any “hard proof” that Lombok itself was problematic to my work project.  I downloaded lombok and did a small test at home.  I didn’t have any difficulties and the functionality is pretty neat.

Thus there is nothing bad to report but this functionality is mainly to simplify the definitions of getters and setters for some plain old java class that is just an abstract data type.

If this is the extent of what is necessary you could go back to the olden days and just have an object and address each field directly.

package com.company.de;

public class ComplicatedObject2 
{
	String First;
	String Last;
	int age;
	String Address;
	String City;
	String State;
	int zipcode;
	int iq;

	public String toString()
	{
		return First + " " + Last + " " + Address + " " + City + " " + State + " " + zipcode + " " + iq;
	}
	public static void main(String[] args) 
	{
		ComplicatedObject2 person = new ComplicatedObject2();

		person.First = "Max";
		person.Last = "Musterman";
		person.Address = "123 Main street";
		person.City = "Smalltown";
		person.State = "IA";
		person.zipcode = 12345;
		person.iq = 125;

		System.out.println(person.toString());
	}
}

I am not saying you should do this but this is essentially what adding all getters and setters to a simple java class does.

The ugly

We did have a few problems with Lombok in our project but I think that this might have been due to a misconfiguration.  We are still looking into that.

Posted in programming | Tagged | Leave a comment

AWS – Fun with S3 Buckets

My last post was discussing the S3 bucket which can be used as more than a simple dumb disk for storing family photos or videos.

One of the more interesting things that can be done with an S3 bucket is to use it as a web server.

Web Server

Don’t get overly excited.  Indeed S3 can be configured to perform as a web server but it is not a full fledged server that you might be used to.  That is to say that it will serve up static content but not run server side scripts.

Once you have a S3 bucket setup it is trivial to create the static web site. Simply go into the properties for the bucket and enable “static website hosting” and provide the actual html script or scripts to be used.

However, just like in my previous article AWS – S3 buckets permissions are the tiny bug-a-boo that could cause some behavior problems in your website.

This simple example uses exactly one html page and two graphic files but because the permissions for one of the graphic files was not set to public the contents are not displayed when someone visits the web page.  This is a common permission problem that needs to be kept in mind when creating static web pages on S3.

I am not a html programmer but I would suppose that the code (below) is virtually identical to what you might see in your normal website.

I would have loved to put the actual code here but was having formatting problems.  The code is actually fairly simple html, if you are really curious you can download it here.

Download files

I am not expecting any problems with the Amazon S3 bucket but this web site does have one little flaw.  If for some reason this S3 service was not available, it might be difficult to move it to another bucket to run.  The reason for this is that the references to the various resources are using the actual path to the regional bucket (s3.us-east-2.amazonaws.com) and not something more generic like supercoolwebsite.com.  However, this could probably be corrected by using route 53 and your own domain – it would still leave you to design a highly tolerant solution.  You might want to replicate your files to another bucket in another region just in case.

 

Posted in Setup From Scratch | Tagged , , | Leave a comment

AWS – S3 and Simple Notifications

Individual Amazon web services are actually quite amazing all on their own but they are really neat when you start to use them together.

There probably isn’t anyone who in their life hasn’t had a sdcard or hard disk fill up who just needed a small bit of extra space to complete their action.  Of course in that situation in the real world you have to stop what you are doing and free up (ie delete something) so you can continue.

Amazon S3 doesn’t have that problem.  If you have the budget, you can keep adding data to it until you are satisfied you are finished.  Sure you have to keep on eye on the costs but that is a completely separate issue.

However, it isn’t any one service that makes AWS so cool as much as how they all seem work together.  One such example of that is the ability to send notifications based on some event that has occurred.  This might be an event you setup to monitor your costs or it might be used as a trigger to an application.

In my case, I am going to demonstrate an email notification going out if a file ends up in a S3 bucket.  If you were some sort of picture site, this might instead be triggering a lambda function to create thumbnails or perhaps this information might be put into a queue for some other processing (or both).

In my previous article, AWS – Simple Notification Service, I discussed everything that needs to be done in order to setup a Simple Notification Service topic but in this blog entry I will actually use put the AWS SNS to use.

In addition to sending out messages, I will also add replication to a s3 bucket.  This will provide a cool way to put data into one bucket and watch it being replicated to the second bucket.  This replication is pretty much as the name says.  If you add data to the source bucket, it will be added to the destination bucket but if you delete it from the source bucket it will also be deleted from the destination bucket.

Replication

The replication is actually quite simple. The setup is essentially from where do you want to copy what, and where should it be placed.  Replication setup is available from the management tab on the bucket.

source

It is also possible, actually recommended that you check the checkbox to encrypt the objects that are replicated.

Destination

The replicated box must be in another region.  It is also possible to change the storage class in the destination.  By selecting a class with a different type it may be possible to reduce the cost of the storage in this additional location.

Permissions

I did not create this IAM rule, nor name myself – I had it created for me.  This is necessary in order to allow the proper read and writing for these two S3 buckets.

Review

Once the replication setup has been saved then new data that is saved or deleted from the source bucket will be replicated a short while later in the destination bucket.

Notifications

The actual notifications on the S3 bucket are trivial to setup.  Simply go to the properties of the bucket and setup an “event”.

Delete event setup

It is possible to be notified depending on which type of action occurred, ranging from simple create or even just simple HTTP commands.

However, it might not be quite that simple as it appears on first look.

You might get an error if the permissions are not properly setup in the simple notification service.

Original notification setup

 

Proper – notification setup

Once you setup the proper permissions in the simple notification setup you can then create and save other rules as long as they do not overlap in functionality (ie two different types of create)

create event setup

Posted in Setup From Scratch | Tagged , , | Comments Off on AWS – S3 and Simple Notifications

More posts to love

Just in case you haven’t noticed it yet the Paranoid professor has doubled our staff. My youngest wanted to balance the computing and other world news with news of sport.

We will still cover all the usual technical positions but now we will see a few more posts on the world of soccer.

Posted in Soapbox | Comments Off on More posts to love

Belgium vs. Japan

Hi guys did you guys watch the game? I did. The ball was more on the Japanese side for the first 20. minutes.Japan scored a goal in the 48. minute and in the 52.minute. And Belgium in the 69. minute. and in the 73.minute and in the additional time. And Belgium won.

 

Posted in Sports | Comments Off on Belgium vs. Japan

Sweden vs. Switzerland

Sweden is OK. Switzerland I don’t now. For who where you? I was for nobody. For the first 50 minutes the ball was mostly on the side of the Swiss. Sweden fouls a lot. Sweden scored in the 66. minute.sweden wins 1-0.

Posted in Sports | Comments Off on Sweden vs. Switzerland

Columbia vs. England

Did you guys watch it I did?Columbia fouls a lot.England scored a penalty.Columbia got a goal in the additional time.England won 4-5.yeah.

Posted in Sports | Comments Off on Columbia vs. England

spain vs. russia

Did you guys watch spain vs russia?I did it was a OG from russia(own goal) and a penalty goal for russia.Even Ramos plaid with 24 red kards and 418 yellow kards.he is europs kard king.for who where you?Did you now that somwone in the spain team is called Nacho.Mmmmmmmmmmmmmmmmmmhhhhhhhhhhhhhhhh Nachos.Sadly it was not finisched because of rain.

Posted in Sports | Comments Off on spain vs. russia

King of sports

  • Hi guys I am going to talk about soccer.I love soccer I wish I could be referee.I now a lot about soccer.If you have any ?questions? about soccer just ask and I  will answer them.Just say them.What is your favorite team my favorite team is germany and france.France because of Mbappe,Dembele,Pobga,Kante,Hernandez,Lloris,Giroud,Lemar,Thauvin,Fekir,Tolisso,N´Zonzi,Varane,Rami,Umtiti,Kimpembe,Sidibe,Pavard,areola,Mandanda.germany because of Manuel Neuer,Marc-Andre ter Stegen,Kevin Trapp,Jerom Boateng,Matthias Ginter,Jonas hector,Mats Hummels,Joshua Kimmich,Antonio Rüdiger,Niklas Süle,Julian Brandt,Julian Draxler,Leon Gorezka,Ilkay Gündogan,Sami Khedira,Toni Kroos,Thomas Müller,Mesut Özil,Marco Reus,Mario Gomez,Timo Wearner,Sebastian Rudy and Trainer Joachim Löw.

 

 

Posted in Sports | Comments Off on King of sports

The internet is for … porn

 

HP 1312 color laser printer

Perhaps I am pretty easily persuaded by the brand as quite a few years back I purchased a HP color printer – the 1312 multi function printer to be exact.

It is a bit late to review this printer as it is no longer possible to purchase it – well at least on Amazon.

It is a color laser printer and the quality it produces is quite reasonable for any home or small business.  I can scan from either the flat bed scanner or by placing papers into the paper feeder.  The paper tray is a bit finicky to get in and out.  I guess they have forgotten how to build a heavy duty printer like their old HP laserjet III’s.  Yet having said all of that I will admit the printer has lasted me a very long time and I haven’t needed to invest in any repairs until now.

The Symptoms

I have had some fairly troubling problems in the last few months.  While printing it sounds like it is grinding up gears and there have been a lot of mis-feeds.  That rate went from sometimes to every other page just last week.  Just yesterday it looked like the blue was being printed slightly askew of the rest of the page.

So I spent a number of hours googling every part of the internet that I could find in order to find a solution.  The solution is to replace those parts that might be old and worn out.  More specifically those parts are the pickup roller and the roller separator.

  

problem area                                                        whilte locking tabs

 

  

separator roller and its cover                             here is the right locking pin
(pointing to locking pin)

The repair itself took about 30 minutes and I suppose a HP professional could have done it in about 15.  The only thing that made this possible was the fact that there are a few repair guides on the internet.  My savior was from the Liberty Parts Team.

http://www.lbrty.com/tech/tarticles/taCM1312roller.pdf

The cost of the repair was both really cheap and fairly expensive.  The parts cost a princely amount of 22.48 including delivery.  The real cost was in both nerves and time to research.

Porn

Oh, the porn?  Well, I have seen and heard the song “The internet is for porn”, but perhaps there are a few other things there as well.

Well, I guess the other thing is Google.

 

I wouldn’t mind a new printer which is why I went ahead on this journey but I really didn’t want to purchase one right now.  If you are also so inclined then next time you have a computer problem it is time to surf the net.

Posted in Setup From Scratch | Tagged | 1 Comment