Skip to content

Instantly share code, notes, and snippets.

stephan.com stephancom

Block or report user

Report or block stephancom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View blink_1.rb
@stephancom
stephancom / all_scratch.sublime.py
Created Aug 13, 2019
set all tabs to scratch for closing in sublime
View all_scratch.sublime.py
len([v.set_scratch(True) for v in sublime.Window.views(sublime.active_window())])
View rebase_deploy.sh
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
notes on vaccine video
View antivaxxer.md

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
Markdown fields concern
View markdown_fields.rb
# __ __ _ _ ___ _ _ _
# | \/ |__ _ _ _| |____| |_____ __ ___ _ | __(_)___| |__| |___
# | |\/| / _` | '_| / / _` / _ \ 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 Apr 27, 2019
migrate to actiontext (untested)
View migrate_fields_to_action_text.rb
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 Apr 20, 2019
not rewritable validator
View en.yml
en:
errors:
messages:
changed: "can't be changed"
@stephancom
stephancom / copy_protect.coffee
Created Apr 20, 2019
block copy/paste etc on web page
View copy_protect.coffee
# __ __ __ __ __ __ ___ ___ __ ___ __
# / ` / \ |__) \ / |__) |__) / \ | |__ / ` | | / \ |\ |
# \__, \__/ | | | | \ \__/ | |___ \__, | | \__/ | \|
#
# https://stackoverflow.com/a/32804545/444955
$ ->
$.fn.blockCopy = (options) ->
settings = $.extend({ blockPasteClass: null }, options)
style_appender = (rule) ->
@stephancom
stephancom / write_once_field.rb
Created Apr 19, 2019
"write once" fields in rails. Can be set on create or ONCE on update, cannot be changed in mass assignment
View write_once_field.rb
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
View block_queue.rb
class BlockQueue
def initialize(name)
@name = name
@blocks = []
end
def run_later(&block)
Progress.log "queueing job for #{@name}"
@blocks << block
end
You can’t perform that action at this time.