IBM WebSphere 6.1 on Ubuntu

Install
1. install java 1.5 from oracle
2. start WAS install: 
	cd /********/Downloads/was.cd.6100.trial.base.linux.ia32/WAS/
	/********/apps/opt/java/jdk1.5.0_22/bin/java -jar setup.jar
3. WAS install window should start ...

Configuration
export JAVA_HOME=/********/apps/opt/java/jdk1.5.0_22
export PATH="/********/apps/opt/java/jdk1.5.0_22/bin:$PATH"
cd /********/apps/opt/WebSphere/AppServer/bin
mv /********/apps/opt/WebSphere/AppServer/java/bin/java /********/apps/opt/WebSphere/AppServer/java/bin/java1
ln -s $JAVA_HOME/bin/java /********/apps/opt/WebSphere/AppServer/java/bin/java
./manageprofiles.sh help -> this should work now!

JAX-RS with Jersey

Terms
resource method designator - annotation such as @GET, @PUT, @POST, @DELETE
sub-resource methods - methods annotated with @Path and also with resource method designators such as @GET or @POST
sub-resource locators - methods annotated with @Path but not with resource method designators such as @GET or @POST

Tips & Tricks
Jersey gives you an option to register so called model processor providers (org.glassfish.jersey.server.model.ModelProcessor). These providers are able to modify or enhance the application resource model during application deployment.

Use @InjectLink on an entity (returned by server) field in order to inject it with a link (intead of using a link header).

Do not use ApacheConnectorProvider nor GrizzlyConnectorProvider neither JettyConnectorProvider connector implementations with Jersey Multipart features. See Header modification issue warning for more details.

javax.activation.MimetypesFileTypeMap - utility for getting the MIME type of a file

@Produces({"application/xml; qs=0.9", "application/json"})
If client accepts both "application/xml" and "application/json" (equally), then a server always sends "application/json", since "application/xml" has a lower quality factor.

HttpHeaders, Request, UriInfo, SecurityContext can be injected into constructor or class fields of a singleton (using the @Context annotation).
For these objects the runtime will inject proxies which are able to simultaneously server more request.

The @FormParam annotation is special and may only be utilized on resource and sub-resource methods. This is because it extracts information from a request entity.

By default, the transport layer in Jersey is provided by HttpUrlConnection. This transport is implemented in Jersey via HttpUrlConnectorProvider that implements Jersey-specific Connector SPI. HttpUrlConnection by default restricts the use of some headers. In order to permit all headers to be sent the system property sun.net.http.allowRestrictedHeaders must be set to "true".

Sub-resource locator return types
@Path("/")
public ItemContentResource getItemContentResource() {
	// instance
	return new ItemContentResource();
}
@Path("kid1")
public Class getMySubResource1() {
	// Class
	return MySubResource1.class;
}
@Path("kid2")
public Resource getMySubResource() {
	// Resource (programmatic resource model return type)
	return Resource.from(MySubResource2.class);
}
@Path("kid5")
public MySubResource5 getMySubResource(@QueryParam("impl") String impl) {
	// Object (the way to support polymorphism)
	// @QueryParam("impl") won't be available into sub-sesource
	if (impl.equals("a")) {
		return new MySubResource5a(impl);
	} else {
		return new MySubResource5b(impl);
	}
}

Architecture (the usual usage)
invocating a jax-rs service
ClientBuilder builds Client (dealing with registration of providers, features, filter and interceptors).
Client builds WebTarget (dealing with the URI construction including query and matrix parameters, template values).
WebTarget builds Invocation.Builder (dealing with any except URI construction; deals with headers and cookies, filter-accesible properties).
Invocation.Builder builds Invocation/AsyncInvoker (dealing with the "actual call" and getting the result).
Invocation.Builder can behave also as SyncInvoker in order to do the "actual call".

javax.ws.rs.core.Response created by server
Response creates a ResponseBuilder while also being able to set the http status.
ResponseBuilder sets headers (status, link, lastModified, entity tag, location, etc), cookies, entity (+annotations).
ResponseBuilder then builds the Response.

javax.ws.rs.core.Response used by client
Response is obtained as a result of the "actual call" facilitated by Invocation.Builder.
Response provides headers, cookies and entity access (Response.readEntity(Class entityType, Annotation[] annotations)).
For reading the entity a MessageBodyReader in used based also on annotations provided to Response.readEntity().

Chunked Output
In Jersey you can use ChunkedOutput to send response to a client in chunks. 
This can be achived by returning ChunkedOutput from a resource method - this makes the method automatically asynchronous.
Then one writes T for the client using ChunkedOutput. After sending some T one should close the ChunkedOutput.

Client side one uses Response.readEntity in order to get a ChunkedInput from which reads T while not null.

Server-Sent Events
This is the server side support for services which can be consumed from java script with EventSource.
The resource method should return org.glassfish.jersey.media.sse.EventOutput which is a ChunkedOutput - this makes the method automatically asynchronous. Then one uses EventOutput in order to write OutboundEvent which is a wrapper for the actual entity one wants to send. Finally one would close the EventOutput in order to end the communication.

Client side one gets a EventInput instance from where reads InboundEvent which is a wrapper for the actual entity sent by server. The connection is closed when null EventInput is received or InboundEvent.isClosed() returns true.
instead of getting an EventInput instance one could use EventSource then register an EventListener in order to receive InboundEvent.

security
Security information of a request is available by injecting a JAX-RS SecurityContext instance using @Context annotation.
You can define the access to resources using annotations from package javax.annotation.security defined by JSR-250 (PermitAll, RolesAllowed).

bean validation support
Jersey does not support, and doesn't validate, constraints placed on constructors and Bean Validation groups (only Default group is supported at the moment). Constraint annotations are allowed in resource method parameters, fields and property getters as well as resource classes, entity parameters and resource methods (return values). E.g. validation on resource method parameters:
@NotNull @FormParam("lastName") String lastName, @Email @FormParam("email") String email, @Valid User user.
The @Email annotation is defined as:
@Constraint(validatedBy = EmailValidator.class)
public @interface Email { ...
The constraint class is defined as:
public class EmailValidator implements ConstraintValidator { ...

Entity Data Filtering
Entity filtering is achived with:
- custom annotations (server and client side support)
- role-based Entity Filtering using (javax.annotation.security) annotations (server and client side support)
- dynamic and configurable query parameters
With custom annotations one uses @EntityFiltering meta-annotation to creates a custom annotation e.g. @UserDetailedView.
Then creates a response e.g.:
Response.ok().entity(new User(), isDetailed ? new Annotation[]{UserDetailedView.Factory.get()} : new Annotation[0]).build();
or 
simply annotates with @ProjectDetailedView the resource method.
Then the client shall receive an User entity populated only for the fields annotated with @UserDetailedView or not annotated at all with @EntityFiltering.
With role-based Entity Filtering using (javax.annotation.security) annotations one uses javax.annotation.security annotations same way as he would with custom annotations entity-filtering. Instances of security annotations can be created using SecurityAnnotations factory class that is part of the Jersey Entity Filtering API.
Entity Filtering based on dynamic and configurable query parameters allows one to specify the select query parameter in order to filter the entity's fields e.g. http://example.com/user/51234?select=name,surname,country.name -> here only name, surname, country.name fields from User entity shall be populated.

MVC Templates
Use @Template(templateName) on a resource method in order to define a template (jep, freemarker, mustache) processing the entity returned. 
Jersey will assign the entity instance to an attribute named model which can be user with e.g. ${model} in jsp or freemarker.
One could use @ErrorTemplate the same way where Bean Validation errors will be accessible with the attribute name error.

Configuration
jersey specific: org.glassfish.jersey.client.ClientConfig implements javax.ws.rs.core.Configurable, ...
jersey specific: org.glassfish.jersey.client.ResourceConfig implements javax.ws.rs.core.Configurable, ...
ClientConfig and ResourceConfig both use javax.ws.rs.core.Configurable's ergonomic methods in order to construct javax.ws.rs.core.Configuration.
While constructing javax.ws.rs.core.Configuration also ResourceConfig constructs javax.ws.rs.core.Application (main objective by the way).
ClientConfig aim is the construct of a javax.ws.rs.core.Configuration which further would be used by 
javax.ws.rs.client.ClientBuilder.newClient(Configuration configuration) to construct javax.ws.rs.client.Client.

Filters can be used when you want to modify any request or response parameters like headers.

Interceptors share a common API for the server and the client side. Whereas filters are primarily intended to manipulate request and response parameters like HTTP headers, URIs and/or HTTP methods, interceptors are intended to manipulate entities, via manipulating entity input/output streams.

@MapKey vs @MapKeyColumn

// @MapKey refers the field/property (unique one) in the Entity witch is the value of a Map field/property
// @MapKeyColumn refers the column in an @ElementCollection

@Entity
public class Person6 {
    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "person6")
    @MapKey(name = "address") // is the Address6's address property
    public Map<String, Address6> getAddress6Map() {
        return address6Map;
    }
...

@Entity
public class Address6 {
    private Integer id;
    private String address;
    private Person6 person6;
...

ESB

ESB
- match and route (filter node for IBM)
- convert (protocols)
- format data
- orchestration (e.g. from some web services, dbs, files, etc collect partial data and create a new web services)
- event delivering

ESB = Enterprise service bus
contains the integration logic

IBM Integration BUS = IBM's ESB implementation

Ubuntu XRDP (remote desktop from windows)

installation
Consider ubuntu xrdp error problem connecting 5910 solution:
tightvncserver MUST be installed before xrdp!!!

sudo apt-get install xfce4
sudo apt-get install tightvncserver
sudo apt-get install xrdp
sudo usermod -aG xrdp adr

configure XRDP (option 1)
cat ~/.xsession
echo 'xfce4-session' > ~/.xsession (when having XFCE or xubuntu desktop)
or
echo 'mate-session' > ~/.xsession (when having MATE desktop)
or
echo 'startlxde' > ~/.xsession (when having LXDE or lubuntu desktop)
or use 'lxsession -s Lubuntu -e LXDE' or 'lxsession -s Lubuntu-Netbook -e LXDE' instead of 'startlxde'

configure XRDP (option 2)
In /etc/xrdp/startwm.sh replace the line ". /etc/X11/Xsession":
sudo sed -i s/"^\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\nstartxfce4"/ /etc/xrdp/startwm.sh
or
sudo sed -i s/"^\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\nmate-session"/ /etc/xrdp/startwm.sh
or
sudo sed -i s/"^\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\nstartlxde"/ /etc/xrdp/startwm.sh
or use 'lxsession -s Lubuntu -e LXDE' or 'lxsession -s Lubuntu-Netbook -e LXDE' instead of 'startlxde'

configure XRDP for PATH and .profile problem
Change in /etc/xrdp/startwm.sh:
#!/bin/sh
# see http://askubuntu.com/questions/92333/ubuntu-haves-a-different-path-when-access-via-xrdp-session
. /etc/environment
. ~/.profile
...

start xrdp
sudo systemctl restart xrdp
See the log file:
tail -f /var/log/xrdp-sesman.log

login from windows
When logging with windows RDC first you'll get an error message. Press ok in the error's message window then you'll be asked (using a linux-style window) for the user and password. Fill the required fields (the ones already filled in RDC) then press ok and that's it.

See also
gnome-fallback-way: http://c-nergy.be/blog/?p=3518
inspired by: http://www.tweaking4all.com/software/linux-software/use-xrdp-remote-access-ubuntu-14-04/

Handling video in Linux

video exif tool
sudo apt-get install libimage-exiftool-perl

display video's rotation exif
exiftool -Rotation 20151024_132350.mp4

rotate the exif metadata only
ffmpeg -i 20151024_132350.mp4 -metadata:s:v rotate="0" -vf "hflip,vflip" -c:v libx264 -crf 23 -acodec copy 20151024_132350b.mp4

resize to 720p
ffmpeg -i IMG_0001.MOV -vf scale=-1:720 IMG_0001-720p.MOV

VMWare

ERROR1
	VMWare says something like "vmware kernel module updater ..." and requires pressing Install button then nothing happens.
ERROR2
	After some Ubuntu updates the vmware network adapters are gone.
SOLUTION
	sudo vmware-modconfig --console --install-all

fan speed control/monitor

Install the lm-sensors Install lm-sensors and fancontrol Install fancontrol packages.
# Configure lm-sensors; respond with yes for everything below (will modify /etc/modules):
sudo sensors-detect
# Monitoring programs won't work until the needed modules are
# loaded. You may want to run '/etc/init.d/kmod start' to load them.
/etc/init.d/kmod start
# Configure fancontrol
sudo pwmconfig
# Set up fancontrol service
sudo service fancontrol start
# show sensors command line
sensors

/var/mail && thunderbird

See http://askubuntu.com/questions/1916/how-can-i-access-system-mail-in-var-mail-via-thunderbird.

Create the account
Thunderbird -> Edit -> Account settings -> Account Action -> Add Another Account -> Unix Mailspool (Movemail)
Your Name: adr (mailspool)
Email Address: adr@localhost
Browse your mails
Open Thunderbird then press Get Messages button; you can now see the messages from /var/mail/adr.

See your mails in console
cat /var/mail/adr

Redirect cron mails to you
When running cron jobs with other user (e.g. root) configure MAILTO****@adr-desktop to received a cron-status.

command for sending a mail to adr@localhost
/usr/bin/printf "%b" "***** your mail body here *****" | /usr/bin/mail -s "** your mail subject here **" adr@adr-desktop

nagios3

# change user & password in passwd-file specified by /etc/nagios3/apache2.conf
# change nagiosadmin to the user chosen
sed -i s/"nagiosadmin"/"adr"/ /etc/nagios3/cgi.cfg
# Edit the disk.cfg file located in /etc/nagios-plugins/config and add the arguments
# -A -i '.gvfs'
# at the end of the command line arguments for the command check_disk and check_all_disks. 
service nagios3 restart

Angularjs project setup (NODE & YEOMAN)

# see also https://docs.angularjs.org/guide/migration

# general setup
sudo ln -s /usr/bin/nodejs /usr/bin/node	-> when node file is not found
sudo npm install -g yo bower grunt-cli generator-karma generator-angular
# see https://docs.npmjs.com/cli/view
# npm help list
# sudo npm list -gp grunt-wiredep@3.0.1
sudo npm list -gp --depth=0
# in project's path immediately after checkout from svn/git
npm install
bower install
# bower cache list, clean
bower cache list
bower cache clean

Linux errors/problems, tips & tricks

# error
# adr@adr-desktop:~$ su-to-root -X -c zenmap
(gksu:24352): Gtk-WARNING **: cannot open display: 
adr@adr-desktop:~$ echo $DISPLAY
... showing nothing ...
adr@adr-desktop:~$ export DISPLAY=:0.0 -> add this in .bashrc
adr@adr-desktop:~$ su-to-root -X -c zenmap
... now is working ...

# vmware security problem; closing ports 443 and 902 opened by VMware Authentication Daemon
# https://communities.vmware.com/thread/425526?start=0&tstart=0
# http://blog.martinshouse.com/2012/11/vmware-90-on-linux-closing-ports-443.html
sudo service vmware-workstation-server status
sudo nmap -T4 -A -v localhost
1. In /etc/init.d/vmware
Comment out the line:
         vmware_exec 'VMware Authentication Daemon' vmware_start_authdlauncher
Add the following line:
         echo 'Skipping: VMware Authentication Daemon'
2. In /etc/init.d/vmware-workstation-server
After the line:
          ### END INIT INFO
Add two new lines:
          echo Aborting launch of vmware-workstation-server
          exit 0
2. or (not tested) better use this to disable vmware-workstation-server autostart
sudo service vmware-workstation-server stop
sudo update-rc.d vmware-workstation-server disable
sudo service vmware-workstation-server status
sudo update-rc.d vmware-workstation-server defaults
2. VMware Workstation -> Edit -> Preferences -> Shared VMs
uncheck "Enable virtaul machine sharing and remote access" 

# error at apache2 startup
	AH01574: module dav_module is already loaded, skipping
# solution; edit /etc/apache2/mods-available/dav.load
	<IfModule !mod_dav.c>
		LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so
	</IfModule>

# error
Fetched 759 kB in 8s (91.2 kB/s)
W: Failed to fetch http://ro.archive.ubuntu.com/ubuntu/dists/vivid-updates/universe/binary-amd64/Packages  Hash Sum mismatch
W: Failed to fetch http://ro.archive.ubuntu.com/ubuntu/dists/vivid-updates/universe/binary-i386/Packages  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.
Error executing command, exiting
# solution
Check that everything is on in Synaptic Package Manager -> Settings -> Repositories.
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

# error
Dash (from Unity) does not showing Applications.
Message presented is "Sorry, there is nothing that matches your search".
# solution
# http://askubuntu.com/questions/501880/applications-dont-appear-in-the-dash-14-04
sudo apt-get install desktop-file-utils
# list the files containing errors:
desktop-file-validate ~/.local/share/applications/*.desktop | grep -i "desktop: error" | awk '{sub(/:$/,"",$1); print $1}' | uniq
desktop-file-validate ~/.gnome/apps/*.desktop | grep -i "desktop: error" | awk '{sub(/:$/,"",$1); print $1}' | uniq
desktop-file-validate /usr/share/applications/*.desktop | grep -i "desktop: error" | awk '{sub(/:$/,"",$1); print $1}' | uniq
# in order to see the errors run:
desktop-file-validate ~/.local/share/applications/*.desktop
desktop-file-validate ~/.gnome/apps/*.desktop
desktop-file-validate /usr/share/applications/*.desktop
# move the error-desktop-files to a temporary location:
mkdir -p ~/temp/error-desktop-files1 ~/temp/error-desktop-files2 ~/temp/error-desktop-files3
desktop-file-validate ~/.local/share/applications/*.desktop | grep -i "desktop: error" | awk '{sub(/:$/,"",$1); print $1}' | uniq | xargs sudo mv -t ~/temp/error-desktop-files1/ {}
desktop-file-validate ~/.gnome/apps/*.desktop | grep -i "desktop: error" | awk '{sub(/:$/,"",$1); print $1}' | uniq | xargs sudo mv -t ~/temp/error-desktop-files2/ {}
desktop-file-validate /usr/share/applications/*.desktop | grep -i "desktop: error" | awk '{sub(/:$/,"",$1); print $1}' | uniq | xargs sudo mv -t ~/temp/error-desktop-files3/ {}
# At this point your problem is solved but some application still are missing (the ones for whom you moved the *.desktop files).
# What's strange is that after moving back the *.desktop files to where they originally were the problem still remains solved.
# I suppose you have to first access the dash in order to show the applications before
# moving them back to where they originally were, otherwise would be more than strange.

# Enable *.sh executing on double-click for Xfce (thunar 1.6.6 minimal):
# see then created: Settings -> Settings Editor -> thunar -> misc-exec-shell-scripts-by-default
xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default --create --type bool --set true

# video card info
# see also http://ubuntuforums.org/showthread.php?t=2294502
# using chromium navigate to chrome://gpu/
lspci | grep VGA
sudo lshw -C video
# That's because your hardware is newer than Trusty's copy of the PCI ID database of names. 
# Run this (once, with internet connection on) to update to the most current database of 
# PCI/USB device names, and then run lspci again:
sudo update-pciids
sudo update-usbids
# other video test
export LIBGL_DEBUG=verbose
glxgears -info
# display info about a GLX extension and OpenGL renderer
glxinfo
# display information from VA API driver
vainfo

# Disable The User List Or Guest Session In Ubuntu 15.10
# see also http://sourcedigit.com/17187-disable-user-list-guest-session-ubuntu/
# when using lightdm login manager:
gksu gedit /etc/lightdm/lightdm.conf
[SeatDefaults]		-> existing line
allow-guest=false	-> append this line
sudo systemctl restart lightdm

# show current login manager
cat /etc/X11/default-display-manager

# list available login managers
update-alternatives --list x-window-manager

# Enable password-less login
# Use "Users and Groups" utility.

# XFCE Whisker Menu (http://gottcode.org/xfce4-whiskermenu-plugin/)
# search whisker in Synaptic for maybe other related useful packages
sudo apt-get install xfce4-whiskermenu-plugin xfce4-goodies
# then add the Whisker Menu in Panel 1 and remove the Application menu

# XFCE + annoying security popups
# https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html
In /usr/share/polkit-1/actions/org.freedesktop.accounts.policy configure:
<defaults>
  <allow_any>auth_self</allow_any>
  <allow_inactive>auth_self</allow_inactive>
  <allow_active>auth_self_keep</allow_active>
</defaults>
# or at XFCE Settings -> Session and Startup (Application Autostart TAB):
# uncheck PolicyKit Authentication Agent but with this side effect e.g.:
# when starting Synaptic you won't longer be prompted for password so you'll have to start it with gksudo synaptic

# public key authentication not working (Permission denied (publickey))
# possible solution:
sudo chown -Rv $USER: ~/.ssh
sudo chmod -v 700 ~/.ssh
sudo chmod -v 600 ~/.ssh/*
# also remove any other user from the group named as the $USER (the base group)

# ERROR1
	VMWare says something like "vmware kernel module updater ..." and requires pressing Install button then nothing happens.
# ERROR2
	After some Ubuntu updates the vmware network adapters are gone.
# SOLUTION
	sudo vmware-modconfig --console --install-all

# problem: masked service
# This will prevent the service from being started, automatically or manually, for as long as it is masked.
sudo service transmission-daemon status
● transmission-daemon.service
   Loaded: masked (/dev/null)
   Active: inactive (dead)
sudo service transmission-daemon start
Failed to start transmission-daemon.service: Unit transmission-daemon.service is masked.
sudo systemctl unmask transmission-daemon.service
Removed symlink /etc/systemd/system/transmission-daemon.service.
sudo service transmission-daemon status
● transmission-daemon.service - LSB: Start or stop the transmission-daemon.
   Loaded: loaded (/etc/init.d/transmission-daemon)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)

# show open ports:
sudo nmap localhost
# use zenmap gui:
sudo zenmap

# how to install vmware tools on linux:
sudo apt-get install open-vm-tools

# get hdd partition uuid
sudo blkid /dev/sda2
# result e.g: /dev/sda2: LABEL="Windows7_OS" UUID="4250D1BE50D1B8BD" TYPE="ntfs" PARTUUID="33ca1039-02"

Unity Tweak Tool - usefull tweaks:
select Launcher -> "Show Desktop" icon
select Search -> Search online sources
select Panel -> Date & time

Compiz Config Settings Manager (compizconfig-settings-manager) - settings:
General Options -> Display Settings (for default monitor selection)
Ubuntu Unity Plugin -> Launcher -> Minimize Single Window Applications (check in order to maximize/minimize window when clicking on it's launcher icon)

After updating an Ubuntu server I occasionally see the message you 
may need to re-run your boot loader[grub] after updating the kernel:
sudo update-grub

# Remote desktop + XFCE + terminal auto complete commands
# http://ubuntuforums.org/showthread.php?t=1771058&page=2
edit ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
find the line
<property name="custom" type="empty">
	<property name="&lt;Super&gt;Tab" type="string" value="switch_window_key"/>
and change it to
<property name="custom" type="empty">
	<property name="&lt;Super&gt;Tab" type="empty"/>
reboot or whatever and then tab will work properly!

# download from https with public/private key and user/password
# see also https://adrhc.go.ro/wordpress/how-to-create-a-certificate/
wget --no-hsts --no-check-certificate --user=uuu --password=ppp --certificate=xxx_pub.pem --private-key=xxx_key.pem https://svn-ubuntu/zzz/yyy.xml
PS: make sure "certificate common name" match host name (e.g. svn-ubuntu); put it in /etc/hosts in order to match

# clear HSTS data for chrome
chrome://net-internals/#hsts

# PROBLEM:
# umount: /mnt/adrhc-davp: target is busy
# SOLUTION:
# list open files in /mnt/adrhc-davp:
sudo lsof | grep /mnt/adrhc-davp
# or identify processes using /mnt/adrhc-davp:
fuser -u /mnt/adrhc-davp

# convert m4a or m4b to mp3
# use soundconverter:
sudo apt-get install soundconverter

# nomodeset
# http://askubuntu.com/questions/207175/what-does-nomodeset-do
The newest kernels have moved the video mode setting into the kernel. So all the programming of the hardware specific clock rates and registers on the video card happen in the kernel rather than in the X driver when the X server starts.. This makes it possible to have high resolution nice looking splash (boot) screens and flicker free transitions from boot splash to login screen. Unfortunately, on some cards this doesnt work properly and you end up with a black screen. Adding the nomodeset parameter instructs the kernel to not load video drivers and use BIOS modes instead until X is loaded.

# ssh with pre-configured port and user name
# http://linux.die.net/man/5/ssh_config
# create/edit ~/.ssh/config:
Host gigi
    HostName www.gigi.com
    Port 22
    User gigikent
    ServerAliveInterval 30
# now you can login with: ssh gigi
Host gigi18375
    HostName www.gigi.com
    Port 18375
    User gigikent
    ServerAliveInterval 30
# now you can login with: ssh gigi18375

# RAM info
sudo dmidecode -t memory

# generate nive html reports on computer access for a custom period of time
# see also /etc/cron.daily/epylog
# see also /etc/epylog/modules.d/*.conf
# see /etc/epylog/epylog.conf for configuration:
# [file]
# method = file
# path = /var/www/html/epylog
sudo epylog --last day

# access samba share; put this in your File Manager tab:
smb://ip

# teamviewer setup:
# https://www.linuxbabe.com/desktop-linux/install-teamviewer-ubuntu-16-04-xenial-xerus

# Errors in /var/log/syslog:
# Too many open files
# TCP: request_sock_TCP: Possible SYN flooding on port 8080. Dropping request.  Check SNMP counters.
# http://serverfault.com/questions/294209/possible-syn-flooding-in-log-despite-low-number-of-syn-recv-connections
netstat -tuna | wc -l
watch --interval=1 'netstat -tuna | grep "SYN_RECV" | wc -l'
# /etc/sysctl.conf:
# http://www.dba-oracle.com/oracle10g_tuning/t_ios_kernel_parameters.htm
net.ipv4.tcp_max_syn_backlog = 2048
less /etc/sysctl.conf
sysctl -a
# /etc/security/limits.conf:
# -: changes both soft and hard limit
username soft nofile 2048
username hard nofile 65536
username - memlock 524288
@groupname soft nofile 2048
@groupname hard nofile 65536
# shows all limits for current user:
# http://ss64.com/bash/ulimit.html
ulimit -a
# xrdp ignores /etc/security/limits.conf
# http://florent.clairambault.fr/xrdp-and-the-ulimits-nofile-issue
# Edit /etc/pam.d/common-session and add the following line:
session    required   pam_limits.so
# e.g. change memlock limit then login with current user:
# won't work with only "ulimit -l 1024"
sudo sh -c "ulimit -l 1024 && exec su $LOGNAME"
# e.g. print limits set for the process with pid 1831:
cat /proc/1831/limits
# http://www.cyberciti.biz/tips/linux-procfs-file-descriptors.html
# http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
# To count the number of open file handles of any sort, type the following command:
lsof | wc -l
# see also nginx setup:
worker_rlimit_nofile, worker_connections, proxy_read_timeout
# see also limits for sslh and sshttp:
ps -e -o pid,comm,cmd | grep [s]shttp
ps -e -o pid,comm,cmd | grep [s]slh

# wget console output
wget --no-check-certificate https://www.google.ro/ -qO-

# nginx ssl configuration:
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
# https://github.com/mozilla/server-side-tls
# ttps://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations
# http://security.stackexchange.com/questions/54639/recommended-ssl-ciphers-for-security-compatibility-perfect-forward-secrecy
# https://www.ssllabs.com/ssltest/analyze.html?d=adrhc.go.ro

# ERROR: sudo apt-get install ttf-mscorefonts-installer
# ttf-mscorefonts-installer: processing...
# ttf-mscorefonts-installer: downloading http://downloads.sourceforge.net/corefonts/andale32.exe
# Get:1 http://downloads.sourceforge.net/corefonts/andale32.exe [198 kB]
# Fetched 198 kB in 1s (184 kB/s)                                                              
# W: Can't drop privileges for downloading as file '/var/lib/update-notifier/package-data-downloads/partial/andale32.exe' couldn't # be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
# ttf-mscorefonts-installer: downloading http://downloads.sourceforge.net/corefonts/arial32.exe
# SOLUTION:
# see https://ubuntuforums.org/showthread.php?t=2323229
apt-cache policy ttf-mscorefonts-installer
ll /var/lib/update-notifier/package-data-downloads/partial
sudo rm /var/lib/update-notifier/package-data-downloads/partial/*
sudo apt-get --purge --reinstall install ttf-mscorefonts-installer

# Adding CAcert root certificate to Debian/Ubuntu
# https://www.brightbox.com/blog/2014/03/04/add-cacert-ubuntu-debian/
# see: curl-config --ca
sudo mkdir /usr/local/share/ca-certificates/svn-ubuntu-2017
sudo cp -v svn-ubuntu.cer-chain.b64-ascii.crt /usr/local/share/ca-certificates/svn-ubuntu-2017/
sudo update-ca-certificates
# or this way:
sudo bash -c "echo -n | openssl s_client -showcerts -connect host-name-here:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> /etc/ssl/certs/ca-certificates.crt"
Frozen linux restart
https://forum.likg.org.ua/linux-specific/magic-sysrq-key-t395.html
http://www.exploringbinary.com/binary-converter/
cat /proc/sys/kernel/sysrq
Ctrl + Alt + SysRq + key
Under graphical environments (such as Gnome or KDE) 'Alt'+'PrintScrn/SysRq'+key combination generally only leads to a screenshot being dumped. To avoid this Print Screen feature the magic SysRq combination should include the Ctrl, becoming 'Ctrl'+'Alt'+'SysRq'+key. For the same purposes the AltGr key, if present, can be used in place of the Alt key.

#54: Protect log files
see http://www.tuxradar.com/content/linux-tips-every-geek-should-know

angularjs errors

# error (e.g. in project named projectx)
Running "imagemin:dist" (imagemin) task
Fatal error: Cannot read property 'contents' of undefined
# solution 1
remove node_modules/grunt-contrib-imagemin from projectx
copy node_modules/grunt-contrib-imagemin to projectx from another working project
run again grunt build
# solution 2
comment imagemin in Gruntfile.js:
dist: [
//    'imagemin',

# error
Images are optimized and renamed to something like 8c5d3fdb.logout-16x16.png but not in html too (they are still referenced as e.g. logout-16x16.png).
# solution 1
Patch node_modules\grunt-usemin\lib\htmlprocessor.js:
if (srcfile !== file) {
  self.log(match + ' changed to ' + res);
}
while(res.indexOf('../images/') > -1){	
	res = res.replace("../","");
}
return res
# solution 2 (srcFile might be srcfile)
Patch node_modules\grunt-usemin\lib\fileprocessor.js:
var srcFile = filterIn(src);	-> already exisnting line
debug('Let\'s replace ' + src);
while(srcFile.indexOf('../images/') > -1){	
	srcFile = srcFile.replace("../","");
};
debug('Looking for revved version of ' + srcFile + ' in ', assetSearchPath);

# error (when running "npm install" in project dir)
npm ERR! Error: EACCES, mkdir '/********/.npm/minimatch/1.0.0'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/********/.npm/minimatch/1.0.0']
npm ERR!   errno: -13,
# solution
Run as administrator:
sudo npm install

npm

# npm cache data directory
npm config get cache
# npm cache list, clean
npm cache ls
npm cache clean

# list local node modules (project/node_modules)
npm ls --depth=0
# list global node modules (/usr/lib/node_modules)
npm ls -gp --depth=0

# install global package, specific version
sudo npm install -g webpack@2.2.0-rc.4

# uninstall global package (don't specify the version)
sudo npm uninstall -g -verbose webpack-dev-server

# https://npmsearch.com/
# https://docs.npmjs.com/cli/search
npm search angular-in-memory-web-api

# show the dependencies of the typings package at version 1.4.0 (or just check its package.json file)
npm view typings@1.4.0 dependencies

ERROR
	npm WARN retry will retry, error on last attempt: Error: certificate has expired
	npm ERR! code CERT_HAS_EXPIRED
SOLUTION
	npm config set strict-ssl false

Node js

# see https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories
# First, you need to install the PPA in order to get access to its contents
# curl -sL https://deb.nodesource.com/setup | sudo bash -
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
# then install nodejs
sudo apt-get install nodejs

# initialize a node.js project (creates package.json):
node init

linux, networking, howto, nginx, mysql, plex …

Facebook Auto Publish Powered By : XYZScripts.com