Monday, September 4, 2017

Manjaro Linux 17.0 - Arch Linux - Brother HL-2270DW Wireless Printer

How to add a wireless  Brother HL-2270DW Wireless Printer to Manjaro
  1. First, your wireless printer should already be configured and online; you can check the network settings by pressing the "Go" button on the printer three times within two seconds. This will print 3 pages and one of them would have the IP address of the printer.
  2. Install the AUR package (https://aur.archlinux.org/packages/brother-hl2270dw/):
    yaourt brother-hl2270dw
  3. Go to Manage Printing (CUPS Web Interface) http://localhost:631
    1. Use your user's login information when prompted
    2. Go to Administration, Add printers
    3. Follow the wizard, it should now list Brother HL-2270DW series as one of the "Discovered Network Printer". Select it and add this printer.
  4.  Print a test page: From the printers menu, select "Maintenance" and then select "Print Test Page".
    1. From the Jobs, you can see this new print task. If if is successful, congrats else, it will show an error like "Could not find printer BRX3X0X5X1XAXAX.local ".
    2. Edit /etc/hosts file and add the printer IP address from the network printer settings
      e.g, 10.111.112.12  BRX3X0X5X1XAXAX.local
    3. Save the hosts file, and retry printing. 



Saturday, July 25, 2015

Manjaro 0.8.13 x64 and Asus USB-N13 B1

I have been using Manjaro Linux + Xfce for a while now and I am very satisfied with the overall performance and simplicity of this distro.
I have a  Asus USB-N13 B1 and the default installation used a driver that would not give enough speed. The signal strength also stayed under 90%.
Make sure the revision is in fact B1. There's a different revision, A1 that uses a different chipset and this procedure will not work.
It's quite easy to install a proper driver for this USB wifi dongle.
I used yaourt to install 8192CU driver from AUR. I have 3.18.18.1 Linux kernel and also installed the linux headers for this. I don't think this step was necessary, since it seems the dependencies pull these when installing the driver.
The driver install may error out with this:
modprobe: ERROR: could not insert '8192cu': Device or resource busy
but the driver installation actually goes through. Just restart the machine and make sure lsmod shows the 8192cu loaded. Also, the installation will create a blacklist file (blacklist-8192cu-dkms.conf ) at /etc/modprobe.d location. This will blacklist the installed rtl8192cu etc. drivers.
Ran into an issue with the next manjaro update. The update included a kernel upgrade from the original 3.18.18.1 to 3.18.20-1-MANJARO, and it broke the driver. Ideally the kernel upgrade is supposed to reconfigure all the dkms modules, but in this case it did not, and I was unable to connect to the internet.
The best thing to do after a kernel upgrade is to manually run the following command. Do this before restarting the machine, so you are not left without an internet.
$ sudo dkms autoinstall
Optionally, you can specify the kernel module as well.
$ sudo dkms autoinstall -k $(uname -r)

Saturday, December 13, 2014

Amazon Instant Video on Ubuntu 14.04

From various sources, I was able to play Amazon Instant video in Firefox on Ubuntu 14.04

Here are the commands. Note I already had flash plugin installed for ff and chrome, so I could play videos from youtube but not Amazon Instant video.

sudo add-apt-repository ppa:mjblenner/ppa-hal
sudo apt-get update
sudo apt-get install hal

Thursday, July 17, 2014

Netgear WNDR3700v2 - stuck on firmware 1.0.0.32? Need to downgrade to older firmare?

In my zeal to have the latest greatest router firmware for Netgear WNDR3700v2, 
I jumped to 1.0.0.32. However, I noticed that my Epson Workforce printer stopped 
connecting to the router, so no wireless printing for me. After some time now, 
my wireless network is not stable. Signal strength is awfully weak, and I started 
disconnecting form the router.

So the recourse was to upgrade the firmware. However, if you have 1.0.0.32 then
The instructions are pretty accurate, but they did not work for me.
  1. I used a Mac.
  2. Downloaded TFTP Client. It's a shareware, and it worked like a charm.
  3. I had a difference router ip: 10.0.0.1 and a different password than the default 'password'. I think that was the issue for the posted instructions not to work.
  4. I went to http://routerlogin.net/index.htm use admin and my password, then Maintenance, Backup Settings - Erase. Erase all the settings so now the router IP was 192.168.1.1 and username password: admin/password.
  5. I then use TFTP server: No matter what I did, it won't allow me to upload any firmware. Searching for the issue, 
I found a few posts here and here

So these are the following differences:

Finally, the upload succeeded. Now I am back to v1.0.0.12.
Now its to be seen how it will fair! I will venture into other firmwares, but for now my wrestling with this router is at an end.

Thanks to the sources above.

Monday, March 11, 2013

Notepad++ RegEx Search & Replace

Often times we need to search and replace using more than just the default search words. If you are using Notepad++ for some basic code development, it has a nice feature of using regex - for both search & replace. Here is an example & I will probably add a few more as and when I use others.

Search for a hex color code (#000FF0) and remove the # sign or make it 000FF0.
Search: #(\w{6})
 - () : Marks the group. Here this will be the 1st so group 1.
- \w : Any character
- {6} : Limits the count to 6 characters
Replace: $1
 - The first matched group identified about.

Other serious choices would be sed on the unix shell. 

Friday, August 17, 2012

Spring MVC - Convention over Configuration w/o Confusion?

Convention over configuration is an essential feature of Spring MVC and it does save some unnecessary coding effort, but I have more than one case where it can get really messy debugging issues.
Here is a simple example: URL app/contact - worked before invoking list method as the only GET method w/o any method level mapping - catch all after the controller mapping.

Beginning 3.1 it will not & throws a 404. But app/contact/list works & will invoke this GET method (IRRESPECTIVE OF THE METHOD NAME), as long it is the only catch-all GET method.

So you could even name it as fooBar and the same URL will invoke it. If however you get confident that the catch-all GET method will always be called for the GET and the URL won't matter, you are right but then the RequestToViewNameMapping goes out the window for the desired view; instead it will look for foorBar.jsp
Something to watch out for!
@Controller
@RequestMapping("contact")
public class ContactController{

@RequestMapping(method = RequestMethod.GET)
 public List<contact> list() {
  logger.info("default method list");
  return contactService.list();
 }
}
Note the mapping generated for this method: INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/contact/*],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List com.aj.recipes.web.ContactController.list()

Wednesday, August 15, 2012

Spring Converter/ConversionService Example

Spring MVC provides so many cool features to make the controller code as minimal as possible. Converter & the ConversionService is one such feature that will be invoked by the framework to carry out type conversions. I have been looking for a decent example & stackoverflow came to the rescue.

I want to add some more information to the solution. As per the Spring documentation here a URI template variable gets translated to the target object using the Converter/ConversionService. I tried to use a `@RequestParam("id") @ModelAttribute("contact") Contact contact`, but I was getting an `IllegalStateException: Neither BindingResult nor plain target object for bean name 'contact' available as request attribute` for not having the model object `contact` in my view edit.jsp. This can be easily resolved by declaring a `Model model` and `model.addAttribute(contact);`. However, there is an even better way; using the URI template variable. It's strange why `@RequestParam` did not work. DID NOT WORK
    @RequestMapping("edit") //Passing id as .. edit?id=1
 public String editWithConverter(@RequestParam("id") @ModelAttribute("contact") Contact contact){
  logger.info("edit with converter");
   return "contact/edit";
 }
WHAT WORKED
    @RequestMapping("edit/{contact}") //Passing id as .. edit/1
 public String editWithConverter(@PathVariable("contact") @ModelAttribute("contact") Contact contact){ // STS gave a warning for using {contact} without @PathVariable 
  logger.info("edit with converter");
   return "contact/edit";
 }

So what does this thing do
.. a link like `...edit/1` implicitly invokes the converter for String '1' to Contact of id '1' conversion, and brings this contact object to the view. No need for `@InitBinder` and since its a `Converter` registered with the `ConversionService` I can use this **anywhere I want - implicitly or explicitly**.

Converter:
public class StringToContactConverter implements Converter <String, Contact > {
 private static final Logger logger = LoggerFactory
   .getLogger(StringToContactConverter.class);
 @Autowired
 private ContactService contactService;
 public void setContactService(ContactService contactService) {
  this.contactService = contactService;
 }
 @Override
 public Contact convert(String id) {
  logger.info("Converting String to Contact");
  Contact contact = contactService.getContact(Long.parseLong(id));
  return contact;
 }
}
Configuration: servlet-context.xml
<annotation-driven conversion-service="conversionService"/>

<beans:bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" >
<beans:property name="converters">
<beans:list>
<beans:bean class="com.aj.recipes.web.convert.StringToContactConverter">
</beans:bean></beans:list>
</beans:property>
</beans:bean>