Synology DS216+II RAM Upgrade

image

Just finished upgrading my Synology DS216+II to 8GB of DDR3L (low voltage) Kingston memory, from the stock 1GB RAM.. This will hopefully improve performance and caching, especially since I can turn off memory compression now and perhaps help with Plex Hardware Transcoding.

image

The disassembly was pretty straight-forward. After removing the drives and  sliding the top cover backward (fastened to the frame by 2 plastic pegs inside) simply remove the 7 screws holding the chassis in place.

image

Then gently pry the board out to reveal the DIMM slot at the bottom:

image

…put it back together, and viola!

SSD cloud hosting for cheap

image

I decided to try Linode
Cloud hosting

for 10USD (500PHP) a month. You get a high performance VPS which can run several sites for cheap, the only catch is you have to set it up and maintain it yourself. Here’s what I did to get mine up and running in a couple of minutes:

I started by creating an Ubuntu 16.04 LTS node,
then secured my server with their Securing Your Server guide. I also created another user group to make uploading files later easier, then add the non-root user to that group:

I installed Apache next with their guide: Hosting a Website.  I then change some settings in my Apache config but adding some mods I use like mod_rewrite:

I then install mySQL and lock it down using the following commands, which are also found in the Linode Guide:

The I optimize my my.cnf for my puny 2GB server (/etc/mysql/my.cnf):

Ubuntu 16.04 LTS does not have support for PHP5 anymore so I used PHP7, so I installed that with the following commands:

then I install some extensions I need like mySQL, curl etc. THe first commands list the available PHP extensions, then second installs the ones I use.

We’ll need to install postfix also so PHP’s mail() function will work.

Be sure to set “Internet Site: in the configuration dialog. The sendmail_path should be pre-configured correctly already, if not simply set it to:
/usr/sbin/sendmail -t -i

I now Install my FTP server, I use FileZilla since I use the client on my machine natively, then simply connect via SSH/SFTP

Once that is done, I simply point my domains to my server IP. Linode offers a DNS Manager but I prefer to use GoDaddy’s for simplicity. Hen the IP resolves, I test all my settings then I am off!

UPDATE:

When adding new sites or downloading scripts via wget you’ll need to set permissions again to be able to modify them via FTP:  So I add my FTP user to the www-data group so I do not have permission errors.

Gulp! My assets pipeline 2.0 on WIndows

image

This is an update to my previous setup I wrote about on: How I build my assets pipeline on Windows using NodeJS. This time around I use Gulp to simplify things and add more automation.

First up, you’ll need to install gulp globally (npm i -g gulp) if you haven’t yet, then install it in your project directory (npm i gulp -D). The goal is accomplish the following automatically:

  • compile and minify my javascript files when changes are made
  • compile and compress my sass into css when changes are made
  • automatically reload my browser when the css/js is compiled

Here’s a list of the plugins I use and what they in relation to my workflow. This assumes you are familiar with NodeJS already, if not you may read this post first.

Some none-gulp plugins we’ll also need are:

Once you have all these installed, create a gulpfile.js in your project directory (where your package.json is) then you can start creating task. In my setup, I simply run the gulp command to watch my JavaScript and sass files, compile them, and reload the browser. I have a different gulp task to compress the images since this is not done often. Note that the paths may vary depending on how you structure your working environment.

UPDATE April 5, 2018fix for deprecated packages and missing Python executable. UPDATE: October 6, 2018 – I updated the image compress gulp task for better compression and added SVG, and GIF support. Also added the default task to trigger image compression when the source image folder contents are updated. Website Planet has an  image compression tool which inspired this update.

UPDATE October 11, 2019 – updated the gulp plugin dependency changes and added a non-minified version of the bundled CSS and JS files

Open cmd.exe here for NodeJS

Since NodeJS works off the Windows’ shell (command prompt) I find myself needing to open the terminal (cmd.exe) more often now. Here are several ways I open the Command Prompt in a specific location within Windows Explorer on Windows 10.

method 1: simply navigate to the desired folder within Windows Explorer and type cmd in the location bar then press enter.

method 2: Navigate to the desired location within Windows Explorer then press (ALT F, M) on your keyboard. This will give you an option to open either an Elevated Command window (ALT F, M, A) or a normal Command window (ALT F, M P).

method 3: hold shift on your keyboard then right click within the desired folder location within Windows Explorer. AN “Open Command window here” context menu will appear.

How I build my assets pipeline on Windows using NodeJS

image

I develop on Windows 10 (currently) with NodeJS, I am assuming you are running both already. Below is a bare-bones list of modules i use:

  • browserify – this allows my to write my JavaScript in the NodeJS convention as well as concatenate multiple JavaScript dependencies like jQuery and GSAP.
  • uglify-js – this will allow me to minify all my javascript code and dependencies.
  • watchify – will give give us the ability to monitor my javascript files for any changes.
  • node-sass – SASS compiler without having to know or setup Ruby. THis also compresses the output CSS code.
  • nodemon – monitor our scss files for any changes.
  • concurrently – will allow us to run multiply npm command concurrently on Windows using one terminal window.

Some optional modules I use are:
jquery and, bootstrap-sass.

Now we initialize our project with the following commands

  • mkdir public – this will be my webroot folder. This will be the destination folders (public/assets/css,
    public
    /assets/js

    ) for the output files nodeJS will generate for us.

  • mkdir client – this will where my source files will be
  • npm init – create a package.json file for our project
  • npm i <module_name> -D – this is how I install the node modules i need. the -D option will put the module in our package.json as a dependency.

once all the the modules I need are installed, I openup my package.json file and write the scripts I will be using to monitor and compile my CSS and JS files. The gist is to output 2 files bundle.js and bundle.css where all dependencies and custom code are concatenated into one file respectively and compressed.

  • build-js – will read my index.js file which is my main node javascript file and concatenate and minify all the custom code and dependencies into my production bundle.js file.
  • watch-js – will monitor any changes on my index.js file then automatically compile it.
  • build-css– will compile all my scss files and compress it into one bundle.css file. I also included a folder where I put my other scss snippet files.
  • watch-css – this will monitor all .scss files specified in the watch-css command then run build-css once changes are saved on any of the files.
  • build-assets– will build my js and css files
  • watch-assets – will monitor my scss and js files and compile them once changes have been made.

Once I have this setup, i simply do npm run-watch-assets while I am developing to automatically compile all my assets on the files while I code. It’s a great time saver and cleans up my code a whole lot, especially since I only have to include 1 .js file and .css file in my html files for all the dependencies and plugins i use..

Amazon EC2 server setup guide

Here’s a guide which help me setup an AWS  (Amazon Web Services) EC2 server for one of my clients. I used to use their free S3 CND service a few years back; though the process has changed a bit since then; so without further flim-flam.

We’ll be needing PuTTY and FileZilla FTP client for this endeavor. Once you’ve got that sorted, login into your AWS console and proceed to the EC2 link under the Service tab. Once there click launch instance, this will launch a wizard which assist you in creating your machine.

image

Select the Amazon Linux AMI (Amazon Machine Image)

image

Click on the next steps selecting the defaults until you reach the Security Groups section; once there add the HTTP and HTTPS rules.

image

After which you will asked to review your settings and prompted to import or add a key pair. Create a new one and save it somewhere safe. Without the key, you will not be able to access the machine, you will not be able to add a new one too.

image

Download the Key Pair then launch the instance. The instance will take 5-10 minutes to initialize; during that time, process to Network and Security > Elastic IP’s and click Allocate New Address. When the new IP is created, take note of it then right click on the IP and select Associate Address, then select the instance you just made.

image

When this is done, your machine is not up and running. You can now connect to this virtual machine via PuTTY and Filezilla.

Open Filezilla, on the File menu bar, click on Edit > Settings, then go to SFTP then click Add File. Locate and add the key pair file (.pem) file you downloaded earlier. You will be prompted to convert the .pem file to a .ppk.file, click yes and save that file too.

image

Now connect via FTP by putting the Elastic IP you created earlier as the host, SFTP as the protocol and ec2-user as the username; this is the default. Leave the password blank. If everything goes well you should be able to connect without any issues.

image

Now open up PuTTY, use the same IP as the host and connect via SSH. Under Connection > SSH > Auth: Click add file then select the .ppk file created by Filezilla earlier from the original .pem file, then click Open.

image

Login as the ec2-user and hit enter. If everything worked out, you now have root access to the machine.

image

From here you can proceed to install and setup the services you need to run a your web server. Below is a quick cheat sheet I used to get mine running.

My webdev environment on Windows

Here the web development environment I have setup on my laptop. It’s simply a run-through and short tutorial of the things I use for those of you who are interested in getting into the web development scene.

To start of, here’s a list of apps I use:

  • WAMP – This basically has everything you need to get started; it also included some extensions you may find useful like XDebug.
  • Node.js – I primarily use this as a command line interface for the tools I use like Bower and Grunt.
  • Sublime Text – this is the best text editor I’ve used. It’s free to try but you can buy it if you like it.

Setting things up is pretty straight forward for WAMP and Node.js, configuration will be subjective so I’ll leave that to your personal preferences. Node.js already comes with npm.  so you can jump right into installing Grunt and Bower via the Node.js CLI (Command Line Interface). You can also use npm in other development environments like Phonegap apps.

If you’re on Windows like me, you will need to install GIT for Windows to get Bower working properly.  You can also use this tool to manage your repositories if you have any.

image

After installing git you will need to add the installation path to your PATH Environment Variable, which is typically located in C:Program Files (x86)Gitcmd. You may have to restart your system for the changes to take effect.

Once you’re done with that you can turn your attention to Sublime Text. I like the simplicity versatility and light foot print it has over other text editors. Like npm it also has a a package manager called Package Control you can use to add more functionality to it. You will need to enable this by opening the Sublime Text console (Control + `) and paste the code below. For detailed instructions you can visit the installation guide.

Sublime Text 3

Sublime Text 2

After that you will see the Package Control menu by going to Preferences > Package Control.

Signing Android apps on Phonegap for release

You will need to digitally sign your apps for release if you want to install them on your device for live testing. If not you will get a parse error when installing.

image

We will need to use the keytool from the JDK to create a key we can use to sign our apps whenever we build them (be sure you already added the JDK path to your Environment Variables before proceeding). To do this open your command prompt and navigate to your project folder. Once there enter the command below:

You will need to change the values in angle brackets (<>). Once you enter the command, answer the questions asked. Remember to take note of the passwords you enter, you will need that in a bit. When you are done you will see a .keystore file on your project folder.

Now create an ant.properties file in your <PROJECT-PATH>platformandroid folder with the following contents:

Note the double slash () between folder paths.

Now you can build your Phonegap/Cordova app for release with the following command.

phonegap setup guide for android on Windows

This is a short guide on how to setup a working and testing environment for either native or Phonegap/Cordova based Android app development on a Windows machine.

NOTE: the versions of the software I list here are the current versions available  as of this article’s posting, or my personal preference.

To get you on your merry way of building android apps via Phonegap on Windows 8/8.1 you’ll be needing the following software:

Now we set things up one at a time…

Java SDK

Install the JDK first since it is required by both the Android Studio and Apache-Ant. After installing take note of the installation folder which is typically in C:Program FilesJavajre7, we will be appending this to our PATH environment variable later on. We will need this to access the Java keytool for signing our apps.

Android Studio

After installing this in your preferred settings open the SDK Manager and check the tools you’ll need. This is dependent on which version of android you plan to support; also make sure to select ARM-EABI System image for each version of android you on using. If your system supports Intel Virtualization be sure to check Intel x86 Emulator Accelerator as well. Now that you’re done click on Install Packages.

image

While that’s downloading we will setup paths. Navigate to System Properties (you can search system environment in Windows 8 to open the dialog) then click on Environment Variables. Once there we will be adding some variables, you may choose to either add it globally or for the current user.

image

Add the variable ANDROID_HOME with value of the SDK path found in the SDK Manager dialog (see the image up top). After that you’ll want edit the PATH variable and append the path to Android’s tools and platform-tools folder like so (note the semi-colon as the separator)

Notice the ANT_HOME variable? to save time we will segue a bit and set this up now. Simply extract the apache-ant archive to your preferred location, this will be the value of the ANT_HOME variable (e.g.C:apache-ant-1.9.4).

We also added the the bin folder location of our Java SDK which is in the installation directory we noted earlier.

That’s it! Just remember that we also appended the %ANT_HOME%bin to the PATH variable as well.

Before proceeding any further open your commend prompt and test to see if the paths are properly set by echoing each variable you added/changed (e.g. echo %ANDROID_HOME%). You may have to restart your system for the variables to take effect. You may also try the “ant -diagnostics” command without quotes to see if the paths for it are correct. You may encounter an error like Unable to locate tools.jar. which you can ignore.

Assuming that the packages are done downloading and installed. If your system supports Intel Virtualization (VT-x, VT-d). proceed to your Android SDK folder then look for the Intel x86 Emulator Accelerator which is typically in extraIntelHardware_Accelerated_Execution_Managerintelhaxm-android.exe and install it manually.

If you are getting errors during installing despite having support for Virtualization:

  1. check if you are running Hyper-V (a Windows 8 Pro feature) and disable it in the control panel.
  2. if you are running Avast, navigate to Setting > Troubleshooting then uncheck Enable Assisted Hardware Acceleration.
image

Now proceed to Tools > Android > AVD Manager (Android Virtual Device) in Android Studio and ad a virtual device for testing. For the System Image setting it is much faster to use the x86/x86_x64 if your system supports Virtualization; if not choose the ARMEABI albeit really slow.

image

Node.js and Phonegap

After installing Node.js locate and open the Node.js command prompt shortcut then install phonegap and cordova by executing the commands below. This will download and install the latest versions of the packages.

once that is done, you can now start building and testing phonegap apps.

Phonegap Build caveat

There is also a Phonegap build service you may use for free.Simply supply your html files in zip format from either  a public repository or by uploading them to their servers and in turn will supply you with a compiled app for the platforms you choose.

The disadvantage being that you will have to upload files every time you want to rebuild/debug the source. It doesn’t not provide emulation or testing environment either; So what ever time you save skipping the setup of your development environment will be negated sooner than later when you start to test.