This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import invoke | |
import io | |
@invoke.task | |
def ls(ctx): | |
result = ctx.run("dir", hide="out") | |
lines = [line.strip() for line in io.StringIO(result.stdout) if not line.startswith(" ")] | |
filenames = [fn for *_, fn in [line.rsplit(" ", 1) for line in lines if line != ""]] | |
print("\n".join(filenames)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cmd | |
class BasicShell(cmd.Cmd): | |
"""Basic shell | |
To create interactive shell, subclass the cmd.Cmd class. | |
To start the shell, call the `cmdloop()` method, implemented in the base class. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
The function returns an OAuth2 access token for the resource specified with URI. | |
.DESCRIPTION | |
Obtains and returns an OAuth2 access token for the resource specified with URI. | |
.OUTPUTS | |
Token object | |
#> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_databricks(): | |
'''Detect if Python code is running in Databricks''' | |
import os | |
return 'DATABRICKS_RUNTIME_VERSION' in os.environ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Add Application Registration Owner | |
#> | |
function Add-AzAdApplicationUserOwnerXYZ($ApplicationName, $UserName) { | |
$ApplicationId = (Get-AzureADApplication -SearchString $ApplicationName).ObjectId | |
if (!$ApplicationId) { Throw "Unable to find application $ApplicationName" } | |
$UserId = (Get-AzureADUser -ObjectId $UserName).ObjectId | |
if (!$UserId) { Throw "Unable to find user $UserId" } | |
Add-AzureADApplicationOwner -ObjectId $ApplicationId -RefObjectId $UserId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
class Pipe: | |
def __init__(self, seq): | |
self._seq = seq | |
def __iter__(self): | |
return iter(self._seq) | |
def map(self, func): |