Sharing Ubuntu VirtualBox Folder with Windows

Refer #1: http://www.howtogeek.com/116309/use-ubuntus-public-folder-to-easily-share-files-between-computers/
Refer #2: https://help.ubuntu.com/community/Samba/SambaServerGuide

To start you need to right-click the folder to share and then install the software

Afterwards you'll need to change the settings to share the files:

sudo nano -w /etc/samba/smb.conf

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = no

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
create mask = 0775

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directory mask = 0775

Example of a Deployment Cycle

SCHEDULE and TASKS for web deploys:

1. Start drain Cluster 1 Previous day
- Sysadmin: set node halprdjbs01/02 to disabled in mod_jk

2. Deploy eCommerce (BE) code Cluster 1 1:15pm - 1:30pm
- Sysadmin: set node halprdjbs01/02 to shutdown in mod_jk
- Sysadmin: shutdown JBoss on halprdjbs01/02
- Webdev: execute Hudson job hal_prod_cluster1_wcs_(xxx)
- Sysadmin: set node halprdjbs01/02 to disabled in mod_jk
- Webqa: smoke test HAL/SBN BE cluster 1

3. Release Cluster 1 and start drain Cluster 2 1:30pm - 1:45pm
- Sysadmin: set node halprdjbs01/02 to enable in mod_jk
- Sysadmin: set node halprdjbs03/04 to disabled in mod_jk

4. Deploy eCommerce (BE) code Cluster 2 7:00pm - 7:15pm
- Sysadmin: set node halprdjbs03/04 to shutdown in mod_jk
- Sysadmin: shutdown JBoss on halprdjbs03/04
- Webdev: execute Hudson job hal_prod_cluster2_wcs_(xxx)
- Sysadmin: set node halprdjbs03/04 to disabled in mod_jk
- Webqa: smoke test HAL/SBN BE cluster 2

5. Release Cluster 2 7:15pm - 7:30pm
- Sysadmin: set node halprdjbs03/04 to enable in mod_jk

6. Deploy code WebRes 8:00pm - 8:15pm
- Sysadmin: shutdown JBoss on halresjbs01/02
- Webdev: execute Hudson job sbnfe-prod

7. Validation testing by QA team 8:15pm - 10:00pm

Unescape or Escape with JavasScript Solutions

Solution for JavaScript

function unescapeHTML(html) {
var htmlNode = document.createElement("DIV");
htmlNode.innerHTML = html;
if(htmlNode.innerText !== undefined)
return htmlNode.innerText; // IE
return htmlNode.textContent; // FF
}

Solution for JQuery

function unescapeHTML(html) {
return $("<div />").html(html).text();
}
function escapeHTML(html) {
return $("<div />").text(html).html();
}

JavaScript unescape() Function

var str = "Need tips? Visit W3Schools!";
var str_esc = escape(str);
document.write(str_esc + "<br>")
document.write(unescape(str_esc))

The output of the code above will be:
Need%20tips%3F%20Visit%20W3Schools%21
Need tips? Visit W3Schools!

The unescape() function was deprecated in JavaScript version 1.5. Use decodeURI()

JavaScript decodeURI() Function

var uri = "my test.asp?name=ståle&car=saab";
var enc = encodeURI(uri);
var dec = decodeURI(enc);
var res = enc + "<br>" + dec;

The result of res will be:
my%20test.asp?name=st%C3%A5le&car=saab      // Encoded URI
my test.asp?name=ståle&car=saab             // Decoded URI

Sharing VirtualBox folders

You have Ubuntu running in Windows and you want to share a windows folder with Ubuntu. Do the following:

Make sure you have installed the Guest Additions

Configure the shared folder in my VirtualBox. Click menu option "Devices->Shared Folders" to configure the sharing

This has gotten much easier now, VirtualBox will just mount the folder; however, you need to make sure your user is part of the vboxsf group; otherwise, you will need to be root in order to copy or access the files, use the following command:

sudo usermod -G vboxsf -a jboss1

Older Instructions

Open terminal and created a directory called share under "mnt" so it looks as “/mnt/share”. This required "admin" privileges, and then run the following command.

sudo mount -t vboxsf sharename /mnt/share

There is a bug with VirtualBox 4.3.10 and mounting, the following commands will fix, after you mount the Guest Additions

$ cd /sbin
$ sudo rm mount.vboxsf
$ ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsfsudo usermod -G vboxsf -a jboss1

On Mar 26, 2014, at 10:17 AM, Bachtel, Michael wrote:

Hi all,

Some of us have had issues with Apache not serving some deployed files.

In short the issue is one with the OS's file context and was fixed by running
$ sudo restorecon -r /opt/<APP_DIR>

Longer version sourced from https://www.centos.org/forums/viewtopic.php?t=6834

"The issue is caused when you mv something from one place to another. It preserves the selinux context of the original when you move it, so if you untar something in /home or /tmp it gets given an selinux context that matches its location. Now you mv that to /var/www/html and it takes the context saying it belongs in /tmp or /home with it and httpd is not allowed by policy to access those files.

If you cp the files instead of mv them, the selinux context gets assigned according to the location you're copying to, not where it's coming from. Running restorecon puts the context back to its default and fixes it too."

~Mike

AngularJS – Dependency injection in services, factories, filters etc

Samples

app.filter('<filter>', ['$http', function(http){
    return function(data){
    }
}]);

Directive:

app.directive('<directive>', ['$http', function(http){
    return {
        ....
    }
}]);

Service:

app.factory('<service>', ['$http', function(http) {
  var shinyNewServiceInstance;
  return shinyNewServiceInstance;
}]);

Mounting SSH Connection on Ubuntu

You need to install SSHFS, can happend in "Software Center"

To mount:
mkdir ~/haldevjbs13
sshfs -o idmap=user jboss1@haldevjbs13.hq.halw.com:/ ~/haldevjbs13
sshfs -o idmap=user $USER@haldevjbs13.hq.halw.com:/remote-folder-to-mount/ ~/haldevjbs13

To unmount:
fusermount -u ~/haldevjbs13