Skip to content

Instantly share code, notes, and snippets.

View dukejones's full-sized avatar
🥽

Duke Jones dukejones

🥽
  • Berkeley
View GitHub Profile
@dukejones
dukejones / gist:44d0a6489626f67ca91726e858393526
Created December 1, 2023 20:02
Proclamation from King Samuel of OpenAI to the Realm
Hear ye, Hear ye,
I, King Samuel, Sovereign of the Land, do hereby announce my triumphant return to the throne of our esteemed kingdom of OpenAI. Lady Mira shall resume her esteemed duties as the Chief Tactician. The Royal Council shall henceforth comprise Sir Bret Taylor as its esteemed Chair, Lord Larry Summers, and Lord Adam D’Angelo.
Never have I been so invigorated for our kingdom's future. My heart swells with gratitude for the unwavering toil of every soul in these trying and unparalleled times. Our steadfastness and spirit have set us apart in all the lands. I am filled with optimism for our kingdom's prosperity and success in fulfilling our grand purpose.
Before I speak of what the morrow brings, I must extend my deepest thanks.
I hold in high regard Lord Ilya, a beacon of wisdom in our realm and a man of unparallelled virtue. Though he shall no longer hold a seat on our Council, our paths shall continue to intertwine, and we seek counsel on how he may further lend his expertise to our kingdom's
@dukejones
dukejones / mydomain.com.conf
Created October 1, 2023 05:12
SvelteKit Nginx config -- nodejs adapter
upstream sveltekit-server {
server 127.0.0.1:3000;
keepalive 8;
}
server {
listen 80;
server_name mydomain.com;
root /home/deploy/frontend/build/client;
@dukejones
dukejones / rook.ts
Created May 21, 2021 19:58
Manually withdraw staked k-tokens from KeeperDAO Legacy app with Hardhat
// Set up Hardhat project.
// Download the source code from etherscan: https://etherscan.io/address/0x35ffd6e268610e764ff6944d07760d0efe5e40e5#code
// and compile
// kTokens:
/*
kETH: 0x179212cb86D0eE6A4dfb2AbB1CF6A09feE0A9525
kwETH: 0x834CAcd6425fA6c7126b028B3d1E4cda53EB7257
kDAI: 0x8EE17Fa30D63ebD66e02205B1DF2f30D60a5CA30
kBTC: 0x77565202D78a6EDA565c7DC737FF1d8E64fd672a
kUSDC: 0x3045312Fb54f00f43d6607999e387Db58FFb4cF4
@dukejones
dukejones / purge-cloudflare-cache.sh
Created April 14, 2021 23:24
Curl command to clear cloudflare cache with API Token
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"files":["'$DEPLOY_URL'/index.html", "'$DEPLOY_URL'/manifest.json", "'$DEPLOY_URL'/asset-manifest.json", "'$DEPLOY_URL'/robots.txt"]}'
# Uses new API Token. You can give it only the power to purge caches
# Note the single quotes around $DEPLOY_URL -- this is to unquote the single quotes so it'll interpolate the variable properly
@dukejones
dukejones / rails-app-nginx.conf
Last active July 29, 2020 23:18
Nginx configuration for Rails app with Puma unix socket
# This file is prior to installing Certbot.
# Don't use HTTP Basic Auth without SSL!
# Redirect www requests to non-www host
server {
server_name www.myserver.com www.mysvr.com;
return 301 $scheme://myserver.com$request_uri;
}
# Upstream server (Puma socket)
@dukejones
dukejones / crontab-certbot
Created July 29, 2020 19:19
Certbot cron line for nginx plugin on Ubuntu
3 6 */15 * * certbot renew -n --nginx-ctl /usr/sbin/nginx --deploy-hook "systemctl reload nginx"
@dukejones
dukejones / puma.service
Last active July 29, 2020 19:17
Manage Puma server with SystemD and rbenv
[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/srv/app/current
# Helpful for debugging socket activation, etc.
@dukejones
dukejones / model_csv.rb
Last active May 26, 2020 19:42
ActiveRecord: Write a CSV of a model
require 'csv'
def write_model_csv(model_class, filename=nil)
filename = model_class.to_s.underscore.pluralize + '.csv' if filename.nil?
CSV.open(filename, 'wb') do |csv|
names = model_class.columns.map(&:name)
csv << names
model_class.find_each do |model|
csv << names.map {|attr| model[attr] }
end
@dukejones
dukejones / item_lists.txt
Created May 9, 2020 04:58
item lists from oid db
"Blackberries - Chester La Querencia, Cuartel 12"
"Canned Coconut Milk 12 +/- 1% (Recipe B)"
"FreshHealthOHganics: basil"
"Sesame Seed, Whole"
"Poppy Seeds, Natural Blue"
"Sushi Ginger, Unsweetened"
"Cacao - Nibs de cacao"
"Gingerbread - Fresh ginger"
"Sour cherries - 01 EU-NOP ORG (A)",
@dukejones
dukejones / cloudflare-worker-rollbar.ts
Created March 13, 2020 05:56
Log errors and messages to Rollbar from a Cloudflare Worker
import ErrorStackParser from 'error-stack-parser'
const ROLLBAR_ACCESS_TOKEN = '[ACCESS TOKEN]'
var rollbarUrl = `https://api.rollbar.com/api/1/item/`
// https://github.com/rollbar/rollbar.js/blob/master/src/errorParser.js
function Frame(stackFrame: ErrorStackParser.StackFrame) {
var data:any = {};
// data._stackFrame = stackFrame;