MEAN.JS is one of the “Open-Source Full-Stack solutions” for developing MEAN applications freely available. There’s other equally acceptable solutions out there, each of them with their particularities.
MEAN applications are those that integrates MongoDB, ExpressJS, AngularJS and Node.js, and it’s a configuration that it’s being used more and more frequently in the last years. There are many options available, sometimes with very similar names (MEAN.io from Linnovate, and MEAN.JS as a community-governed project from the same creator: Amos Haviv) or technologies still in development (Angular2 is used in some generators even when it’s still in beta at the moment of writing this article). The speed in which a stack solution, generator, framework, or any other starting point for MEAN development, is released and became outdated is astonishing fast. Sometimes, even updates implies a new approach that requires the change of the structure of the code. This makes very confusing for any coder willing to start learning with the tools available.
Leaflet is an “Open-Source JavaScript library for mobile-friendly interactive maps”. It’s very powerful and easy to use, and with the addition of Stamen we can make eye-candy maps very easily.
So, getting to the point. What’s the easiest way to integrate MEAN.JS and Leaflet? In around 5 minutes, and with a little help of copy-paste, we can have a working example.
Installing MEAN.JS
You will require a working installation of node.js. That’s out of the scope in this article, but in treehouse is easily explained. You’ll need a reboot in your machine in order to be sure that the folders are properly added to the path.
Then, we need to create a fresh copy of MEAN.JS. In this example, I will be using MEAN 0.4.2. That’s the version you should initiate if you want to be sure that my tutorial is working. I’ll ask the generator to create all the available examples. They are quite convenient in order to understand how the code should be structured.
yo meanjs
Let’s say you create a project folder named mean-leaf. Then, you’ll need to get into that folder.
cd mean-leaf
You will need a working global installation of Grunt and Bower. So, if you need to install them:
npm install -g grunt-cli
npm install -g bower
We add the angular-leaflet-directive:
bower install angular-leaflet-directive --save
And now, we use Grunt to run the application:
grunt
If you have the error “You need to have Ruby and Sass installed and in your PATH for this task to work”, just execute the following and run grunt again:
sudo gem install sass
Adding the Leaflet maps
With the previous steps, MEAN.js should be up and running. Now, we are going to integrate the Leaflet map. More examples can be found in the angular-leaflet-directive Github page, but I found the “Center example” the most appropriate for having an initial taste.
Remember that you’ll need the angular-leaflet-directive installed as mentioned above.
Adding the required JavaScript and CSS files
We’ll need to add the leaflet CSS and JavaScript files to config/assets/default.js. I found quite useful using the CDN versions, so that’s what I’ll show here. The code will be more or less this (just showing the modified sections):
Now, we need to add the JavaScript to /config/assets/default.js. Is the same file we used previously, but now we’re adding a line in the client > lib > js section. After the changes, it will be something like this:
But that’s is not enough. We need do some modifications to the code of the controller modules/core/client/controllers/home.client.controller.js(be very careful with the indentation here, WordPress is breaking the code and it’s important):
This should be enough. Just run grunt and visit your website. If you have errors with eslint and the indentation, just edit modules/core/client/controllers/home.client.controller.js and make the modifications displayed in the console.
The result should be something like the following screenshot:
The example used for this article, and many others, are available in the angular-leaflet-directive examples gallery, and also in their Github.
The UEFI (Unified Extensible Firmware Interface) is an example of a good idea developed, enforced, and implemented in the wrong way. What was meant to help us protecting our computer, turned into some kind of kidnapper that prevented us to use the OS of our choice.
Installing a different OS to the provided by the manufacturer is a, sometimes impossible, sometimes painful, task. Some manufacturers simply don’t contemplate the use of anything different from Windows 8 or 10 in their machines (ajem, HP, ajem), forcing us to press the Boot-order-selection key during the booting of OUR devices in order to being able to start, let’s say, Linux. Every single time. I repeat. Every. Single. Time. And it’s curious how, no matter which procedure you use, and how many times you change the UEFI boot order, Windows always comes to the top.
Although I have not been able to fix this problem in my HP machine (well, I know the solution, not buying HP products anymore), I successfully managed to fix it in 2 Lenovo machines. The procedure is quite easy -but use it under your own responsibility. Presuming that Linux has been installed in UEFI mode correctly (there are different methods to check this, but the easiest is to check if you have a boot/efi folder using the command df -h –local | grep /boot), you just need to install boot-repair:
Just the quick setup should do the magic. However, in my experience, it was not so easy, and the machine was still booting into Windows. I had to boot into Windows and execute the following command in the command line with administrative privileges:
For many reasons, you can find yourself working with a server where many and constant changes need to be done. This usually implies doing a modification to a file, uploading it, testing it, modifying something again, uploading, and repeating.
There’s many different approaches to manage this routine.
The 1st option is editing from the terminal. This is not bad, as Vim, Nano (I previously wrote how to activate markdown in Nano), and other command line editors are powerful options and allow us to fulfill most of the tasks. However, it can be a headache editing several files, not being able to use the mouse’s scroll wheel (that is there to be used!), or the beautify plugin.
Another option that works perfectly fine requires the creation of Grunt tasks. However, we could lack a little bit of flexibility if we do many different tasks. Also, we still need to spend some extra time creating connections and uploading the files.
We could also install a X server and access through remote desktop to our server, but that will imply an use of extra resources (memory, space, and bandwidth… And therefore, money) that could be used for more interesting things.
At the moment, the way I’m using to bypass all this trouble and make my life easier, consists in using SSHFS and Fuse. Basically, I will have my remote drive mounted like a local drive, and I can use all the editors I want, and I can use drag’n’drop to easily play with my files. Something similar can be done using the FTP protocol, but this is inherently insecure. That’s why I decided to use SFTP in this case, which is FTP implemented under SSH.
So… How I do it? Easy. First, SSH access is needed. If you can connect to the server through SSH to your server, you can use sftp to transfer files from/to your server, as they explain in DigitalOcean.
SFTP is pretty cool by itself, but we can make it awesome. Oh, laziness, the mother of the best inventions… SSHFS will be the responsible to mount the remote folder in our system. The installation is a piece of cake in Ubuntu and derivatives:
My suggestion is to mount the folder the first time as
sshfs HOSTuser@remote.host.or.ip:/ ~/Desktop/sftp
in order to find out which folder is mounted as default, as it depends on the server and user configuration.
If you have some error like
fusermount: failed to open /dev/fuse: No such file or directory
there’s a easy workaround:
sudo mknod -m 666 /dev/fuse c 10 229
You can create an alias, or a .bashrc entry to automatise this task every time you boot your computer, but I rather prefer to do it manually when I consider is the moment. That’s why I created 2 easy scripts:
mount_sftp_folder.sh
#!/bin/bash
# Mount sftp folder
sshfs TheUser@YourIP:/home/TheUser ~/Desktop/sftp
echo "Done"
Cool, isn’t it? Just remember to be careful, I’m not responsible if something goes wrong. If you want to know a little bit more, you can visit damontimm‘s website, where I took much of the information from.
Elementary OS Freya. Simple. Elegant. But there is still some things I miss, like the option to open a folder or a file with root permissions from the file explorer. With these easy steps this issue can be easily solved:
1.- Install gksu in order to be able to prompt for superuser permissions from the window manager.
Sorry guys, only if you are using Linux you can have Arduino up and running after only 1:20 (approx) , and the only thing you need to do is to write 1 single code in the terminal:
Open the Arduino IDE, press “Add” on the screen that appears, reboot the computer, open again the Arduino IDE, connect your board to your PC, select the serial port under “Tools > Serial port”, select your board model from “Tools > Board” and.. Presto!
You can upload the blink example (any other component but the Arduino board is required) just selecting it at “File > Examples > 01. Basics > Blink” and press “Upload”.
Microsoft’s arm is really long. There is many Microsoft users and it is really easy to find a document or a website using proprietary fonts included in Windows. Sometimes this can be a problem if we want to see that document or website as the designer intended, as usually are not included by default in Linux.
Usually, just installing the Microsoft True Type Core Fonts for the Web solves the problem. This package includes:
Andale Mono
Arial Black
Arial (Bold, Italic, Bold Italic)
Comic Sans MS (Bold)
Courier New (Bold, Italic, Bold Italic)
Georgia (Bold, Italic, Bold Italic)
Impact
Times New Roman (Bold, Italic, Bold Italic)
Trebuchet (Bold, Italic, Bold Italic)
Verdana (Bold, Italic, Bold Italic)
Webdings
[codebox 1]
You will need to accept the license in order to allow the installation to complete.
If you are using Ubuntu, you need to activate the Multiverse repository previous to installation.
However, we can also use the package ttf-liberation, which includes fonts developed by Fedora with the same metrics than the Microsoft ones. The fonts included in this package are:
I’m not writing now about all the problems with the HP laptops and Linux. I’m not going to say that Microsoft is a bully and HP is his sycophant. Not today.
If you have one of those HP laptops with Beats Audio and you managed to install Linux, you will realise that the sound is… Well… Crap.
This is how you solve it:
1.- Install alsa-tools-gui:
[codebox 1]
If you have any problem, try adding this repository:
[codebox 2]
2.- Launch hda-jack-retask:
[codebox 3]
3.- Select the codec beginning by IDT and remap these pins (you need to check “Show unconnected pins”):
0x0d (Internal Speaker, Front side) to “Internal speaker”
0x0f (“Not connected” but is the under-display speakers) to “Internal speaker”
0x10 (“Not connected” but is the subwoofer) to “Internal speaker (LFE)”
Click on “Apply now”. Un-mute the sound and increase and decrease the sound volume. Now run this in a different terminal to be sure that everything is workign fine:
[codebox 4]
If something goes wrong, just reboot. If everything is working fine, press on “Install boot override”.
In the case those overriding pins are not correct, you can try your own configuration until everything goes all right.