Skip to content

Instantly share code, notes, and snippets.

View tammymakesthings's full-sized avatar

Tammy Cravit tammymakesthings

View GitHub Profile
@tammymakesthings
tammymakesthings / textilewc_v2.rb
Created September 16, 2008 23:18
markupwc 1.0 release
#!/bin/env ruby
###########################################################################
# mkdwc: Behaves like wc(1) but operates on the raw text of one or more
# Markdown or Textile files.
# Tammy Cravit, [email protected]
###########################################################################
# This code can also be included into another script if you want to extend
# the MarkdownWC class.
###########################################################################
# This is the third take on this script, and abstracts out the markup-
@tammymakesthings
tammymakesthings / kcurl.sh
Created October 14, 2010 21:32
Download PDFs etc. and send them to your Kindle from the command line.
#!/bin/env bash
##############################################################################
# kcurl: Download one or more files and send them to the Kindle.
# Version 1.1, Tammy Cravit, [email protected], 10/14/2010
#
# Requires that cURL and mutt be installed. The "home Wi-Fi" detection code
# only works on MacOS X 10.x (probably with x > 4), but I welcome patches.
#
# To use this script, you'll need to configure the Kindle e-mail name and
# home Wi-Fi SSID below.
@tammymakesthings
tammymakesthings / on_execute.rb
Created January 5, 2012 15:41
Make a Ruby file behave correctly whether run from the command line or included in another script. (Thanks to elliotcable for this one)
module Kernel
def on_execute
calling_file = caller.first.split(':').first
if File.expand_path(calling_file) == File.expand_path($0)
yield
end
end
end
@tammymakesthings
tammymakesthings / look_and_say_sequence.rb
Created January 5, 2012 15:44
Ruby implementation of the "look and say sequence" (after John H. Conway and Bob Morris)
#########################################################################
# A simple Ruby implementation of the Look-and-Say sequence (also known
# as the Conway sequence or the Morris puzzle).
#
# In the Look-and-say Sequence, each term describes the previous term.
# So, the first term is "1". This term consists of 1 of the digit '1',
# so the next term is "11". This term consists of 2 of the digit '1',
# so the next term is "21". This term consists of a single 2, followed
# by a single "1", and so the next term is "1211". The next term would
# be "111221", and so forth.
############################################
# In lib/do_evil_things_to_strings.rb
############################################
class String
old_is_utf8 = instance_method(:is_utf8?)
define_method(:is_utf8?) do
return false if calling_method == 'quote'
old_is_utf8.bind(self).()
class Property < ActiveRecord::Base
has_many :exclusions
def excluded_on?(a_date)
self.exclusions.each do |offering|
return false if offering.start_date >= a_date && offering.end_date <= a_date
end
true
end
end
# I'm looking for a tidy named scope or class method I can define for a User
# that will give me all the Events for which the user hasn't yet registered.
class Event < ActiveRecord::Base
has_many :registrations
has_many :users, through: :registrations, as: :registrants
end
class Registration < ActiveRecord::Base
belongs_to :event

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@tammymakesthings
tammymakesthings / arduino-cli.yaml
Created December 30, 2019 16:06
arduino-cli configuration
proxy_type: auto
sketchbook_path: C:\Users\tammy.cravit\Documents\Arduino
arduino_data: C:\Users\tammy.cravit\AppData\Local\Arduino15
board_manager:
additional_urls:
- https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
- https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json
- https://arduboy.github.io/board-support/package_arduboy_index.json
- http://www.leonardomiliani.com/repository/package_leonardomiliani.com_index.json
- https://arduino.esp8266.com/stable/package_esp8266com_index.json
@tammymakesthings
tammymakesthings / ArduinoCLI.bat
Last active June 23, 2023 06:08
Install Arduino-cli stuff
arduino-cli config set sketchbook_path %HOME%\projects\arduino
arduino-cli core update-index
arduino-cli core install arduino:avr
arduino-cli core install adafruit:avr
arduino-cli core install arduino:samd
arduino-cli core install adafruit:nrf52
arduino-cli core install adafruit:samd
arduino-cli core install adafruit:wiced
arduino-cli core install esp8266:esp8266