Skip to content

Instantly share code, notes, and snippets.

View stephancom's full-sized avatar

stephan.com stephancom

View GitHub Profile
@stephancom
stephancom / Orient.cpp
Created July 22, 2020 19:38
M5StickC Orientation
// ,88~-_ ,e, d8
// d888 \ 888-~\ " e88~~8e 888-~88e _d88__
// 88888 | 888 888 d888 88b 888 888 888
// 88888 | 888 888 8888__888 888 888 888
// Y888 / 888 888 Y888 , 888 888 888
// `88_-~ 888 888 "88___/ 888 888 "88_/
//
// persistent orientation for M5StickC
#include "Orient.h"
@stephancom
stephancom / topline.rb
Created July 12, 2020 01:47
Application to Topline
# _ _ _
# | |_ ___ _ __| (_)_ _ ___ __ _ __ _ _ __ ___ ___
# | _/ _ \ '_ \ | | ' \/ -_) / _` / _` | ' \/ -_|_-<
# \__\___/ .__/_|_|_||_\___| \__, \__,_|_|_|_\___/__/
# |_| |___/
#
# application application
#
# (c) 2013 stephan.com
@stephancom
stephancom / omniauthed.rb
Created June 23, 2020 03:05
pretty version of oath creation
# ___ _ _ __ __
# .' `. (_) / |_[ | | ]
# / .-. \ _ .--..--. _ .--. __ ,--. __ _ `| |-'| |--. .---. .--.| |
# | | | |[ `.-. .-. | [ `.-. | [ | `'_\ :[ | | | | | | .-. |/ /__\\/ /'`\' |
# \ `-' / | | | | | | | | | | | | // | |,| \_/ |,| |, | | | || \__.,| \__/ |
# `.___.' [___||__||__][___||__][___]\'-;__/'.__.'_/\__/[___]|__]'.__.' '.__.;__]
#
# Facebook, Google, Apple, the world?
module Omniauthed
extend ActiveSupport::Concern
@stephancom
stephancom / unistrike.rb
Created February 13, 2020 21:41
not quite working :(
def unistrike(str)
# return "\u0336#{str}".unicode_normalize
str.split.map { |c| "\u0336#{c}".unicode_normalize }.join
end
@stephancom
stephancom / polynomial_to_s.rb
Last active January 5, 2020 05:11
polynomial to string
POWERS = ['', '', '²', '³', '⁴'].freeze
def poly_to_s(coefs)
coefs.each_with_index.inject('') do |str, (coef, index)|
term = if index == 4
[coef]
else
[coef.positive? ? '+' : '-', ' ', coef.abs]
end
term << 'x' if index > 1
@stephancom
stephancom / audit_dummy.rb
Created December 13, 2019 05:35
AuditDummy: handy for use in PaperTrail for a fake user that can have a GID
# ,ggg,
# dP""8I 8I I8
# dP 88 stephan.com 8I I8
# dP 88 presentsL 8I gg 88888888
# ,8' 88 8I "" I8
# ,gggggggggggg, d88888888 gg gg ,gggg,8I gg I8
# dP"""88""""""Y8b, __ ,8" 88 I8 8I dP" "Y8I 88 I8
# Yb, 88 `8b, dP" ,8P Y8 I8, ,8I i8' ,8I 88 ,I8,
# `" 88 `8b Yb,_,dP `8b,,d8b, ,d8b,,d8, ,d8b,_,88,_,d88b,
# 88 Y8 "Y8P" `Y88P'"Y88P"`Y8P"Y8888P"`Y88P""Y88P""Y8
@stephancom
stephancom / imperial.rb
Created December 13, 2019 05:34
feet/inches utilities
# ___ _ _
# |_ _|_ __ _ __ ___ _ _(_)__ _| |
# | || ' \| '_ \/ -_) '_| / _` | |
# |___|_|_|_| .__/\___|_| |_\__,_|_|
# |_|
module Imperial
extend ActiveSupport::Concern
included do
# options for select menu
@stephancom
stephancom / activeadmin_top_sidebar.rb
Created December 7, 2019 03:40
Monkey patch ActiveAdmin to allow sidebars placed at the top
module ActiveAdmin
class DSL
alias bottom_sidebar sidebar
def top_sidebar(name, options = {}, &block)
config.sidebar_sections.prepend ActiveAdmin::SidebarSection.new(name, options, &block)
end
def sidebar(name, options = {}, &block)
if options.delete(:prepend)
@stephancom
stephancom / activeadmin_top_sidebar.rb
Created December 7, 2019 03:39
Monkey patch ActiveAdmin to allow sidebars placed at the top
module ActiveAdmin
class DSL
alias bottom_sidebar sidebar
def top_sidebar(name, options = {}, &block)
config.sidebar_sections.prepend ActiveAdmin::SidebarSection.new(name, options, &block)
end
def sidebar(name, options = {}, &block)
if options.delete(:prepend)
@stephancom
stephancom / blink_1.rb
Created August 18, 2019 00:44
blink(1) rspec