Search

Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts

Tuesday, May 05, 2020

Using Visual Studio Codespaces



One of the pain points we face with remote development is having to go through few extra hops to get to our virtual dev boxes. Many of us uses Azure VMs for development (in addition to local machines) and our security policy is to lock down all VMs to our Microsoft corporate network.

So to ssh or rdp into an Azure VM for development, we first connect over VPN to corporate network, then use a corpnet machine to then login to the VMs. That is painful and more so now when we are working remotely.

This is  where the newly announced Visual Studio Codespaces come in. Basically it is a hosted vscode in the cloud. It runs beautifully inside a browser and best of all comes with full access to the linux shell underneath. Since it is run as a service and secured by the Microsoft team building it, we can simply use it from a browser on any machine (obviously over two-factor authentication).

At the time of writing this post, the cost is around $0.17 per hour for 4 core/8GB which brings the price to around $122 max for the whole month. Codespaces also has a snooze feature. I use snooze after one hour of no usage. This does mean additional startup time when you next login, but saves even more money. In between snooze the state of the box is retained.



While just being able to use the IDE on our code base is cool in itself, having access to the shell underneath is even cooler. Hit Ctrl+` in vscode to bring up the terminal window.


I then sync'd my linux development environment from https://github.com/abhinababasu/share, installed required packages that I need. Finally I have a full shell and IDE in the cloud, just the way I want it.

To try out Codespaces head to https://aka.ms/vso-login

Sunday, January 12, 2020

How to run Windows 7 after end of support





Windows 7 end of support is upon us in 1 more day (1/14/2020). This post tries to answer the question on whether you can safely continue to run it. The short answer is that you can't, atleast if it is connected to the outside in some form.

However, I have a friend back in India who has some software that he relies on and he can't run it on modern Windows. So when I was answering his question on how he can run it, I thought I'd write it up in the blog as well.

This post outlines how you can run Windows 7 in virtual machine running on Microsoft Hyper-visor on a windows 10 machine. The process also uses checkpoints to reset the VM back to the old state each time. This ensures that even if something malicious gets hold of the system, you can simple go back to the pristine state you started with.

Pre-requisite

Obviously you need a computer capable of running Hyper-V. For my purpose I am using a Windows 10 Professional machine. You should also have more than enough CPU cores and memory to run Windows 7 in that machine. I recommend atleast 4 cores and 8GB memory so that you can give half of that to the Windows 7 VM and keep the rest for a functional host PC.

Get hold of Windows 7 ISO or download it from https://www.microsoft.com/en-us/software-download/windows7.

Then visit the system requirement https://support.microsoft.com/en-us/help/10737/windows-7-system-requirements. I decided to give roughly twice the resources as the requirements to create my VM.

Setup VM

Hit windows-key and type hyper-v to launch. Then start creating a VM by clicking New and then Virtual machine.



Choose the following Generation 1



I decided to then give it 4GB memory and 2 CPU cores

Chose to create a 40GB OS disk




Then install from bootable CD and pointed the location of the image file to the downloaded ISO image

Click through next to end and finish the creation wizard. Then right click on the newly created VM and choose "Connect".



Install Windows 7


At this point if everything went well the VM has booted off the installation ISO and we are on the following screen. Choose "Clean install" and proceed through the installation wizard.




Finally installation starts.


A reboot later we have Windows 7 starting up!

Created a username, password


Finally booted into Windows 7 and here's my website displayed in Internet Explorer


Secure by Checkpoint

Even though we have booted into Windows 7 soon this will be a totally unsupported OS, that means no security updates. This is a dangerous system to keep open to the internet. I recommend never doing that!! Also to be doubly sure, we will create a checkpoint. What that does is it creates a snapshot of the memory and the disk. So in case something malicious lands in this VM, we can go back to the pristine state when the snapshot was created and hence rollback any changes made by the virus or malware.

To create a  checkpoint right click on the VM in hyper-v manager and choose Checkpoint


You can see the checkpoints created in the Hyper-V Manager.



Lets make a change to the Windows 7 VM by creating a file named "Howdy I am created.txt" on the desktop.


Since the checkpoint was created before creating the file, I can revert back to the checkpoint by right-click on the checkpoint and choosing Apply.

After applying the checkpoint when I go back into the VM, the created file is all gone!!!

Finally

This is a hack at best and not recommended. However, if for some applications or other need where you "have" to run Windows 7, this can be an option.

Tuesday, November 04, 2014

.NET RyuJIT Rocks

IMG_0070_stitch.jpg

As the CLR team announced a few days back, CTP for the new fast JIT from .NET (code named RyuJIT) is out. Go check out the announcement at http://blogs.msdn.com/b/clrcodegeneration/archive/2014/10/31/ryujit-ctp5-getting-closer-to-shipping-and-with-better-simd-support.aspx. In the post they say

Recently the Bing team has tried using RyuJIT on top of 4.5.1 in some of their processing, and they see a 25% reduction in startup time in their scenario.  This is the most significant real-world throughput win we have witnessed on RyuJIT thus far.

Being from that “Bing Team” let me just say that RyuJIT just blew our expectation. Some of our workloads run incredibly large managed loads (many 1000s of assemblies running million of methods). We saw dramatic drop in startup time as well as subsequent JIT time. And also may I add that we are actually using the CTP bits to serve live traffic. It’s been pretty stable for us.

The graph shows the startup times averaged over all machines.

image

Friday, October 31, 2014

Halloween Costume with Arduino

This Halloween me and my daughter decided to add some dazzle to her fairy costume. Since we were anyway learning to code on Arduino we decided to dip our hands in wearables.

The basic idea is to build a costume that glows when someone comes close. The project was intended to teach a 9 year old to code and is hence simple enough for her to grasp. We used the following

Parts

  1. Arduino UNO board
  2. TIP120 transistor
  3. Diode 1N4004
  4. 1K Resistor
  5. HC-SR04 Ultrasonic Range Finder

Circuit

It’s best to consider the circuit as two separate pieces. One to acquire the distance of someone approaching using the HC-SR04 ultrasound range finder. The second is to actually make the LED strip glow.

The first part consists of connecting the 4 pins of the HC-SR04 as follows

image

We cannot simply drive the LED strip using an output pin of Arduino because the strip drains way more current than that can be supplied by the Arduino chip. So we use a TIP120 or TIP121 chip as shown below

image

There is a nice explanation of this whole setup at http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/. The same principles hold, but instead of a fan we use a LED strip in our case.

Code

The entire code is available on GitHub at https://github.com/bonggeek/GlowDress/ (I cleaned up the code a tiny bit after my daughter wrote it). This is how it looks

#include <ultrasonicranging.h>

#define ECHO_PIN 2 // ECHO pin of HC-SR04
#define TRIG_PIN 3 // Trigger pin of HC-SR04
#define LED_OUT 5 // Drive LED (Base pin of TIP120

const int space = 125; // Distance in cm in which to trigger LED

void setup()
{
Serial.begin (9600);
pinMode(TRIG_PIN, OUTPUT); // trigger pin of US range finder
pinMode(ECHO_PIN, INPUT); // Echo pin of US range finder
pinMode(LED_OUT, OUTPUT); // base of TIP120 to drive LED

analogWrite(LED_OUT, 0);
}

void GlowLed()
{
// Slowly get from LED strip off to full bright (glow-in)
for (int brightness = 0; brightness < 255; brightness++)
{
analogWrite(LED_OUT, brightness);
delay(3);
}

// Slowly get from LED strip on to full off (glow-out)
for (int brightness = 255; brightness >= 0; brightness--)
{
analogWrite(LED_OUT, brightness);
delay(3);
}
}

void loop()
{
int distance = GetDistanceInCm(TRIG_PIN, ECHO_PIN);
Serial.println(distance);

if (distance <= 0 || distance > space)
{
analogWrite(LED_OUT, 0);
delay(500);
return;
}

if (distance <= space)
{
GlowLed();
}
}

Here to abstract away the intricacies of how distance is received from the ranger, I have used GetDistanceInCm. The source for this library is at  https://github.com/bonggeek/GlowDress/tree/master/UltraSonicRanging.


Once we tested out the circuit we went ahead and soldered it on a board. My daughter did receive a battle scar (a small burn from iron) but we battled on.

IMG_0565This is how it looks partially done 

IMG_0574


With my wife’s help we sewed it underneath her fairy dress. It was pretty well concealed other than the sensor sticking out a bit.


IMG_0578


Tuesday, June 17, 2014

Fastest way to switch mouse to left handed

Milky way

 

I think I was born left handed, unfortunately I was brought up to be right handed. This was not uncommon in India 30 years back. Left hand usage was looked down upon.

However, the good thing is I am still ambidextrous (equal handed) in some things like using the mouse. For ergonomic reason I keep switching between left and right hand usage to ensure I do not wear out both my wrists with 12 hour daily computer usage.

The main problem I face when I switch and even otherwise when I am in left-hand mode is that most PC’s are configured for right hand use. In a course of the day I use many machines (upwards of 10) as I remote into data-center machines and even 3-4 local machines. The fastest way I have found to switch between left and right hand mouse is just run the following command either from the console or from WindowsKey+R

rundll32.exe user32.dll,SwapMouseButton

Basically this command calls the SwapMouseButton win32 function in user32.dll.


If you know of anything more brief either using command shell or powershell do let me know.

Tuesday, April 02, 2013

Moving to Outlook from Google Reader

I am sure everyone by now knows that Google Reader is being shutdown. I am a heavy user of Google Reader or Greeder as I call it and I immediately started looking for an alternative, when this suddenly occurred to me, that all PC’s I use have Outlook installed on them. So if you work for an organization that runs on Exchange server, this could really work out well. You can use Office Outlook and Exchange as a great RSS feed reader. Consider this

  1. It will provide full sync across multiple Outlook clients running on different PCs
  2. It will provide on the go access via Outlook Web-access
  3. Your phone’s outlook client should also work with it
  4. You can pretend to work while wasting time on boingboing

First things first: Export the opml file from Google Reader

Login to www.google.com and then go to https://www.google.com/takeout/#custom:reader

image

This will take some time and create an archive.

image

Click on the download button and save the zip. Then extract the zip as follows

image

Inside the extracted folder you will have the opml file. For me it’s in C:\Users\admin\Desktop\XXXXXXXX@gmail.com-takeout\XXXXXXXX@gmail.com-takeout\Reader\subscriptions.xml

Import to Outlook

This opml file needs to be imported into outlook. Use the File tab and bring up the following UI in Outlook.

image

Then use Import. To bring up the following

image

Choose OPML file and tap on Next. Now point it to the file you extracted. For me it was C:\Users\admin\Desktop\XXXXXXXX@gmail.com-takeout\XXXXXXXX@gmail.com-takeout\Reader\subscriptions.xml

Hit next and finally choose the feeds you want to import (Select All).

image

The tap on Next and here you have Outlook as an Rss feed reader…

image

Read Everywhere

It totally sync’s on the cloud. Here I have it open on the browser. As you read a post it tracks what you are reading and across the browsers and all your outlook clients at work and home it will update and keep everything in sync.

image

Works great on the Windows Phone as well. I assume any Exchange client should work.

wp_ss_20130314_0002wp_ss_20130314_0001

Pain Points

While reading on Outlook was seamless, there are some usability issues in both the browser and the phone. Surface RT is broken. Someone should really fix the mail client on Surface Sad smile

The major paint point I see is that in the Outlook Web Access the pictures are not shown. Tapping on the picture placeholders work. I think some security feature is blocking the embedded images.

Also on the Windows Phone you have to go to each feed and set it up so that it syncs that folder. This is a pain but I guess this is to protect against download over the carrier networks.

Tuesday, October 16, 2012

Core Parking

Rainier

For some time now, my main box got a bit slow and was glitching all the time. After some investigation I found that some power profile imposed by our I T department enabled CPU parking on my machine. This effectively parks CPU on low load condition to save power. However,

  1. This effects high load conditions as well. There is a perceptible delay between the load hitting the computer and the CPU’s being unparked. Also some CPU’s remain parked for spike loads (large but smaller duration usage spikes)
  2. This is a desktop and not a laptop and hence I really do not care about power consumption that much

Windows Task Manager (Ctrl + Shift + Esc and then Performance tab) clearly shows this parking feature. 3 parked cores show flatlines

clip_image002

You can also find out if your machine is behaving the same from Task Manager -> Performance Tab -> Resource Monitor -> CPU Tab. The CPU graphs on the right will show which cores if any are parked.

clip_image004

To disable this you need to

  1. Find all occurrences of 0cc5b647-c1df-4637-891a-dec35c318583 in the Windows registry (there will be multiple of those)
  2. For all these occurrences set the ValueMin and ValueMax keys to 0
  3. Reboot

For detailed steps see the video http://www.youtube.com/watch?feature=player_detailpage&v=mL-w3X0PQnk#t=85s

Everything is back to normal once this is taken care off Smile

clip_image006

Sunday, December 20, 2009

Indic Language Input

Diwali 2009

If you have tried inputting Indian languages in Windows you know it’s a major pain. That is particularly sad because Windows comes with very good support of Indian languages. I had almost given up using my native language Bengali on a computer due to this. Even when I was creating the About Page for this blog and wanted to have a version in Bengali, I had to cut it short a lot because typing it out was so painful.

There are web-based tools like the Google Transliteration tool that works well for entering text into web-pages where they are integrated (e.g. Orkut). However, I wanted a solution that pans the desktop, so that I can use it for say writing a post using Windows Live Writer.

Enter the Microsoft Indic Language Input tool. Head over to the link and install the desktop version. You can install the various languages individually (currently Bengali, Hindi, Kannada, Malayalam, Tamil and Telugu is supported). I personally installed the Bengali and Hindi versions.

Since I am on Windows 7 which comes pre-installed with Complex language support I needn’t do anything special. However, on older OS like XP you need to do some extra steps which are available through the Getting Started link on that page.

Once you are setup you can keep the Windows Language Bar floating on the desktop. The tool extends the language bar to allow you to enter Indic languages using an English keyboard via transliteration.

image

Go to the application where you want to enter Indic language and then switch to Bengali (or any of the other 6 supported Indic language) using this language bar. Start typing বেঙ্গলি using English keyboard and the tool will transliterates. The moment you’d hit a word terminator like space it inserts the Bengali word.

image

I tried some difficult words like কিংকর্তববিমূঢ় and it worked amazingly well

image

I had a very good experience with the tool. The only issue I faced was that the tool was extremely slow with some WPF apps like Seesmic twitter client. However, I got to know from the dev team that they are aware of the issue (it’s for some specific WPF apps and not WPF in general). I hope they fix it before they RTM (the tool is in Beta).

Tip: You can hit alt+shift to cycle the various languages in the toolbar without having to use your mouse (which is handy if you typing using a mix of languages).