Monday, December 28, 2015

Visual Studio revisited

I have a chance to be on a little C# project on Visual Studio 2015. The last time I really used it for a living was pre .NET. However, in 2009, I even landed on a .NET job I don't get to do .NET code and soon went back to java in another job. Visual Studio has changed quite a bit and still remain recognizable. Visual Basic STILL does not have multi-line comments!

Oh my, look, now it is cross platform, even for mobile. You can theoretically even do native phone apps on Android and iOS? (haven't really tried yet) https://www.visualstudio.com/en-us/features/mobile-app-development-vs.aspx and now .NET things can run on Linux? http://techcrunch.com/2015/04/29/microsoft-launches-its-net-distribution-for-linux-and-mac. Finding that hard to believe. That DLL stuff can be run outside windows nowadays?

Here is some annoyance. When the code is running the Solution Explorer just goes away hiding even if you pin it. Look I want to just see what code am I running. And if I want to edit the file? Boom an Msgbox comes saying you can't. Come on, just edit, not run. Nope, can't. But it is a snap to run with the VCR play button.

SQL Server and its left-hand-side explorer tab still feel strange as ever. You can probably use another db with Microsoft things but perhaps just very difficult. There is even online version of Visual Studio now. wow you can do team chat and even task/bug tracking that other people usually need multiple tools for.

This Model-view-Controller thing is just like what people typically do in Java (as in Spring MVC). Now there is odd Razor thing which looks much like the pre .NET old ASP. http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-c

I need this Visual Studio because I'll be dealing with SignalR.. some push pull thing http://www.asp.net/signalr, based on WebSocket of HTML5. Can I use java with this? theoretically yes, chances are this would be a bit painful. So as always... Microsoft things may work well but you have to put up with any annoyance that you don't like, and you got to use Microsoft for everything. And when they change often and you have to follow them along all the time, probably paying big money along the way.

Have a chance to use a different tool is a good thing for life as a programmer. But people make more money than me just by talking about programming don't have to touch anything.

Wednesday, December 16, 2015

Interesting prime

Came across this article about interesting numbers here.

Oh, learned something new today, the Belphegor's prime number.

1000000000000066600000000000001

Ooh 666 in middle! 13 0's to the left, 13 0's to the right, and bookended by 1's.

I am not going to bother testing rather this is real prime or not (it sure should be). So high school students write little program that test if an integer is a prime? Well this is an integer that too big to fit in your little int types. See, computer integer are not really the mathematics integer.

Download an image locally

To copy any image you want that you found in internet, sure, right-click save-as. But what if you have a ton to do?

You can write a little java program. Boy it takes just 3 lines (or less if you jam everything in 1). These Files and Paths things are in java.nio.file package.

 public static void downloadLocalCopy(String localFile,String urlString) {
  try {
   URL url = new URL(urlString);
   try(InputStream in = url.openStream()){
   Files.copy(in, Paths.get(localFile));
   }
   
  }
   catch (Exception e) {
   e.printStackTrace();
  }

 }
Sample usage: downloadLocalCopy("mycopy.png","https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");

Yes, this came from a stackoverflow post.