Skip to content

Instantly share code, notes, and snippets.

View farisachugthai's full-sized avatar

Faris A Chugthai farisachugthai

View GitHub Profile
farisachugthai /
Created December 25, 2020 16:57
Do IOError and OSError catch each other correctly?
"""IOError and OSError are seemingly interchangeable!
The reference docs encourage using OSError; however, they seemingly
work with each other just fine.
def raise_ioerr():
raise IOError
farisachugthai /
Last active October 5, 2020 04:07
Initializing classes in python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""First example. Goes over an example where properties are really needed."""
class InitializationExample:
"""Be wary when you assign data to an attribute in a class's ``__init__``.
If the value could change, it's probably better to avoid it.
If other attributes depend on the value of the first attribute, avoid
farisachugthai /
Last active October 5, 2020 04:27
Display what statements execute in what order in a python file, then check the doctests.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Here's an interesting example of how python orders statements.
In addition, let's go over how initialization works as well.
.. code-block:: bash

Building Neovim on Windows

Note: Requires Visual Studio

Most of the existing guides I've seen either assume msys2, which I didn't intend on downloading or don't give a particularly useful amount of direction to someone who's not well versed with Visual Studio.

As a recent Windows adopter (hence my use of neovim), I wanted to lay out how to best build neovim.

1) Installing Visual Studio.

farisachugthai /
Created May 5, 2020 01:10
Change rst.txt to rst files --- Python Standard Library Documentation
#!/usr/bin/env python3
# Seemingly the easiest way to so, and I'll admit I felt clever for coming up with this off the top of my head.
import shutil, pathlib
for i in Path.cwd().iterdir():
shutil.move(i, i.stem)
farisachugthai / add_node_exceptions.ps1
Created February 6, 2020 02:02 — forked from darvell/add_node_exceptions.ps1
Adds useful exceptions to Windows Defender for node.js developers.
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator"))
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
Write-Host "Excluding appdata NPM folder and Node.JS install folder from Windows Defender."
Add-MpPreference -ExclusionPath ([System.Environment]::ExpandEnvironmentVariables("%APPDATA%\npm\"))
Add-MpPreference -ExclusionPath (Get-ItemProperty "HKLM:SOFTWARE\Node.js" | Select-Object -Property InstallPath)