My labtop is Lenovo ThinkPad E440 and I'm using Ubuntu 14.04. To adjust the screen brightness or volume, I use F5/F6 or F2/F3, respectively. And if I want to refresh page in browser, I need to press Fn+F5. I want to remap the function key by just pressing F5 to refresh a page in browser and Fn+F5/F6 to adjust screen brightness instead.
To do that, I just press Fn key and tap Esc key and that's it. It invokes function lock. You'll see LED light up on the Fn key as indicator.
Reference
http://forums.lenovo.com/t5/11e-Windows-E-and-Edge-series/E540-Fn-Fx-remapping/m-p/1628646#U1628646
Saturday, February 7, 2015
Ubuntu and Levono: Brightness is reset to maximum on every restart
I'm using Ubuntu 14.04 and my labtop is Lenovo ThinkPad. The brightness is reset to maximum every time I reboot my machine. I have fixed the problem by:
1. Adjust the brightness to the level you want (by pressing the brightness key, Fn and F5/F6 in my case).
2. Note the output value of the following command.
3. Add the following line to the file /etc/rc.local
I also added the command to modify the permission of the file to be writable by all users. I experienced the problem that even though I already modified the file's permission to be writable by all users, it was reset back to not writable even if for root user after reboot.
4. Add
5. Run the following command:
Please note that step 1, 2 and 3 keep the screen brightness level remain the same after reboot but it will be reset to maximum if the machine is suspended or the screen is lock. Step 4 and 5 will fix this.
Reference
http://askubuntu.com/questions/151651/brightness-is-reset-to-maximum-on-every-restart
http://askubuntu.com/questions/138386/the-brightness-gets-reset-after-unlocking
1. Adjust the brightness to the level you want (by pressing the brightness key, Fn and F5/F6 in my case).
2. Note the output value of the following command.
cat /sys/class/backlight/intel_backlight/actual_brightnessIn my case, it's 1700. It's the current level of brightness. If you want to know the maximum value, you can adjust the brightness to maximum and then run the command.
3. Add the following line to the file /etc/rc.local
echo 1700 > /sys/class/backlight/intel_backlight/brightnessSo the content of my file would be:
GNU nano 2.2.6 File: /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.
chmod 666 /sys/class/backlight/intel_backlight/brightness echo 1600 > /sys/class/backlight/intel_backlight/brightness exit 0
I also added the command to modify the permission of the file to be writable by all users. I experienced the problem that even though I already modified the file's permission to be writable by all users, it was reset back to not writable even if for root user after reboot.
4. Add
acpi_osi=Linux acpi_backlight=vendor to the value of the GRUB_CMDLINE_LINUX_DEFAULT variable inside /etc/default/grub file. Below is the file's content snippet after I've updated.# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux acpi_backlight=vendor" ...
5. Run the following command:
sudo update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.13.0-24-generic Found initrd image: /boot/initrd.img-3.13.0-24-generic Found memtest86+ image: /memtest86+.elf Found memtest86+ image: /memtest86+.bin Found Windows 8 (loader) on /dev/sda1 done
Please note that step 1, 2 and 3 keep the screen brightness level remain the same after reboot but it will be reset to maximum if the machine is suspended or the screen is lock. Step 4 and 5 will fix this.
Reference
http://askubuntu.com/questions/151651/brightness-is-reset-to-maximum-on-every-restart
http://askubuntu.com/questions/138386/the-brightness-gets-reset-after-unlocking
Tuesday, February 3, 2015
Ivy Issue: Unresolved Dependencies - java.lang.NullPointerException at java.util.Hashtable.put()
You might encounter the following error while building your project and Ivy is unable to resolve dependencies.
[ivy:retrieve] [ivy:retrieve] :: problems summary :: [ivy:retrieve] :::: WARNINGS [ivy:retrieve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:retrieve] :: UNRESOLVED DEPENDENCIES :: [ivy:retrieve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:retrieve] :: org.mortbay.jetty#jetty;6.1.26: java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:514) [ivy:retrieve] :::::::::::::::::::::::::::::::::::::::::::::: [ivy:retrieve] [ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS BUILD FAILED
It's probably because of some files, for example the checksum file, was corrupted so to solve the error, just delete the library from Ivy's cache so Ivy will download the library again when you rebuild. I used Ubuntu and I deleted it with the following command:
rm -rf ~/.ivy2/cache/org.mortbay.jetty/jetty
MariaDB Installation Error: The following packages have unmet dependencies
You might encounter the following error while trying to install MariaDB on Ubuntu:
1. Show version of mysql-common
> sudo apt-get install mariadb-server-5.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mariadb-server-5.5 : Depends: mariadb-client-5.5 (>= 5.5.41+maria-1~trusty) but it is not going to be installed
Depends: mariadb-server-core-5.5 (>= 5.5.41+maria-1~trusty) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
It's said here Version Mismatch Between MariaDB and Ubuntu/Debian Repositories that:It is rare for the version numbers of mysql-common or libmysqlclient to be higher in the official Ubuntu or Debian repositories than they are in the MariaDB repositories, but it has happened. Whenever it has it has been because of critical bug fix releases for bugs that existed in the version of MySQL in the distribution repositories but which had already been fixed in the version of MariaDB in the MariaDB repositories. If a situation as described above exists when you try to install MariaDB you will get an error like this: The following packages have unmet dependencies: mariadb-server : Depends: mariadb-server-5.5 but it is not going to be installed E: Unable to correct problems, you have held broken packages A way to fix this is to specify the exact version of the two packages that you want to install. To do this, first determine the full version numbers of the affected packages. An easy way to do so is with 'apt-cache show'
You need to do as following:
1. Show version of mysql-common
> apt-cache show mysql-common | grep Version Version: 5.5.41+maria-1~trusty Version: 5.5.41-0ubuntu0.14.04.1 Version: 5.5.35+dfsg-1ubuntu12. Show version of libmysqlclient18
> apt-cache show libmysqlclient18 | grep Version Version: 5.5.41+maria-1~trusty Version: 5.5.41-0ubuntu0.14.04.1 Version: 5.5.35+dfsg-1ubuntu13. Install MariaDB
sudo apt-get install mariadb-server-5.5 mariadb-client-5.5 \ > libmysqlclient18=5.5.41+maria-1~trusty \ > mysql-common=5.5.41+maria-1~trusty
Sunday, January 25, 2015
Enabling Shared Folder Feature in Virtual Box
To be able to share a folder from host to guest VMs, you need to install Guest Additions. To install it, click on Devices menu and then Install Guest Additions... And then the setup files will be mounted to the CD-ROM drive of the guest OS. Suppose your guest OS is Windows 8 (32 bit) so you can double click on the file VBoxWindowsAddition-x86.exe to install it. After the installation has finished, you'll see your shared folder appear as a new drive if you already configured it.
Please note that if you click on Install Guest Additions... and then nothing happens, it's probably because of your virtual CD-ROM drive is already being mounted to something else. If it is, you should unmount it first.
To unmount it:
1. Go to the settings of the OS guest and click Storage
2. Select the mounted file under the virtual CD-ROM drive for example, Controller IDE.
3. Click on the disc symbol next to CD/DVD Drive combobox and then Remove disk from virtual drive
Please note that if you click on Install Guest Additions... and then nothing happens, it's probably because of your virtual CD-ROM drive is already being mounted to something else. If it is, you should unmount it first.
To unmount it:
1. Go to the settings of the OS guest and click Storage
2. Select the mounted file under the virtual CD-ROM drive for example, Controller IDE.
3. Click on the disc symbol next to CD/DVD Drive combobox and then Remove disk from virtual drive
Tuesday, January 20, 2015
Ivy HelloWorld example
What is Ivy?
Ivy is additional set of Ant task created by Apache. It's packaged as JAR file and needs to be put in $ANT_HOME/lib, just like other third-party tasks. (To create your own task, you need to create a Java class that extends org.apache.tools.ant.Task)Ivy contains a set of tasks (resolve, cachepath, retrieve, install, publish) which works like Apache Maven phases. For example, the resolve task downloads all dependencies from Maven's public repository and stores them in ivy cache (~/.ivy2/cache directory).
Why Ivy?
One of the reasons is you are familiar with Ant and you don't want to spend more time to learn Maven.HelloWorld Example
We are going to show how to use Ivy to compile Java HelloWorld program.
1. Downloading Ivy
2. Installing Ivy
cp apache-ivy-2.2.0/ivy-2.2.0.jar $ANT_HOME/lib3. Creating HelloWorld.java
Suppose we are currently in $WORKSPACE directory then create the file in the directory $WORKSPACE/src/com/vathanakmao/ivytest/ as following:
package com.vathanakmao.ivytest;
import org.apache.commons.lang.StringUtils;
public class HelloWorld {
public static void main(String[] args) {
String string = StringUtils.upperCase("Hello World!");
System.out.println(string);
}
}
4. Creating build.xml file
<project name="test ivy" default="resolve"
xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="resolve" description="resolve dependencies with ivy">
<ivy:resolve />
<ivy:cachepath pathid="default.classpath"/>
</target>
<target name="compile" depends="resolve" description="Compile">
<mkdir dir="build/classes" />
<javac srcdir="src" destdir="build/classes">
<classpath refid="default.classpath" />
</javac>
</target>
</project>
The resolve task (The cachepath task (
5. Creating ivy.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="com/vathanakmao/ivytest" module="helloworld" status="integration"></info>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.6" />
</dependencies>
</ivy-module>
6. Compiling
ant compile
Monday, January 19, 2015
Embedding Jetty Server: HelloWorld example
Jetty has a slogan, "Don't deploy your application into Jetty. Deploy Jetty into your application". This means that instead of bundling you application as a standard WAR deployed in Jetty, you can use Jetty server as a software component in a Java program just like any POJO.
1. Download the following JAR files:
- Jetty aggregate jar file from http://central.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/9.3.0.M1/jetty-all-9.3.0.M1.jar Jetty is decomposed into many different dependencies or JAR files. The aggregate JAR file contains all classes of the dependencies. It should not be used for production. All dependencies should be managed by Maven.
Open browser and type http://localhost:8080 and then you should see "Hello World".
1. Download the following JAR files:
- Jetty aggregate jar file from http://central.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/9.3.0.M1/jetty-all-9.3.0.M1.jar Jetty is decomposed into many different dependencies or JAR files. The aggregate JAR file contains all classes of the dependencies. It should not be used for production. All dependencies should be managed by Maven.
- Servlet API 3.0 from http://central.maven.org/maven2/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar Please note that Jetty 9 is compatible with Servlet 3.0 so it won't work with Servlete 2.5.
2. Create handler class, HelloWorld.java
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
public class HelloWorld extends AbstractHandler {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletExce$
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.getWriter().println("<h1>Hello World</h1>");
}
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
server.setHandler(new HelloWorld());
server.start();
server.join();
}
}
3. Compiling
> javac -cp javax.servlet-3.0.0.v201112011016.jar:jetty-all-9.3.0.M1.jar HelloWorld.java
4. Running
> java -cp .:javax.servlet-3.0.0.v201112011016.jar:jetty-all-9.3.0.M1.jar HelloWorld.java
2015-01-04 21:15:28.066:INFO::main: Logging initialized @140ms
2015-01-04 21:15:28.175:INFO:oejs.Server:main: jetty-9.3.0.M1
2015-01-04 21:15:28.248:INFO:oejs.ServerConnector:main: Started ServerConnector@7afc02c8{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-01-04 21:15:28.250:INFO:oejs.Server:main: Started @329ms
Open browser and type http://localhost:8080 and then you should see "Hello World".
Reference
Subscribe to:
Posts (Atom)
