Monday, October 10, 2022

Some useful grep tricks I keep having to look up

 As I've said, this blog is meant for things I find myself repeatedly doing.  Especially, when I am doing them on different *nix systems I end up googling and eventually finding my same references:

This stackoverflow thread tends to be my main one to use for when I need to look for files containing as specific thing in them.  For instance, I often forget the full syntax in proc means for SAS.  

So I go to my code bases and execute the following:

      find . -name "*.sas" | xargs grep "proc means" | less

I also sometimes need to find files that contain specific things in them and copy them to a specific location.  I found this stackexchange thread useful (although not totally clean yet):

      find . -name "*.sas" | xargs grep -l "proc means" | xargs cp -t ~/destination




Thursday, April 28, 2022

Sending code to debug console in Visual Studio for Python

 Similar to this advice I found on stackoverflow, I did the following to be able keyboard debug my Python code:

File > Preferences > Keyboard Shortcuts

Then in the top right there is an icon to Open Keyboard Shortcuts (JSON), in there I put:

[
    {
        "key": "shift+c",
        "command": "editor.debug.action.selectionToRepl"
    }
]

BOOM!  Now I can highlight my code, and hit Shift+c to send the snippet to the debug console.  

NOTE: I used Shift+c as it is similar to C-c C-c in Emacs, and C-c is taken in Windows for Copy.


EDIT:  Oops, I can't use capital C with this, so instead I am now using Ctrl+alt+enter

// Place your key bindings in this file to override the defaults
[
    {
        "key": "ctrl+alt+enter",
        "command": "editor.debug.action.selectionToRepl"
    }
]

Friday, April 8, 2022

View WiFi Password on Windows

Thanks to this post, I can now use the following command to view my WiFi passwords without having to repeatedly ask for them when hooking up other gadgets:


Open your command prompt with Administrator Privileges (This is necessary to see the WiFi password)

This is to see your networks you've already setup:


netsh wlan show profiles

And when you see your SSID in there, I'll call this <SSID>, then type:

netsh wlan show profile name= <SSID> key=clear

You should see your password on the Key Content line in the Security Section.

Cool!