Regex to parse date formats when unknown
I’m working on an app that will parse different file sources and aggregate it for a report. Of course, each format has a different date format and trying to parse it all has proved to be a pain. I wrote a regex that’ll parse out just about every datetime format I’ve run into that I am sharing in case someone else finds it useful. I’ve put it on a Github gist along with a sample of the various dates I’ve tested it against and confirmed to work. If you find a format not covered by the regex, post a comment and I’ll update the gist.
Just a note that I haven’t finished parsing the timestamp (e.g. 1997-07-16T19:20:30+01:00) format. The date portion does get extracted correctly so I left it in.
Copy File Context to Clipboard via Command Line, Git Bash (Mingw64), or Terminal
I’ve been spending more time switching from SVN to Git and learning the command line options. I’m finding a lot of the Mac Git terminal commands I run aren’t the same in Git Bash (Mingw64). One of the commands I use is the pbcopy command to copy the ssh key to the clipboard to paste into Github and Bitbucket accounts. I’m starting to use it more as I am learning managing Linux servers and adding my key to login. I’m adding it here as a cheatsheet for myself but I thought others may find it useful.
On Windows, you can run this command to copy your ssh key to the clipboard:
clip < ~/.ssh/id_rsa.pub
pbcopy < ~/.ssh/id_rsa.pub
or if you want to view it in the terminal window:
ASP.NET MVC Model Generator
In making the switch to ASP.NET MVC, I’ve moved away from using my old Data Access Layer that I’ve used for years and have opted to use Dapper as my ORM of choice in the quest for optimal performance. My DAL was actually pretty optimized for WinForms and WebForms (using straight SQL Queries and SQL parameters) but mapping it to models wasn’t something I had in mind when I created it. I’m finding Dapper takes some getting used too but it is still pretty fast. The downside is that writing the code for Models to wire it up is proving to be a little tedious.
To that effect, I wrote a little application that has helped me generate the models from a database dynamically. It’s in it’s infancy stages and something I cobbled together in less than 8 hours but it works. I’ll add more features too as time goes on if there’s enough interest or to satisfy my own needs. In the meantime, I’m open sourcing the project as it may help others and I’d love to see it become something grander if others are willing to contribute to it. There’s also some useful bits of code that others may find useful to reference like dynamically reading fields from a database, pluralization/singularization of words, amongst others.
You can find the repository on Github: https://github.com/gregvarghese/MVCModelGenerator