Skip to content

Instantly share code, notes, and snippets.

View rpalo's full-sized avatar

Ryan Palo rpalo

View GitHub Profile
@rpalo
rpalo / ulysses_t2s.py
Created July 3, 2019 14:24
A script for converting tabs in Python code blocks of the markdown output of Ulysses to spaces.
#!/usr/bin/env python3
import argparse
import fileinput
parser = argparse.ArgumentParser(description="Convert tabs in markdown files to spaces.")
parser.add_argument("-a", "--all", action="store_true", help="Convert all tabs to spaces")
parser.add_argument("-n", "--number", type=int, default=4, help="Number of spaces to use.")
parser.add_argument('files', metavar='FILE', nargs='*', help="files to read, if empty, stdin is used")
import turtle
window = turtle.Screen()
window.setup(width=800, height=600, startx=10, starty=0.5)
euler = turtle.Turtle() # A good mathy name for our turtle
euler.shape("turtle")
scale = 5 # This isn't a turtle module setting. This is just for us.
# Move the little buddy over to the left side to give him more room to work
euler.penup()
import turtle
window = turtle.Screen()
euler = turtle.Turtle() # A good mathy name for our turtle
euler.shape("turtle")
current = 0 # Here's how we know where we are
seen = set() # Here's where we'll keep track of where we've been
# Step increases by 1 each time
import turtle
window = turtle.Screen()
euler = turtle.Turtle() # A good mathy name for our turtle
euler.shape("turtle")
current = 0 # Here's how we know where we are
seen = set() # Here's where we'll keep track of where we've been
# Step increases by 1 each time
import turtle
window = turtle.Screen()
joe = turtle.Turtle()
joe.forward(50)
joe.left(90)
joe.forward(100)
turtle.done()

Here we go. Here's a nice gist.

Check me out:

3.times do
  puts "Hello, there"
end
@rpalo
rpalo / walle.zsh
Last active October 3, 2018 04:07
Print a colored Wall-E in your Zsh terminal!
#!/usr/bin/env zsh
lightgrey() {
print -nrP -- "%{$FG[250]%}$@"
}
grey() {
print -nrP -- "%{$FG[244]%}$@"
}
white() {
print -nrP -- "%{$FG[255]%}$@"
@rpalo
rpalo / sotw-analysis.ipynb
Created August 29, 2018 04:17
The State of the Web data analysis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rpalo
rpalo / water_trap.py
Last active June 26, 2018 15:03
Calculate how much water a group of walls can hold. Interview Question from @cassidoo's email newsletter.
"""Calculate how much water is trapped between walls.
| |
Basically, wall sections of the pattern |___| are easier to calculate than |___|. So,
Split the walls up into water-tight sections where the last wall >= the first wall.
If that's not possible, then reverse the whole section so that you have at least one increasing section
and keep working.
| | | | | |
|__|__|__|__| This gets processed in these chunks: |__|, |__|, |__|, and |__|.
They hold 1, 2, 1, and 1, respectively, for a total of 5!
@rpalo
rpalo / walle.fish
Created June 23, 2018 18:01
Print a colored Wall-E in your terminal!
function walle
set light_blue C7E2E8
set gray C1C1BD
set light_gray EEE
set dark_gray 565653
set bronze C6973F
set yellow FFE500
set lime C6E80B
set brown 8C5D05