Skip to main content

Posts

Showing posts from December, 2008

Google dictionary for Bash

For Bash, use Google to get word definitions on the command line by putting this in your .bashrc file: def () { lynx -cfg=/dev/null -dump "http://www.google.com/search?q=define%3A$*" | less; } (Make sure that is all on one line) Then type "def word" to get a definition for "word". You can also create a shell script like so: #!/bin/csh -f lynx -cfg=/dev/null -dump "http://www.google.com/search?q=define%3A${1}" | less This will work if you aren't using Bash. Make the script executable and put it in your search path (~/bin is a good place). You need a copy of lynx (or better yet links ) for this to work. The "-cfg=/dev/null" is optional for lynx, but should be removed if you are using links.

List all IP addresses bound to a box with C#

RegistryKey adaptersRegKey = Registry.LocalMachine; adaptersRegKey = adaptersRegKey.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Adapters"); String[] adapterGuids = adaptersRegKey.GetSubKeyNames(); foreach (String giud in adapterGuids) { RegistryKey interfaceRegKey = Registry.LocalMachine; interfaceRegKey = interfaceRegKey.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" + giud); try { Console.WriteLine("Checking: " + giud); Object ipObject = interfaceRegKey.GetValue("IPAddress"); Array ipArray = (Array)ipObject; foreach (string ip in ipArray) { Console.WriteLine("Found IP: " + ip); } interfaceRegKey.Close(); } catch (NullReferenceException) { } } adaptersRegKey.Close();