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
// HERE'S THE PROBLEM I'VE BEEN TRYING TO SOLVE: | |
// Is it possible (in some type-safe language) to enforce the correctness of a SQL-query-like code joining a transactions table with a conversionRates table (that is, to only allow the amount * rate multiplication if the tables were joined the right way; on both the date and currency columns)? | |
// SOLUTION ATTEMPT IN SWIFT: | |
// A "value" represents either a property (cell) of a record, or a record (row) itself | |
protocol Value {} |
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 time | |
import pandas | |
from chatgpt_wrapper import ChatGPT | |
chat = ChatGPT() | |
def run_chat_loop(id_series, question_series, question_prefix, destination_path, pause_duration=1): | |
assert id_series.shape[0] == question_series.shape[0],\ | |
f"Non matching shapes for id ({id_series.shape}) and question series ({question_series.shape})" | |
result = pandas.DataFrame({'id': pandas.Series(dtype='str'), 'answer': pandas.Series(dtype='str')}) |
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
// | |
// ContentView.swift | |
// ABCBug | |
// | |
/* | |
Is this a bug? | |
Why does pressing the button change | |
the "outer" value and not the "inner" value? |
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
\documentclass[10pt]{article} | |
\pagestyle{empty} | |
\setlength{\topskip}{0pt} | |
\setlength{\parindent}{0pt} | |
\setlength{\abovedisplayskip}{0pt} | |
\setlength{\belowdisplayskip}{0pt} | |
\usepackage[T1]{fontenc} | |
\usepackage{geometry} |
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 selenium.webdriver.common.action_chains import ActionChains | |
import selenium.webdriver | |
import inspect | |
import time | |
from selenium.webdriver.common.keys import Keys | |
import os | |
import tempfile | |
import subprocess | |
import shutil | |
import sys |
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 http.server import BaseHTTPRequestHandler, HTTPServer | |
import mimetypes | |
import urllib.parse | |
import posixpath | |
import os | |
from http import HTTPStatus | |
import shutil | |
from io import BytesIO | |
import json | |
from urllib.parse import urlparse, parse_qs |
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
/* | |
* ThrowingOperators.swift | |
*/ | |
import Darwin | |
import CoreGraphics | |
// MARK: Operators | |
infix operator &&+ {associativity left precedence 140} | |
infix operator &&- {associativity left precedence 140} |
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
/* | |
* Usage.swift (continued #3) | |
*/ | |
// MARK: SafeMatrix methods. | |
func usageMethods() throws { | |
let W = try SafeMatrix<Matrix,M,N>([1,2,3,4,5,6]) // MxN | |
let X = try W.transpose() // NxM | |
let Y = try X * W // NxN | |
let Z = try Y.inverse() // NxN |
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
/* | |
* MatrixSetup.swift (continued #3) | |
*/ | |
// MARK: SafeMatrix methods | |
extension SafeMatrixProtocol where MatrixType == Matrix { | |
func transpose() throws -> SafeMatrix<Matrix,Columns,Rows> { | |
return try SafeMatrix(matrix: matrix.transpose()) | |
} | |
} |
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
/* | |
* Matrix.swift (continued) | |
*/ | |
import Darwin | |
// MARK: Stubbed methods | |
extension Matrix { | |
func transpose() -> Matrix { | |
abort() |
NewerOlder