Tuesday, April 5, 2016

I have been using iTextSharp to merge multiple PDF files

A few years ago, I was wondering if there was any easy way to merge my PDF files all together into one single file. I knew there were a few commercial products out there, but I wanted something letting me handle the page number freely.

That was the reason why I developed this PDF_MergeFiles using iTextSharp, an opensource .NET library.  I am sure iTextSharp has added many new features since then, but I here post my codes hoping they will be useful to you.

public static void PDF_MergeFiles(string targetFile, string[] sourceFiles,
int pageFrom = 1)

  targetFile = a target file name with a full path  (C:\temp\myFile.pdf)
  sourceFiles = must be provided as an array of string, each file name with a full path
  pageFrom = 1, the target file will have a page number from the first page 

Place two source files in your project to consume these static methods. Also, iTextSharp DLL files must be part of your project too.

All files can be found from here at my git repositories, risknet.

Tuesday, March 29, 2016

eileensnotes in GitHub & going back to BootStrap

For my first Ruby on Rails applicaiton, eileensnotes, this Zurb Foundation web UI simply worked great.

After trying and playing with other tools and gems for my new projects, I have decided to go back to Bootstrap 3 and Simple Form for Ruby on Rails application.

Therefore, I will gradually update healthrecord.com and eileensnotes.com to use a new version of Bootstrap.

Also, as I promised before, I just opened a complete set of source codes for eileensnotes.com and they are accessible as of today from my github repository.

I will keep you posted.

Sunday, March 27, 2016

I am back!

Dear my online friends,

I am finally back!

It's been a while since I posted the last article onto this blog, but I am finally back to restart sharing with you my knowledge and what I have learned from the field.

As always, I will greatly appreciate it you leave any comments or feedback for any posts. Also, please feel free to ask any questions in public/private and I will do my best to post my answers onto this site. From now on, I will actively use github to share my source code of any modules that might be more useful to you too.

For anyone who is learning Ruby on Rails, I am about to share my source code for eileensnotes and will post all files into my github account. This was my first Rails' application when I was learning RoR version 2. I am sure you will clone the site in a much better way.

Let's try to get together online often here again!

Thank you

Monday, December 29, 2014

Where do you keep your health record?

I have been using my own web application, healthrecordhub.com 

This web application was originally developed solely for my own needs to keep my blood pressure readings along with my daily exercise activities. As I used it on a daily basis, I asked myself one day. "Why not have all of my key health records in my site?" Since I had some health issues to control on a daily basis, logging my activities and checking them from time to time have been an important part of my daily routine.

Please try and share your thoughts or comments with me. I will continue to enhance the site and application to benefit all users.

It is easy to use and simply makes sense.  See some screenshots from the site.

Log Your Daily Blood Pressure

Daily Average on Blood Pressure

Daily Average on Weight

Log Your Prescription

Log Other Test (Dental / Kidney / Head & Neck / etc)

Thursday, September 4, 2014

EileensNotes - supporting a private answer

Another new feature for Questions and Answers in EileensNotes is enabling user to answer any question privately. It means that only the user who asked a question will see any private answers going forward.  If you are a tutor or teacher and want to privately answer to any question posted by your students, then this is the feature you will need to use when answering a question.

(Fig 1. You can now post a private answer to any question)

Thursday, April 10, 2014

EileensNotes - major changes will be introduced

In April, a major change for EileensNotes will be introduced.  This will include the upgrade in infrastructure , some cosmetic changes in layout and a few functional changes.

In fact, the new layout and color schemes have been already applied to current version of EileensNotes.
EileensNotes is now using much lighter layout and more organized user interface for easier access to all features from any screen.

( Fig. 1 - EileensNotes use smaller but clearer fonts in all screens )

( Fig. 2 - Popular tags are displayed on top of screen along with a search box )

One noticeable change I have made to EileensNotes is to use smaller and clearer fonts in every user interface screen along with different colored labels.  Also, the navigation top bar has a new color scheme as well.

The other change that's useful for all users is that I have placed popular tags along with a search box on top of Q&A and Advertisements pages.  This will help users quickly access or search any information.

Another new feature for Questions and Answers, which will be introduced shortly, is enabling user to answer any question privately. It means that only the user who asked a question will see any private answers going forward.  If you are a tutor or teacher and want to privately answer to any question posted by your students, then this is the feature you will need to use when answering a question.

EileensNotes is working hard to provide a better tool to all students and learners, and I will continue to do work hard for my kids and students to achieve their academic goals.

Friday, November 22, 2013

Upgrading EileensNotes to Rails 4 + DEVISE

My personal project, EileensNotes, has been running on Rails 3 + Ruby 1.9.3 (with Nginx and Passenger) with no issues since its launch.

Recently, I started to study all new great features introduced in Ruby on Rails 4 and decided to upgrade EileensNotes to the new version as well.   So, here I'd like to share with you on what I have done when upgrading to Rails 4.

This is one of series that I will continue to post, so please feel free to ask any questions related to Rails 4 upgrade.  I updated my gem file to ensure that all of my gems support Rails 4.0.0.

DEVISE - one of my core user account management gem

To simply test if my "user login" works ok on Rails 4, I performed the following basic tests manually on my test platform.

  1. Create a new user
  2. Reset my password
  3. Update my account

Before I tested "creating a new user by using SIGN UP," this was the first thing I had to add to application.rb in controller directory.  Take a look at your user model carefully that you created for DEVISE, and you need to update the following protected procedure accordingly.

before_action :configure_permitted_parameters, if: :devise_controller?


# updated to support Rails 4
# secure parameters and permit only these parameters from form for DEVISE

def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password, :remember_me) }
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation) }
    devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :name, :password, :password_confirmation, :current_password) }

Ok. After my updating application.rb, the "Sign Up" worked and I had to confirm if my email address was valid.  Since I did not use any local "smtp" or "email emulator" in my development platform, I simply opened a development.log file to search for the body of confirmation email.  I had set up my mailer for DEVISE so that it sent an email having the confirmation token.

I simply copied the confirmation token (URL) and pasted it in my web browser to validate user email address.  This was supposed to simply work, but there was an error so my email couldn't be validated.
There is one change DEVISE made in its new version for Rails 4, and this was what I had to change accordingly to make it work.

There were three places where this change needed to be applied, and they were all in "mailer" for DEVISE.  So, simply search for these three url commands in DEVISE mailer directory and change yours accordingly with bold faced variable name.

confirmation_url(@resource, :confirmation_token => @token) %>
unlock_url(@resource, :unlock_token => @token
edit_password_url(@resource, :reset_password_token => @token)

Now, the URL with a confirmation token should work.
So, I manually deleted a new user from my user table and signed up again.  This time, it looked like the confirmation token URL looked slightly different with a shorter format.
The validation worked with no issue after applying those changes mentioned above.

To ensure @token was the right variable, I performed the following two more tests manually.

  • Resetting a password
  • Updating my password
  • Updating my user account

So far, all sign up/sign in/edit account/reset password worked with no issue.
I was able to log in to EileensNotes test platform and could continue to test rest pieces inside the application.

DEVISE was my main core "user management" gem I chose without any hesitation as it was being widely used in Rails community, and I was always able to get updates from GitHub for changes and additional document.

But, recently, I had chance to read a new book called "Learning Devise for Rails" published by PACKT and I think this is a great extra resource to all Rails developers who currently use/or will use a DEVISE.

Having a set of core Rails books beside you always will make you feel secured.

This is my first series of "Upgrading to Rails 4" and I hope that I helped someone with this blog today.