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!

Thursday, July 5, 2018

Emacs Keyboard Macros and Key Binding

I recently came across these two articles that I think would come in quite handy for some customization to our current Emacs configuration:

Keyboard Macros: Build custom commands with the Emacs Command Language

Mastering Key Bindings in Emacs




Wednesday, August 30, 2017

Kicking off processes from a web interface

In a previous job I had, we did a lot of work with Django as a front end for the control of our analytical system.  In the process, someone used cron to track the system frequently in order to be able to pick up toggles input through the UI.  I wasn't the biggest fan of this approach, but that's a story for another day, because the reality is that I couldn't think of a better approach.  Enter my recent discovery of Celery.  I have been wanting to try this out, because it might be exactly what I'm looking for when it comes to this, and I want to save this tutorial on just a proof of concept:


So, I'll have to have a follow-up blog with my experience with using it.

P.S. He also has a thorough Flask tutorial as well: