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 | |
# | |
# This script will patch a Helm release secret and move it to another namespace. | |
# It will also delete the original secret after the patching is done. | |
# It's useful when you want to move a Helm release to another namespace without having to delete and recreate it. | |
# | |
# Credits for the original idea: https://blog.random.io/moving-helm-release-to-another-kubernetes-namespace | |
# |
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
from multiprocessing import cpu_count, get_context | |
from tqdm.auto import tqdm | |
from time import sleep | |
# A fake function to simulate some work | |
def process_data(x: str) -> str: | |
sleep(0.001) | |
return x + " processed" | |
def main(): |
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
from transformers import pipeline | |
pipe = pipeline("fill-mask", model="roberta-large", top_k=1) | |
def get_topic_using_fill_mask(words): | |
results = pipe(f"{words}. \n These words are about <mask>.") | |
return results[0]["token_str"].strip() | |
get_topic_using_fill_mask(["terra, mars, moon, saturn, jupyter"]) |
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 openai | |
res = openai.Completion.create( | |
model="text-davinci-002", | |
prompt="How are you?\n", | |
temperature=0, | |
max_tokens=64, | |
top_p=1 | |
) |
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
from scrapy import Spider | |
from bs4 import BeautifulSoup | |
class AmazonSpider(Spider): | |
name = "amazon" | |
allowed_domains = ["amazon.com"] | |
custom_settings = { |
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 | |
curl 'localhost:9200/_cat/indices/' | awk '{ print $3 }' | xargs -I % curl -XDELETE 'localhost:9200/%' | |
# - useful if you can't delete using a wildcard | |
# - `xargs` can be swapped with `GNU parallel` | |
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
/** | |
* Module dependencies | |
*/ | |
var less = require('less'); | |
// wrap less.render() in a native Promise |
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
# | |
# This is a simple, clean PS1 with current git branch displayed. | |
# How will look like: | |
# | |
# λ ~/home/project (master) | |
# | |
# NOTE: You may have to configure your terminal to support UTF-8 Unicode (so λ will displayed correctly) | |
function parse_git_branch () { |