pip install pre-commit
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
#!/bin/bash | |
# ============================================================================= | |
# | |
# Very random gcloud related snippets | |
# | |
# ============================================================================= | |
set -e | |
set -o nounset |
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
#!/bin/bash | |
ES_HOST=localhost | |
ES_PORT=9200 | |
ES_USERNAME=elasticsearch | |
ES_PASSWORD=oohlala | |
ES_URL="https://$ES_USERNAME:$ES_PASSWORD@$ES_HOST:$ES_PORT" | |
dump_mapping() { | |
local index_name="$1" |
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
""" | |
Identify out-of-sync replica shards for an Elasticsearch index | |
-------------------------------------------------------------- | |
This program will output a list of all shards for a given index, identifying | |
the ones that are out-of-sync with respect to the primary shard. |
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
#!/usr/bin/env python3 | |
""" | |
Looks up an IP address using GeoLite2 City Database | |
""" | |
from functools import lru_cache | |
import geoip2.database | |
import geoip2.errors |
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
""" | |
Example of inference of masked LM models via Huggingface | |
and transformers/bert in Italian language | |
""" | |
import torch | |
from torch.nn import functional as F | |
from transformers import AutoModel, AutoModelWithLMHead, AutoTokenizer | |
#model_name = "dbmdz/electra-base-italian-xxl-cased-discriminator" |
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
// https://stackoverflow.com/a/11760121/11303 | |
function julian_days() { | |
const date = new Date(); | |
//const jd = Math.floor((date / 86400000) - (date.getTimezoneOffset() / 1440) + 2440587.5); | |
const jd = (date / 86400000) - (date.getTimezoneOffset() / 1440) + 2440587.5; | |
console.log("jd=" + jd); | |
return jd; | |
} | |
// https://en.wikipedia.org/wiki/Position_of_the_Sun |
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
// Modified from http://www.stargazing.net/kepler/jsmoon.html | |
// | |
// This page works out some values of interest to lunar-tics | |
// like me. The central formula for Moon position is approximate. | |
// Finer details like physical (as opposed to optical) | |
// libration and the nutation have been neglected. Formulas have | |
// been simplified from Meeus 'Astronomical Algorithms' (1st Ed) | |
// Chapter 51 (sub-earth and sub-solar points, PA of pole and | |
// Bright Limb, Illuminated fraction). The libration figures |
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
""" | |
Lists all the GCP CloudNat IP addresses in a list of projects | |
Usage: | |
./gcp-list-nat-ips.py --project <gcp-project-name> | |
""" |
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 os | |
import dotenv | |
from langchain import PromptTemplate, HuggingFaceHub, LLMChain | |
# Add your HuggingFace hub token in a `.env` file, as: | |
# | |
# ``` | |
# HUGGINGFACEHUB_API_TOKEN=hf-.... | |
# ``` |