Posts

Showing posts from 2017

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

Sync Gmail Contacts Between Accounts

Image
For the last few years I've needed a way to easily sync contacts between gmail accounts. The only method previously supported by Google is to export to csv then re-import the contact list . This may work for some, but clearly there is a desire for something else. I finally found some time to dig into the Google Contact APIs  and created a site to perform this sync operation easily, without needing to install any software: https://www.mycontactsync.com/ Steps to sync:  1. Authorize your gmail account  2. Link an second gmail account (up to 5 currently)  3. Compare two accounts to see which email addresses and phone numbers will be created.  4. Click the Sync Accounts button to initiate the sync! It's that easy! Hope this helps, Aaron links: product hunt note: this website was previously named "gmail contacts sync". The name was changed to verify the google api use.

Hide Main Menu for Visual Studio 2017

Image
To improve my development experience, I disable as many windows and toolbars in Visual Studio as possible. The one toolbar that you can not disable via the IDE itself is the "main menu" toolbar (File, Edit, View, etc.). There is an extension that I've used in previous versions of Visual Studio that hides this menu until the user presses the `alt` key. Here is a link to that extension in the gallery: old --  https://marketplace.visualstudio.com/items?itemName=MatthewJohnsonMSFT.HideMainMenu  -- old For whatever reason, that extension does not appear available in 2017, so I've published my own extension to complete the same task:  https://marketplace.visualstudio.com/items?itemName=AaronHoffman.HideMainMenu2017 I will gladly take mine down if Matthew Johnson ever updates his extension. Hope this helps! Aaron

git - protect local master branch, prevent commit and push

Image
If you've worked with a remote git hosting service like github , you're likely familiar with the concept of protecting a branch . Other remote git hosting services ( vsts , bitbucket , gitlab , etc) also support the concept. It's a good idea to protect your remote in this way, but why stop there? You can also protect your local dev environment from human error by using git hooks . A new git repo (`git init`) comes with various hook examples in the `.git/hooks/` directory. We can tie into two of those hooks, `pre-commit` and `pre-push`, to prevent commits to your local master branch, and to prevent attempting to push to the remote master branch (even from a local feature branch). Place the two files found in the gist linked below in your repo's .git/hooks directory to prevent the two actions described above: https://gist.github.com/aaronhoffman/ffbfd36928f9336be2436cffe39feaec Hope this helps, Aaron

Search iPhone Text Messages with SQLite SQL Query

Image
While you're here, check out some of our interactive visualizations: Would you like to visualize your text messages? ------------------------------------------------------------------------------- In my experience, the iPhone text message search functionality is usually pretty awful. Especially if you're trying to find a text from a few years ago. Luckily, if you backup your iPhone using iTunes, your text messages are exported/stored in a SQLite database, and it is fairly easy to query. Here are the steps to SQL Query your Text Messages.   1. Backup your iPhone using iTunes.   2. Find the SQLite file that contains your text messages .     - in ~/Library/Application Support/MobileSync/Backup/* with a filename of 3d0d7e5fb2ce288813306e4d4636395e047a3d28   3. Ensure you have a SQLite Query tool ( SQLiteBrowser is pretty good ).   4. Open your SQLite Text Message DB File using your favorite SQLite query tool.   5. Execute this query to see all your mess

Azure Kudu Deployment with Version Number

I recently blogged about generating a version.txt file on every build via Visual Studio . This solution is fine if you are building from you local machine and using Web Deploy to deploy to Azure, but if you have a github webhook and are using kudu, the VS Post Build Events are not executed. The easiest way I found to generate a version.txt file for every deployment is to add a post deployment action  to your Web App/App Service. Create a file within the /site/deployments/tools/PostDeploymentActions/ folder of your App Service (you may need to create that folder). You can name the file whatever you'd like, I chose `generategitversionfile.cmd`. The file should contain at least the following line: git rev-parse HEAD > "..\wwwroot\version.txt" This command will be executed within the context of the `/site/repository` directory, that's why we need a more fully qualified path for where to write the file. Now, after every kudu deploy, a new version.txt file wil

Stop Azure WebJob from Azure WebSite

Image
I recently had the need to toggle the status of an Azure WebJob from the WebSite in the same Azure App Service. I found a couple half-complete answers online, but I thought I'd put together this simple guide to have a complete example all in one place. To accomplish this, we'll be using the kudu REST API  for WebJobs . (note: I also looked into toggling the WEBJOBS_STOPPED environment variable from the WebSite, however I was not able to verify that solution was going to work. I confirmed I was able to set the environment variable from the website, however the value did not update in the "Application Settings" section of the Azure Portal and I was concerned the WebJobs may read a separate environment variable than the WebSite [process scoped vs machine envar for example]) The first thing you'll need to do is download the PublishSettings file (aka "Publish Profile") associated with the App Service (you need the username/password from this file to s

Version your Visual Studio Builds by Git Commit Hash

Image
Semantic versioning is great, but more often than not, when I'm looking at a folder of deployed binaries, I want to know the git  commit   hash of the source code that was used to generate them (a versioned container might be better in some cases, but that's not applicable in every situation at the moment). A simple way to accomplish this is to generate a "version.txt" file at build time that will eventually be deployed with the code. Visual Studio makes it pretty easy to automatically generate this version.txt file with it's built in " build events ". Simply add the following line to the "Post-build event command line:" textbox, and a version.txt file will appear in your build output directory with the current commit hash after a successful build. "C:\Program Files\Git\bin\git.exe" rev-parse HEAD > "$(ProjectDir)$(OutDir)version.txt" If you'd like to generate this file after an Azure Kudu deployment, se

Replace Azure Scheduler with Azure Functions

Image
I have written before about the shortcomings of the Azure Scheduler  (doesn't integrate with classic [non-RM] Azure Storage accounts, message body pushed to Azure Storage Queue is wrapped in XML, costs $15/mo for basic scheduling tasks...) but the good news is, now with Azure Functions , your Scheduler Tasks can mostly be replaced with Functions. Here are a couple tables to break down the differences in Triggers and Actions. Scheduler Triggers compared to Function Input Bindings Scheduler Functions Manual X X Timer X X Http X Storage Queue X Service Bus Queue X Service Bus Topic X Blob X Event Hub X Scheduler Actions  compared to Built-in Function Output Bindings   Scheduler Functions Http X X Storage Queue X X Service Bus Queue

Census.gov QuickFacts Data Set

To create a visualization for  https://www.sizzleanalytics.com/  I had to compile census information from the census.gov QuickFacts tool. As for as I could tell, they don't provide an easy way to automatically download all the data, so I manually downloaded each state then used a simple node script to merge them together. Data set available here: https://data.world/aaronhoffman/census-gov-state-quickfacts Hope this helps, Aaron

Azure Functions and AWS Lambdas

I'm working on a new talk about Azure Functions and AWS Lambdas . I'm writing this blog post to compile a list of links to more information for people that attended the talk. Presentation Slides:  https://drive.google.com/open?id=0BwgLvVq0rcS7cmxrQUhCWUxTNTQ Azure Function Intro Source Code:  https://github.com/Stonefinch/AzureFunctionIntro Azure Intro Web App Source Code:  https://github.com/Stonefinch/AzureIntro Azure Function Tools for Visual Studio:  https://blogs.msdn.microsoft.com/webdev/2016/12/01/visual-studio-tools-for-azure-functions/ AWS Lambda C# in Visual Studio:  https://aws.amazon.com/blogs/developer/using-the-aws-lambda-project-in-visual-studio/ I'll add more links and update the slides as I continue to build out the talk. Hope this helps, Aaron