This file contains 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
# some alternatives to get date or datetime | |
# in order to get epoch seconds of the beginning of the choosen date | |
# -------------------------------------------------------------------------------- | |
# alternative 1 | |
# -------------------------------------------------------------------------------- | |
from datetime import datetime | |
from zoneinfo import ZoneInfo | |
datetime.now(tz=ZoneInfo('localtime')) | |
# requires an extra std package `zoneinfo` |
This file contains 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 urllib.request | |
import json | |
def get_public_ip(url): | |
try: | |
req = urllib.request.Request( | |
url, | |
headers={'User-Agent': 'curl/7.74.0'} | |
) | |
with urllib.request.urlopen(req) as response: |
This file contains 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
#!/bin/bash | |
# Replace with the actual directory path to search in | |
search_dir=$(git rev-parse --show-toplevel 2>/dev/null || git rev-parse --git-dir 2>/dev/null | sed 's/\.git$//') | |
# Replace with your list of strings | |
search_strings=("< pattern 1 >" "< pattern 2 >" "< pattern 3 >") | |
# Create a pattern by joining the search strings with a pipe (|) as the separator | |
pattern=$(printf "%s\\|" "${search_strings[@]}") |
This file contains 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
start=$(date +%s%N) | |
# any command | |
end=$(date +%s%N) | |
elapsed_nanosec=$((end - start)) | |
formatted_elapsed_nanosec=$(printf "%'d" "$elapsed_nanosec" | sed 's/,/_/g') | |
echo "Elapsed time: $formatted_elapsed_nanosec nanoseconds" |
This file contains 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
{ | |
test1: repository(owner: "robfig", name: "cron") { | |
...RepoFragment | |
} | |
} | |
fragment RepoFragment on Repository { | |
name | |
defaultBranchRef { |
This file contains 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
# -------------------------------------------------------------------------------- | |
# option 1: using numpy.array(< list >, dtype=object).flat) | |
# -------------------------------------------------------------------------------- | |
import tracemalloc | |
import functools | |
import operator | |
import itertools | |
import numpy |
This file contains 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
{ | |
"backmatter": "", | |
"bulletListMarker": "-", | |
"codeBlockStyle": "fenced", | |
"contextMenus": true, | |
"disallowedChars": "[]#^", | |
"downloadImages": false, | |
"downloadMode": "downloadsApi", | |
"emDelimiter": "_", | |
"fence": "```", |
This file contains 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
#!/usr/bin/env python | |
# MIT License | |
# Copyright (c) 2022-present, Manuel Solorzano | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains 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 requests | |
# r = requests.get("coderbyte.com/api/challenges/json/age-counting") | |
# d = r.json() | |
d = { | |
"data": "key=IAfpK, age=58, key=WNVdi, age=64, key=jp9zt, age=47, key=0Sr4C, age=68, key=CGEqo, age=76, ... key=cFCfU, age=5, key=J8an1, age=48, key=dkSlj, age=5" | |
} | |
l = d['data'].split(", ") |
This file contains 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
# -------------------------------------------------------------------------------- | |
# temp stage | |
FROM python:3.10.9-slim-bullseye as builder | |
WORKDIR /code | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 |
NewerOlder