Saturday, 24 March 2018

How to switch the editor in mc (midnight commander) from nano to mcedit?

There are several ways, 2 worked for me

1. Press the following keys in order, one at a time:

  1. F9 Activates the top menu.
  2. o Selects the Option menu.
  3. c Opens the configuration dialog.
  4. i Toggles the use internal edit option.
  5. s Saves your preferences.
alt text

2. Working on Debian

Run MC as usual. On the command line right above the bottom row of menu selections type select-editor. This should open a menu with a list of all of your installed editors. This is working for me on all my current Linux machines.

3. Open a Terminal and type this command:

sudo update-alternatives --config editor
You will get an list of the installed Editors in your Ubuntu, and you can chose your favorite.

Wednesday, 4 January 2017

Language Hotkeys removed by itself in Windows 10 after sleep or restart

Original post:
http://superuser.com/questions/1031736/language-hotkeys-removed-by-itself-in-windows-10


I have four keyboards and I have defined Ctrl+1, Ctrl+2 and Ctrl+3 ... hot-keys for them. The problem is that either all of the hot-keys or the first one is removed regularly. For example every time the computer goes to sleep (or even locked) all of them are removed.
I even tried other hot-keys (Ctrl+Shift+1, ... Ctrl+Shift+4) or (Alt+Shift+1, ... Alt+Shift+4) and the problem still exist.
If I assign a transition key (Left Shift+Alt) it will work but that's not that useful when you have more than 2 keyboards and you want to regularly change the keyboard.
It appears that the problem has existed in Windows 8 too (and has something to do with welcome screen) but the solution I found does not work on Windows 10 (http://answers.microsoft.com/en-us/windows/forum/windows_8-desktop/custom-hotkeys-to-change-input-language-disappear/66d1d89d-e5dc-41e1-a8b3-48d596ab8e11).


down voteaccepted
I finally found the solution and I am posting, in case someone else has the problem.
1- Define your hot-keys.
2- Search and find the "region" settings palette and go to administrative tab.
region-administrative tab
Now go to "Copy Settings" section.
copy settings
Select both tick boxes below the window and press ok.
In my case this applied the settings in a way that they are no more removed.

Thursday, 28 April 2016

Tuesday, 29 March 2016

Complete Guide to Symbolic Links (symlinks) on Windows or Linux

Original post here: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

Complete Guide to Symbolic Links (symlinks) on Windows or Linux

Want to easily access folders and files from different folders without maintaining duplicate copies?  Here’s how you can use Symbolic Links to link anything in Windows 10, 8, 7, Vista, XP, and Ubuntu.
image

So What Are Symbolic Links Anyway?

Symbolic links, otherwise known as symlinks, are basically advanced shortcuts. You can create symbolic links to individual files or folders, and then these will appear like they are stored in the folder with the symbolic link even though the symbolic link only points to their real location.
There are two types of symbolic links: hard and soft. Soft symbolic links work essentially the same as a standard shortcut.  When you open a soft link, you will be redirected to the folder where the files are stored.  However, a hard link makes it appear as though the file or folder actually exists at the location of the symbolic link, and your applications won’t know any different. Thus, hard links are of the most interest in this article.

Why should I use Symbolic Links?

There are many things we use symbolic links for, so here’s some of the top uses we can think of:
  • Sync any folder with Dropbox – say, sync your Pidgin Profile Across Computers
  • Move the settings folder for any program from its original location
  • Store your Music/Pictures/Videos on a second hard drive, but make them show up in your standard Music/Pictures/Videos folders so they’ll be detected my your media programs (Windows 7 Libraries can also be good for this)
  • Keep important files accessible from multiple locations
  • And more!
If you want to move files to a different drive or folder and then symbolically link them, follow these steps:
  • Close any programs that may be accessing that file or folder
  • Move the file or folder to the new desired location
  • Follow the correct instructions below for your operating system to create the symbolic link.
Caution: Make sure to never create a symbolic link inside of a symbolic link. For instance, don’t create a symbolic link to a file that’s contained in a symbolic linked folder. This can create a loop, which can cause millions of problems you don’t want to deal with. Seriously.

Create Symlinks in Any Edition of Windows in Explorer

Creating symlinks is usually difficult, but thanks to the free Link Shell Extension, you can create symbolic links in all modern version of Windows pain-free.  You need to download both Visual Studio 2005 redistributable, which contains the necessary prerequisites, and Link Shell Extension itself (links below).  Download the correct version (32 bit or 64 bit) for your computer.
Run and install the Visual Studio 2005 Redistributable installer first.
image
Then install the Link Shell Extension on your computer. Your taskbar will temporally disappear during the install, but will quickly come back.
image
Now you’re ready to start creating symbolic links.  Browse to the folder or file you want to create a symbolic link from.  Right-click the folder or file and select Pick Link Source.
image
To create your symlink, right-click in the folder you wish to save the symbolic link, select “Drop as…”, and then choose the type of link you want.  You can choose from several different options here; we chose the Hardlink Clone.  This will create a hard link to the file or folder we selected.  The Symbolic link option creates a soft link, while the smart copy will fully copy a folder containing symbolic links without breaking them.  These options can be useful as well.
image
Here’s our hard-linked folder on our desktop.  Notice that the folder looks like its contents are stored in Desktop\Downloads, when they are actually stored in C:\Users\Matthew\Desktop\Downloads.  Also, when links are created with the Link Shell Extension, they have a red arrow on them so you can still differentiate them.
image
And, this works the same way in XP as well.
image
Symlinks via Command Prompt
Or, for geeks who prefer working via command line, here’s how you can create symlinks in Command Prompt in any version of Windows.

In Windows 10, 8, 7, or Vista

In Windows Vista and 7, we’ll use the mklink command to create symbolic links.  To use it, we have to open an administrator Command Prompt.  Enter “command” in your start menu search, right-click on Command Prompt, and select “Run as administrator”.
image
To create a symbolic link, we need to enter the following in command prompt:
mklink /prefix link_path file/folder_path
First, choose the correct prefix.  Mklink can create several types of links, including the following:
  • /D – creates a soft symbolic link, which is similar to a standard folder or file shortcut in Windows.  This is the default option, and mklink will use it if you do not enter a prefix.
  • /H – creates a hard link to a file
  • /J – creates a hard link to a directory or folder
So, once you’ve chosen the correct prefix, you need to enter the path you want for the symbolic link, and the path to the original file or folder.  For example, if I wanted a folder in my Dropbox folder to appear like it was also stored in my desktop, I would enter the following:
mklink /J C:\Users\Matthew\Desktop\Dropbox C:\Users\Matthew\Documents\Dropbox
Note that the first path was to the symbolic folder I wanted to create, while the second path was to the real folder.
Here, in this command prompt screenshot, you can see that I created a symbolic link of my Music folder to my desktop.
image
And here’s how it looks in Explorer.  Note that all of my music is “really” stored in C:\Users\Matthew\Music, but here it looks like it is stored in C:\Users\Matthew\Desktop\Music.
image
If your path has any spaces in it, you need to place quotes around it.  Note also that the link can have a different name than the file it links to.  For example, here I’m going to create a symbolic link to a document on my desktop:
mklink /H “C:\Users\Matthew\Desktop\ebook.pdf”  “C:\Users\Matthew\Downloads\Before You Call Tech Support.pdf”
Don’t forget the syntax:
mklink /prefix link_path Target_file/folder_path

In Windows XP

Windows XP doesn’t include built-in command prompt support for symbolic links, but we can use the free Junction tool instead.  Download Junction (link below), and unzip the folder.  Now open Command Prompt (click Start, select All Programs, then Accessories, and select Command Prompt), and enter cd followed by the path of the folder where you saved Junction.
image
Junction only creates hard symbolic links, since you can use shortcuts for soft ones.  To create a hard symlink, we need to enter the following in command prompt:
junction –s link_path file/folder_path
As with mklink in Windows 7 or Vista, if your file/folder path has spaces in it make sure to put quotes around your paths.  Also, as usual, your symlink can have a different name that the file/folder it points to.
Here, we’re going to create a symbolic link to our My Music folder on the desktop.  We entered:
junction -s “C:\Documents and Settings\Administrator\Desktop\Music” “C:\Documents and Settings\Administrator\My Documents\My Music”
image
And here’s the contents of our symlink.  Note that the path looks like these files are stored in a Music folder directly on the Desktop, when they are actually stored in My Documents\My Music.  Once again, this works with both folders and individual files.
image
Please Note: Junction would work the same in Windows 7 or Vista, but since they include a built-in symbolic link tool we found it better to use it on those versions of Windows.

Symlinks in Ubuntu

Unix-based operating systems have supported symbolic links since their inception, so it is straightforward to create symbolic links in Linux distros such as Ubuntu.  There’s no graphical way to create them like the Link Shell Extension for Windows, so we’ll just do it in Terminal.
Open terminal (open the Applications menu, select Accessories, and then click Terminal), and enter the following:
ln –s file/folder_path link_path
Note that this is opposite of the Windows commands; you put the source for the link first, and then the path second.
For example, let’s create a symbolic link of our Pictures folder in our Desktop.  To do this, we entered:
ln -s /home/maguay/Pictures /home/maguay/Desktop
image
Once again, here is the contents of our symlink folder.  The pictures look as if they’re stored directly in a Pictures folder on the Desktop, but they are actually stored in maguay\Pictures.
image
Delete Symlinks
Removing symbolic links is very simple – just delete the link!  Most of the command line utilities offer a way to delete a symbolic link via command prompt, but you don’t need to go to the trouble.
image
Conclusion
Symbolic links can be very handy, and we use them constantly to help us stay organized and keep our hard drives from overflowing.  Let us know how you use symbolic links on your computers!

Wednesday, 17 February 2016

Play framework Start/Stop Script.

Great post how to exec Play framework as a demon:
http://vladsprogrammingblog.blogspot.co.il/2014/01/play-startstop-script.html?showComment=1455741528114#c2535977690511914718

Play Start/Stop Script.

Here is a start/stop script that I use for my Play! 2.2.x applications.
#!/bin/bash

println() {
    echo
    echo $1
    echo
}

get_or_else() {
        if [ "x" = "x$1" ]
          then echo $2
          else echo $1
        fi
}

check_status() {
    if [ -f $PID_FILE_PATH ]
    then
        kill -0 $( cat $PID_FILE_PATH ) 2> /dev/null
        echo $?
    else
        echo 1
    fi
}

STARTUP_CONFIGURATION_FILE_PATH=/etc/default/play

if [ ! -f "$STARTUP_CONFIGURATION_FILE_PATH" ]
then
  println "Please set STARTUP_CONFIGURATION_FILE_PATH variable in the $0"
  exit 1
fi

source $STARTUP_CONFIGURATION_FILE_PATH

if [ ! -d "$BASE_DIR" ]
then
  println "Please set BASE_DIR variable in the $STARTUP_CONFIGURATION_FILE_PATH"
  exit 1
fi

OPTS="-server"
START_DELAY=3
STOP_DELAY=3

CMD=$BASE_DIR/bin/myapp

PORT=$(get_or_else "$PORT" '9000' )
LISTEN_IP=$(get_or_else "$LISTEN_IP" '0.0.0.0' )
PID_FILE_PATH=$(get_or_else "$PID_FILE_PATH" "$BASE_DIR/play.pid" )
STDOUT_LOG=$(get_or_else "$STDOUT_LOG" '/dev/null' )
HEAP_START_SIZE=$(get_or_else "$HEAP_START_SIZE" '128M' )
HEAP_MAX_SIZE=$(get_or_else "$HEAP_MAX_SIZE" '1024M' )

OPTS="$JAVA_OPTS -Dpidfile.path=$PID_FILE_PATH -J-Xms$HEAP_START_SIZE -J-Xmx$HEAP_MAX_SIZE"

if [ "x" != "x$CONFIGURATION_FILE_PATH" ]
then
  OPTS="$OPTS -Dconfig.file=$CONFIGURATION_FILE_PATH"
fi

if [ "x" != "x$LOG_CONFIGURATION_FILE_PATH" ]
then
  OPTS="$OPTS -Dlogger.file=$LOG_CONFIGURATION_FILE_PATH"
fi

COMMAND="$CMD $OPTS -Dhttp.address=$LISTEN_IP -Dhttp.port=$PORT"

status() {
    if [ 0 -eq $(check_status) ]
    then
        println "Play! is running: [$( cat $PID_FILE_PATH )]."
    else
        println "Play! is not running."
    fi
}

start() {
    if [ 0 -eq $(check_status) ]
    then
        println "Play! is running. [$( cat $PID_FILE_PATH )]."
    else

        rm $STDOUT_LOG >/dev/null 2>&1

        nohup $COMMAND >>$STDOUT_LOG 2>&1 &

        sleep $START_DELAY

        if [ 0 -eq $(check_status) ]
        then
                println "Started."
        else
                rm $PID_FILE_PATH >/dev/null 2>&1
                println "Could not start Play!, please see [$STDOUT_LOG] for more details."
        fi
    fi
}

stop() {
    if [ 0 -eq $(check_status) ]
    then

        if kill $( cat $PID_FILE_PATH )
        then

          sleep $STOP_DELAY

          if [ 0 -lt $(check_status) ]
          then
            println "Stopped."
          else
            println "Could not stop Play! process. Please stop it manually."
          fi

        else
          println "Could not stop process $( cat $PID )."
        fi

    else
        println "Play! is not running."
    fi
}

case "$1" in
    'start')
            start
            ;;
    'stop')
            stop
            ;;
    'restart')
            stop ;
            start
            ;;
    'status')
            status
            ;;
    *)
            echo
            echo "Usage: $0 { start | stop | restart | status }"
            echo
            exit 1
            ;;
esac

exit 0


To run this script just change value of the CMD=$BASE_DIR/bin/myapp variable in the script and create your configuration file/etc/default/play. Here is an example of configuration file I have.


#Base directory of the play project
BASE_DIR=/opt/app/myapp

#Path to the file with process ID
#PID_FILE_PATH=$BASE_DIR/play.pid

#Path to the file, where process output will be redirected
STDOUT_LOG=$BASE_DIR/play.out

#Play! configuration file
CONFIGURATION_FILE_PATH=$BASE_DIR/../myapp.conf

#Logging configuration file
LOG_CONFIGURATION_FILE_PATH=$BASE_DIR/../logger.xml

#Play! port
PORT=9090

#Play! host
#LISTEN_IP='127.0.0.1'

#Additional JVM options
#JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
JAVA_OPTS="-DapplyEvolutions.default=true -DapplyDownEvolutions.default=true"

#Start size of JVM heap
HEAP_START_SIZE=1024M

#Maximum size of JVM heap
HEAP_MAX_SIZE=1024M

Copy start/stop script to /etc/init.d
cd /etc/init.d
chmod +x script-name
update-rc.d script-name defaults (to remove update-rc.d -f script-name remove)
systemctl daemon-reload

Monday, 9 November 2015

Gitlab git push DO NOT work because Gitlab Server Send Error 503 for remote origins ending with a "/"

https://gitlab.com/gitlab-org/gitlab-ce/issues/2727

Got a problem and resolved,
git push DO NOT work because Gitlab Server Send Error 503 for remote origins ending with a "/"

......
Have  issue with Nginx and Omnipackage, but received not 503 but 521 error. 
I resoled issue with steps: 
1. in /etc/gitlab/gitlab.rb
 gitlab_git_http_server['listen_network'] = "tcp"
 gitlab_git_http_server['listen_addr'] = "localhost:8181"
but leave nginx[‘enable’] = true
and run gitlab-ctl reconfigure
2, Change generated gitlab-http.conf
in first part change
upstream gitlab-git-http-server {
  server unix:localhost:8181;
}
to
upstream gitlab-git-http-server {
  server localhost:8181;
}
and after location @gitlab { …} add new section
  location ~ [-\/\w\.]+\.git\/ {
    ## If you use HTTPS make sure you disable gzip compression
    ## to be safe against BREACH attack.
    # gzip off;


    ## https://github.com/gitlabhq/gitlabhq/issues/694
    ## Some requests take more than 30 seconds.
    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;

    # Do not buffer Git HTTP responses
    proxy_buffering off;

    # The following settings only work with NGINX 1.7.11 or newer
    #
    # # Pass chunked request bodies to gitlab-git-http-server as-is
    # proxy_request_buffering off;
    # proxy_http_version 1.1;

    proxy_set_header    Host                $http_host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   $scheme;

    proxy_pass http://gitlab-git-http-server;
  }
Now gitlab-ctl restart and all return to work

Sunday, 25 October 2015

mongodb service is not starting up

Answer helped me:
http://stackoverflow.com/questions/17527606/mongodb-failing-on-debian
if you don't find any traces in the logs:
tail -f -n50 /var/log/mongodb/mongodb.log
you should try to start the server in foreground:
sudo -u mongodb mongod --dbpath /var/lib/mongodb/
and see what's happening. For instance, I had a locale problem:

root@server :~# sudo -u mongodb mongod --dbpath /var/lib/mongodb/
2015-10-25T09:45:23.613+0000 E NETWORK  [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2015-10-25T09:45:23.613+0000 E NETWORK  [initandlisten]   addr already in use
2015-10-25T09:45:23.613+0000 W -        [initandlisten] Detected unclean shutdown - /var/lib/mongodb/mongod.lock is not empty.
2015-10-25T09:45:23.614+0000 I STORAGE  [initandlisten] exception in initAndListen: 98 Unable to lock file: /var/lib/mongodb/mongod.lock errno:11 Resource temporarily unavailable. Is a mongod instance already running?, terminating
2015-10-25T09:45:23.614+0000 I CONTROL  [initandlisten] dbexit:  rc: 100
To see config problem:

root@server :~# sudo -u mongodb mongod --dbpath /var/lib/mongodb/ -f /etc/mongod.conf
Unrecognized option: net.authorization
try 'mongod --help' for more information