Universal SMS Archiver

May 13, 2016 Leave a comment

Users who have been using Android devices will swear by SMS Backup and Restore to backup their SMS, while iOS users have iTunes backup. While these works, one issue with such software is that you generally do not want to keep or transfer all of your old SMS into the new device.

Introducing Universal SMS Archiver!

  • It is a desktop app that runs on Windows, and has the ability to automatically import your SMS from iTunes and SMS Backup and Restore files.
  • You can also manage the entire list of SMS into a current as well as archived list.
  • It has the ability to export your current sms list into Excel for further processing

image

The latest executable can be downloaded at https://onedrive.live.com/redir?resid=895931B65435BB3D!30467&authkey=!AG-VaHLPBh10qLg&ithint=file%2czip

Source code can be found at https://github.com/kwanann/Hobbies/tree/master/Universal%20SMS%20Archiver

InvoicePlane–Enabling Date Parameters

February 25, 2016 Leave a comment

Sometimes it is necessary to include some form of dates in either the item or the item description for InvoicePlane.

In order to do so, you will need to edit 3 files

application\helpers\pdf_helper.php

search for function generate_invoice_pdf

and replace

$data = array(
        ‘invoice’ => $invoice,
        ‘invoice_tax_rates’ => $CI->mdl_invoice_tax_rates->where(‘invoice_id’, $invoice_id)->get()->result(),
          ‘items’ => $CI->mdl_items->get_items_and_replace_vars($invoice_id, $invoice->invoice_date_due),
        ‘payment_method’ => $payment_method,
        ‘output_type’ => ‘pdf’
    );

 

application\modules\guest\controllers\view.php

search for  public function invoice

$data = array(
                ‘invoice’ => $invoice,
                     ‘items’ => $this->mdl_items->get_items_and_replace_vars($invoice->invoice_id, $invoice->invoice_date_due),
                ‘invoice_tax_rates’ => $this->mdl_invoice_tax_rates->where(‘invoice_id’, $invoice->invoice_id)->get()->result(),
                ‘invoice_url_key’ => $invoice_url_key,
                ‘flash_message’ => $this->session->flashdata(‘flash_message’),
                ‘payment_method’ => $payment_method
            );

 

application\modules\invoices\models\mdl_items.php

add the following function to Mdl_Items class

public function get_items_and_replace_vars($invoice_id, $invoice_date_created = ‘now’)
     {
         $items = array();
         $query = $this->where(‘invoice_id’, $invoice_id)->get();

         foreach($query->result() as $item) {
             $item->item_name = $this->parse_item($item->item_name, $invoice_date_created);
             $item->item_description = $this->parse_item($item->item_description, $invoice_date_created);
             $items[] = $item;
         }
         return $items;
     }

 

 

Now you can do things like

Support and maintenance for {{{Month}}} {{{Year}}}

 

which will then appear as

image

Categories: Invoice Plane

Dependency Injection in ASPNET VNext (RC1)

February 23, 2016 Leave a comment

This article will document how to do dependency injection for vNext

1. Create the class to be injected (https://gist.github.com/kwanann/a0363add23870a949334)

image

2. Configure startup.cs (https://gist.github.com/kwanann/7bced8e22fec229bd0be)

image

There are 4 methods of adding to services

AddTransient: It will create a new instance each time it is accessed. e.g when I call it from the MVC Controller and from frontend MVC code, I will get 2 independent instances

AddScoped: It will create a new instance for the particular request, e.g when I call it from MVC Controller and frontend MVC Code, it’s the same instance. However it does not survive across different OWIN middleware

AddSingleton: Creates a single instance for all requests

AddInstance: Creates a single instance for all requests, but the constructor is left to the developer

3. If you need to call it from within the MVC Controller (https://gist.github.com/kwanann/c987314e0eecdab20a7b)

image

Inject the interface you need into the constructor and then assign it to a local variable. You may then use it however you wish

Categories: 5.0, ASP.NET, vNext

Microsoft Team Foundation Server–Undoing checkout for a workspace that no longer exists

February 2, 2016 1 comment

Every once in a while, you get a request from your developer telling you that they have reformatted their machine and unfortunately there is still one or 2 files inside that workspace that they forgot to checkout

Visual studio comes with tools that allows you to undo checkout. Unfortunately it runs from the CLI

  1. Goto the visual studio folder
    cd “C:\Program Files (x86)\Microsoft Visual Studio 14.0”
  2. List workspaces of the user
    tf workspaces /collection:http://mytfsserver:8080/tfs/defaultcollection /owner:JohnDoe

    Collection: http://mytfsserver:8080/tfs/defaultcollection
    Workspace Owner          Computer  Comment
    ——— ————– ——— ————————————————————————————
    JD-PC JohnDoe JD-PC
    JD-PC2     JohnDoe JD-PC2
    JD-PC3    JohnDoe JD-PC3

  3. Figure out which workspace contains the file to undo and fire up the undo command

    tf undo /workspace:JD-PC2;JohnDoe /s:http://mytfsserver:8080/tfs $/Path/To/The/File.cs

if it works, you will get the following reply:

The operation completed successfully.  Because the workspace JD-PC2;JohnDoe is not on this computer, you must perform a separate get operation in that workspace to update it with the changes that have been made on the server.

Easy way to IMAP sync 2 mailboxes

February 2, 2016 Leave a comment

Linux has a great tool to sync 2 different mailboxes, this is especially useful when you need to migrate from one mailbox to another

  1. First install imapsync
  2. Then run the following command

imapsync –host1 –user1 –password1 –host2 [destination server] –user2 [destination email] –password2 [destination password]

Categories: CentOS, Open Source, Ubuntu

Selenium WebDriver – Element is not clickable at point

February 2, 2016 Leave a comment

Selenium is a fantastic tool for website automation, you simply nuget it into your .NET project and you will be able to use it to automate testing using Firefox

Nuget link: https://www.nuget.org/packages/Selenium.WebDriver

 

However, if you are upgrading from versions < 2.48 to the latest version, you will realize that a lot of your codes will suddenly throw the following error

OpenQA.Selenium.WebDriverException: Unexpected error. Element is not clickable at point (x, y). Other element would receive the click:

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)

 

This is due to the way Selenium handles Mouse Clicks from version 2.48 onwards, version 2.50 is the currently “safer” version to use

https://github.com/SeleniumHQ/selenium/issues/1202

image

 

Of course all of these does not fix the issues you have with the code, here are some possible ways to fix them

#1: Use SendKeys

SendKeys automatically focuses to the element that it needs to send keys to, however this is restricted to input elements

e.g Element.SendKeys(Keys.Escape)

 

#2 Use MoveToElement

MoveToElement is another way to move focus to the element.

e.g new OpenQA.Selenium.Interactions.Actions(driver).MoveToElement(elem).Perform();

#3 Use Javascript

Javascript allows you to pretty much do anything

e.g. ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(" + elem.Location.X + "," + elem.Location.Y + ")")

 

#4 Use ScrollIntoView

ScrollIntoView is another  possible javascript that you can use

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);

ASP.NET vNext – EntityFramework 7.0 Database First (RC1)

February 2, 2016 Leave a comment

This is the updated version using RC1 for https://jefferytay.wordpress.com/2015/11/04/asp-net-vnext-entityframework-7-0-database-first/

Changes from beta8 are colored in red

EF 7.0 supports both code first aka POCO as well as database first. However you do need a bit of tweaking in order to get EF to generate the classes for you. Take note that edmx files are no longer used for EF 7.0.

Step by step guide
  • Starting with a blank project, add the following dependencies

"EntityFramework.Commands": "7.0.0-rc1-final",
  "EntityFramework.Core": "7.0.0-rc1-final",
  "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
  "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",

Which should make your dependencies look like this

image

  • Visual Studio 2015 should then run nuget in the background to obtain the new libraries. Once that is done, your dependencies list in VS should show the RC1 libraries

You will also need to add the following item into your list of commands

    "ef": "EntityFramework.Commands"

Which will then make your commands list look like

image

  • Now you need to run a command prompt and browse to the project directory, and then run the following command, replacing the brackets with actual data

dnx ef dbcontext scaffold –c [DBContextName] –o [Output folder] [SQLConnection string] EntityFramework.SqlServer

e.g

dnx ef dbcontext scaffold -c TestDbContext -o Models "Data Source=.; Initial Catalog=Test;User ID=myusername;Password=P@ssw0rd"  EntityFramework.MicrosoftSqlServer

image

Common errors that you will typically encounter when you see “One or more errors occurred.”:

Take note that the stack trace is VERY long, so you will need to scroll right to the front to see the error message

System.AggregateException: One or more errors occurred. —>Microsoft.Data.Entity.Design.OperationException: Unable to find design-time provider assembly. Please install the EntityFramework.SqlServer.Design NuGet package and ensure that the package is referenced by the project. —> System.IO.FileNotFoundException: Could not load file or assembly ‘EntityFramework.SqlServer.Design’ or one of its dependencies. The system cannot find the file specified.

-> this means project.json does not have the EntityFramework.SqlServer.Design, save the project file and do a dnu restore to ensure that all the packages are restored

System.AggregateException: One or more errors occurred. —>System.Data.SqlClient.SqlException: Login failed for user ‘myusername’.

-> obvious, means you entered the wrong password or are connecting to the wrong database server

Follow

Get every new post delivered to your Inbox.