Who or what is nwtraders.msft?

I was searching for this answer and couldn’t find it quickly, thus decided to create this post. I keep running into the nwtraders.msft hostnames because I’m using CentOS images in Vagrant.., to be precise; the london.nwtraders.msft hostname..

NWTraders is a fictional company, created by Microsoft to showcase Microsoft Access.

Continue reading “Who or what is nwtraders.msft?”

Vagrant proxy through CNTLM on Windows using CYGWIN

Wow, talk about a crappy post title, but I just got this working on my corporate network and was quite happy about it.

Reason for this post; Every time I start a new assignment at a (rather big) corporation, I need to follow these steps to be able to access the internet from my vm’s.

(and I keep forgetting the steps, I’m getting old..)

What we’ll use to get this working:

  • Cygwin : https://www.cygwin.com/
  • Vagrant : https://www.vagrantup.com/
  • Virtualbox : https://www.virtualbox.org/
  • Cntlm : http://cntlm.sourceforge.net/

I’m running CentOS vm’s inside Vagrant with Virtualbox provisioning on Cygwin on Windows 7. I’m running Cntlm to create a local proxy for all stuff what I’m doing through cygwin, because I don’t like putting clear text passwords in bashrc or in Win / Bash variables.

Steps:

  1. Get your corporate proxy URL (Via Google Chrome)
  2. Configure Cntlm
  3. Configure Cygwin
  4. Configure Vagrant
  5. Use teh interwebs from your VM, practicing ninja turtle coding skillz and be instantly awesome!!1!

Continue reading “Vagrant proxy through CNTLM on Windows using CYGWIN”

CHere Bash Here without Admin Rights – CYGWIN

I wanted to add a “Bash Here” context entry when I right click on a directory:

Screenshot - 28-2-2014 , 13_01_20

This Bash Here would open that directory in Cygwin (mintty).

My current PC is fairly regulated, so without admin rights and thus I can’t use the CHere option which I would normally use.

I just created the registry keys via regedit and that works fine.

You can use two options:

  1. Import the registry file mentioned below
  2. Create the keys yourself

1. Import the registry file

Create a file called cygwin_bash_here.reg with the following contents:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Directory]

[HKEY_CURRENT_USER\Software\Classes\Directory\shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\bashhere]
@="Bash Here"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\bashhere\command]
@="C:\\cygwin\\bin\\mintty.exe"

Save the file and double click on it to import it to the registry.

2. Create the keys yourself

  1. Open the registry editor: Start – Run – “regedit”
  2. Open the following path: HKEY_CURRENT_USER\Software\Classes
  3. Create key: “Directory”
  4. Inside Directory, create key: “shell”
  5. Inside shell, create key: “bashhere”
  6. Inside bashhere double click on the standard key and insert text “Bash here” without quotes (This is the text which is displayed in the context menu.
  7. Inside bashhere, create key: “command”
  8. Inside command, double click on the standard key and insert text “C:\cygwin\bin\mintty.exe” without quotes. Important: This is the command which is run. Please change directory to your cygwin directory

Screenshot - 28-2-2014 , 13_16_02

Conclusion

Both options will create a context menu item which opens Cygwin at your current windows directory!

Cygwin – Your group is currently mkpasswd

This message occurs every time you start your freshly installed Cygwin when you’re logged in as a domain user.

Your group is currently "mkpasswd".  This indicates that your
gid is not in /etc/group and your uid is not in /etc/passwd.

The /etc/passwd (and possibly /etc/group) files should be rebuilt.
See the man pages for mkpasswd and mkgroup then, for example, run

mkpasswd -l [-d] >> /etc/passwd
mkgroup  -l [-d] >> /etc/group

Note that the -d switch is necessary for domain users.

Important: You need to install Cygwin with the user you are logged in with.
Tip
: Remove the word “setup” from the cygwin executable to be able to install it without administrator privileges. (e.g. setup-x64.exe should be renamed to cygwin-x64.exe)

  • mkpasswd -l only shows my local users, and not the domain user I’m logged in with, so that does not solve this.
  • mkpasswd -l -d get an enormous amount of users because it tries to replicate my whole organisation, which is not necessary.

We just need our current user ( mkpasswd -c ) to be sent to the /etc/passwd and /etc/group files, to do this, we use this command:

Solution:

mkpasswd -c >> /etc/passwd
mkgroup -c >> /etc/group

After that, our current account is added to both /etc/passwd and /etc/group and the annoying greeting message is gone!

Format any XML (windows)

With this blog post, it’s possible to format any xml you’ve selected.

It will take about 5 minutes to get this working, a couple of manual steps are necessary.

These are the tools being used:

Steps to get it working: (All steps are necessary!)

  1. First install AutoHotKey_L and start it, you’ll see the logo if it’s running: AutoHotKey logo
  2. Create a folder on your Hard Drive called “C:\autohotkey”
  3. Create a file “tidycfg.ini” in the location “C:\autohotkey\tidycfg.ini” with the following contents:
    1. [Clean Indent XML]
      input-xml: yes
      bare:no
      clean:no
      fix-bad-comments:no
      fix-backslash:no
      indent:yes
      indent-attributes:no
      indent-spaces:4
      char-encoding:raw
      replace-color:no
      wrap:0
      wrap-asp:no
      wrap-jste:no
      wrap-php:no
      write-back:yes
  4. Place tidy.exe in the location C:\autohotkey
  5. Create a file called “autohotkey.ahk” in C:\autohotkey with the following contents:
    1. #x::
      sleep 50
      Send ^c
      ClipWait
      clipboard = %clipboard%
      FileDelete, C:\autohotkey\format_with_tidy.xml
      FileAppend, %clipboard%, C:\autohotkey\format_with_tidy.xml
      sleep 50
      RunWait, %comspec% /c C:\autohotkey\tidy.exe -config C:\autohotkey\tidycfg.ini C:\autohotkey\format_with_tidy.xml
      clipboard =
      FileRead, clipboard, C:\autohotkey\format_with_tidy.xml
      Return
  6. Doubleclick the file “autohotkey.ahk” in C:\autohotkey
  7. Select unformatted xml and press [ WINKEY+X ]
  8. The formatted xml is now in your clipboard and can be pasted anywhere.

Extra information:

These are the steps what is happening in the autohotkey file:

  1. Configure the keyboard shortcut (# = winkey, x = x-key)
  2. Wait 50 milliseconds
  3. Send the ctrl-c with keyboard combination ^c ( ^ = ctrl, c = c-key)
  4. Wait until the clipboard is filled
  5. remove all formatting from the clipboard
  6. Delete the temporary file (if present)
  7. Paste the clipboard contents in the temporary file
  8. Wait 50 milliseconds
  9. Run tidy.exe on the temporary file with the configuration settings
  10. empty the clipboard
  11. Paste the contents of the temporary file in the clipboard
  12. End script