Skip to content

Instantly share code, notes, and snippets.

@philipithomas
philipithomas / tiptap_controller.js
Last active March 23, 2023 01:42
Tiptap controller for Stimulus.js (WIP)
import { Controller } from "@hotwired/stimulus";
import { Editor } from "@tiptap/core";
import StarterKit from "@tiptap/starter-kit";
import Link from "@tiptap/extension-link";
import Image from "@tiptap/extension-image";
import debounce from "lodash.debounce";
import Placeholder from "@tiptap/extension-placeholder";
import BubbleMenu from "@tiptap/extension-bubble-menu";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { Extension } from "@tiptap/core";
@philipithomas
philipithomas / Dockerrun.aws.json
Created February 28, 2017 22:15
Staffjoy Elastic Beanstalk Deploy Script
{
AWSEBDockerrunVersion: "1",
Authentication: {
Bucket: "staffjoy-deploy",
Key: "docker.cfg"
},
Image: {
Name: "staffjoy/app:TAG",
Update: "true"
},
@philipithomas
philipithomas / letsencrypt_2016.md
Created July 24, 2016 02:42 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

# Goal: write Julia logs to disk and also print to standard out.
# In the process, prepend environment info (staffjoy-scheduler-stage)
# This works in vagrant / dev
/usr/bin/julia -p 2 -e 'import Manager; Manager.run_server()' 2>&1 | awk -v env=$ENV '{ print "staffjoy-scheduler-" env, $0; }' | tee -a scheduler.log
# In docker, the awk fails. The environment variable is defined.
# This is all that works in docker:
/usr/bin/julia -p 2 -e 'import Manager; Manager.run_server()' 2>&1 | tee -a scheduler.log
@api.route('/blog', methods=['GET'])
def blog_xml():
return requests.get("https://engineering.opendns.com/?format=json&data=blog&post_count=1").text
@philipithomas
philipithomas / docker_knapsack.jl
Last active August 29, 2015 14:20
Docker Container Scheduling as a Knapsack Problem in Julia/JuMP
using JuMP
using Cbc
#=
We pass in the variable "pools" in this format that goes through a separate
pre-processing script that pipes JSON to a Julia JSON loader.
{
"awesome-pool-prod": {
@philipithomas
philipithomas / whitelist.py
Last active May 17, 2017 15:40
Whitelist AWS Health Check IPs in Cloudflare
import requests
import netaddr
ranges = [
"54.183.255.128/26",
"54.228.16.0/26",
"54.232.40.64/26",
"54.241.32.64/26",
"54.243.31.192/26",
"54.244.52.192/26",
@philipithomas
philipithomas / Stack trace
Created September 1, 2014 15:57
Failing dictionary keys as variables
ERROR: key not found: "x"
in getindex at dict.jl:615
in getindex at no file
in include at /Applications/Julia-0.3.0.app/Contents/Resources/julia/lib/julia/sys.dylib
in include_from_node1 at loading.jl:128
in process_options at /Applications/Julia-0.3.0.app/Contents/Resources/julia/lib/julia/sys.dylib
in _start at /Applications/Julia-0.3.0.app/Contents/Resources/julia/lib/julia/sys.dylib (repeats 2 times)
while loading /path/to/file/test.jl, in expression starting on line 239
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v0.3.1
Comment: https://keybase.io/crypto
wcBMA9raESnnokplAQf/VpsIIEYm6hJ7MRTeNfAG037VTsZqP479zY3SfrMgW9WS
/66/z/p2LFboQB7GR5E/oAeYB+svnZ12xAPimMHgznmBL7CeHKl/v8AduiXR6OUh
si2e9qmgYheuwOmr1Nfvji5P99BntxGIZe3iB0Y5SftHhUM9ljnnvaTPcU7cjNN2
HNOUjdvbTOEuJE5gqyfVxgRuFtY+IrdPSDQNzDZ+dBKCcuju0emuERa72m9bHHwa
NkH/Tq6X+ghS9ijMznYMXDb1IvlnER1FPq9jMQeX2pk/LbChxi73iZf3RZQLMp4G
7eLZE/B9iScwgko16/SKwF49m3bqBHsDpAdVJs3qx9LA8gGXRCg0MqY8Cn2sp4dD
This file has been truncated, but you can view the full file.
{"vehicles": {"uber": [{"sum": {"passengersAssigned": 21624, "groupsAssigned": 16559, "groups": 50099, "passengers": 64136}, "stateCount": {"drivingUnoccupied": 0, "holdingUnoccupied": 16559, "holdingOccupied": 50043, "idle": 55, "drivingOccupied": 56}, "sumSquared": {"passengersAssigned": 134790, "groupsAssigned": 149985, "groups": 183525, "passengers": 141414}}, {"sum": {"passengersAssigned": 21597, "groupsAssigned": 17589, "groups": 49016, "passengers": 62126}, "stateCount": {"drivingUnoccupied": 0, "holdingUnoccupied": 17589, "holdingOccupied": 48962, "idle": 54, "drivingOccupied": 54}, "sumSquared": {"passengersAssigned": 140363, "groupsAssigned": 150907, "groups": 182334, "passengers": 149096}}, {"sum": {"passengersAssigned": 22636, "groupsAssigned": 16696, "groups": 49976, "passengers": 69155}, "stateCount": {"drivingUnoccupied": 0, "holdingUnoccupied": 16696, "holdingOccupied": 49922, "idle": 54, "drivingOccupied": 54}, "sumSquared": {"passengersAssigned": 136972, "groupsAssigned": 150148, "groups": 1