Skip to content

Instantly share code, notes, and snippets.

Legal pages go into components/Legal/Foo
process from updating from google doc / word:
* save google docs as docx
* open in word, save as html, webpage, filtered
* copy + paste html into html formatter to cleanup (like * https://webformatter.com/html, use 2 spaces)
* copy html into <template>
* move <style> in head into:
<style lang="css" scoped>
# https://stackoverflow.com/questions/47480803/construct-nested-openstruct-object
require 'json'
private def deep_openstruct(hash)
JSON.parse(hash.to_json, object_class: OpenStruct)
end
>> $LOAD_PATH << "."
=> ["/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/x86_64-darwin20", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/vendor_ruby/2.6.0", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/vendor_ruby/2.6.0/x86_64-darwin20", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/vendor_ruby", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0", "/Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/x86_64-darwin20", "."]
>> require 'fakefs'
=> true
>> File.touch("foo")
Traceback (most recent call last):
4: from /Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/bin/irb:23:in `<main>'
3: from /Users/smtlaissezfaire/.rvm/rubies/ruby-2.6.6/bin/irb:23:in `load'
2: from /Users/smtlaiss
$ irb -r './hash_shorthand.rb'
>> x = 10
>> y = 20
>>
>> puts hash_shorthand(binding, :x, :y)
{:x=>10, :y=>20}
/Users/smtlaissezfaire/.atom (master)$ apm install find-and-replace@0.218
The find-and-replace package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall find-and-replace` to uninstall it and then the version bundled
with Atom will be used.
/Users/smtlaissezfaire/.atom (master)$ apm uninstall find-and-replace
Uninstalling find-and-replace ✗
Failed to delete find-and-replace: No package.json found at /Users/smtlaissezfaire/.atom/packages/find-and-replace/package.json
@smtlaissezfaire
smtlaissezfaire / migration_before.rb
Last active February 5, 2020 00:42
Lookup migration by file name, then get the version number (rails). Handy for migrating up + down based on the migration name (for instance `rake db:migrate VERSION=$(migration_before create_users)`)
#!/usr/bin/env ruby
name = ARGV[0]
verbose = ARGV[1] == "--verbose"
if name.nil? || name.empty?
puts ""
puts "\tUsage: migration_before <migration_name> [--verbose]"
puts ""
puts "\tLookup migration by file name, then get the version number (rails). "
# partially taken from https://dalibornasevic.com/posts/68-processing-large-csv-files-with-ruby
# thanks!
require 'csv'
require 'benchmark'
require 'tempfile'
def print_memory_usage
memory_before = `ps -o rss= -p #{Process.pid}`.to_i
yield
@smtlaissezfaire
smtlaissezfaire / fire_meetup_notes_2019_01_20.txt
Created January 22, 2019 02:33
fire_meetup_notes_2019_01_20
Notes from FI/RE Meetup - Jan 20, 2019
Lively - HSA - https://livelyme.com/
ADU = Accessory Dwelling Units
Vicki Robin - https://vickirobin.com/
William Burnstein - https://www.amazon.com/Personal-Finance-William-J-Bernstein/s?ie=UTF8&page=1&rh=n%3A2717%2Cp_lbr_one_browse-bin%3AWilliam%20J.%20Bernstein ?
# monkey patch to get uncompleted tasks from asana
# call with:
# options = {
# params: { completed_since: 'now' }
# }
# Asana::Resources::Task.find_by_project(client, projectId: project.id, options: options).each do |task|
# ...
# end
Asana::Resources::Task.module_eval do
/Users/smtlaissezfaire/src/git/onpoint/ui-on-rails (master)$ irb
clas>> class A
>> def foo
>> 1
>> end
>> alias_method :bar, :foo
>> end
=> A
>> class B < A
>> def foo