Linting in Visual Studio Code for Python Turtle graphics

Apr 27 2018

The built-in linter doesn’t do well with turtle. You can choose a different linter like flake8. However, you’ll trade off one annoying thing for a different annoying thing. Choose your poison.

  • Open the command palette (⌘ + Shift + P)
  • Select “Python: Select Linter”
  • Choose “flake8”
  • If you’ve never used that before, you’ll be prompted to install it with a prompt similar to this

linter_install_prompt

  • Do that and restart VS Code
  • Now you can get the red squiggles to go away on the turtle function names by explicitly naming them in multiple import statements (this is the annoying thing about the fix).

turtle_code_without_squiggles

  • To switch back to the default linter, choose “Python: Select Linter” again and choose “pylint”

Resources:
https://github.com/Microsoft/vscode-python/issues/1056
https://code.visualstudio.com/docs/python/linting

No responses yet

Index.php Wouldn’t Load Correctly

Jan 12 2017

I managed to screw up my website at some point. Index.php would not load correctly. You would instead be prompted to download a file. Other WordPress websites in my hosting package worked correctly and other PHP pages in this website worked — just not index.php.

I casually troubleshooted it at times and kept being pointed to htaccess or the PHP configuration being the problem but nothing I found worked. Today I decided to get to the bottom of it. Obviously it was something relatively simple since the other sites and pages worked, I just had to find it. I compared the htaccess file between this site and another similar WordPress site I have. Both were exactly the same. There were some permission differences between the directory structures — mostly the “group” part of the permissions didn’t have read and/or execute rights on this site. Changing the permissions didn’t change the behavior.

Finally I saw a comment about having an index.html in the root directory of the site. I didn’t have that file but I did have index.html.old and index.php.old. I don’t remember what either of those were used for but I moved them both out of the directory. Boom! The site loads correctly now. I went a little further to figure out if one or both of the files was the actual problem and it turns out index.html.old was the issue. So even though it wasn’t named index.html (or index.htm), apparently Apache found it and tried to load it instead of index.php.

No responses yet

Powershell and Unicode

Oct 23 2012

I’m writing a Powershell script that creates an FTP script and then runs the FTP command using that script. The file created fine and the FTP command ran but the FTP script did not work:
$exportDirectory = “\\server\share”
$file= “$exportDirectory\test.txt”

function FTP-File($FTPusername, $FTPpassword, $FTPfile){
      “open 192.168.1.1” > $exportDirectory\ftp.scr
      $FTPusername >> $exportDirectory\ftp.scr
      $FTPpassword >> $exportDirectory\ftp.scr
      “put $FTPfile” >> $exportDirectory\ftp.scr
      “quit” >> $exportDirectory\ftp.scr
      ftp.exe -s:$exportDirectory\ftp.scr
}

FTP-File “username” “password” $file

FTP error
After struggling with it for a few minutes I realized it might be a file encoding problem. That weird character on the first line seemed to point to that. I looked and the ftp.scr file was encoded as “UCS-2 Little Endian” — well that’s an odd format. Outside of the script I change the encoding of that file to ANSI and ran the FTP command and it worked perfectly.
So Powershell file redirection creates Unicode files and the command line does not understand Unicode. The fix? Use Out-File instead.
function FTP-File($FTPusername, $FTPpassword, $FTPfile){
      “open 192.168.1.1” | Out-File $exportDirectory\ftp.scr -Encoding ASCII
      $FTPusername | Out-File $exportDirectory\ftp.scr -Encoding ASCII -Append
      $FTPpassword | Out-File $exportDirectory\ftp.scr -Encoding ASCII -Append
      “put “ + $FTPfile | Out-File $exportDirectory\ftp.scr -Encoding ASCII -Append
      “quit” | Out-File $exportDirectory\ftp.scr -Encoding ASCII -Append
      ftp.exe -s:$exportDirectory\ftp.scr
      Remove-Item $exportDirectory\ftp.scr
}

No responses yet

Watch Youtube Videos At A Faster Speed

Jun 22 2012

I’m currently going through the Udacity CS101 course. Much of the material I’ve already seen before in other languages but I don’t want to miss the Python specific information. Usually, in this situation, it feels like the video takes FOREVER to get through.

I’ve used VLC to watch downloaded videos at a faster speed (1.5x or 2.0x) but haven’t found anything that will do the same for streaming Youtube videos. Finally today I found it.

First, you have to opt-in to the HTML5 beta for Youtube. HTML5 gives you an alternative to Flash videos. It doesn’t work for all Youtube videos yet, but I haven’t run into any that it doesn’t work on. You can opt-in here: http://www.youtube.com/html5

After you’ve done that, the next video you load will have some extra options if the video supports it. Click on the gear and you should see some speed options to use. MUCH better!

HTML5 Youtube Settings

3 responses so far

Help! I Can’t Find This User To Add Them to an Active Directory Group!

May 30 2012

I ran into an issue at work where we couldn’t add a user to a local computer group. I later determined that you couldn’t find the user anytime you had to use the “Select Users, Contacts, Computers …” search window, like when you add the user to an AD group.

ad-search

You could, however, find the user in the “Find Users, Contacts, and Groups” search box in ADUC.

I used a Powershell command to output the properties of the user account to a text file. I did the same thing for another non-problematic account. Then I used Beyond Compare to compare them. I found that the showInAdvancedViewOnly attribute was set to TRUE on the problem account and FALSE on the non-problem account.

Import-Module ActiveDirectory
 Get-ADUser ProblemUser -Properties * | fl c:\temp\problemuser.txt

I changed the value of showInAdvancedViewOnly to FALSE and now I can find the account and add it to groups.

One response so far

Older posts »