Skip to content

Instantly share code, notes, and snippets.

View empty-table-hack.py
# Make sure the table is created in the db even if it's empty. This is ugly,
# including in that every column will have type `string`, but the types will be
# fixed up as soon as there's actual data to load
if count == 0:
nulls_df = result_to_df([], field_info)
nulls_df = pd.concat(
[nulls_df, pd.DataFrame([{c: None for c in nulls_df.columns}])]
)
nulls_df.to_sql(
# ...
View airtable-iterator-error.py
def load(connection, airtable, table_name, field_info, destination):
restarts = 0
while True:
try:
chunks = airtable.iter_chunks(table_name)
# Airtable will give us the records in chunks of 100, which is
# inefficiently small for loading into Snowflake, so buffer them up into
# chunks of a few thousand
chunks = rechunked(chunks, 5000)
return _load_chunks(connection, chunks, field_info, destination)
View airtable-retry-logic.py
class AirtableClient:
# ...
def request(self, method, *args, **kwargs):
# ...
retries = 0
wait = 30
while True:
response = self.session.request(method, *args, headers=headers, **kwargs)
if response.status_code != 429 or retries == 3:
View metabase-console-log.txt
metabase/redux/metadata fetchDatabaseMetadata
v @ app-main.bundle.js?a0cb8a0cb1424da110c7:1
app-main.bundle.js?a0cb8a0cb1424da110c7:1 Error getting setting graph.x_axis._is_timeseries TypeError: Cannot read property 'cols' of undefined
at Object.getDefault (app-main.bundle.js?a0cb8a0cb1424da110c7:1)
at g (app-main.bundle.js?a0cb8a0cb1424da110c7:1)
at t.getComputedSettings (app-main.bundle.js?a0cb8a0cb1424da110c7:1)
at h (app-main.bundle.js?a0cb8a0cb1424da110c7:1)
at t.value (app-main.bundle.js?a0cb8a0cb1424da110c7:1)
at t.value (app-main.bundle.js?a0cb8a0cb1424da110c7:1)
at u.performInitialMount (vendor.bundle.js?a0cb8a0cb1424da110c7:1)
View metabase-server-log.txt
09-16 16:08:02 WARN middleware.process-userland-query :: Query failure {:status :failed,
:class java.sql.SQLNonTransientConnectionException,
:error "(conn=6989) Connection timed out (Write failed)",
:stacktrace
("org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:234)"
"org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:165)"
"org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:238)"
"org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:232)"
"org.mariadb.jdbc.MariaDbPreparedStatementClient.execute(MariaDbPreparedStatementClient.java:159)"
"org.mariadb.jdbc.MariaDbPreparedStatementClient.executeQuery(MariaDbPreparedStatementClient.java:174)"
View tableplus-snowflake-segfault
Process: TablePlus [5322]
Path: /Applications/TablePlus.app/Contents/MacOS/TablePlus
Identifier: com.tinyapp.TablePlus
Version: 2.8.3 (259)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: TablePlus [5322]
User ID: 503
Date/Time: 2019-09-13 11:19:10.648 -0400
@johnmastro
johnmastro / Card.java
Last active Oct 11, 2021
Card and Deck classes in Java (from an assignment in my Java class)
View Card.java
import java.util.Objects;
/**
* Class representing a playing card from a standard 52-card deck.
*/
public class Card
{
/**
* Enum representing playing card suits.
*/
@johnmastro
johnmastro / perl6-mode-imenu-chunk-bad.el
Created Jul 29, 2016
Example in a discussion on help-gnu-emacs
View perl6-mode-imenu-chunk-bad.el
;;; perl6-imenu.el --- Imenu support Perl 6 -*- lexical-binding: t; -*-
;;; fragment
;; Imenu functions and variables are defined here.
;; a new definition of the Variables entry regex:
(defconst perl6-vars
(concat
"^\\s-*" ; leading ws allowed
"\\(?:my\\|our\\)\\s-+" ; scope of var, followed by mandatory ws
"\\(" ; start capture group 1 for the var name
View newline-indent-comint-send-input.el
;; This is just an example related to the discussion in this Emacs.SE question:
;; https://emacs.stackexchange.com/questions/20732/how-do-i-enable-indentation-in-an-inferior-scheme/
(defun newline-indent-comint-send-input ()
(interactive)
(newline-and-indent)
(comint-send-input))
(with-eval-after-load 'cmuscheme
(define-key inferior-scheme-mode-map (kbd "RET") #'newline-indent-comint-send-input))
@johnmastro
johnmastro / slime-ac-example.el
Created Feb 24, 2016
Example of setup with SLIME and auto-complete
View slime-ac-example.el
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
(defvar my-packages '(slime auto-complete ac-slime)
"List of packages to install automatically.")
(let ((need (delq nil (mapcar (lambda (pkg)