Skip to content

Instantly share code, notes, and snippets.

@timcharper
timcharper / copilot-electric-indent-workaround.el
Last active February 9, 2024 04:33
Some modes, like typescript-mode, cause electric-indent-mode to interfere with copilot
;; see https://github.com/copilot-emacs/copilot.el/issues/250
(defun copilot/cancel-on-electric-indent-chars (arg)
"Cancel copilot completion eagerly when electric-indent-mode is triggered."
(interactive "p")
;; clear the overlay if visible and keypress is in electric-indent-chars. Not really a rejection, so maybe let's not notify it as such?
(when (and (copilot--overlay-visible)
(memq last-command-event electric-indent-chars))
(defun insert-hello ()
(interactive)
(insert "hello"))
;; Define a function to cancel the keymap override
(defun cancel-override ()
(interactive)
;; Remove the override from `minor-mode-overriding-map-alist`
(setq minor-mode-overriding-map-alist
(assq-delete-all 'copilot-mode minor-mode-overriding-map-alist)))
@timcharper
timcharper / repro.org
Created February 1, 2024 22:24
Reproduce dape jest integratedTerminal issue

Create the files

mkdir -p src/__tests__/

cat <<-EOF > ./package.json
{
  "name": "debug-repro",
@timcharper
timcharper / README.md
Last active October 22, 2023 13:05
Macvlan using systemd

Before

yum install -y systemd-networkd
modprobe macvlan # make sure this returns no errors

Put config files in place

eth0.network and mac0.{netdev,network} go in /etc/systemd/network/

Keybase proof

I hereby claim:

  • I am timcharper on github.
  • I am timcharper (https://keybase.io/timcharper) on keybase.
  • I have a public key ASAArrwBGzgx-G6HftrQEiwrRODyANlf7FgG4mZfkyChewo

To claim this, I am signing this object:

@timcharper
timcharper / autoscroll.html
Created November 12, 2012 21:41
autoscroll embedded javascript with some test text
<html>
<body>
<script type="text/javascript">
javascript:/*The Autoscroll Bookmarket:Tim Harper:http://tim.theenchanter.com*/
var _ss_interval_pointer;
_ss_speed = 1;
_ss_speed_pairs = [[0, 0], [1, 200.0], [1, 120.0], [1, 72.0], [1, 43.2], [1, 25.9], [2, 31.0], [4, 37.2], [8, 44.8], [8, 26.4], [16, 32.0]];
_ss_last_onkeypress = document.onkeypress;
_ss_stop = function() {
clearTimeout(_ss_interval_pointer)
@timcharper
timcharper / mem.py
Created May 13, 2020 18:25
Allocate n mb per second
#!/usr/bin/env python3
from time import sleep
from sys import exit, argv, getsizeof
# this simple python script allocates memory, waits for a while, and then exits successfully
mem = 0
allocs = []
try:
mem = int(argv[1])
except ValueError:
print("Usage: mem.py <mb-to-allocate-per-cycle>")
#!/usr/bin/env python3
from time import sleep
from sys import exit, argv, getsizeof
# this simple python script allocates memory, waits for a while, and then exits successfully
mem = 0
try:
mem = int(argv[1])
except ValueError:
print("Usage: mem.py <mb-to-allocate>")
exit()
@timcharper
timcharper / apnea-plots.R
Created January 19, 2020 17:32
Apnea Plots
require("tidyverse")
require("ggplot2")
require("dplyr")
## install.packages("tidyverse")
require("lubridate")
pressure_begin6 = as.Date("2019-11-01")
pressure_begin10 = as.Date("2019-12-09")
pressure_begin6_r2 = as.Date("2019-12-23")
pressure_begin10_r2 = as.Date("2020-01-03")
Nov 19 18:44:23 ip-....internal marathon.sh[10865]: [2019-11-19 18:44:23,612] INFO Migration for storage: Version(18, 200, 0, PERSISTENCE_STORE) to target: Version(19, 300, 0, PERSISTENCE_STORE): apply change for version: Version(19, 200, 0, PERSISTENCE_STORE) (mesosphere.marathon.storage.migration.Migration:scala-execution-context-global-65)
Nov 19 18:44:23 ip-....internal marathon.sh[10865]: [2019-11-19 18:44:23,646] INFO Starting migration to 1.9.200 (mesosphere.marathon.storage.migration.MigrationTo19200:scala-execution-context-global-64)
Nov 19 18:44:23 ip-....internal marathon.sh[10865]: [2019-11-19 18:44:23,698] INFO Leadership ended with failure; exiting (mesosphere.marathon.core.election.ElectionServiceImpl:marathon-akka.actor.default-dispatcher-4)
Nov 19 18:44:23 ip-....internal marathon.sh[10865]: mesosphere.marathon.MigrationFailedException: while migrating storage to major: 19
Nov 19 18:44:23 ip-....internal marathon.sh[10865]: minor: 200
Nov 19 18:44:23 ip-....internal marathon.sh[10865]: pa