Skip to content

Instantly share code, notes, and snippets.

View cpjolicoeur's full-sized avatar

Craig P Jolicoeur cpjolicoeur

View GitHub Profile
#
# Klipper configuration file for Anycubic i3 MEGA S
#
# This config file contains settings of all printer pins (steppers, sensors) for Anycubic i3 mega S with TMC2208 Drivers with stock plug orientation
# Klipper firmware should be compiled for the atmega2560
#
# Config file includes
# - Original or 2208(2209) rotated by cable drivers
# - Mesh bed leveling: BLtouch (3DTouch sensor from Triangelab)
# - Manual meshed bed leveling (commented out)
@cpjolicoeur
cpjolicoeur / klipper.i3_mega_s.printer.cfg
Last active April 10, 2024 12:59
Klipper printer.cfg for my Anycubic i3 Mega S printer
# This file contains pin mappings for the Anycubic i3 Mega with
# Ultrabase from 2017. (This config may work on an Anycubic i3 Mega v1
# prior to the Ultrabase if you comment out the definition of the
# endstop_pin in the stepper_z1 section.) To use this config, the
# firmware should be compiled for the AVR atmega2560.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PF0
@cpjolicoeur
cpjolicoeur / gist:3590737
Created September 1, 2012 23:15
Ordering a query result set by an arbitrary list in PostgreSQL

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@cpjolicoeur
cpjolicoeur / gist:1855097
Created February 17, 2012 19:50 — forked from folke/gist:1453374
Gmail to OmniFocus
javascript:(function(){
if(top.document == document) {
var msg = document.getElementById("canvas_frame");
if(msg){
subjectEl = msg.contentDocument.getElementsByClassName("hP");
subject = subjectEl[0].innerText;
bodyEl = msg.contentDocument.getElementsByClassName("adP");
body = bodyEl[0].innerText;
@cpjolicoeur
cpjolicoeur / cors.janet
Created June 17, 2020 15:11
CORS middleware for Joy framework
(defn cors [handler &opt opts]
(default opts @{})
(def defaults @{"Access-Control-Allow-Origin" "*"
"Access-Control-Allow-Methods" "GET, OPTIONS"
"Access-Control-Allow-Headers" "Content-Type"
"Access-Control-Max-Age 86400})
(def options (merge defaults opts))
(fn [request]
(if (= "OPTIONS" (get request :method))
@{:status 204, :body "" :headers options}
defmodule DaydreamWeb.API.UnitAvailabilityControllerTest do
use DaydreamWeb.ConnCase
alias Daydream.{Fixtures, HomeShare, Repo}
alias Daydream.HomeShare.{UnitAvailability}
alias Daydream.Accounts.{Tenant}
import Ecto.Query, only: [from: 2]
@today Date.utc_today()
defmodule DaydreamWeb.API.UnitAvailabilityControllerTest do
use DaydreamWeb.ConnCase
alias Daydream.{Fixtures, HomeShare, Repo}
alias Daydream.HomeShare.{UnitAvailability}
alias Daydream.Accounts.{Tenant}
import Ecto.Query, only: [from: 2]
@today Date.utc_today()
[
{
"Name": "Aaron Gordon",
"Slug": "gordoaa01",
"Pos": "PF",
"Age": 23,
"G": 78,
"MP": 2633,
"PER": 15.1,
"TS%": 0.54,
@cpjolicoeur
cpjolicoeur / .tigrc
Last active August 31, 2017 07:16 — forked from aesnyder/.tigrc
bind generic f !@git fetch
bind generic p !@git pull
bind generic P !@git push
bind generic { !?git push -f
bind generic r !git rebase -i master
bind generic U !@sh -c "git checkout master && git pull && git checkout - && git rebase master"
bind generic M !@git checkout master
bind generic ! !@git reset HEAD^
bind generic @ !@?git reset --hard HEAD^
bind generic a !git commit --amend
@cpjolicoeur
cpjolicoeur / upgrade.md
Created March 6, 2017 15:56 — forked from chrismccord/upgrade.md
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs: