Skip to content

Instantly share code, notes, and snippets.

https://try.ocamlpro.com/#code/open'Format!!exception'Exit'of'int!!type'info'='FI'of'string'*'int'*'int'$5'UNKNOWN!type'$,a'withinfo'='$4i:'info;'v:'$,a$6!!let'dummyinfo'='UNKNOWN!let'createInfo'f'l'c'='FI(f,'l,'c)!!let'errf'f'=!print_flush();!open_vbox'0;!open_hvbox'0;'f();'print_cut();'close_box();'print_newline();!raise'(Exit'1)!!let'printInfo'=!''(*'In'the'text'of'the'book,'file'positions'in'error'messages'are'replaced!with'the'string'$(Error:$('*)!function!FI(f,l,c)'-$.!print_string'f;!print_string'$(:$(;!print_int'l;'print_string'$(.$(;!print_int'c;'print_string'$(:$(!$5'UNKNOWN'-$.!print_string'$($-Unknown'file'and'line$.:'$(!!let'errfAt'fi'f'='errf(fun()-$.'printInfo'fi;'print_space();'f())!!let'err's'='errf'(fun()-$.'print_string'$(Error:'$(;'print_string's;'print_newline())!!let'error'fi's'='errfAt'fi'(fun()-$.'print_string's;'print_newline())!!let'warning's'=!print_string'$(Warning:'$(;'print_string's;!print_newline()!!let'warningAt'fi's'=!printInfo'fi;'print_string'$('Warning:'$(;!print_string's;'
@jimwhite
jimwhite / fib.roc
Created July 2, 2024 22:54
Fibonacci in Roc by ChatGPT
module [Fibonacci]
## Returns the Fibonacci sequence up to the nth term.
fibonacci : U32 -> List U32
fibonacci = \n ->
if n == 0 then
[]
else if n == 1 then
[0]
else
@jimwhite
jimwhite / math_notation_2020.html
Created May 17, 2024 05:51
Notation List for Cambridge International Mathematics Qualifications (For use from 2020) converted by GPT-4o to HTML and MathJax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mathematical Notation</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body>
@jimwhite
jimwhite / requirements.txt
Created April 19, 2024 21:53
Python 3.11 `pip install lumibot` (3.3.7) then `pip freeze` results
aiodns==3.2.0
aiohttp==3.9.5
aiosignal==1.3.1
alpaca-py==0.20.3
alpha-vantage==2.3.1
annotated-types==0.6.0
appdirs==1.4.4
APScheduler==3.10.4
asttokens==2.4.1
attrs==23.2.0
@jimwhite
jimwhite / requirements.txt
Created April 19, 2024 21:48
Python 3.11 `pip freeze` for https://github.com/Lumiwealth/lumibot at fce4b08
aiodns==3.2.0
aiohttp==3.9.5
aiosignal==1.3.1
alpaca-py==0.20.3
alpha-vantage==2.3.1
annotated-types==0.6.0
appdirs==1.4.4
APScheduler==3.10.4
asttokens==2.4.1
attrs==23.2.0
@jimwhite
jimwhite / plot_itransformer.py
Last active April 17, 2024 04:13
Plot all the models on one chart that just covers the predicted dates
plt.figure(figsize=(16, 8))
stock_data_subset = stock_data[stock_data['ds'].isin(rescaled_predictions_df['ds'])]
plt.plot(stock_data_subset['ds'], stock_data_subset['y'], label='Actual Price', linewidth=3, color='blue')
# ['iTransformer', 'TSMixer', 'NHITS', 'PatchTST']
plt.plot(rescaled_predictions_df['ds'], rescaled_predictions_df['iTransformer'],
label='iTransformer', linewidth=1, color='purple')
plt.plot(rescaled_predictions_df['ds'], rescaled_predictions_df['TSMixer'],
label='TSMixer', linewidth=1, color='green')
plt.plot(rescaled_predictions_df['ds'], rescaled_predictions_df['NHITS'],
label='NHITS', linewidth=1, color='red')
@jimwhite
jimwhite / gist:bc44ad2e3e1b4647afd2d5c4de87ccb6
Last active February 19, 2024 07:53
Quickstart for running Python using NixOS flox.dev in Docker
# Run Docker image with NixOS and flox:
# https://flox.dev/docs/install-flox/
# docker run --pull always --rm -it ghcr.io/flox/flox
docker run -it ghcr.io/flox/flox
# Then in that shell:
# flox config --set-bool disable_metrics true
cd ~
flox init
flox install python311Packages.python
@jimwhite
jimwhite / fetch_news.py
Last active January 11, 2024 03:56
Fetch history news using Alpaca API, raw JSON format, one article per file
import os
import json
from datetime import datetime, timezone
import time
import argparse
from alpaca.data.historical.news import NewsClient
from alpaca.data.requests import NewsRequest
from alpaca.data.timeframe import TimeFrame
@jimwhite
jimwhite / llama_example.ipynb
Created December 26, 2023 23:02
llama_example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jimwhite
jimwhite / gist:7866da091ddd56e5ba4a485a0295f7da
Last active October 31, 2023 23:06
Bard's code naming style guide
When naming variables in code, you can follow these best practices:
Descriptive: Choose names that are easy to remember.
Concise: Use clear and concise names.
A longer name needs to earn its length vs a shorter one by being more informative.
Lowercase: Use lowercase letters.
Underscores: Use underscores to separate words in a name.
No spaces: Avoid using spaces in names.
No special characters: Avoid using special characters.
No acronyms: Avoid using acronyms and abbreviations.
No conflicts: Avoid names that could be confused with keywords or built-in functions.