Skip to content

Instantly share code, notes, and snippets.

@phord
phord / numwords.py
Created December 11, 2019 23:39
Convert numbers to words or roman numerals
#Some play code to see if I can improve on a "coding nightmare" that I saw online
#The goal is to enter an integer and return the same integer written out (e.g. '1'="one")
def sub1000(i):
'''Spells out any integer 0-999'''
#Create dictionaries to translate number:word depending on its place
onesdict = dict({1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine'})
tensdict = dict({2:'twenty',3:'thirty',4:'forty',5:'fifty',6:'sixty',7:'seventy',8:'eighty',9:'ninety'})
teensdict = dict({0:'ten',1:'eleven',2:'twelve',3:'thirteen',4:'fourteen',5:'fifteen',6:'sixteen',7:'seventeen',8:'eighteen',9:'nineteen'})
#Convert integer to a three digit number, identify hundreds place, tens place, ones place
@phord
phord / hangout-filter.py
Last active September 28, 2019 02:04 — forked from kylemcdonald/hangout-filter.py
This script will process the json dump from Google Takeout to extract all messages sent between two people. Before extracting the conversation you need to know the conversation_id.
# example:
# python hangout-filter.py Hangouts.json Ugw3axd-nDFKCvFsDi94AaABAQ | sort | tr '\n' ' ' > words.txt
# !/usr/bin/env python
import json
import argparse
import dateutil.parser
import re
import time
@phord
phord / Pure2-lego.gcode
Created September 19, 2018 00:30
Some g-code with segmented arcs
This file has been truncated, but you can view the full file.
; generated by Slic3r Prusa Edition 1.40.1-rc+linux64 on 2018-07-21 at 18:44:42
;
; external perimeters extrusion width = 0.45mm
; perimeters extrusion width = 0.45mm
; infill extrusion width = 0.45mm
; solid infill extrusion width = 0.45mm
; top infill extrusion width = 0.40mm
; first layer extrusion width = 0.70mm
But since you asked...
It's difficult for me to think of the concept of 'movement error' since we are so intolerant of any errors at all. I think that is only possible for us because we use steppers to move and to know where we moved. Therefore we must assume we always move to where we commanded. In a servobot with encoder feedback, they may command a movement to precise positions but they can be somewhat sloppy with it because of the motor physics involved, and they will use a PID to accelerate, decelerate, and guide their movement based on this real-world feedback.
In reality we do not have an error-free movement, either. We experience errors in the form of oscillation, "ringing" which shows up repeatedly on each layer near a sharp corner, for example. But we can also experience real slip errors where we encounter too much jerk which causes the motor to skip a step or slip too far. We control these with acceleration, and we try to limit accel to the level our printer can handle.
The Bath paper is a
@phord
phord / atom-git-confusion.sh
Last active April 20, 2016 13:45
Script to set up repositories to show Atom's confusion
#!/bin/sh
# Setup demo of atom's git directory confusion
set -e
set -x
ROOT=$(pwd)
rm -rf folder
mkdir folder
git init folder/super