Archive for 'Fluff'
What a time to be a .Net Developer. It used to be that one had to hang your head in certain circles when you were asked about your job. Admitting that you programmed in the Microsoft stack was seen as “less than cool”. All the cool kids were programming in Ruby, Node, Haskell, etc. Pick your poison. It was more popular than ever to write the “Why I’m Leaving .Net” blog post and just vamoose.
Recently, however, Microsoft has been changing ever since Satya Nadella has taken over. In reality, some of the changes started even before his arrival, but they have been leaping forward recently. .Net is Open Source, Microsoft projects are on GitHub and being developed in the open, and .Net has finally fulfilled its promise and is fully cross platform. You can develop full .Net apps on Windows, Linux, or the Mac and you can share the projects between the three without much issue.
Microsoft is now a Platinum Sponsor of the Linux Foundation. That means that Microsoft donates $500,000 annually to help the development of Linux, which is the highest level of sponsorship alongside Oracle, HP, IBM, and others. Google has joined the .Net Foundation to help steer .Net into the future.
SQL Server is on Linux (in preview at the time I write this). That says almost everything there.
Visual Studio is available for the Mac (also in preview). I’m not talking about VS Code, I’m talking full Visual Studio.
The other night, I took a shot at this brave new world. I installed Linux Mint 18 Sarah (MATE version) in a virtual machine on my iMac and attempted to get a fully functional ASP.Net MVC site up and running. I will admit that the tooling is not quite there yet and I did spend about three hours on the entire process, but I learned a lot. There were some versioning issues, but I finally now have a complete working toolchain using VS Code, .Net Core, npm, and tools like Yeoman. Here was my first console application that I wrote:
After that, I got Yeoman installed and configured:
Finally, I was able to generate an ASP.Net MVC 6 site running on .Net Core developed and running on a Linux box that I set up.
The future is here. As Apple continues to get more and more evil and not care about its customers, Microsoft is seeking newer and newer ways to engage developers across all spectrums. Honestly, engaging developers is always what they’ve done well. Now, they are just taking it to the next level. I can’t wait to get more and more of these kinds of applications into production and to be able to hold my head high and say that I’m a .Net Developer. I’m still waiting to read the first “Why I left Node for .Net” post, though 😉
Last year, at CodeMash v126.96.36.199, I really wanted to get a photo with Jon Skeet. Most people who know StackOverflow know that Jon Skeet has the highest reputation on the site by far. On top of that, he is an accomplished author, blogger, speaker, and all around nerd hero.
Jon has been to CodeMash for several years and I could never get up the nerve to interrupt him and ask for a picture. Finally, at last year’s event, I did it. My friend Russell and I got a picture with him… or so I thought. While I was able to take a picture of Russell with Jon, Russell failed to get a picture of me. In fact, he didn’t notice until we were walking away and I wanted to see the picture. No photo in the gallery.
Well, I wasn’t going to go back and bug him again. I felt like I already put him out. I did get to meet him and I had a pretty good story (of Russell’s failure), so I was ready to leave well enough alone. Poor Russell had to endure a year’s worth of teasing by co-workers for being unable to operate a camera.
Fast forward to CodeMash v188.8.131.52. Russell was going to go, but I decided to skip it this year. That meant that I wouldn’t be able to try for round 2 of my Jon Skeet photo shoot. We all decided, though, that it would be funny if Russell got a picture of Jon Skeet holding a picture of me. We were mostly kidding, but we found ourselves hilarious.
Russell was determined to redeem himself, so he reached out to Jon and set it up, tracked him down, and followed through. Somehow, out of the goodness of his heart, Josh allowed himself to be roped into the adventure of stalking Jon. Josh also made sure that a picture was actually taken this time. Russell then got the photo printed out and framed for my enjoyment. So I present to you my new favorite desk adornment:
This is all way better than if I had just gotten the picture last year! Big thanks to Russell and Josh!
This is definitely going to be one of those posts where I’m posting this not only for others to find while they are Binging and Googling, but for future Pete to come back and re-figure out how to do something that took him some time to figure out in the first place. I’ve had several posts like that (this gem chief among them), and this sort of situation is a very good reason to have a blog. Blogs are good places for a brain dump.
My issue this time was with a tool called Sql Power Architect. Sql Power Architect is a data modeling tool that I was using kind of as an Erwin-lite due to Erwin’s super high price tag and Architect’s free community edition.
I was trying to make a diagram of a database that I was being asked to examine for issues. I was able to reverse engineer the database and lay it out like so:
However, when I tried to generate the PDF of this diagram, I got this error:
So, I did some searching and I wanted to increase the Java heap size, but only for that application if possible. I don’t run that many Java programs on my machine and I definitely didn’t want to upset the delicate balance of the Android environment that I have set up on the Windows side (which, incidentally is way more “picky” that the Android environment on the Mac side).
What I found is the Xmx switch for the java command line. I navigated to the Sql Power Architect install folder and figured out that architect.exe probably just called architect.java under the covers, so I executed this command below:
java -Xmx1024m -jar architect.jar
That fired up the program with a 1 gig heap size. After that, I loaded my diagram and was able to export it to PDF without any issues.
The finished PDF:
As I said, hopefully this post can be helpful to some poor soul in the future (even if that soul is me).
I was checking out the internet and I came across someone doing a code kata for prime factorizations. I stopped watching what they were doing and decided to try my own hand at it. Here is the result:
You call it like so:
var primeFactors = PrimeFactors.Of(1305294);
I’ve run tests on this and some timings. Here are some representative findings:
198,602 = 2 * 199 * 499 (40 milliseconds to run)
4,678,421 = 11 * 101 * 4,211 (3,131 milliseconds to run)
17,841,257 = 7 * 2,548,751 (20,603 milliseconds to run)
2,548,751 is a pretty big prime! (Verified by http://is.2548751.aprimenumber.com/.)
I use the trick that says that a number is prime if it isn’t divisible by any of the numbers up to its square root. That definitely sped up performance. Other than that, I think the biggest spot for potential refactoring is around actually checking and calculating the prime factors. I laid it out very much like I would do the prime factorization with pencil and paper, but I don’t know if there is a better or more elegant way to attack that.
I’d be interested in any feedback and in seeing how some other people might solve the problem.
I often have no shortage of belief in myself and my abilities. When in doubt, I will always “bet on myself” when the chips are down to get things done. That confidence has allowed me to be very fortunate in professional settings. At times it can be misconstrued and at times I know that people can think that I don’t have any right to be as confident as I am. However, earlier this year, I read Ball Four by Jim Bouton and was really struck by this passage.
I’ve had some thoughts on what separates a professional athlete from other mortals. In a tight situation the amateur says, “I’ve failed in this situation many times. I’ll probably do so again.” In a tight situation the professional says (and means it), “I’ve failed in this situation and I’ve succeeded. Since each situation is a separate test of my abilities, there’s no reason why I shouldn’t succeed this time.”
Then there is also the case of the professional player who is not professional enough. He goes on a fifteen-game hitting streak and says, “Nobody can keep this up.” And as the streak progresses, his belief in his ability to keep it alive decreases to the point where it’s almost impossible for him to get a hit.
The real professional – and by that I suppose I mean the exceptional professional – can convince himself that each time at bat is an individual performance and that there is no reason he can’t go on hitting forever.
He is 100% saying how I feel about my potential for success in any given situation. Why not me? Why not now? Why can’t I do this thing? Why can’t I continue to succeed, or rally to success after a failure?
More importantly, why not you? Why not now? Why can’t *YOU* do the thing you want to do? Why can’t you continue to succeed, or snatch victory from the jaws of defeat?
Go do it!