Tuesday, January 17, 2017

Swing/AWT Peculiarities: Graphics vs Graphics2D And Other Oddities


I was recently thrust into GUI programming in Java. And I do have to admit that it turned out to be harder than I expected. The primary reason for that is that I thought having done it while working on an ImageJ plugin back in 2010-2012 I would remember every little detail but my memory turned out to be far less effective than I expected it to be.
One thing I had sort of forgotten about is how confusing thread and concurrency issues can get in the context of a GUI. Another thing - how many ways that should seemingly work the same way and accomplish the same objective within the AWT/Swing class collections, yet don't always work the same way.
So here I would like to just list a few oddities I discovered this time around as this will hopefully save other people time and effort and help me remember them too. So here we go.

Graphics vs Graphics2D

For some reason, many 2D graphics functions work better when called from a Graphics2D instance than from a Graphics instance. I am not sure why, especially given that the former is a subclass of the latter, but according to many sources I have consulted as well as my own experience that is indeed so. Hence effectively it is best to structure your code as follows:

JPanel panel;
Some code that initializes panel, attaches it to the frame, etc.
Graphics g = panel.getGraphics();
Graphics2D g2d = (Graphics2D)g;
/* Now let's draw something */
g2d.drawLine(5, 5, 20, 20);
g2d.drawOval(50, 50, 150, 150);

The snippet above will draw a line and a circle, and in most instances will do so more reliably than an equivalent snippet using a Graphics instance.

paint() and repaint(): how to stop random removal of your graphics

For some  reason, default behaviour of the paint()/repaint() methods is to just repaint the whole JPanel instance to blank slate. Not sure why - I guess I could come up with a few rationales but I still view this default behaviour as suboptimal. Be that as it may, the Swing creators thought differently and hence we have what we have.
The practical outcome of this was that at certain junctures my whole panel would lose all its content. The way to overcome it that I came up with was somewhat primitive but effective. I defined a JPanel subclass that looks as follows:
import javax.swing.JPanel;

public class MainAppPanel extends JPanel {

    public MainAppPanel() {
        // TODO Auto-generated constructor stub

    public MainAppPanel(LayoutManager arg0) {
        // TODO Auto-generated constructor stub

    public MainAppPanel(boolean isDoubleBuffered) {
        // TODO Auto-generated constructor stub

    public MainAppPanel(LayoutManager layout, boolean isDoubleBuffered) {
        super(layout, isDoubleBuffered);
        // TODO Auto-generated constructor stub
     * @OVERLOAD
    public void repaint(){
     * @OVERLOAD
    public void paint(){


Naturally, I then used MainAppPanel instead of JPanel - and the graphics stayed the way I expected to.

Hat tips

Too many to mention - lots of people on various forums whose input was invaluable. This all happened a few weeks ago but I was just too disorganized to put it all in writing, so I don't remember the URL's and names anymore but that doesn't mean I am any less grateful.

Tuesday, November 29, 2016

Epoch & Unix Timestamp Conversion Tools

Yes, this is just a shameless prop for a utility I happened to like.

Long story short - I was running a ping with a "-D" (timestamp) option and I wanted to see how to turn something like this:
[1480443528.089965] 1208 bytes from icmp_seq=21548 ttl=244 time=781 ms
[1480443529.079493] 1208 bytes from icmp_seq=21549 ttl=244 time=771 ms
[1480443530.119068] 1208 bytes from icmp_seq=21550 ttl=244 time=811 ms

into something where I would know when the ping happened without counting off seconds since the start of 1970.

So I started searching and found this utility site:

I think it is quite useful and so - have at it!

Wednesday, October 26, 2016

Nginx, Drupal and mbstring: a major mess, and how to avoid it

This is not a particularly interesting issue, merely one of a particularly confusing nature. So I decided to write about it for future reference. And if that saves anybody time when they encounter the same situation I was in that would make it worth the effort to document it as it took me quite some time to sort out.

So I have tried to get Drupal 7 to run under NGINX 1.10 on my CentOS 7 VM. The first major requirement that required custom work was the one calling for PHP v5.2.4 or higher (full list of requirements available here). I have chosen to go for PHP v5.5 (I forget the exact reason but now, at least based on the Wiki article, I may be due for another update - at least to PHP 5.6 or PHP 7). So I did indeed install PHP 5.5. I don't remember the exact sequence for that - and that stage went through smoothly, something along the lines outlined here. At any rate, that was an easy and uneventful phase of the process.

Now with that out of the way I thought things were on track to get better - but fate would have it different. As I tried to go through the moves and initialize the Drupal-based website I was working on I got the following:

Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentation for more information.
As I tried resolving the issue I asked for advice on the NGINX user forum (the thread available here, in Russian). Skipping every twist and turn of this rather protracted affair let me just summarize it by saying that mostly everyone, myself included was looking for ways to turn off the multibyte string processing without realizing that the relevant module had to first be installed which it was not.

So the solution turned out to be simple. But like I said - it took time. The solution was this:

1) Install the relevant module:

yum install php55w-mbstring

2) Change the relevant lines in the config files. The lines to alter need to look as follows:

ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');

as detailed here.

So yes - Drupal wants you to install the functionality it does not need (multi-byte strng processing) and then wants you to disable it. Go figure.

Once again - thanks to everyone who helped me in the process, and if that helps somebody avoid the pain I had to go through, then this post is of some use.

Friday, September 9, 2016

Displaying labels on Blogger

Only of interest to those who, like myself, are on Google Blogger.

If you need to add a complete or partial list of labels used within your blog displayed within that blog what you need to do is select the "Layout" settings within the dashboard for your blog and then add the labels to one of the sections of your blog.

Just one of the these "useful to know" things.

Hat tip: Mayura4Ever.

Thursday, June 30, 2016

Where is my archived Gmail messages?

Never paid my attention to the notion of "archived" messages in Gmail - which I presume means just "stored but not immediately visible". Not sure I see much value in that designation - but be that as it may, just last night I archived one by mistake and then didn't know where to look for it.

Turns out it can all be found under the "All mail" umbrella in the labels/categories pulldown on the left. Details over at StackExchange. Hat tip to all who had done the research.

Tuesday, May 17, 2016


Boris Epstein

Boston, Massachusetts - Providence, RI, US

E-Mail: borepstein@gmail.com
Phone: 617.816.9654


Extensive experience in IT and programming and good practical ability to apply that experience to real-world problems. Have on several occasions successfully suggested and introduced solutions that have made a qualitative difference to the efficiency and reliability of the system in question. Capable of thinking outside the box and showing initiative. Good ability to see the big picture as well as the details of the immediate task.
Quick learner, capable of rapidly coming up to speed on new technologies. Have a good understanding of logistics, process and technology. Have experience working in small teams where being a jack of all trades is pretty much required and learning new technologies is almost an everyday constant.

Operating Systems: Linux/UNIX, Mac OS X, MS Windows, MS DOS, Apollo Aegis, VMS
Programming Languages: C/C++, Pascal, PERL, Ruby, JAVA, UNIX (C-Shell, Bourne, Korn), Tcl/Tk, PHP, Lisp/Scheme
Tools: Netbeans, Eclipse, TogetherJ, Emacs, MS Office, OpenOffice, LibreOffice, FrameMaker, VI
Technologies: MySQL, PostgreSQL, SYBASE, KVM, Xen, VirtualBox, OpenVPN, Oracle RDBMS, CVS, SVN, ClearCase, DSEE, SalesForce, RemedyForce, OTRS, Redmine, Nagios, Zabbix, MediaWiki, Altassian Confluence, NFS, NIS, LDAP, DHCP, Webmin, TCP/IP, iptables, routers/firewalls, etc.
Hardware: IBM-compatible PC, HP, SUN, Mac

May 2014 - May 2016
Framingham, MA
Worked as a system administrator in a small team responsible for corporate IT services in a company with a global reach. Responsible for key elements of the corporate infrastructure such as IT support ticketing system (RT), VMware ESXi cluster, Dell KACE systems management/deployment facilities, Druva inSync endpoint backup/availability infrastructure and others.
Daily tasks included supporting and servicing servers in the datacenter, physical and virtual, supporting the VoIP telephony for a number of offices, fielding unusual helpdesk requests and other tasks.
Participated in the 24 hours support rotation. Interacted and worked together with the colleagues worldwide.

August 2012 - May 2014
Cambridge, MA
Worked as a system administrator in the US Operations/Customer Support group. Interacted with customers world wide on a daily basis. Helped develop and improve operational logistics and day to day support and operations methods and procedures.
Supported and troubleshot unique Infiniband-based Cloud infrastructure. Provided technical expertise during all phases of the sales process. Assisted with system migration and integration into the ProfitBricks' KVM-based instances.
Worked in a highly diverse and challenging environment continually adjusting to the demands of a very aggressively growing successful high-tech startup.

May 2007 - August 2012
Cambridge, MA
Worked as something akin to a one-person IT department for a small cutting-edge research lab. Supported communication and integration needs between the lab and various collaborators. Planed and implemented the lab's hardware and software infrastructure while at the same time provided everyday support to lab's users. Participated in coding lab's internal utilities as well as the publicly available OpenMIMS Analysis Module. Integrated various software and hardware systems for the lab's needs. When necessary fulfilled general office management duties such as scheduling meetings, placing orders, etc.
Played a pivotal role in the lab's transition to a enterprise-level configuration featuring MooseFS-based distributed file storage, functionally segmented network architecture, Subversion-based code control, Bugzilla-based bug tracking, etc. Have a track record of setting up systems and services that sometimes ran for over two years with no downtime.
Beyond officially delineated responsibilities maintained my own privately-run VPN solution to provide connectivity to the lab's employees and collaborators outside the lab.

April 2004 - May 2007
Travel. Educational activities. Occasional freelance projects.Provided technical assistance to several online projects including Cooperative Research and New England JAVA Users Group.In 2005, in the wake of Hurricane Katrina helped coordinate volunteer relief activities in the Gulf and personally participated in those activities.

July 2001 - April 2004
Waltham, MA
Worked as a programmer involved in development and support of the ETMS air traffic management software for the FAA at the Volpe National Transportation Systems Center in Cambridge, MA. Specific area of concentration was the CDMcomponent of the ETMS. The tasks included design and development of new functionality, as well as supporting legacy code. A large codebase together with the need for system reliability provide for a challenging task. The code was originally written in Pascal and later migrated to C.
The system was in essence a large transportation management system receiving and reflecting frequent (mostly once-a-minute) updates regarding the status of flights operating over the US airspace. Near realtime requirements were in place for processing and analyzing data which made for an exciting and challenging task.

December 1999 - April 2001
Boston, MA
Performed multiple roles on a daily basis, including those of a senior system designer and developer, Windows NT and UNIX system administrator and web hosting support engineer. Key player in the technology planning and implementation area. As a sole expertise in a number of areas, including object-oriented design and development, networking, network security and systems management, advised other team members on various technology issues.
Main tasks included web site backend implementation for clients, in-house product design and implementation as well as day-to-day activities mentioned above. Most of the coding was done using object-oriented technology, with JAVA as a programming language of choice.
Provided critical insight which allowed to greatly improve stability and efficiency of the internal systems.
Clients included Davox Corporation (now part of Aspect Software), Pilates StoreLobsters-Online, Inc. and others.

September 1999 - January 2000
Medford, MA
Worked as a UNIX administrator in a large-scale web and dataserver hosting facility. Was responsible for maintenance and troubleshooting of multiple industrial-scale UNIX servers in SUN, HP and IBM platforms. Performed database maintenance of SYBASE and ORACLE databases as well as data recovery and general server troubleshooting.

May 1999 - July 1999
GTE International (currently part of Level3 Communications)
Cambridge, MA
As part of the Y2K team worked on the remediation of custom SUN Solaris machines hosting clients' mission-critical WWW sites and applications. Complex upgrades and modifications had to be accomplished requiring an absolute minimum in customers' downtime. Tasks included upgrades of the OS, DB servers and various other third-party software. Custom scripting and coding was often required to facilitate the necessary transition.

November 1995 - May 1999
Cambridge, MA
Originally hired as an outside contractor. Accepted a permanent staff position in a three months' time. Throughout my whole tenure was a critical part of a small and continually overtasked team. Responsibilities included day-to-day maintenance and support of a network of UNIX hosts. Maintained code control systems. Designed and implemented a data backup/archival system for in-house use. Created web pages using HTML, PERL and JAVA. With the emphasis on publicly available software restructured the environment to optimize and economize the development and production process. Modified publicly available software for local needs using C, Tcl/Tk, PERL, JAVA, etc. Was also involved in equipment and software installation and support at client sites. Worked with medical applications and protocols including DICOM, ISG's VRS graphical application and AWARE wavelet compression. Wrote system installation and maintenance scripts. Modified and integrated various third party software packages. Worked with multimedia devices in medical data capture/processing systems. Set up and supported LANs and WANs.

July 1992 - November 1995
Kenan Systems Corporation (currently part of Alcatel-Lucent)
Denver, CO - Cambridge, MA
Participated in database design of SYBASE databases.As part of a product team supported development effort in a heterogeneous UNIX environment. Oversaw the operation of a distributed development environment which included multiple geographically disjoint locations. Wrote a suite of PERL scripts that encompassed the local customizations to ClearCase as required by the project. Other responsibilities included release/code management using ClearCase code control system, SYBASE database administration, system design activities.

Summers of 1990 and 1991
Cambridge, MA
Participated in the development of ATMS (Automated Traffic Management System), an air traffic management and control system for the FAA. Coding was done in Pascal against a proprietary database. The network consisted of a multitude of Aegis hosts on the Apollo platform. The development was done under DSEE as an integrated code control and management environment.

Born in St. Petersburg, Russia in 1969. Have lived in the US since 18 years of age. Attended Tver University (website in Russian) in Tver, Russia; Boston University and University of Massachusetts at Amherst graduating in 1992 with a Bachelor's Degree in Mathematics/Computer Science.

Available upon request.

Sunday, May 4, 2014

Back to Drupal after many years

Working on a site using Drupal. It is very powerful but somehow cryptic, I think. I get a feeling that if only I could tune into the same mental wavelength the people behind it are on things would take off faster.

But for now - one simple remark. If the site is to be presented in both HTTP and HTTPS it is higly recommended that the URL be defined as an HTTPS one. Here's how: edit the setting file (/sites/default/settings.php) and define $base_url as follows:

$base_url = 'https://your-site.com';  // NO trailing slash!