Skip to content

Instantly share code, notes, and snippets.

View stephancom's full-sized avatar

stephan.com stephancom

View GitHub Profile
@stephancom
stephancom / all_scratch.sublime.py
Created August 13, 2019 15:29
set all tabs to scratch for closing in sublime
len([v.set_scratch(True) for v in sublime.Window.views(sublime.active_window())])
@stephancom
stephancom / rebase_deploy.sh
Created August 13, 2019 14:54
rebase and deploy
git branch devserver-scratch devserver
git checkout devserver-scratch
git rebase development
sed -i delme "s/set :branch.*/set :branch, \'devserver-scratch\'/" config/deploy.rb
git push --force -u origin devserver-scratch
cap devserver deploy
rm config/deploy.rb
mv config/deploy.rbdelme config/deploy.rb
git checkout development
git branch -D devserver-scratch
@stephancom
stephancom / antivaxxer.md
Last active May 14, 2019 07:31
notes on vaccine video

first video https://youtu.be/Q6u8yJpV3qg

  1. 0:00 You actually expect me to take seriously a video by "Mango & Space Panther" over the Center for Disease Control, the Food and Drug Agency, and the American Medical Association. I have an open mind, but I think I may need a bigger speculum.

  2. 2:10 Don't give me some asshole's hippie conspiracy theory twitch video, give me the data, I can do math. The one you want is here: https://www.who.int/vaccine_safety/initiative/tools/MMR_vaccine_rates_information_sheet.pdf?ua=1 . I'm gonna read that and do my own math BEFORE I watch the rest of the video

... and of course I'll be ignoring the mild adverse events as the video says it will do, particularly since I expect in many of those cases the event might have been caused by something else. I'll also note that, personally, I would much prefer my child to have an "adverse event" happen in the doctors office or shortly after immunization is given and care (such as epinephrine for an allergic reaction) is immediate

@stephancom
stephancom / markdown_fields.rb
Created May 6, 2019 20:59
Markdown fields concern
# __ __ _ _ ___ _ _ _
# | \/ |__ _ _ _| |____| |_____ __ ___ _ | __(_)___| |__| |___
# | |\/| / _` | '_| / / _` / _ \ V V / ' \| _|| / -_) / _` (_-<
# |_| |_\__,_|_| |_\_\__,_\___/\_/\_/|_||_|_| |_\___|_\__,_/__/
#
# "Immature poets imitate; mature poets steal" - T. S. Eliot
# "When there's anything to steal, I steal" - Pable Picasso
# "Good artists copy; great artists steal" - Steve Jobs
#
module MarkdownFields
@stephancom
stephancom / migrate_fields_to_action_text.rb
Created April 27, 2019 17:14
migrate to actiontext (untested)
class MigrateFieldsToActionText < ActiveRecord::Migration[5.2]
class ActionTextRichText < ActiveRecord::Base
belongs_to :record, polymorphic: true
end
TARGETS = {
ModelName => [:field],
OtherModelName => %i[field1 field2 field3]
}.freeze
def up
@stephancom
stephancom / en.yml
Created April 20, 2019 13:18
not rewritable validator
en:
errors:
messages:
changed: "can't be changed"
@stephancom
stephancom / copy_protect.coffee
Created April 20, 2019 05:48
block copy/paste etc on web page
# __ __ __ __ __ __ ___ ___ __ ___ __
# / ` / \ |__) \ / |__) |__) / \ | |__ / ` | | / \ |\ |
# \__, \__/ | | | | \ \__/ | |___ \__, | | \__/ | \|
#
# https://stackoverflow.com/a/32804545/444955
$ ->
$.fn.blockCopy = (options) ->
settings = $.extend({ blockPasteClass: null }, options)
style_appender = (rule) ->
@stephancom
stephancom / write_once_field.rb
Created April 19, 2019 15:50
"write once" fields in rails. Can be set on create or ONCE on update, cannot be changed in mass assignment
validate :forbid_changing_some_field, on: :update
def forbid_changing_some_field
return unless some_field_changed?
return if some_field_was.nil?
self.some_field = some_field_was
errors.add(:some_field, 'can not be changed!')
end
class BlockQueue
def initialize(name)
@name = name
@blocks = []
end
def run_later(&block)
Progress.log "queueing job for #{@name}"
@blocks << block
end
@stephancom
stephancom / populate.rb
Created March 22, 2019 23:31
"populate" file header
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-. #
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / #
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' #
# .-------. ,-----. .-------. ___ _ .---. ____ ,---------. .-''-. #
# \ _(`)_ \ .' .-, '. \ _(`)_ \.' | | | | ,_| .' __ `.\ \ .'_ _ \ #
# | (_ o._)| / ,-.| \ _ \ | (_ o._)|| .' | |,-./ ) / ' \ \`--. ,---'/ ( ` ) ' #
# | (_,_) /; \ '_ / | :| (_,_) /.' '_ | |\ '_ '`) |___| / | | \ . (_ o _) | #
# | '-.-' | _`,/ \ _/ || '-.-' ' ( \.-.| > (_) ) _.-` | :_ _: | (_,_)___| #
# | | : ( '\_/ \ ;| | ' (`. _` /|( . .-' .' _ | (_I_) ' \ .---. #
# | | \ `"/ \ ) / | | | (_ (_) _) `-'`-'|___ | _( )_ | (_(=)_) \ `-' / #