I hereby claim:
- I am affinespaces on github.
- I am affinespaces (https://keybase.io/affinespaces) on keybase.
- I have a public key ASD5y8pqPADG0-x9qYC0p3Wagc8I4BzC2GWz_m1aggbR6Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# Using SQLite's CSV mode from Python for extremely fast bulk data loads | |
# | |
# Note that if the target table does not exist, SQLite will create it automatically, | |
# creating column names from the first row in the CSV assuming TEXT datatypes. | |
# | |
# If the target table does exist, SQLite will treat the first row in the CSV file | |
# as *data*. So if the CSV file contains a header, you should either delete it from the | |
# source file, or, if using SQLite > 3.32.0, pass the `--skip 1` flag to the `.import` | |
# command (`import data.csv Data --skip 1`) | |
# |
Computer programs consist of instructions that either
Instructions that compute values are called expressions. Expressions always return a value. For example, 2 + 3
, add(50, 100)
, "Nestor " + "is a cat"
, 1
, "hello"
and 3.141592653589793
are all expressions (why?).
Instructions that perform actions are called statements. The actions they perform are called "side effects". This nearly always implies some kind interaction with the world outside the program: printing stuff to a terminal screen, fetching data over the internet, or creating and deleting files. Often, but not always, statements return None
(different from the string "None"
). Paradoxically, None
is a value that signifies the quality of not having a value!
import numpy as np | |
from scipy.linalg import norm, solve | |
from itertools import pairwise | |
golden_ratio = (np.sqrt(5) + 1) / 2 | |
def gss(f, a, b, tol=1e-10): |
import itertools | |
def exhausted(generator): | |
try: | |
next(generator) | |
return False | |
except StopIteration: | |
return True | |
from enum import Enum, auto | |
from collections import namedtuple | |
class Operation(Enum): | |
PUSH = auto() | |
STORE = auto() | |
LOAD = auto() |
import pprint | |
from enum import Enum, auto | |
class TokenType(Enum): | |
COMMENT = auto() | |
SEMICOLON = auto() | |
DATATYPE = auto() | |
STRING = auto() |
""" | |
Zero dependency script that extracts inlined SQL from a C# module and translates it to a Databricks formatted notebook | |
Suppose that you have a 2500 line C# module containing lots of methods of the form | |
public DataTable GetSomething(...) { | |
... | |
var sql = @"<sql query>" | |
... | |
} |
from scipy.linalg import norm | |
from chebyshev import ChebyshevPolynomial | |
import numpy as np | |
from itertools import combinations, combinations_with_replacement | |
import matplotlib.pyplot as plt | |
# Usage: | |
# Ensure Docker daemon is running, then run from the same directory as this Dockerfile: | |
# | |
# docker build -t my-mssql-server . | |
# docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Yourstr0ngp@ssword' -p 1433:1433 --name sql1 -d my-mssql-server | |
# | |
# This builds the image. Then execute the following SQL on the server in SSMS to enable SQL Agent: | |
# | |
# EXEC sp_configure 'show advanced options', 1; | |
# EXEC sp_configure 'Agent XPs', 1; |