Add, edit or delete sudo users using putty/bash

To add, edit or delete sudo users in putty/bash do the following

  1. Type visudo and press enter.
  2. Navigate using the arrow keys to where you want to edit.
  3. Press insert to enter edit mode.
  4. Make your changes. It is very important that you use tabs and spaces correctly.
  5. Press esc to exit edit mode.
  6. Type :wq and press enter. I remember this command as “write quit”

This is a pretty simple process, but very easy to forget when you only make changes sporadically.

read more

Cross browser compatible numbers only textbox

While working on a browser compatibility project recently I ran into an issue where using an onkeypress attribute on an input field was firing when using the left and right arrows keys and the delete button. This functionality differs from how IE and Chrome work, so the old code that used to be IE only compatible wouldn’t let a user do anything except type numbers (Good!) and use the backspace (Bad!). The users needed to be able to use arrow keys and the delete button in Firefox.

Since we’re only supporting the latest browsers, IE 11, Chrome, Safari and Firefox, We thought using an input with type=”number” was a good solution, but it adds awful looking up/down arrow buttons in the field and it actually doesn’t do anything to prevent letters from being entered, so that was obviously out.

We tried countless regEx patterns but finally settled on the following which lets you use all arrow keys and the delete key, but still only allows you to enter numbers into the text field. Big thanks to Scott Busche for coming up with the correct regEx

$('.numbersOnly').keyup(function() {
  var pattern = new RegExp(/\D/);
  var validString = $(this).val().replace(pattern, '');
  if ($(this).val() !== validString) {
    $(this).val(validString);
  }
});

Rather than calling a function on key press however we decided to add a specific class to these fields and handle the result with a jQuery selector. The downside to this function is that you are actually allowed to type letters and special characters and they will show up for a millisecond, but they will be removed from the input box.

If anyone has anything that works better and is compatible on all the latest browsers I’d love to hear your solution.

read more

Websphere unable to check if application exists

I’m still fairly new to Websphere, but this seemed like a pretty common problem someone would have and I couldn’t find anything that properly explained the issue to me. I was running into an issue where WebSphere kept saying it was unable to check if application exists when it was being deployed. I thought initially this was a permissions problem, so I fooled around with permissions but had the same issue. If you scroll down a ways on the stack trace it says

insufficient or empty credentials

I double checked my configuration in Hudson/Jenkins and testing the connection worked fine, so I continued searching for other solutions. There are literally 3 search results on google for “unable to check if application exists” and 0 results on bing. Most of the other articles I found offered no help. Eventually I circled back around and decided to look at the access level my user had in WebSphere. Turns out it wasn’t listed as a user! I’m still not sure how testing the connection in Hudson worked but I wasn’t listed as a user in WebSphere. I checked this half a dozen times just to make sure I wasn’t mistaken.

To add a user in WebSphere

  1. Users and Groups
  2. Administrative user roles
  3. Select the Administrator role
  4. Enter the user to search for
  5. Use the arrow to move the user to the Mapped to role box
  6. Click OK
  7. Click Save

Step 7 is super important because it requires an additional save than most programs do and I find myself forgetting to do the second confirmation too often. After you’ve added the appropriate permissions redeploy your ear and you should be all set.

Full stack trace of the error I was getting

[INFO] No custom module-to-server mappings found -- using default configuration.
com.insertcompanynamehere.websphere.deployment.client.DeploymentException: Unable to check if application exists 'NewBusiness'
at com.insertcompanynamehere.websphere.deployment.client.was61.DeploymentManager.applicationExists(DeploymentManager.java:265)
at com.insertcompanynamehere.websphere.deployment.WebsphereDeploymentTask.execute(WebsphereDeploymentTask.java:59)
at com.insertcompanynamehere.hudson.plugin.WebSphereDeploymentBuilder.perform(WebSphereDeploymentBuilder.java:194)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:721)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:670)
at hudson.model.Run.execute(Run.java:1743)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: com.ibm.websphere.management.exception.AdminException:
at com.ibm.websphere.management.application.AppManagementProxy.proxyInvoke(AppManagementProxy.java:189)
at com.ibm.websphere.management.application.AppManagementProxy.checkIfAppExists(AppManagementProxy.java:266)
at com.insertcompanynamehere.websphere.deployment.client.was61.DeploymentManager.applicationExists(DeploymentManager.java:263)
... 11 more
Caused by: javax.management.JMRuntimeException: ADMN0022E: Access is denied for the checkIfAppExists operation on AppManagement MBean because of insufficient or empty credentials.
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.handleAdminFault(SOAPConnectorClient.java:948)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invokeTemplateOnce(SOAPConnectorClient.java:916)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invokeTemplate(SOAPConnectorClient.java:682)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invokeTemplate(SOAPConnectorClient.java:672)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invoke(SOAPConnectorClient.java:658)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invoke(SOAPConnectorClient.java:480)
at $Proxy43.invoke(Unknown Source)
at com.ibm.ws.management.AdminClientImpl.invoke(AdminClientImpl.java:224)
at com.ibm.websphere.management.application.AppManagementProxy.proxyInvoke(AppManagementProxy.java:183)
... 13 more
Build step 'IBM WebSphere v8.0 Deployment' changed build result to FAILURE
Finished: FAILURE

read more

Enabling offline mode in Google Chrome

In April and May I was traveling every other week for work and to keep myself occupied I would open a bunch of articles in chrome on my phone to read them on the plane. Much to my chagrin the first time I did this about half the articles were automatically reloaded by chrome and I wasn’t able to read them because I didn’t have an internet connection. I started trying to fix this by looking for a way to disable the setting that would reload tabs, but was unsuccessful. What I did find was an option to reload an article from the cache if you were offline.

Simply type chrome://flags into your address bar and find the Enable Show Saved Copy Button setting.

Enable Show Saved Copy Button Mac, Windows, Linux, Chrome OS, Android setting.

When a page fails to load, if a stale copy of the page exists in the browser cache, a button will be presented to allow the user to load that stale copy. The primary enabling choice puts the button in the most salient position on the error page; the secondary enabling choice puts it secondary to the reload button. #show-saved-copy

You can enable this setting as a primary or secondary button. Primary will enable this setting as the most noticeable option when you’re offline and secondary will make it the secondary option to reloading the page.

Before I found this setting I stumbled upon Pocket which is a much better option for saving articles overall, but won’t help you recall a webpage you visited earlier. The other downside to pocket is it’s much easier to forget about than an open tab and you’ll probably let articles sit in their forever before you read them.

read more

Hard refreshing in Google Chrome

All of us are probably familiar with ctrl + F5 to hard refresh a page but I ran into a cool feature in Chrome today that will save you a second or two if your hand is already on the mouse. If you have the console open and long press on the refresh button you’re given three options

  1. Normal Reload
  2. Hard Reload
  3. Empty Cache and Hard Reload

You can already disable cache while the console is open but this option will empty the entire cache and re-download everything on the current page. The difference is if the current website has content loaded through a CDN this will force a re-download of that content.

chromerefresh

read more

Aligning monitors vertically in Windows

At work I have dual monitors but with my docking station can also use my laptop as a 3rd monitor which is great. The thing that always annoyed me was my laptop was my third monitor and was located all the way to the right, so to get to it I had to mouse all the way to the right. A minor annoyance for the convenience of having 3 monitors. I mentioned something to someone about this the other day and they asked why I didn’t position my laptop monitor as below the dual monitors and I said “I would if I could”. Then I opened up the monitor control panel and tried to drag the monitor below and lo and behold it worked! I’m not sure why I never thought of this before as it seems so obvious now.

This would also work if you have one external monitor positioned directly above your laptop. Rather than scrolling to the right to get to the 2nd screen you can scroll verticallywhich is a lot more intuitive. This works with the Intel Control Panel and also with the GeForce Experience Control Panel.

read more

Groovy, Grails and Responsive Web Design Stack Overflow

I’ve taken inspiration from Stephen Moretti and his CFOverflow twitter account and started twitter accounts for Groovy, Grails and Responsive Web Design that post the latest questions on each topic from Stack Overflow. For Groovy it posts the latest questions tagged Groovy and the same goes for Grails. I originally set these up as just one feed, but the questions coming in to the two feeds don’t really overlap as much as I thought they might so I decided to split them into two accounts.

For the Responsive Web Design account the latest Stack Overflow posts tagged “media queries” or “responsive design” are posted.

Stephen said he added some filters to prevent duplicates from posting, but I haven’t done that yet. If duplicates start showing up in the feeds I will take a look at the filters.

If anyone thinks other feeds should be added to these accounts let me know and I can get them added. Any feedback at all in appreciated

Groovy questions

Grails questions

Responsive Web Design questions

read more

Registration for Iowa Code Camp is now open!

Registration for Iowa Code Camp is now open. The event is completely free for anyone who wants to attend and includes breakfast and lunch onsite and also an after party hosted by Robert Half Technology.

The event is Saturday, May 9th from 8 am to 5:30 pm at the Hotel Kirkwood in Cedar Rapids. There will be 5 blocks of sessions with 7 sessions going on at a time, so you’re sure to find something you want to attend during each time slot.

There are 100, 200 and even a few 300 level sessions covering topics such as Agile methodologies, DevOps, Ember, Git, Go, Kafka, R and Responsive Web Design. If you attended Iowa Code Camp last November in Ankeny there are many speakers who presented that are presenting again this year on different topics.

read more

I'm speaking at Iowa Code Camp!

I’m happy to announce I’ve been selected to speak at Iowa Code Camp, May 9, 2015 at The Hotel Kirkwood in Cedar Rapids. If you’re interested in attending the cost is absolutely free for anyone wanting to attend and registration will be open shortly. I’ll have a follow up post once registration is open.

I will be speaking about Responsible Responsive Web Design. In the 75 minute talk I’ll be covering what responsive design is and how to build a website using it. I’ll also cover how to design a responsive website responsibly – How you can delivery a consistent user experience to users on small and large screen devices and how to decrease your website’s page size quickly and effectively to make your website load fast even on slow internet connections. Lastly, I’ll cover how to use the newest HTML5 specifications even on browsers that do not have native support.

A big thanks goes out to Scott Jehl, who wrote the book Responsible Responsive Design that inspired this talk.

read more

Checking an HTML page for duplicate IDs using JavaScript

A couple years back I wrote a post about Checking an HTML page for duplicate IDs using jQuery. A pretty useful tool when you need to ensure IDs on a page are unique. The downside to that code was that it required jQuery and the app I’m currently working with does not use jQuery, so I modifed the existing code to write a pure JavaScript solution that does the same thing.

var allElements = document.getElementsByTagName("*");
var allIds = {};
var found = false;
for (var i = 0, n = allElements.length; i < n; ++i) {
  var id = allElements[i].id;
  if (id) {
    if (allIds[id] === undefined) {
      allIds[id] = 1;
    } else {
      found = true;
      console.warn('Duplicate ID #' + id);
    }
  }
}
if (!found) {
  console.log('No duplicate IDs found');
}

All you need to do is create a new bookmark with the following as the URL

javascript: (function() {var allElements = document.getElementsByTagName('*');var allIds = {};var found = false;for (var i = 0, n = allElements.length; i < n; ++i) {var id = allElements[i].id;if (id) {if (allIds[id] === undefined) {allIds[id] = 1;} else {found = true;console.warn('Duplicate ID #' + id);}}}if (!found) {console.log('No duplicate IDs found');}})();

Or you can simply drag the bookmarklet below onto your bookmark toolbar

Duplicate ID Checker

Update: Ryan Guill let me know he wrote something similar and he’s saved it as a Gist. It’s interesting seeing the different approaches to accomplish the same thing.

read more