Skip to content

Instantly share code, notes, and snippets.

View stephancom's full-sized avatar

stephan.com stephancom

View GitHub Profile
@stephancom
stephancom / stripe_customer.rb
Created March 21, 2014 03:54
Stripe Customer rails concern
# _ _
# __| |_ _ _(_)_ __ ___
# (_-< _| '_| | '_ \/ -_)
# /__/\__|_| |_| .__/\___|
# |_|
# __ _ _ __| |_ ___ _ __ ___ _ _
# / _| || (_-< _/ _ \ ' \/ -_) '_|
# \__|\_,_/__/\__\___/_|_|_\___|_|
#
# (c) 2013 stephan.com
@stephancom
stephancom / startup.gcode
Created November 5, 2022 01:12
Cura startup gcode for CR-6 SE with wire brush cleaning
; Script based on an original created by tjjfvi (https://github.com/tjjfvi)
; An up-to-date version of the tjjfvi's original script can be found
; here: https://csi.t6.fyi/
; Note - This script will only work in Cura V4.2 and above!
; --- Global Settings
; layer_height = {layer_height}
; smooth_spiralized_contours = {smooth_spiralized_contours}
; magic_mesh_surface_mode = {magic_mesh_surface_mode}
; machine_extruder_count = {machine_extruder_count}
; --- Single Extruder Settings
@stephancom
stephancom / destructive.rake
Last active September 29, 2022 04:25
guard for destructive rake tasks
# _ _ _ _
# __| | ___ ___| |_ _ __ _ _ ___| |_(_)_ _____
# / _` |/ _ \/ __| __| '__| | | |/ __| __| \ \ / / _ \
# | (_| | __/\__ \ |_| | | |_| | (__| |_| |\ V / __/
# \__,_|\___||___/\__|_| \__,_|\___|\__|_| \_/ \___|
# handy guard for destructive rake tasks
# just include this before any troublesome task
# typical usage:
# task :riskytask, [:destructive, :environment] do
@stephancom
stephancom / rails_six_calculations.rb
Created May 6, 2022 09:26
Rails 6 date/time calculations, backported
module CoreExtensions
module DateAndTime
# ___ _ _ ___ _ ___ _ _ _ _
# | _ \__ _(_) |__/ __(_)_ __/ __|__ _| |__ _ _| |__ _| |_(_)___ _ _ ___
# | / _` | | (_-<__ \ \ \ / (__/ _` | / _| || | / _` | _| / _ \ ' \(_-<
# |_|_\__,_|_|_/__/___/_/_\_\\___\__,_|_\__|\_,_|_\__,_|\__|_\___/_||_/__/
#
# A little backporting
# https://github.com/rails/rails/pull/32398
# https://github.com/rails/rails/pull/32398/commits/4e68b159d5696ca58c015a790ef3ceacb90b27c1
#
# superegg.rb
# Piet Hein's superegg
#
# ported from Python in 2022 by stephan.com
#
# original by Chris Wallace (kitwallace) 2013
# https://www.thingiverse.com/thing:48808
#
# https://en.wikipedia.org/wiki/Superegg
#
# superegg.rb
# Piet Hein's superegg
#
# ported from Python in 2020 by stephan.com
#
# original by Chris Wallace (kitwallace) 2013
# https://www.thingiverse.com/thing:48808
#
# https://en.wikipedia.org/wiki/Superegg
@stephancom
stephancom / tasks.rb
Created February 23, 2022 11:07
spec/support/tasks.rb
# https://www.eliotsykes.com/test-rails-rake-tasks-with-rspec
require 'rake'
# Task names should be used in the top-level describe, with an optional
# "rake "-prefix for better documentation. Both of these will work:
#
# 1) describe "foo:bar" do ... end
#
# 2) describe "rake foo:bar" do ... end
#
@stephancom
stephancom / enlang.rb
Last active December 5, 2021 06:32
a langfeldian binary encoding tool
#! /usr/bin/ruby
# full of sound and fury
class Hippie
def initialize(name)
@name = name
end
def smoke(this)
ciphertext = encode(this)
@stephancom
stephancom / delang.rb
Last active December 5, 2021 05:48
a software poem for john langfeld
#! /usr/bin/ruby
pearls = <<~ENDOFPOEM.freeze
Framed, Mounted and Preggers'
22975
6/19/19
Sneaking out of the bedroom in the wee hours he sat,
staring at digits and images and flummox and hope.
Who stared back?
01010100 01101000 01100101 00100000
@stephancom
stephancom / 5x5.rb
Created August 11, 2021 19:45
five by five, redux - blacksmith gunpowdery II
#!/usr/bin/ruby
# (c) 2021 stephan.com
# Find to N words of M letters, all unique
#
# No five-letter/five-word set exists, but there is a single
# result for two words of ten letters: blacksmith gunpowdery
require 'Set'
require 'progress_bar'