Chinh Dohttp://www.chinhdo.com
Chinh's not quite random thoughts on software development, .NET, gadgets, and other things.Mon, 14 Dec 2015 21:57:31 +0000en-UShourly1https://wordpress.org/?v=4.4.1037.661647-77.526326ChinhDohttps://feedburner.google.comSubscribe with My Yahoo!Subscribe with NewsGatorSubscribe with My AOLSubscribe with BloglinesSubscribe with NetvibesSubscribe with GoogleSubscribe with PageflakesHow to get free 2 GB of data on each line for Life on Verizon Wireless for about $40http://feedproxy.google.com/~r/ChinhDo/~3/ljQ1tiwroNs/
http://www.chinhdo.com/20151214/how-to-get-free-2-gb-of-data-on-each-line-for-life-on-verizon-wireless-for-about-40/#commentsMon, 14 Dec 2015 21:57:31 +0000http://www.chinhdo.com/?p=610Verizon Wireless is running a promo until 1/6/2016, that will give you 2 GB of free data for life if you are on an XL plan or larger, and you upgrade an existing device or add a new device.

Here’s how to you can take advantage of this promo and add the 2 GB of bonus data per line for life by spending about $50, even if you don’t have an upgrade available. To me, $40 for 2 GB of data per month for life is more than worth it.

Here’s how:

“Upgrade” your device to the cheapest smartphone available. Right now for me it would be the Droid Mini. The full price is $108.

If you are ordering online, make sure the confirmation page says you are getting 2 GB data bonus. If via a Verizon rep, confirm with her/him.

Activate the new Droid Mini.

Wait a day or two, and reactive your original phone, and sell the Droid Mini on eBay or the marketplace of your choice. You should get about $90 for it.

Total cost to you, excluding shipping, etc is about $40.

Disclaimer: while I believe this to work based on my own experience and available information. I cannot warranty that this will work for you.

]]>http://www.chinhdo.com/20151214/how-to-get-free-2-gb-of-data-on-each-line-for-life-on-verizon-wireless-for-about-40/feed/4http://www.chinhdo.com/20151214/how-to-get-free-2-gb-of-data-on-each-line-for-life-on-verizon-wireless-for-about-40/Make all of your home servers reachable by Remote Desktophttp://feedproxy.google.com/~r/ChinhDo/~3/EHr5A-n0btA/
http://www.chinhdo.com/20150131/make-all-of-your-home-servers-reachable-by-remote-desktop/#respondSat, 31 Jan 2015 05:26:03 +0000http://www.chinhdo.com/?p=597If you have more than one servers/PCs running at home behind the internet router, you can normally set up the router port forwarding to forward Remote Desktop traffic to just one server. However, by assigning different incoming ports for different servers, you can connect to each server individually.

Basically, use a different port for each server. Then configure the port forwarding on the router to router each port to the appropriate server on 3389. This assumes that your router supports different ranges for external and internal ports.

For example, for my home setup, I use three different port numbers for the 3 servers I have at home:

By using non-standard ports, there’s also a side benefit of a little extra security.

In Remote Desktop Client, you would add the port number to the Computer name like this:

]]>http://www.chinhdo.com/20141114/posting-a-feed-to-google-search-appliance-gsa-from-powershell/feed/0http://www.chinhdo.com/20141114/posting-a-feed-to-google-search-appliance-gsa-from-powershell/Finding the Last Friday (or any weekday) of the Month in PowerShellhttp://feedproxy.google.com/~r/ChinhDo/~3/mdhvq8SU1vU/
http://www.chinhdo.com/20140913/finding-the-last-friday-or-any-weekday-of-the-month/#commentsSat, 13 Sep 2014 04:09:01 +0000http://www.chinhdo.com/?p=555If there are less than 7 days left in the month, then it’s the last weekday of this type in this month.

]]>http://www.chinhdo.com/20140913/finding-the-last-friday-or-any-weekday-of-the-month/feed/1http://www.chinhdo.com/20140913/finding-the-last-friday-or-any-weekday-of-the-month/Bulk Operations Using Oracle Data Provider for .NET (ODP.NET)http://feedproxy.google.com/~r/ChinhDo/~3/8WQzDlat12I/
http://www.chinhdo.com/20140402/bulk-operations-using-oracle-data-provider-for-net-odp-net/#respondWed, 02 Apr 2014 14:26:47 +0000http://www.chinhdo.com/?p=538Putting up an old article I published on .NET Slackers.

Introduction

In a typical multi-tier application, one of the biggest performance bottlenecks is the overhead of making round-trips to the database. Minimizing these round-trips is often the first area you should look at during performance tuning. Fortunately, the Oracle Data Provider for .NET (ODP.NET) makes it fairly easy to do this by providing several built-in methods to write and read data in bulk.

Bulk Inserts Using Array Binding

The Array Binding feature in ODP.NET allows you to insert multiple records in one database call. To use Array Binding, you simply set OracleCommand.ArrayBindCount to the number of records to be inserted, and pass arrays of values as parameters instead of single values:

As you can see, the code does not look that much different from doing a regular single-record insert. However, the performance improvement is quite drastic, depending on the number of records involved. The more records you have to insert, the bigger the performance gain. On my development PC, inserting 1,000 records using Array Binding is 90 times faster than inserting the records one at a time. Yes, you read that right: 90 times faster! Your results will vary, depending on the record size and network speed/bandwidth to the database server.

A bit of investigative work reveals that the SQL is considered to be “executed” multiple times on the server side. The evidence comes from V$SQL (look at the EXECUTIONS column). However, from the .NET point of view, everything was done in one call.

Bulk Inserts Using PL/SQL Associative Arrays

PL/SQL Associative Arrays (formerly PL/SQL Index-By Tables) allow .NET code to pass arrays as parameters to PL/SQL code (stored procedure or anonymous PL/SQL blocks). Once the arrays are in PL/SQL, you are free to use them in whichever way you wish, including turning around and inserting them into a table using the “forall” bulk bind syntax.

Why would you want to insert bulk records using PL/SQL Associative Arrays instead of the simple syntax of Array Binding? Here are a few possible reasons:

You need to perform additional work in PL/SQL, in addition to the bulk insert.

The application login does not have permission to perform the work, but you can grant the necessary privilege to a stored procedure.

The major drawback with using Associative Arrays is that you have to write PL/SQL code. I have nothing against PL/SQL, but it’s not part of the skill set of the typical .NET developer. To most .NET developers, PL/SQL will be harder to write and maintain, so you will have to weigh this drawback against the potential gain in performance.

In the following example, we use PL/SQL Associative Arrays to insert 1,000 records, and returning a Ref Cursor at the end. As you can see, there’s quite a bit of more code to write:

Ref Cursors

ODP.NET Ref Cursors are objects that point to Oracle server-side cursors (or result sets). The important thing to .NET developers is that a Ref Cursor can be converted to the familiar OracleDataReader. With Ref Cursors, the logic to open result sets can be written entirely in PL/SQL and the results returned to .NET via Ref Cursors.

Why would you want to use Ref Cursors, instead of just doing an ExecuteReader with a SELECT statement? Here are some possible reasons:

You need to perform additional work in PL/SQL before returning the result set(s).

The user does not have direct access to the table(s) in question.

Here is a real world example. Say you need to update a record in the Orders table and insert a new record into the OrdersAudit table at the same time. Instead of executing two database calls, you can wrap everything into an anonymous PL/SQL block and make one database call.

See the previous section for code example using a Ref Cursor.

Controlling FetchSize

Controlling the FetchSize property is another method to minimize server round-trips. When you read data from the server using the OracleDataReader object, ODP.NET retrieves the data for you in chunks behind the scene. By default, a 64K chunk of data is retrieved each time. However, you can change the chunk size by setting the FetchSize property. By increasing FetchSize, you will lower the number of data retrieval round-trips and increase the overall retrieval operation.

It’s typical to set the FetchSize property is to the RowSize (of the OracleCommand object) multiplied by the number of records expected:

When working with a Ref Cursor, the OracleCommand.RowSize property is always zero. You either have to calculate the row size at design time or use reflection at run-time to determine the RowSize by looking at the instance variable m_rowSize on the OracleDataReader object:

On my development PC, when reading 10,000 records from BULK_TEST, setting FetchSize = RowSize * improves the total elapsed time by a factor of two over leaving FetchSize at the default value (985 vs. 407 milliseconds).

Notes

For clarity purposes, the example code in this article does not use the “using” pattern for IDisposable objects. It’s recommended that you always use “using” with IDisposable objects such as OracleConnection or OracleCommand.

Summary

In this article, we looked at how various bulk operations in ODP.NET 2.0 can help you improve the performance of your ODP.NET application. Being familiar with these techniques can help you plan, design and implement applications that meet performance goals.

References

]]>http://www.chinhdo.com/20140402/bulk-operations-using-oracle-data-provider-for-net-odp-net/feed/0http://www.chinhdo.com/20140402/bulk-operations-using-oracle-data-provider-for-net-odp-net/Running MSDEPLOY from PowerShellhttp://feedproxy.google.com/~r/ChinhDo/~3/SqaXfQfYtAw/
http://www.chinhdo.com/20140312/running-msdeploy-from-powershell/#respondWed, 12 Mar 2014 18:39:55 +0000http://www.chinhdo.com/?p=531I had to spend quite a bit of time figuring this out. So hopefully this will help someone out there. To launch MSDEPLOY from PowerShell, make sure you escape any quote or comma characters.

The “2>&1” at the end allows Powershell to detect errors and bail out if you have $ErrorActionPreference = “Stop”

If you still have problems, download and use EchoArgs.exe to see exactly what PowerShell sees.

This is the error I got when trying to start Web Deployment Agent Service: “Web Deployment Agent Service” on some of my servers. The exact error message is: “Windows could not start the Web Deployment Agent Service service on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion.”

In the System Events Log, there are these generic service start-up error messages:

The Web Deployment Agent Service service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion.”

A timeout was reached (30000 milliseconds) while waiting for the Web Deployment Agent Service service to connect.

The fix for me was to uninstall any previous version of Web Deploy, then re-install the latest version (Microsoft Web Deploy 3.5), and choosing “Complete” at the “Choose Setup Type” page.

My environment: Windows Server 2008 64-bit SP2.

]]>http://www.chinhdo.com/20140303/error-1053-starting-web-deployment-agent-service/feed/3http://www.chinhdo.com/20140303/error-1053-starting-web-deployment-agent-service/An Export of My .NET RSS Feedshttp://feedproxy.google.com/~r/ChinhDo/~3/RdDxpwbKh_E/
http://www.chinhdo.com/20130125/an-export-of-my-net-rss-feeds/#respondFri, 25 Jan 2013 15:31:49 +0000http://www.chinhdo.com/20130125/an-export-of-my-net-rss-feeds/If you are looking for some more .NET bloggers to subscribe to, check out my .NET Programming RSS Feeds. It’s a exported bundle from my Google Reader. I’ve subscribed to these feeds over several years so I am sure many of the blogs are no longer active.