Showing posts with label information-technology. Show all posts
Showing posts with label information-technology. Show all posts

Wednesday, April 27, 2016

Fortran 77 (F77) - How to Convert Integer to String and Concatenate

Recently was working with a 91-year old researcher on their Fortran 77 code written over the last 50-years. It needed debugging and some new coding so it lead to learning an ancient language lovingly called F77. It is an eye-opening experience to realize you are working on something with that much history and contributing to a legacy.

Anyhow, personal reflections aside, here is how you convert an integer into a string in fortran 77 and then concatenate it to another string. Useful for suffixing a filename for example.

Conversion

The basic idea behind converting a variable of any type to a string in Fortran 77 is to write that variable into a Character array variable of some length using the Write function. So in our case we will be writing an Integer into a Character array.

Note: The size of the character array should match the number of digits else you will have a lot of white space. Of course you can do that if you want.

Let's define two such variables and assign them values.

Tuesday, November 17, 2015

Linux SSHD: Per-User or Per-Group Configuration to Disable or Enable Functionality

To have configurations in sshd_config on a per-user or a per-group basis you need to use the Match Group and Match User directives.

Example

To prevent say remotely running GUI programs for all users save some you can use the following snippet. You can of course make other modifications.
# Disable X11 Forwarding and TCP Forwarding.
X11Forwarding no
AllowTcpForwarding no

# This to enable for a group called "X11AllowedList" that you created with 
# its respective members.
Match Group X11AllowedList
    X11Forwarding yes
    AllowTcpForwarding yes

## OR ##

# Or this to enable for a user specifically.
Match User johndoe
    X11Forwarding yes
    AllowTcpForwarding yes

Summary

The indentation is what makes this possible.
Match User johndoe
    X11Forwarding yes

Advanced: To Restrict Commands

If you want something more sophisticated than just preventing some GUI executions, you will want to create a restricted shell so that the users have limited access. This would then be force executed soon as someone logs in using the ForceCommand Directive as follows:
ForceCommand /usr/local/bin/strict_shell

Tuesday, October 2, 2012

GMail Tips: Manage Replied-to and Forwarded Message Workflow

Problem

Frequently, people want there to be some mechanism to know whether they have replied to messages in a conversation thread. Unfortunately, GMail does not have any mechanism for this by default.

Solution

However, using Labels and Filters a little creatively solves the issue mostly. Here are the filters I use for myself.

Replied
Matches: from:me subject:(Re:)
Do this: Apply label "↵", Never send it to Spam

Forwarded
Matches: from:me subject:(Fwd:)
Do this: Apply label "→", Never send it to Spam



Simple Steps to add filters to your GMail account:

  1. You can download my XML file with the filters here:
    1. Click here to get to it.
    2. Click on the "Download" button.

Friday, September 14, 2012

Overriding Shell for Users through SSSD

What is SSSD in a nutshell?

SSSD (System Security Services Daemon) is a collection of daemons used by Linux to manage the authentication and authorization to a system. In particular, it can interface with remote directories such as those that use LDAP (Lightweight Directory Access Protocol), and internally interfaces with NSS (Network Security Services) and PAM (Pluggable Authentication Module). Essentially, it can be configured to control the behaviour of these other services. You can learn more about it here:

https://fedorahosted.org/sssd/

The problem?

I was getting the authentication information from a central LDAP directory however, they only provided /bin/csh and the environment variable for the users while I needed it to be
/bin/bash in my environment.

Ideally, SSSD would have provided a way to override the shell in its configuration files, unfortunately, at the time of this writing that is only available in version 1.9 of SSSD which is currently in beta with the Fedora project. Further, my systems were Red Hat Enterprise Linux 6 (RHEL) which typically runs a few versions behind in most things though security patches and bug-fixes are backported.

Wednesday, August 22, 2012

Matlab and OS X Mountain Lion (10.8)

A little background

The current latest version of Matlab is 2012a. It was released for Mac OS X Lion (10.7) so requires X11 to provide the GUI. However, with the release of Mac OS X Mountain Lion (10.8), X11 is no longer provided by default from Apple. This poses a bit of a problem for Matlab 2012a.

What to do with Matlab 2012a on Mountain Lion?

While Mountain Lion doesn't have X11 and Apple isn't providing their version of X11, they are providing development support to the Open Source project that the Apple X11 was based off of: XQuartz.

Friday, August 3, 2012

GMail Tips: Access Contacts easily when composing messages

Sometimes you need to access your lists of contacts when composing your e-mails without jumping back and forth ad nauseum between GMail and Contacts. This is another one of those useful but too subtle to notice GMail interface features but it works well once you know about it.

  1. Click on the little grey "To" labeling the "To Field"; it is an actual link.
  2. You will get a popup of your Contacts list. Then you can:
    • Click on people's names to select them for sending mail.
    • Click on the drop-down group listing to select a sub-group of people to sift through.
    • Click on "All" or "None" to send mail to the entirety of whichever group is selected.
    • Click on names and then click on "Save as Group..." to add a group label to them; useful for quicker future searches, and quickly sending mail to the entire group.
That should help your workflow.

Tuesday, July 31, 2012

GMail Tips: Forward Conversation Thread in Order

Sometimes people using GMail want to be able to forward a complete conversation thread to someone else, but in order of oldest post first. The menu item placement for that is not intuitive unfortunately. This is what you do:
  1. Click on the conversation (it will take you to the view of the conversation)
  2. Go to the "More" drop-down menu at the top and select "Forward All"
  3. Compose your forwarded message as you like.
That is it. It would be more orthogonal if the "Forward All" was also placed in the message context menu like "Reply All" is.

Tuesday, July 24, 2012

Accessing IPython Notebook remotely over an SSH tunnel

What is IPython Notebook?

IPython Notebook is the web-based environment that comes with IPython and is used for scientific computing and visualization. From their website:

"A web-based notebook with the same core features but support for code, text, mathematical expressions, inline plots and other rich media."

What we wanted to do?

We wanted to be able to access the IPython Notebook environment remotely from researcher machines.  The reasons for this were multiple:
  1. Their data had to reside on the remote machines that we did not have access to. 
  2. Install and configuration of IPython on these remote machines was specifically setup for this use and we wanted to keep that environment consistent.
  3. There were multiple users that wanted to access the IPython Notebook but also each others' information as needed.

The Solution

The solution was to access the IPython Notebook environment remotely over an SSH tunnel.

Tuesday, July 17, 2012

Indenting Tables in Google Docs (work-around)

Limitation: 
You can't move a table around to place it in an arbitrary location. It cannot be indented, right-justified, centered, etc. The top-left corner is locked to the left-most position on the page.

Work-around:
You can, however, resize the table and change the border. So to indent tables the only work-around at the moment is to nest tables. 
  1. Make a table (outer-table) with a white border and create another table inside it (inner-table). 
  2. Adjust the cell-padding on the outer-table to move the inner table around to indent it.
When will it be fixed?
This is a known issue that google is aware of (September 14, 2010):
        http://productforums.google.com/forum/#!topic/docs/6YpTmJZ3Flk

Tuesday, July 10, 2012

What is "this" in Java?


So in learning Java I found the "this" keyword to be a bit of an odd item to work with. It is pretty obvious now but initially it was confusing and some google-fu helped clear things up. The one thing that was a bit subtle was the construct:

InnerClass innerClassObject = this.new innerClassConstructor();

So here is the answer. When you have an Inner Class, it can't be handled directly at all and needs to be referenced via an instanced object of its encapsulating Outer Class. In other words, you need an object created for the Outer Class before you can create an object of the Inner Class. The code would normally look as follows:

OuterClass.InnerClass innerClassObject = new outerClassConstructor().new innerClassConstructor();


Tuesday, July 3, 2012

Issue with 32-bit Applications on 64-bit Linux


When running 32-bit applications on 64-bit Linux you may find that your application does not run and gives the following error (or similar):
GLib-WARNING : getpwuid_r(): failed due to unknown user id
This error was noticed when running 32-bit SPSS on 64-bit RHEL 6 with LDAP authentication. The reason for the issue was the lack of 32-bit versions of sssd;  32-bit applications cannot use the 64-bit versions of the libraries and hence SPSS could not lookup the appropriate user information.

The correct resolution for this is to install the 32-bit version of sssd (in addition to the 64-bit versions) so that the 32-bit versions of pam_sss and nss_sss are available for use by 32-bit applications.