Skip to content

Instantly share code, notes, and snippets.

View RHDZMOTA's full-sized avatar
👨‍💻
More info at: rhdzmota.com

Rodrigo H. Mota RHDZMOTA

👨‍💻
More info at: rhdzmota.com
View GitHub Profile
@RHDZMOTA
RHDZMOTA / hello-world.py
Last active November 8, 2021 06:06
PyCo Snippets: Hello world python script
import os
HELLO_WORLD_DEFAULT = os.environ.get(
"HELLO_WORLD_DEFAULT",
default="World"
)
def hello(world: str = HELLO_WORLD_DEFAULT) -> str:
return f"Hello, {world}!"
import io
import pandas as pd
import requests
data_url = "https://gist.githubusercontent.com/noamross/e5d3e859aa0c794be10b/raw/cars.csv"
data_string = requests.get(data_url).text
df = pd.read_csv(io.StringIO(data_string), index_col=0)
34.62365962451697 78.0246928153624 0
30.28671076822607 43.89499752400101 0
35.84740876993872 72.90219802708364 0
60.18259938620976 86.30855209546826 1
79.0327360507101 75.3443764369103 1
45.08327747668339 56.3163717815305 0
61.10666453684766 96.51142588489624 1
75.02474556738889 46.55401354116538 1
76.09878670226257 87.42056971926803 1
84.43281996120035 43.53339331072109 1
32.502345269453031 31.70700584656992
53.426804033275019 68.77759598163891
61.530358025636438 62.562382297945803
47.475639634786098 71.546632233567777
59.813207869512318 87.230925133687393
55.142188413943821 78.211518270799232
52.211796692214001 79.64197304980874
39.299566694317065 59.171489321869508
48.10504169176825 75.331242297063056
52.550014442733818 71.300879886850353
@RHDZMOTA
RHDZMOTA / hello.py
Last active September 19, 2021 06:00
import os
HELLO_WORLD_DEFAULT = os.environ.get(
"HELLO_WORLD_DEFAULT",
default="World"
)
def hello(world: str = HELLO_WORLD_DEFAULT) -> str:
return f"Hello, {world}!"
@RHDZMOTA
RHDZMOTA / pyenv-manage.sh
Last active September 10, 2021 19:17
Cross operative system pyenv installer.
manage() {
local command="${1}"
case "${command}" in
install)
case "${OSTYPE}" in
msys)
echo "Installing pyenv-win"
git clone https://github.com/pyenv-win/pyenv-win.git "${HOME}/.pyenv-github"
ln -s "${HOME}/.pyenv-github/pyenv-win" "${HOME}/.pyenv"
@RHDZMOTA
RHDZMOTA / hello.py
Created August 22, 2021 05:36
Python script: hello
import os
import argparse
from typing import Optional
DEFAULT = os.environ.get("DEFAULT", "world")
def hello(name: Optional[str] = None):
print(f"Hello, {name or DEFAULT}.")

Shareable Code Sippets

Share beautiful code snippets by using the Github Gists <> Carbon App integration!

The idea is simple:

  1. Identify your github gist's ID

    • https://gist.github.com/<user>/<gist-id>
  2. Append it into the carbo-app URL

@RHDZMOTA
RHDZMOTA / last.py
Last active August 21, 2021 18:09
Get the last element of any python iterator.
from typing import Any, Iterator, Optional
def last(iterator: Iterator[Any]) -> Optional[Any]:
last = None
for last in iterator:
continue
return last
@RHDZMOTA
RHDZMOTA / databricks-job.json
Created July 15, 2021 21:47
Databricks JSON JOB (Layout)
{
"name": "My Job Name",
"new_cluster": {
"spark_version": "7.5.x-scala2.12",
"node_type_id": "m4.xlarge",
"aws_attributes": {
"zone_id": "us-west-2a",
"instance_profile_arn": <AWS-PROFILE-ARN>,
"availability": "SPOT_WITH_FALLBACK",
"ebs_volume_type": "GENERAL_PURPOSE_SSD",