Android App Release: SetNote – Note Taking Simplified

SetNote has been released on Google Play.

setnoteiconOperating system
Android 4.2+

Development environment
Xubuntu
Intel XDK
PhoneGap
Android SDK
jQuery & jQuery Mobile
PhoneGap Build

Testing device
OnePlus One

Status
Released

The application
Developed under the name SetNote, this application consists of a digital notebook, in which you can save information as notes and send them to other people via email. The native device email clients are utilized for this functionality, so you can choose your daily driver without any hassle.

SetNote was developed using PhoneGap and jQuery Mobile as hybrid single-page application, and it makes use of HTML5 local storage in order to store notes in device storage. SetNote doesn’t currently offer cloud backup. While developed mainly for phones, the app should also work well on tablets.

HTML5 local storage, which is extensively used by SetNote, has had issues with Android Lollipop 5.1 in regards to the stored content actually staying in storage. It’s probably not such a common issue, but it should considered when using Android 5.1 or newer.

Android app on Google Play

Background
I’m publishing SetNote under the GNU General Public License (version 3) as a part of my thesis, in which I examined the benefits of PhoneGap and the techniques enabled by it in terms of hybrid Android application development.

Screenshots
Screenshot_2015-05-04-00-08-31Screenshot_2015-05-03-17-14-53Screenshot_2015-05-03-17-12-07

Screenshot_2015-05-03-17-11-47Screenshot_2015-05-03-17-11-31Screenshot_2015-05-03-17-10-25

Screenshot_2015-05-03-17-10-13Screenshot_2015-05-03-17-08-42Screenshot_2015-05-03-17-07-49

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html

Arduino Prototyping – Task 7: Final Course Project

Course
Prototyyping rakentaminen [Building a prototype] by Tero Karvinen at Haaga-Helia University of Applied Sciences

Task
Build the planned course project and perform a demonstration of it to the class on 17/3/2014.

Testing environment
OS: Xubuntu Linux 13.10 “Saucy Salamander” 32-bit (persistent live USB drive)
System: HP EliteBook 2570p Notebook PC
Development Tools Setup

Used components
1x Arduino Uno
1x breadboard
jumper wires
1x green LED
2x HY-SRF05 ultrasonic sensors
1x USB A to B cable

Project: ultrasonic distance meter and centering tool
I built a tool for measuring distances and pinpointing the center point between two objects or surfaces via the use of ultrasonic sensors, Arduino Uno, and other components (see the full list above under “Used components”). The uses for the project could include things like construction work and home renovation.

The distance is measured by two ultrasonic sensors. Finding the center spot is indicated by a green LED activating, once each of the two ultrasonic sensors return the same value (in centimeters). You can find the code and screenshots of the Arduino software and serial monitor on Linux below.

Source code:

const int trigPinRight = 11;
const int echoPinRight = 12;
const int trigPinLeft = 9;
const int echoPinLeft = 10;
const int ledPin = 13;

long durationRight, cmRight;
long durationLeft, cmLeft;
 
void setup() {
    Serial.begin (9600);
    pinMode(trigPinRight, OUTPUT);
    pinMode(echoPinRight, INPUT);
    pinMode(trigPinLeft, OUTPUT);
    pinMode(echoPinLeft, INPUT);
    pinMode(ledPin, OUTPUT);
}
 
void loop() {
    digitalWrite(trigPinRight, LOW);
        delayMicroseconds(5);
    digitalWrite(trigPinRight, HIGH);
        delayMicroseconds(10);
    digitalWrite(trigPinRight, LOW);
    
    durationRight = pulseIn(echoPinRight, HIGH);
    cmRight = (durationRight/2) / 29.1;
    
    digitalWrite(trigPinLeft, LOW);
        delayMicroseconds(5);
    digitalWrite(trigPinLeft, HIGH);
        delayMicroseconds(10);
    digitalWrite(trigPinLeft, LOW);
    
    durationLeft = pulseIn(echoPinLeft, HIGH);
    cmLeft = (durationLeft/2) / 29.1;
 
    Serial.print(cmRight);
    Serial.print("cm - Right side");
    Serial.println();
    delay(800);                       //ms
    Serial.print(cmLeft);
    Serial.print("cm - Left side");
    Serial.println();
    
    if (cmRight == cmLeft) {
      digitalWrite(ledPin, HIGH);
    }
    else {
      digitalWrite(ledPin, LOW);
    }
 
    delay(800);                       //ms
}

FinalProjectArduino

Arduino setup
The red jumper wire runs from the 5V socket on the Arduino Uno board to the Vcc pin of the ultrasonic sensor facing the camera. The black jumper wire runs from the GND socket on the Arduino Uno board to the GND pin of the ultrasonic sensor facing the camera. The yellow jumper wire (echoPinRight) runs from digital pin 12 to the Echo pin of the ultrasonic sensor facing the camera. The blue jumper wire (trigPinRight) runs from digital pin 11 to the Trig pin of the ultrasonic sensor facing the camera.

The white jumper wire (echoPinLeft) on the Arduino Uno board runs from digital pin 10 to the Echo pin of the ultrasonic sensor facing away from the camera. The green jumper wire (trigPinLeft) runs from digital pin 9 to the Trig pin of the ultrasonic sensor facing away from the camera.

The other white jumper wire runs from the 5V jumper wire (red) on the breadboard to the Vcc pin of the ultrasonic sensor facing away from the camera. The grey jumper wire runs from the GND jumper wire (black) on the breadboard to the GND pin of the ultrasonic sensor facing away from the camera.

The green LED is set to digital pin 13 and GND on the Arduino Uno board, observing polarity. The longer lead is the positive (Anode) lead, while the shorter lead is the negative (Cathode) one.

FinalArduinoSetup

References
Arduino Reference (http://arduino.cc/en/Reference/HomePage)
Arduino Playground, Ultrasonic Sensor (http://playground.arduino.cc/Main/UltrasonicSensor)
Karvinen, Tero; Karvinen, Kimmo: Make: Arduino Bots and Gadgets (http://botbook.com/)
Karvinen, Tero: Lessons 2014-3-3, Prototyypin rakentaminen [Building a prototype] (http://terokarvinen.com/2013/aikataulu-%E2%80%93-prototyypin-rakentaminen-bus4tn007-5-alkukevat-2014)

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html
Based on a course by Tero Karvinen, http://www.iki.fi/karvinen

Linux Server – Task 7: Optimization and Varnish

Course
Linux palvelimena [Linux server] by Tero Karvinen at Haaga-Helia University of Applied Sciences

Task
Measure the speed difference between a local computer WordPress page and a similar static page with the ‘ab’ tool. Install Varnish (an HTTP acceleration tool) – measure the performance of a dynamic web page before and after the installation to gain data about the possible improvements.

Testing environment
OS: Xubuntu Linux 13.10 “Saucy Salamander” 32-bit (persistent live USB drive)
System: HP EliteBook 2570p Notebook PC

Preparing the installation environment
LAMP and WordPress have been installed.

Web server performance
I began testing the performance with Apache’s own benchmarking tool, which I started by entering the following in the terminal emulator (in the command -c means the number of clients, and -n the sent number of requests):

$ ab -c 200 -n 300 http://localhost/~xubuntu/jannevaris.com/|grep -P ‘Failed|#/sec|50%|100%|Length’

The results were as follows:
terminal1

The command prints an answer, where the size of the document, the number of failed requests, and the number of requests per second.

Next I ran the same command for one of my local WordPress page’s articles:

$ ab -c 200 -n 300 http://localhost/~xubuntu/jannevaris.com/?p=2/|grep -P ‘Failed|#/sec|50%|100%|Length’

The results were similar:

terminal

After this I tested a similar static page. First I created a new folder under the public_html folder named “statictest” with $ mkdir statictest. I created an index.html file in the folder with $ nano index.html, to which I copied the source code of my local WordPress’s front page. Then I saved the changes.

To finish the testing, I ran the same command for the static page:

$ ab -c 200 -n 300 http://localhost/~xubuntu/statictest/index.html/|grep -P ‘Failed|#/sec|50%|100%|Length’

The results showed that the page worked slightly faster when it was static:

terminal2

Installing Varnish
I installed Varnish with $ sudo apt-get install varnish. After the installation I had to set Varnish to listen to port 80, so I navigated to /etc/default/ with $ cd /etc/default/, and edited the necessary file with $ sudoedit varnish, so that the Alternative 2 part looked like this:

## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request.
#
DAEMON_OPTS=”-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m”

Then I saved the changes. After this I edited Apache’s port settings by navigating to /etc/apache2/ with $ cd /etc/apache2/, and editing ports.conf with $ sudoedit ports.conf. On the “Listen” line, I changed the port to 8080 and saved the changes.

After this I restarted Apache and Varnish with $ sudo service apache2 restart and $ sudo service varnish restart.

Next I compared the results before and after installing Varnish. I ran the following commands again:

$ ab -c 200 -n 300 http://localhost/~xubuntu/jannevaris.com/|grep -P ‘Failed|#/sec|50%|100%|Length’

$ ab -c 200 -n 300 http://localhost/~xubuntu/jannevaris.com/?p=2/|grep -P ‘Failed|#/sec|50%|100%|Length’

The results show that the requests now happen faster, from which we can determine that the pages have better performance after installing Varnish.

terminal3

terminal4

YSlow and Firebug analysis and offered improvements
Yahoo!’s page performance tool YSlow graded the local WordPress front page as A, with an overall performance score of 92. The only features not graded A were:

Grade E on Use a Content Delivery Network (CDN)

There are 5 static components that are not on CDN.

You can specify CDN hostnames in your preferences. See YSlow FAQ for details.

Grade F on Add Expires headers

There are 6 static components without a far-future expiration date.

Firebug’s Net panel came up with no improvement suggestions.

References
WordPress Codex (http://codex.wordpress.org/)
Karvinen, Tero: Lessons 2014-3-10, Linux palvelimena [Linux server] (http://terokarvinen.com/2013/aikataulu-%E2%80%93-linux-palvelimena-ict4tn003-11-ja-12-kevaalla-2014)

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html
Based on a course by Tero Karvinen, http://www.iki.fi/karvinen

Arduino Prototyping – Task 6: Reading Input, Sending Commands

Course
Prototyyping rakentaminen [Building a prototype] by Tero Karvinen at Haaga-Helia University of Applied Sciences

Task
Practice reading Arduino sensor inputs and sending commands via the serial monitor in the Arduino software kit.

Testing environment
OS: Xubuntu Linux 13.10 “Saucy Salamander” 32-bit (persistent live USB drive)
System: HP EliteBook 2570p Notebook PC
Development Tools Setup

Used components
1x Arduino Uno
1x breadboard
4x jumper wires, black, red, orange, green
1x ultrasonic sensor HY-SRF05
1x USB A to B cable

Reading inputs
I practiced reading Arduino inputs with the Ultrasonic Distance Meter project that I had completed previously. I successfully assembled the project again, this time using a different ultrasonic sensor (HY-SRF05), and didn’t encounter any problems. I was able to get the distance readings to display accurately in the serial monitor.

Sending commands
I decided to test turning an LED on and off by sending commands to my Arduino Uno via the serial monitor. The setup used a single LED connected to digital pin 13 and GND on the Arduino Uno board. I used 1 and 0 as the variable states for on and off. I didn’t encounter any issues and was able to turn the LED on and off by entering either 1 or 0 in the serial monitor. You can find the code and a screenshot below.

char pwr = '1';
int ledPin = 13;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if( Serial.available()) {
    pwr = Serial.read();
    Serial.print("The power is: ");
    Serial.println(pwr);
  }
  if( pwr == '1' ) digitalWrite(ledPin, HIGH);
  if( pwr == '0' ) digitalWrite(ledPin, LOW);
  delay(500);                                       //ms
}

1

References
Arduino Reference (http://arduino.cc/en/Reference/HomePage)
Karvinen, Tero; Karvinen, Kimmo: Make: Arduino Bots and Gadgets (http://botbook.com/)
Karvinen, Tero: Lessons 2014-3-3, Prototyypin rakentaminen [Building a prototype] (http://terokarvinen.com/2013/aikataulu-%E2%80%93-prototyypin-rakentaminen-bus4tn007-5-alkukevat-2014)

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html
Based on a course by Tero Karvinen, http://www.iki.fi/karvinen

Linux Server – Task 6: Installing WordPress Et Al.

Course
Linux palvelimena [Linux server] by Tero Karvinen at Haaga-Helia University of Applied Sciences

Task
Install WordPress on top of LAMP (installed previously). Modify the WordPress installation to include selected four customizations from the task list.

Testing environment
OS: Xubuntu Linux 13.10 “Saucy Salamander” 32-bit (persistent live USB drive)
System: HP EliteBook 2570p Notebook PC

Preparing the installation environment
I had already installed LAMP previously using my own instructions (in Finnish). I had also enabled Apache name-based virtual hosting, so I was able to use a www address locally for testing purposes, instead of just typing localhost/~xubuntu/ in the Firefox address bar.

Creating a database for WordPress
I began by logging into the MySQL server monitor by entering $ mysql -u root -p in the terminal emulator. I then created a new database for WordPress with the proper privileges by entering the following command in the terminal prompt:

CREATE DATABASE wpxubuntu;
GRANT ALL PRIVILEGES ON wpxubuntu.* TO wpxubuntu@localhost IDENTIFIED BY "password";
FLUSH PRIVILEGES;

After this I exited the MySQL monitor by typing exit and hitting enter.

Installing WordPress
First I navigated to my www home folder (see Apache name-based virtual hosting) folder by entering $ cd /home/xubuntu/public_html/jannevaris.com in the terminal. Next I downloaded the WordPress tarball with $ wget https://wordpress.org/latest.tar.gz.

I extracted the tarball with $ tar -xf latest.tar.gz, and moved the files in the now-present wordpress folder to the jannevaris.com folder with $ mv wordpress/* ../jannevaris.com/. I then deleted the obsolete wordpress folder and the tarball with $ rm -r wordpress and $ rm latest.tar.gz.

1. I navigated to jannevaris.com in Firefox, and was presented with a page about creating a configuration file:

01

2. I clicked “Create a Configuration File” to move forward. An instruction page was presented:

02

3. I clicked “Let’s go!” to move forward. A database connection details page was presented:

03

4. I filled in the details and clicked “Submit”. A prompt page followed:

04

5. I needed to create a WP config file, so I copied the code from the Firefox page and switched back to the terminal emulator, and ran $ ls in the jannevaris.com folder – no configuration file existed yet, apart from a sample named wp-config-sample.php, which I renamed in to wp-config.php by entering $ mv wp-config-sample.php wp-config.php in the terminal.

I opened the file for editing with $ nano wp-config.php and deleted all the existing code, after which I pasted the copied code in the file. I saved the changes and returned to the Firefox page, clicking “Run the install” to move forward.

6. An information-needed page was presented:

05

7. I filled in the details and clicked the “Install WordPress” button at the end of the page. Success!

06

8. WordPress was now installed, and I could now move forwards to the login page:

07

9. Now I simply logged in and made a test post locally:

08

10. Task complete.

Enabling permalinks
First I navigated to Settings –> Permalinks in the local WP control panel, then I selected “Day and Name” and saved the changes. To complete the task, I still had to create a .htaccess file in the same folder as the rest of the WP files. I created the file with $ nano .htaccess, and added the code presented by WordPress in the Permalinks options:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Then I ran the following in the terminal:

$ sudo a2enmod rewrite
$ sudo service apache2 restart

After this the links worked correctly and looked cleaner, without any extra characters or markers.

Changing the theme
I navigated to the Appearance menu in the WP control panel and selected Themes. After this I changed the active theme to a theme named Twenty Twelve.

Enabling and adding images
Next I wanted to add images to my local WP test site, so I tried uploading one via Media –> Add New in the WordPress control panel. I received the following error:

“os_tux.png” has failed to upload due to an error
Unable to create directory wp-content/uploads/2014/03. Is its parent directory writable by the server?

Which meant that I didn’t have the necessary rights to the folder required the upload process. I fixed the issue by navigating to wp-content in the jannevaris.com folder by entering $ cd wp-content/ in the terminal, and then running $ mkdir uploads and $ chmod 777 uploads/. After this I was able to uploaded the images to my local WordPress installation without any problems, and also attach them to my test posts.

Backing up WordPress content
I made backups of the content via Tools –> Export in the WordPress control panel. Once in the Export menu, I selected “All Content” and then clicked the “Download Export File” button to download the backup file to local folder.

The file format is xml. This particular file was named janne039swordpresstest.wordpress.2014-03-10.xml.

References
WordPress Codex (http://codex.wordpress.org/)
Karvinen, Tero: Lessons 2014-3-3, Linux palvelimena [Linux server] (http://terokarvinen.com/2013/aikataulu-%E2%80%93-linux-palvelimena-ict4tn003-11-ja-12-kevaalla-2014)

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html
Based on a course by Tero Karvinen, http://www.iki.fi/karvinen

Arduino Prototyping – Task 5: Prototype Project Planning

Course
Prototyyping rakentaminen [Building a prototype] by Tero Karvinen at Haaga-Helia University of Applied Sciences

Task
The task was to start planning the final course prototype project based on previous brainstorming sessions, and then reserve an idea for my use on the course.
//Note: The idea was changed on 13/3/2014
//Post edited

Project: Distance Meter and Centering Tool
I decided to attempt building a tool for measuring distances and pinpointing the center position between two objects or surfaces via the use of ultrasonic sensors. The uses could include things like construction work and home renovation.

The distance would be measured by two ultrasonic sensors. Finding the center spot would be indicated by an LED activating, once each of the two ultrasonic sensors returned the same value (centimeters).

Required components
1x Arduino Uno
1x breadboard
jumper wires
1x LED
2x ultrasonic sensors
1x USB A to B cable

References
Arduino Reference (http://arduino.cc/en/Reference/HomePage)
Arduino Playground, Ultrasonic Sensor (http://playground.arduino.cc/Main/UltrasonicSensor)
Karvinen, Tero; Karvinen, Kimmo: Make: Arduino Bots and Gadgets (http://botbook.com/)
Karvinen, Tero: Lessons 2014-2-24, Prototyypin rakentaminen [Building a prototype] (http://terokarvinen.com/2013/aikataulu-%E2%80%93-prototyypin-rakentaminen-bus4tn007-5-alkukevat-2014)

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html
Based on a course by Tero Karvinen, http://www.iki.fi/karvinen

Linux Server – Task 5: Apache Name-Based Virtual Hosting

Course
Linux palvelimena [Linux server] by Tero Karvinen at Haaga-Helia University of Applied Sciences

Task
Get name-based virtual hosting working with Apache. Try a virtual private server (VPS) – get it from Amazon, Linode, DigitalOcean, or another similar internet hosting service.

Testing environment
OS: Xubuntu Linux 13.10 “Saucy Salamander” 32-bit (persistent live USB drive)
System: HP EliteBook 2570p Notebook PC

Apache name-based virtual hosting test
I already had Apache (and LAMP) already installed, so I skipped that part this time (instructions on how to install LAMP (in Finnish)).

I had enabled and tested creating and navigating personal web pages with LAMP before (in English) as well, so I merely checked that they were still working by typing in localhost/~xubuntu/index.html in Firefox. Success.

I then created a folder named jannevaris.com in my public_html folder in my home directory, and moved the aforementioned index.html file in it with $ mv index.html jannevaris.com. I navigated to /etc/apache2/sites-available by typing $ cd /etc/apache2/sites-available in the terminal, and created a new config file there with $ sudoedit jannevaris.conf. I added the following lines to the file and saved the changes:

<VirtualHost *:80>
    ServerName www.jannevaris.com
    ServerAlias jannevaris.com
    DocumentRoot /home/xubuntu/public_html/jannevaris.com
</VirtualHost>

After this I enabled the site by entering $ sudo a2ensite jannevaris.conf, and restarted the Apache daemon with $ sudo service apache2 reload. Next I navigated to /etc via $ cd /etc, and edited the hosts file with $ sudoedit hosts. I added my computer’s ip address alongside the desired virtual hosting addresses defined earlier:

127.0.0.1 localhost
127.0.1.1 xubuntu
my-ip www.jannevaris.com
my-ip jannevaris.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

After this I tested the changes by entering jannevaris.com in Firefox, and the previously mentioned index.html successfully loaded.

References
VirtualHost Examples (http://httpd.apache.org/docs/2.2/vhosts/examples.html)
Karvinen, Tero: Lessons 2014-2-24, Linux palvelimena [Linux server] (http://terokarvinen.com/2013/aikataulu-%E2%80%93-linux-palvelimena-ict4tn003-11-ja-12-kevaalla-2014)

About
This document can be copied and edited according to the GNU General Public License (version 3 or newer). http://www.gnu.org/licenses/gpl.html
Based on a course by Tero Karvinen, http://www.iki.fi/karvinen

Create your own website, free on WordPress.com.Create your own website.
Start free