Skip to content

Instantly share code, notes, and snippets.

@johnmastro
johnmastro / slime-ac-example.el
Created February 24, 2016 21:50
Example of setup with SLIME and auto-complete
(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)
;; 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 / perl6-mode-imenu-chunk-bad.el
Created July 29, 2016 17:13
Example in a discussion on help-gnu-emacs
;;; 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
@johnmastro
johnmastro / Card.java
Last active March 24, 2024 19:13
Card and Deck classes in Java (from an assignment in my Java class)
import java.util.Objects;
/**
* Class representing a playing card from a standard 52-card deck.
*/
public class Card
{
/**
* Enum representing playing card suits.
*/
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
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)"
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)
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:
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)
# 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(
# ...