Skip to content

Instantly share code, notes, and snippets.

Avatar

stephan.com stephancom

View GitHub Profile
@stephancom
stephancom / Orient.cpp
Created Jul 22, 2020
M5StickC Orientation
View Orient.cpp
// ,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 Jul 12, 2020
Application to Topline
View topline.rb
# _ _ _
# | |_ ___ _ __| (_)_ _ ___ __ _ __ _ _ __ ___ ___
# | _/ _ \ '_ \ | | ' \/ -_) / _` / _` | ' \/ -_|_-<
# \__\___/ .__/_|_|_||_\___| \__, \__,_|_|_|_\___/__/
# |_| |___/
#
# application application
#
# (c) 2013 stephan.com
@stephancom
stephancom / omniauthed.rb
Created Jun 23, 2020
pretty version of oath creation
View omniauthed.rb
# ___ _ _ __ __
# .' `. (_) / |_[ | | ]
# / .-. \ _ .--..--. _ .--. __ ,--. __ _ `| |-'| |--. .---. .--.| |
# | | | |[ `.-. .-. | [ `.-. | [ | `'_\ :[ | | | | | | .-. |/ /__\\/ /'`\' |
# \ `-' / | | | | | | | | | | | | // | |,| \_/ |,| |, | | | || \__.,| \__/ |
# `.___.' [___||__||__][___||__][___]\'-;__/'.__.'_/\__/[___]|__]'.__.' '.__.;__]
#
# Facebook, Google, Apple, the world?
module Omniauthed
extend ActiveSupport::Concern
@stephancom
stephancom / unistrike.rb
Created Feb 13, 2020
not quite working :(
View unistrike.rb
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 Jan 5, 2020
polynomial to string
View polynomial_to_s.rb
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 Dec 13, 2019
AuditDummy: handy for use in PaperTrail for a fake user that can have a GID
View audit_dummy.rb
# ,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 Dec 13, 2019
feet/inches utilities
View imperial.rb
# ___ _ _
# |_ _|_ __ _ __ ___ _ _(_)__ _| |
# | || ' \| '_ \/ -_) '_| / _` | |
# |___|_|_|_| .__/\___|_| |_\__,_|_|
# |_|
module Imperial
extend ActiveSupport::Concern
included do
# options for select menu
@stephancom
stephancom / activeadmin_top_sidebar.rb
Created Dec 7, 2019
Monkey patch ActiveAdmin to allow sidebars placed at the top
View activeadmin_top_sidebar.rb
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 Dec 7, 2019
Monkey patch ActiveAdmin to allow sidebars placed at the top
View activeadmin_top_sidebar.rb
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)
View blink_1.rb
You can’t perform that action at this time.