Archive for Uncategorized

Win 10 set default editor

1. Start the registry editor (regedit.exe) and select HKEY_CLASSES_ROOT.

2. Press Ctrl + F to open the Find dialog.

Image

3. Type systemfileassociations, enable “Keys” and deselect “Values” and “Data” check boxes.

4. Press ENTER.

You’ll now be taken to the HKEY_CLASSES_ROOT\SystemFileAssociations branch.

Expand the “SystemFileAssociations” branch by double-clicking on it
Scroll down until you see a subkey named “image”
Double-click “image”

Double-click “shell”

Double-click “edit”

Double-click “command”

src: https://answers.microsoft.com/en-us/windows/forum/windows_10-files-winpc/change-default-image-editor/4b01b777-338f-49c1-8300-9bcd7f60c160

IDEA linux – import module hanging

I tried IDEA on linux. OF course, It started with gooling ūüėÄ

I tried to import the modules, but hanged… (on a freshly created project, with import maven modules)

 

The resolution was:

File -> invalidate caches and restart

src: https://stackoverflow.com/questions/47626478/intellij-idea-stucked-on-loading-project-screen

Disabling UPS beep under Linux

But it will take about 3-5 minutes to make all the setup under Linux properly. We need to run a upscmd at last, but there are a few steps before that.

  • First of all, install¬†nut¬†package:
$ sudo apt install nut
  • Append following lines to¬†/etc/nut/ups.conf¬†according to your ups device (descparameter not important, you don‚Äôt need to give correct brand name either but the given section name will be used later to identify configured ups device, we‚Äôre using¬†eaton¬†as config section name here):
[eaton]
driver = usbhid-ups
port = auto
desc = "Eaton 5E"
  • Now start the upsdriver with¬†upsdrvctl:
$ sudo upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
  • Run upsc command the get beeper status:
$ upsc eaton ups.beeper.status
enabled
  • We‚Äôre so close, now append following lines to¬†/etc/nut/upsd.users, change the username admin or password as you want:
[admin]
password = "test1234"
actions = SET
instcmds = ALL
  • Reload¬†upsd¬†with the new users config:
$ sudo upsd -c reload
  • You can query the list of the commands which will be supported by your ups device with the¬†upscmd:
$ upscmd -l eaton
Instant commands supported on UPS [eaton]:

beeper.disable - Disable the UPS beeper
beeper.enable - Enable the UPS beeper
beeper.mute - Temporarily mute the UPS beeper
beeper.off - Obsolete (use beeper.disable or beeper.mute)
beeper.on - Obsolete (use beeper.enable)
load.off - Turn off the load immediately
load.off.delay - Turn off the load with a delay (seconds)
shutdown.stop - Stop a shutdown in progress
  • As you can see, there is a command named¬†beeper.disable¬†and we‚Äôll be execute this command (give the username and password which we configured just before):
$ upscmd eaton beeper.disable
Username (root): admin
Password: 
OK
  • Now check the beeper status again:
$ upsc eaton ups.beeper.status
disabled

That’s it. It takes some time but your ears will be happy.

 

src: https://linux-tips.com/t/disabling-ups-beep-under-linux/592

Apache CXF Without spring

I found a very good blog post about that topic, here: http://chathurangat.blogspot.com/2014/02/apache-cxf-first-jax-ws-soap-web.html

I copied there, to be here also for the future:


Apache CXF First JAX-WS (SOAP Web Service) Example (CXFNonSpringServlet)

The most of the people think that the Apache CXF supports only to develop Spring based Web Services. this is NOT true. is supports to build both Spring based and Non spring based web services.
1.¬†CXFServlet¬†–¬† this will support for the Spring based web services.
2.¬†CXFNonSpringServlet¬†–¬† this will support for the non spring web services.the purpose of this article is to demonstrate how to develop non spring based web service with Apache CXF. i have already developed and¬† tetsed the service with SoapUI. i am just sharing the source code for your reference.the project structure looks as below.,

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.chathurangaonline.apache.csf.jax.ws.samples</groupId>
    <artifactId>apache-cxf-jaxws-sample</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>apache-cxf-jaxws-sample Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <cxf.version>3.0.4</cxf.version>
    </properties>
 
    <dependencies>
 
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
 
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
 
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>compile</scope>
        </dependency>
 
    </dependencies>
    <build>
        <finalName>apache-cxf-calculator-service</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!--compiles with java 7-->
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <!--WAR plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.5</version>
            </plugin>
        </plugins>
    </build>
</project>

 

CalculatorService.java

the following is the Service Endpoint Interface(SEI).

package com.chathuranga.apache.cxf.jax.ws.samples;
 
import javax.jws.WebMethod;
import javax.jws.WebService;
 
/**
 * <p>
 *     SEI
 * </p>
 * @author Chathuranga Tennakoon / www.chathurangaonline.com
 */
@WebService
public interface CalculatorService {
 
    @WebMethod
    double addNumbers(double num1,double num2);
}

 

CalculatorServiceImpl.java

the following is the Service Implementation Bean (SIB)

package com.chathuranga.apache.cxf.jax.ws.samples.impl;
 
import com.chathuranga.apache.cxf.jax.ws.samples.CalculatorService;
import javax.jws.WebMethod;
import javax.jws.WebService;
 
/**
 * <p>
 *     SIB for {@link com.chathuranga.apache.cxf.jax.ws.samples.CalculatorService}
 * </p>
 * @author Chathuranga Tennakoon / www.chathurangaonline.com
 */
@WebService
public class CalculatorServiceImpl implements CalculatorService {
 
    @WebMethod
    public double addNumbers(double num1, double num2) {
        return num1 + num2;
    }
}

 

AppCXFNonSpringServletImpl.java

the custom implementation for the CXFNonSpringServlet.

package com.chathuranga.apache.cxf.jax.ws.samples.impl;
 
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import javax.servlet.ServletConfig;
 
/**
 * <p>
 *    Application Specific Custom Implementation for the {@link org.apache.cxf.transport.servlet.CXFNonSpringServlet}
 * </p>
 * @author Chathuranga Tennakoon / www.chathurangaonline.com
 */
public class AppCXFNonSpringServletImpl extends CXFNonSpringServlet{
 
    @Override
    public void loadBus(ServletConfig servletConfig){
        super.loadBus(servletConfig);
        ServerFactoryBean factory = new ServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceClass(CalculatorServiceImpl.class);
        factory.setAddress("/calcService");
        factory.create();
    }
}

 

web.xml

<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 
    <display-name>Archetype Created Web Application</display-name>
    <servlet>
        <servlet-name>AppCXFNonSpringServlet</servlet-name>
        <servlet-class>com.chathuranga.apache.cxf.jax.ws.samples.impl.AppCXFNonSpringServletImpl</servlet-class>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>AppCXFNonSpringServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

Source code can be downloaded at :- https://github.com/chathurangat/apache-cxf-jax-ws-first-service

Chathuranga Tennakoon
www.chathurangaonline.com
chathuranga.t@gmail.com

 

OpenVPN Android client, error msg: “option or or was not properly closed out”

The fckn openvpn always s**ked me on android…

I found, why:

I have learned:
1. Filename extension *must* be lowercase
2. Remove all space(s) between last character(s) and CrLf. E.g.:
<CA>{SPACE}CrLf to
<CA>CrLf

src: https://forums.openvpn.net/viewtopic.php?t=25096

Sierra Wireless EM7455 Qualcomm Snapdragon X7 LTE-A – PIN2 – NPCap

I bought a DELL notebook with LTE modem Sierra Wireless EM7455 Qualcomm Snapdragon X7 LTE-A. After that, I installed Whireshark with NPCap.

 

After that, my WWAn connetion didn’t work more.

 

I used the windows troubleshooter and it sometimes put a result to me, I have to add my PIN2 number.

 

After that, I googled a lot, and I find this article.

 

Uninstalled NPCap, and the LTE modem works very well.

tricky…

Ubuntu/Debian (linux) WSL and Docker

If you would like to use docker on windows Ubuntu/Debain WSL you have to modify the .bashrc file in your home directory.

vi ~/.bashrc

and add this line to the end:

export DOCKER_HOST=tcp://localhost:2375

reload the modifications:

source ~/.bashrc

That’s all folks ūüėÄ

Ubuntu WSL add git brach name to promt

you have to mofify ~/.basrc from that:

 

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

to

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
#unset color_prompt force_color_prompt

Modification details:

  • add¬†$(parse_git_branch)\[\033[00m\]¬†
  • and COMMENT the¬†unset color_prompt force_color_prompt line

src: https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt

Transmission network problem

Recently started in debug mode on Transmission and I see:

[17:42:40.319] UDP Failed to set receive buffer: requested 4194304, got 262142 (tr-udp.c:75)
[17:42:40.319] UDP Please add the line "net.core.rmem_max = 4194304" to /etc/sysctl.conf (tr-udp.c:80)
[17:42:40.319] UDP Failed to set send buffer: requested 1048576, got 262142 (tr-udp.c:86)
[17:42:40.319] UDP Please add the line "net.core.wmem_max = 1048576" to /etc/sysctl.conf (tr-udp.c:91)

By tuning the two variables, higher throughput can be achieved more easily using uTP.

Here’s the relevant part from the changeset :

Since we are using a single UDP socket to implement multiple UTP sockets,
and since we are not always timely in servicing an incoming UDP packet,
it is important to use a large receive buffer. The send buffer is probably
less critical, we increase it nonetheless.

Four megabytes might seem huge for embedded clients, but running behind a dedicated connection, it might even become too small. I recommend using 16 megabytes for receive buffering and 4 for the send buffer. That is, because uTP implements a retransmission algorithm and by scaling up the buffers we can achieve fewer retransmits because of dropped datagrams. Let’s set it up that way.

Check actual settings:

sysctl -p

do the modifications:

echo 'net.core.rmem_max = 16777216' >> /etc/sysctl.conf
echo 'net.core.wmem_max = 4194304' >> /etc/sysctl.conf
sysctl -p

src: https://falkhusemann.de/blog/2012/07/transmission-utp-and-udp-buffer-optimizations/

Oracle 11g XE install on Ubuntu 14/16

After Ubuntu downloaded and installed.

First install Java:

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java8-installer

Set JAVA_HOME

sudo nano /etc/bash.bashrc
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export PATH=$JAVA_HOME/bin:$PATH

Reload sources:

source /etc/bash.bashrc

Check:

echo $JAVA_HOME

result should be:

/usr/lib/jvm/java-8-oracle

Second: Download and prepare Oracle DB

Copy the downloaded file and paste it in home directory.

Unzip using the command:
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip 

Install required packages using the command:

sudo apt-get install alien libaio1 unixodbc

Enter into the Disk1 folder using command:

cd Disk1/

Convert RPM package format to DEB package format (that is used by Ubuntu) using the command:

sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm

Create the required chkconfig script using the command:

sudo pico /sbin/chkconfig

The pico text editor is started and the commands are shown at the bottom of the screen. Now copy and paste the following into the file and save:

#!/bin/bash
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
file=/etc/init.d/oracle-xe
if [[ ! `tail -n1 $file | grep INIT` ]]; then
    echo >> $file
    echo '### BEGIN INIT INFO' >> $file
    echo '# Provides: OracleXE' >> $file
    echo '# Required-Start: $remote_fs $syslog' >> $file
    echo '# Required-Stop: $remote_fs $syslog' >> $file
    echo '# Default-Start: 2 3 4 5' >> $file
    echo '# Default-Stop: 0 1 6' >> $file
    echo '# Short-Description: Oracle 11g Express Edition' >> $file
    echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe defaults 80 01

Change the permission of the chkconfig file using the command:

sudo chmod 755 /sbin/chkconfig  

Set kernel parameters. Oracle 11gR2 XE requires additional kernel parameters which you need to set using the command:

sudo pico /etc/sysctl.d/60-oracle.conf

Copy the following into the file and save:

# Oracle 11g XE kernel parameters 
fs.file-max=6815744  
net.ipv4.ip_local_port_range=9000 65000  
kernel.sem=250 32000 100 128 
kernel.shmmax=536870912 

Verify the change using the command:

sudo cat /etc/sysctl.d/60-oracle.conf 

You should see what you entered earlier. Now load the kernel parameters:

sudo service procps start

Verify the new parameters are loaded using:

sudo sysctl -q fs.file-max

You should see the file-max value that you entered earlier.

Set up /dev/shm mount point for Oracle. Create the following file using the command:

sudo pico /etc/rc2.d/S01shm_load

Copy the following into the file and save.

#!/bin/sh
case "$1" in
start)
    mkdir /var/lock/subsys 2>/dev/null
    touch /var/lock/subsys/listener
    rm /dev/shm 2>/dev/null
    mkdir /dev/shm 2>/dev/null
*)
    echo error
    exit 1
    ;;

esac

Change the permissions of the file using the command:

sudo chmod 755 /etc/rc2.d/S01shm_load

Now execute the following commands:

sudo ln -s /usr/bin/awk /bin/awk 
sudo mkdir /var/lock/subsys 
sudo touch /var/lock/subsys/listener

Install Oracle

Install the oracle DBMS using the command:

sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb

Configure Oracle using the command:

sudo /etc/init.d/oracle-xe configure

Setup environment variables by editting your .bashrc file:

pico ~/.bashrc

Add the following lines to the end of the file:

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

Load the changes by executing your profile:

. ~/.bashrc

Start the Oracle 11gR2 XE:

sudo service oracle-xe start

Add user YOURUSERNAME to group dba using the command:

sudo usermod -a -G dba YOURUSERNAME

 

src: https://askubuntu.com/questions/566734/how-to-install-oracle-11gr2-on-ubuntu-14-04 and https://www.quora.com/How-can-I-install-Oracle-11g-in-Ubuntu-16-04LTS