Skip to content

Instantly share code, notes, and snippets.

@bramses
bramses / _result.md
Last active January 8, 2024 09:45
Use GPT-4 to automatically diagnose errors

TLDR

I wrapped Python traceback and Exception so whenever an Exception is raised, an automatic diagnosis is done by GPT-4. See results below:

Prompt (Automatically Generated by error_wrap function)

This error message occurred because of 'test' at line 177 in file api.py, function main. The exception type is <class 'Exception'>. The function is:

import json
import pickle
import struct
import zipfile
import numpy as np
from sentencepiece import SentencePieceProcessor
def rms_norm(x): return (x / np.sqrt(np.square(x).mean(-1, keepdims=True) + 1e-6))
def softmax(x): return (np.exp(x - np.max(x, axis=-1, keepdims=True))) / np.sum((np.exp(x - np.max(x, axis=-1, keepdims=True))), axis=-1, keepdims = True)
@niw
niw / README.en.md
Last active February 13, 2024 04:24
How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac. Enjoy!

NOTE: that this is current, 10/1/2021 state.

Running Windows 10 on ARM

  1. Install Xcode from App Store or install Command Line Tools on your Mac
@DeanLa
DeanLa / nb.py
Last active August 7, 2021 12:48
import os
import sys
from pathlib import Path
import joblib
import numpy as np
import pandas as pd
from IPython import get_ipython
from IPython.display import Markdown, display
from matplotlib import pyplot as plt
@ioggstream
ioggstream / render_calendar.py
Last active August 21, 2023 04:00
Render a simple calendar with python.
from datetime import datetime, timedelta, timezone
from requests import get
import icalendar
from dateutil.rrule import *
import pytz
import locale
locale.setlocale(locale.LC_TIME, "it_IT")
import time
@kirillzubovsky
kirillzubovsky / Zubovsky-pop
Last active March 11, 2022 11:51
A simple html template for a floating corner popup, like the one you see on SmashNotes.com
<link href="https://rsms.me/inter/inter.css" rel="stylesheet" type="text/css">
<style>
#zubovsky-pop-container{
-webkit-font-smoothing: subpixel-antialiased;
background-attachment: scroll;
background-clip: border-box;
background-color: rgb(14, 27, 46);
background-image: none;
background-origin: padding-box;
@tmckayus
tmckayus / remote_crc.md
Last active April 2, 2024 12:13
Running 'crc' on a remote server

Overview: running crc on a remote server

This document shows how to deploy an OpenShift instance on a server using CodeReady Containers (crc) that can be accessed remotely from one or more client machines (sometimes called a "headless" instance). This provides a low-cost test and development platform that can be shared by developers. Deploying this way also allows a user to create an instance that uses more cpu and memory resources than may be available on his or her laptop.

While there are benefits to this type of deployment, please note that the primary use case for crc is to deploy a local OpenShift instance on a workstation or laptop and access it directly from the same machine. The headless setup is configured completely outside of crc itself, and supporting a headless setup is beyond the mission of the crc development team. Please do not ask for changes to crc to support this type of deployment, it will only cost the team time as they politely decline :)

The instructions here were tested with F

function FindProxyForURL(url, host) {
// use proxy for specific domains
if (shExpMatch(host, "*.test.metalkube.org"))
return "SOCKS5 localhost:8053";
// by default use no proxy
return "DIRECT";
}
@rohantmp
rohantmp / rhhi.sh
Last active May 12, 2021 13:52
dev-scripts proxy automation.
# I use ~/.ssh/config to create ssh aliases for my machines.
# script requires passwordless ssh access
# script requires tmux
# After sourcing the script, just call rhhi_cluster_env_init, this will create a proxy to the host on 8053 in a tmux session and copy the kubeconfig from the host
# Once inited, other terminals can be brought into the env using rhhi_cluster_env which sets the env vars `https_proxy` and KUBECONFIG
export RHHI_REMOTE=root@bm9
# the ocp installer asset dir
OCP_LOCATION="/root/dev-scripts/ocp/ostest"
function rhhi_cluster_env {
export https_proxy=SOCKS5://localhost:8053
@PandaWhoCodes
PandaWhoCodes / download_emails.py
Created April 1, 2019 06:01
A script to download emails from gmail - http://www.ashish.ch
import imaplib
import email
import os
def create_folder(folder_name="backup"):
"""
Creates a folder to store all mails
"""
if not os.path.exists(folder_name):