{ForMyFutureQuickReference}-How to setup a Python Virtual Environment

Posts with {ForMyFutureQuickReference} tag are, as the name suggests, for my future quick reference. These posts could also help others, it’s a plus if it does. Instead of depending on the machine level global python installation and packages, you can have a project/application specific set of  python interpreter & packages. The benefit is, you get an isolated python development environment for each of your development projects. You do this by creating a Python Virtual Environment. The following command will create a Python Virtual Environment. python -m venv env1 env1 is the Virtual Environment name. A folder gets created as env1 and it will contain the python interpreter and default libraries. You need to activate the virtual environment by: .\env1\Scripts\activate Now you will get a prompt as below: Notice the “(env1)”, now whatever python packages you install will go into this virtual environment, until you issue the “deactivate” command to come out of the Virtual Environment.

Productivity Tip for Dealing with Frequent Work Revisions (using PowerShell)

Often, when I work on a project that requires a bunch of files to produce an output, be it a set of diagrams or documents or even sometimes code, I produce an output and then I tend to try a different idea by making changes to a bunch of files to see how something looks and then go back to how it was previously and try something else by changing the same or different set of files. You might do things the same way. It quickly gets super tedious to make changes to the files to bring back something I tried a while ago or to restore the work to a particular state that I liked, because you need to keep track of all the changes you made and do them again or undo them all-mostly manually. In such times, I tend to take back up of the whole directory or sub-directory with all its files and sub-directories. I used WinRAR and a quick key combination to add the current directory and create an archive with a timestamp based filename, I keep this archive aside with a label to identify if I need to restore later, sometimes I don’t even

Resuming blogging after a few years…

I started my blog in 2009, a decade ago![true 🙂]. But for the past few years, though I’ve been in the tech field, I’ve not been blogging, sometimes intentionally-to make time for other things & sometimes unintentionally.

I regret for not blogging for the past few years.

I started blogging for many reasons, right now when I think of why I need to blog? – I could tell it is primarily for the following reasons:

  1. It helps to motivate my learning, to maintain myself as a truly hands-on person even after I got into Software architect roles and technology leadership roles, also it prevents burnout in terms of keeping up with learning so many new things popping up in the industry. Additionally, the pressure of wanting to write a new blog post makes one seek new tools/tech to explore, this helps to spread your expertise horizontally, as per your liking.
  2. Blogging is a great note-making/learning tool – my blogging philosophy is, you can blog anything you want to make a note for yourself, some/most times those blog posts may end up being useful for someone.
  3. To save time – sharing a link is easier than guiding someone on a topic/issue. Lot of times, I happen to bring up a team of freshers or cross-train developers into a new technology as part of my work and sharing blog posts for them to get started is easier.

I always blogged on my own domain, first on codehappiness.com (2009-2011) (codesmiles.com was not available then 🙂), then found codesmiles.com being available for registration and migrated to it since 2012 – till date

I felt like moving to a new domain name as I am not sure if I am very fond of my old domain(codesmiles.com), and having your name on the domain is the trend now😎. Also, as I am resuming blogging after a few years, thought to have a kind of “refreshed resumption” if that’s a term 😉, hence I am moving to ashokaOn.Tech domain.

ASP.NET MVC security best practice — Add Authorize attribute for controller instead of individual actions when appropriate

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. Recently I was going through an ASP.NET MVC web application’s source and noted that in some of the Controllers all of its Actions required authorization to access them. So Authorize attribute was added to all of the actions in the controller, as shown below . public class AdminSettingsController : Controller { // // GET: /AdminSettings/ [Authorize] public ActionResult Index() { return View(); } // // GET: /AdminSettings/Details/5 [Authorize] public ActionResult Details(int id) { return View(); } // // GET: /AdminSettings/Create [Authorize] public ActionResult Create() { return View(); } // // GET: /AdminSettings/Edit/5 [Authorize] public ActionResult Edit(int id) { return View(); } // // GET: /AdminSettings/Delete/5 [Authorize] public ActionResult Delete(int id) { return View(); } } But if all of the controller’s actions need authorization then you can add [Authorize] attribute to the entire Controller itself. Doing this would avoid room for errors, as you may miss to add the Authorize attribute to individual actions and that could become a security vulnerability. Below you can see I have removed the Authorize attribute from individual actions. [Authorize] public class AdminSettingsController : Controller { // // GET: /AdminSettings/

Visual Studio 2013 New Features of the IDE

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. Update: I posted this article on Aug 10, 2013 on CodeProject and in this blog around the release of Visual Studio 2013 preview version(all the below mentioned features are still present in the final release). Even though I wrote this post for documenting and sharing the visual studio 2013 new features that I identified when I started exploring Visual Studio 2013, I recently noted many people, even Microsoft folks have talked about the new features in various Microsoft sites, I recommend everyone to check them out too (posting all those links will just make people lazy :-)). Visual Studio 2013 Preview has been launched recently. Like I did with Visual Studio 2010 and Visual Studio 2012, I am writing this with several purposes in mind; I thought of documenting these cool new features of Visual Studio 2013 that I found, so that it will serve as an index for me and I could easily refer to this in talks I may give, or, when sharing these with friends. (Note that one of the ultimate purposes of blogging/posting articles for me is that I can easily

Build 2013 – live streaming now.. Windows 8.1 revealed.. Visual Studio 2013 preview & .Net framework 4.5.1 preview released !

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. Build – a Microsoft’s developer conference occurs every year to inform developers around the world about the technologies & tools available for developers in Windows platform.. This year’s event is from Jun 26 to Jun 28 http://channel9.msdn.com/ -live stream http://channel9.msdn.com/Events/Build/2013 event schedule.. http://www.buildwindows.com/announcement http://www.microsoft.com/visualstudio/eng/2013-downloads – Visual Studio 2013 preview Share the info with your friends.. Alchemists turned into chemists when they stopped keeping secrets. –    Eric Raymond Happiness quite unshared can scarcely be called happiness; it has no taste. –    Charlotte Brontë

Launching your ASP.NET web applications on multiple browsers at the same time from Visual Studio

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. Visual Studio 2010 offered option to view a particular .aspx page on multiple browsers when you right-click the file and chose Browse With… but it didn’t provide storing the setting and allowing to launch the web page on multiple browsers at the same time when you execute every time. In this article we will see how this feature is enhanced in Visual Studio 2012; you can set multiple browsers as default and store this setting permanently and when you Debug(F5) you will get a dialog to choose the browser you’d like to debug with or when you Execute without debugging (Ctrl+F5) you will be able to launch the web application in multiple browsers. As you may have noted from my earlier article about Visual Studio 2012 new features, Visual Studio 2012 has a browser drop down that lets you select the browser that will be used to launch your ASP.NET web application when you debug it (F5) as shown below, as I mentioned in my article, this was achievable in earlier Visual Studio versions via other not-so-quick menu/context menu commands.   If you click the

Visual Studio 2012 New Features of the IDE – better late than never :)

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. I am making this post thinking “Better late than never”, as I was supposed to make this post a long time ago, actually in the beta period of Visual Studio 2012, like I did with Visual Studio 2010, unfortunately I was held up with other stuff, personal and work related. This post remained as partially completed in my blog’s drafts for a long time which I took and finished. Note: This post talks about the Visual Studio 2012’s IDE new features. All non-IDE features, new language features, .net framework 4.5 features, new type of app development support like Windows 8 metro app development and specific code editor enhancements will be discussed in future posts. So with that in mind, here are the new features of Visual Studio 2012’s IDE.. Dark Color Theme for code editor and IDE windows Visual Studio 2012 provides out of the box option to have a White on Black color scheme, Dark AKA White on Black color schemes have become choice of many developers as many have realized that they are easy on the eyes. Dark Theme (click to enlarge)