Posting code in WordPress

You can use the HTML pre tags around the code in the Text mode (aka the source mode).

public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
    }

}

You can use the WordPress code tag. You can read about that at https://en.support.wordpress.com/code/posting-source-code/

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello, World");
    }

}
Advertisements

Installing Chrome on Lubuntu

Since Chrome provides a Debian package, you can do:

s@s-Lubuntu:~/Downloads$ sudo dpkg -i google-chrome-stable_current_amd64.deb 
[sudo] password for s: 
Selecting previously unselected package google-chrome-stable.
(Reading database ... 118145 files and directories currently installed.)
Preparing to unpack google-chrome-stable_current_amd64.deb ...
Unpacking google-chrome-stable (61.0.3163.91-1) ...
dpkg: dependency problems prevent configuration of google-chrome-stable:
 google-chrome-stable depends on gconf-service; however:
  Package gconf-service is not installed.
 google-chrome-stable depends on libgconf-2-4 (>= 3.2.5); however:
  Package libgconf-2-4 is not installed.
 google-chrome-stable depends on fonts-liberation; however:
  Package fonts-liberation is not installed.

dpkg: error processing package google-chrome-stable (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.6.1-2) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Errors were encountered while processing:

That didn’t work since dpkg can’t install dependencies. So I tried using apt.

s@s-Lubuntu:~/Downloads$ sudo apt install ./google-chrome-stable_current_amd64.deb 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 google-chrome-stable : Depends: gconf-service
                        Depends: libgconf-2-4 (>= 3.2.5) but it is not installed
                        Depends: fonts-liberation but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Now using the –fix-broken option

s@s-Lubuntu:~/Downloads$ sudo apt --fix-broken install ./google-chrome-stable_current_amd64.deb 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
Note, selecting 'google-chrome-stable' instead of './google-chrome-stable_current_amd64.deb'
google-chrome-stable is already the newest version (61.0.3163.91-1).
The following additional packages will be installed:
  fonts-liberation gconf-service gconf-service-backend gconf2-common libgconf-2-4
The following NEW packages will be installed:
  fonts-liberation gconf-service gconf-service-backend gconf2-common libgconf-2-4
0 upgraded, 5 newly installed, 0 to remove and 178 not upgraded.
1 not fully installed or removed.
Need to get 987 kB of archives.
After this operation, 4,185 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu zesty/universe amd64 gconf2-common all 3.2.6-3ubuntu7 [20.8 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu zesty/universe amd64 libgconf-2-4 amd64 3.2.6-3ubuntu7 [84.6 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu zesty/universe amd64 gconf-service-backend amd64 3.2.6-3ubuntu7 [57.8 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu zesty/universe amd64 gconf-service amd64 3.2.6-3ubuntu7 [2,038 B]
Get:5 http://us.archive.ubuntu.com/ubuntu zesty/main amd64 fonts-liberation all 1:1.07.4-2 [822 kB]
Fetched 987 kB in 1s (829 kB/s)           
Selecting previously unselected package gconf2-common.
(Reading database ... 118248 files and directories currently installed.)
Preparing to unpack .../gconf2-common_3.2.6-3ubuntu7_all.deb ...
Unpacking gconf2-common (3.2.6-3ubuntu7) ...
Selecting previously unselected package libgconf-2-4:amd64.
Preparing to unpack .../libgconf-2-4_3.2.6-3ubuntu7_amd64.deb ...
Unpacking libgconf-2-4:amd64 (3.2.6-3ubuntu7) ...
Selecting previously unselected package gconf-service-backend.
Preparing to unpack .../gconf-service-backend_3.2.6-3ubuntu7_amd64.deb ...
Unpacking gconf-service-backend (3.2.6-3ubuntu7) ...
Selecting previously unselected package gconf-service.
Preparing to unpack .../gconf-service_3.2.6-3ubuntu7_amd64.deb ...
Unpacking gconf-service (3.2.6-3ubuntu7) ...
Selecting previously unselected package fonts-liberation.
Preparing to unpack .../fonts-liberation_1%3a1.07.4-2_all.deb ...
Unpacking fonts-liberation (1:1.07.4-2) ...
Setting up gconf2-common (3.2.6-3ubuntu7) ...

Creating config file /etc/gconf/2/path with new version
Processing triggers for sgml-base (1.29) ...
Setting up fonts-liberation (1:1.07.4-2) ...
Processing triggers for libc-bin (2.24-9ubuntu2) ...
Processing triggers for fontconfig (2.11.94-0ubuntu2) ...
Setting up libgconf-2-4:amd64 (3.2.6-3ubuntu7) ...
Setting up gconf-service-backend (3.2.6-3ubuntu7) ...
Setting up gconf-service (3.2.6-3ubuntu7) ...
Setting up google-chrome-stable (61.0.3163.91-1) ...
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/google-chrome (google-chrome) in auto mode
Processing triggers for libc-bin (2.24-9ubuntu2) ...

Now you should see Chrome icon in the Internet menu. Enjoy.

Virtualbox and Windows 7 Sleep issues

I got Virtualbox Version 5.1.28 r117968 (Qt5.6.2), running in Windows 7 Ultimate. I installed Ubuntu 16.04 LTS as a guest in Vb. Works great but doesn’t let Windows go to sleep after the sleep timeout. I can put Windows to sleep manually but Windows cannot go to sleep on its own when Ubuntu is running in Vb. Any clues on how to fix this? I like to save power and want Windows to go to sleep on its own if a user forgets to put it to sleep manually.

So I switched to Vmware Player and the sleep works fine. Even the volume keys work in the guest OS (Lubuntu).

Vmware tools installation from Vmware Player CD load didn’t work. You can check by doing this:
s@s-Lubuntu:~$ /etc/init.d/vmware-tools status
vmware-guestd is not running

So install open-vm-tools instead. Here is the command for that:
sudo apt-get update
sudo apt-get install open-vm-tools open-vm-tools-desktop

More on that command here:
https://askubuntu.com/questions/670245/vmware-tools-not-working-14-04

s@s-Lubuntu:~$ /etc/init.d/open-vm-tools status
● open-vm-tools.service – Service for virtual machines hosted on VMware
Loaded: loaded (/lib/systemd/system/open-vm-tools.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2017-09-19 20:19:20 CDT; 9h ago
Docs: http://open-vm-tools.sourceforge.net/about.php
Main PID: 615 (vmtoolsd)
Tasks: 2 (limit: 19660)
CGroup: /system.slice/open-vm-tools.service
└─615 /usr/bin/vmtoolsd

 

Riak backup and restore using defaults

To back up:
riak-admin backup riak@127.0.0.1 riak /tmp/rbak.dat

To restore:
riak-admin restore riak@127.0.0.1 riak /tmp/rbak.dat

If yo run into the following error, make sure riak user has the right permissions. Or just use a tmp directory.

{“init terminating in do_boot”,{{badmatch,{error,{file_error,”/root/rb/rbak.dat”,eacces}}}

 

Riak – CentOS 6 – Cannot connect remotely even after opening firewall

Just update riak.conf and change listener to 0.0.0.0:8098 from 127.0.0.1:8098

Windows ICS with Router as AP

Two ways to do this. You can connect your router’s internet / wan port to your PC lan port. Make sure router gets its IP by DHCP (from ICS), which is the default for a router. Then enable ICS on the Wifi adapter. Only issue with this approach is it creates double NAT. That should not be an issue for most. Anything that connects to router will have an IP like 192.168.1.X, which will be assigned by the router’s DHCP service, not ICS’s DHCP. ICS’s DHCP will give an IP address to the router, not to the router’s clients.

If you don’t like double NAT, just set your router to a static IP like 192.168.137.2 and disable router’s DHCP. Then connect a lan port from router to the ICS PC. Now anything that connects to router will get an IP assigned by ICS and will be able to access internet via ICS.  Anything that connects to router will have an IP like 192.168.137.X.

If you don’t like ICS due the need for a PC running all the time, you can use two routers. One router will bridge to a Wifi using dd-wrt. The other router will connect its internet port to lan port of the bridge router.

You can use either Client or Client-bridge mode with dd-wrt. Client mode is better since you get a firewall with it.

Mac OS X “/usr/local must be writable!” – Brew Update failed

Just do a chown.

sudo chown yourUserName:admin /usr/local

Target.com script to open your gift card history

Target.com gift card page in your account lists the individual gift cards. You can’t open them in a new window by right clicking since the url is generated on the click of a link. Use the following script to open all your gift card details in new windows.

	$('.cardNumber').each(function(){
		window.open('https://gam-secure.target.com/gam-webapp/giftcards/'+this.id)
	})

Target.com Giftcard Autocomplete script

I often get a bunch of gift cards from Target.com but it needs me to enter the name and email for every on them. That is a pain and takes lot of time. You can open your browser console and execute the following scripts to auto complete the gift card fields:

$('[name*=Name_]').val('YourNameHere')
$('[name*=Email_]').val('youremail@youremail.com')

If I get some free time, I will create a Chrome extension to make this even easier.

 

Free SSL Cert from StartCom for Google App Engine

You can get a free domain level (DV) cert from startssl.com and then use it to secure your Google app engine site. For details, go here: https://cloud.google.com/appengine/docs/java/console/using-custom-domains-and-ssl