Posts

Use Azure Functions to Execute a SQL Azure Stored Procedure on a Timer

Image
It was hard to find this information all in one place, so I thought I'd throw a post together quick. If you have the need to execute a stored procedure on a timer, that can be fairly easily accomplished with Azure Functions . Create a new Timer Trigger Azure Function , set the cron timer as desired, and add code similar to the code below: using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using Dapper; public static void Run(TimerInfo myTimer, TraceWriter log) {     var conString = ConfigurationManager.ConnectionStrings["ConString"]?.ConnectionString;          using(var con = new SqlConnection(conString))     {         con.Execute("dbo.MyProc", commandType: CommandType.StoredProcedure);     } } This code will not compile at this time. Note the name of the connection string, we'll need that in the app settings page. Go to the Connection Strings secti...

Create Google Contact via API and Add To My Contacts System Group

Image
When you create a new Contact via the Google Contacts API , by default it will not appear in the list of contacts on the Google Contacts webpage , however, if you search for the contact there, it will appear. If you then click the "Add to contacts" button, it will appear in that contacts list, and increase your contact count in the top left of the page. There is a way to add new contacts via the API and have them show up in this list, it is just not well documented within the API documentation. The code below demonstrates how to do this is C#. What appears to be a list of all contacts on the Google Contacts page is actually just a subset of all your contacts, it is actually the "My Contacts" System Group . When you create a new contact via the API, you must specify that this new contact is part of that system group for it to appear on the contacts page without searching. Steps:  1. Create a ContactsRequest  2. Get a list of all groups and search for t...

Visual Studio 2017 Code Snippet INotifyPropertyChanged

Image
This is an update to the vs2010 code snippet:  https://aaron-hoffman.blogspot.com/2010/09/visual-studio-code-snippet-for-notify.html Code can now be found here:  https://gist.github.com/aaronhoffman/c821acf4bb3b3beb0759e93bbe3a2402 Hope this helps, Aaron

NYSE Historical Stock Price Data From Quandl

Image
Quandl  is a great resource for historical stock price data. I thought I'd pull some meta-data out of the " Wiki EOD Stock Prices " data set in order to help future developers. First, here is the table structure I used to insert the CSV flat file into SQL Server: CREATE TABLE [dbo].[SymbolHistory]( [ticker] [varchar](5) NULL, [date] [date] NULL, [open] [decimal](16, 6) NULL, [high] [decimal](16, 6) NULL, [low] [decimal](16, 6) NULL, [close] [decimal](16, 6) NULL, [volume] [decimal](26, 15) NULL, [ex-dividend] [decimal](22, 18) NULL, [split_ratio] [decimal](21, 19) NULL, [adj_open] [decimal](25, 18) NULL, [adj_high] [decimal](25, 18) NULL, [adj_low] [decimal](25, 18) NULL, [adj_close] [decimal](25, 18) NULL, [adj_volume] [decimal](25, 18) NULL )  Second, here is a list of all 3,194 NYSE symbols in the Quandl flat file as of 2017-11-06, and the min and max dates that they appeared. https://gist.github.com/aaronhoffman/9ef359cbf39f2eefdf5...

Generate Random AES Encryption Key

Image
I was looking for a way to quickly generate a random AES key online, but couldn't find anything. I looked into a couple methods using JavaScript, but determined that a C# solution would be better. I needed to base64 encode the key array to store that value in a config file. Here's the code I ended up with: https://gist.github.com/aaronhoffman/09b56f77a95205fe10365bde2f4a02e5 UPDATE Using Visual Studio's "C# Interactive" screen you can generate a key in a single line: var keyArray = new byte[32]; (new System.Security.Cryptography.RNGCryptoServiceProvider()).GetBytes(keyArray); Convert.ToBase64String(keyArray) Hope this helps! -Aaron