Skip to content

Instantly share code, notes, and snippets.

@dmoulton
dmoulton / rails+react.txt
Last active July 7, 2023 21:17
Process to create monolithic rails and react app
consult https://blog.appsignal.com/2022/08/03/connect-a-ruby-on-rails-app-with-react-in-a-monolith.html
rails new <app name> -d <database> -j esbuild
cd into app
./bin/rails db:create
./bin/rails s
generate a home controller -> ./bin/rails g controller Home index
update routes to make home#index the root
yarn add react react-dom node-uuid
update the build portion of packages.json to be:
Printer
X Width 235
Y Width 235
Z Height 285
origin at center NOT checked
Heated bed checked
Head build volume NOT checked
# Small helper script for weeding out bad images before stacking astroimages
# Requires DS9 fits viewer https://sites.google.com/cfa.harvard.edu/saoimageds9
# Meant to be run in the directory with your fits files
mkdir -p bad
for f in *.fit[s]
do
echo "Opening $f"
ds9 $f
@dmoulton
dmoulton / gist:c3580d53117a26f0182a04344b94d01e
Created February 27, 2018 17:32
Error received in Stephen Grider's course on Elixir and Phoenix at Udemy.com
[error] GenServer #PID<0.2560.0> terminating
** (RuntimeError) cannot encode association :user from Discuss.Comment to JSON because the association was not loaded. Please make sure you have preloaded the association or remove it from the data to be encoded
(ecto) lib/ecto/poison.ex:12: Poison.Encoder.Ecto.Association.NotLoaded.encode/2
(poison) lib/poison/encoder.ex:213: anonymous fn/4 in Poison.Encoder.Map.encode/3
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map."-encode/3-lists^foldl/2-0-"/3
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map.encode/3
(poison) lib/poison/encoder.ex:213: anonymous fn/4 in Poison.Encoder.Map.encode/3
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map."-encode/3-lists^foldl/2-0-"/3
(poison) lib/poison/encoder.ex:214: Poison.Encoder.Map.encode/3
(poison) lib/poison/encoder.ex:213: anonymous fn/4 in Poison.Encoder.Map.encode/3
@dmoulton
dmoulton / jruby_error.pry
Created September 19, 2012 16:22
Error in jruby 1.7.0preview2 but not in preview1
Using jruby 1.7.0preview2 I try to use IMGKit to create a file, I get:
╰─$ rails c
Loading development environment (Rails 3.2.3)
[1] pry(main)> kit = IMGKit.new("hello")
#<IMGKit:0x0000683c
attr_accessor :source = #<IMGKit::Source:0x00006840
@source = "hello"
>,
attr_accessor :stylesheets = [],
@dmoulton
dmoulton / HstoreModel.rb
Created June 12, 2012 19:39 — forked from kfatehi/HstoreModel.rb
Hstore ActiveRecord::Base method_missing
## Hstore Method Missing Extension
module HstoreModel
def method_missing(method, *args, &block)
key = method.to_s.gsub('=','').to_sym
sym_options = options.symbolize_keys
if !self.class.attribute_methods_generated?
self.class.define_attribute_methods
if respond_to_without_attributes?(method)
send(method, *args, &block)
@dmoulton
dmoulton / autotab.rb
Created May 17, 2012 18:58
Rails helper for tab order in forms
# Should probably go in application_helper
# examples (when run in this order):
# autotab # returns 1
# autotab # returns 2
# autotab(100) # returns 102
# autotab # returns 3
# autotab(100,true) # returns 104
# autotab # returns 105
# example f.text_field :address, :tabindex=>autotab
@dmoulton
dmoulton / ipsec.conf
Created February 21, 2012 14:51
My Openswan config files
version 2.0
config setup
nat_traversal=yes
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12
oe=off
protostack=netkey
conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
also=L2TP-PSK-noNAT
@dmoulton
dmoulton / Main.sublime-menu
Created January 27, 2012 04:00
Non interactive ruby REPL for Sublime Text 2
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[