Search

Sara Trice

Just a programmin', bellydancin', cake bakin' kinda girl

Category

Uncategorized

React, tcomb-form, and date fields

Setting my first date field up in tcomb-form, I followed the docs and used tcomb.Date as the field type:

const Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String),
  age: t.Number,
  rememberMe: t.Boolean,
  birthDate: t.Date // a date field
});

Except that gave me this nightmarishly ugly dropdown date format:
Screen Shot 2018-07-11 at 11.20.58 AM

Which accepts a Date object as its value – which this form makes really difficult since if you’re updating on form change, it tries to make a Date object after each change, which results in a lot of invalid dates. Fun.

Even more fun, the values in the month dropdown are in a 0-based array, meaning that when you pick January, you get “0” as your month value, which as you can guess, results in an invalid date.

After some headdesking, I discovered that if you designate the field’s tcomb type as a string and pass the HTML5 “date” type to the field in the form options, you get something a lot prettier (in this example I am using Bootstrap):

 fields: {
   birthDate: {
     label: 'Birth Date',
     type: 'date'
   }
}

Making this a lot easier to deal with on the front and back end.

Advertisements

Copying all Devise emails to Salesforce

I’ve had the “joy” of working with Salesforce.com in the last year or so. When users receive emails from my application, the sales department wants to know about it, including anything that Devise sends (account confirmations, password resets, etc.).

Setting this up is fairly simple. I’m using Devise 3.1.1 in this instance.

First, create a custom mailer:

rails generate mailer CustomDeviseMailer

Then, to config/initializers/devise.rb, add this line:

config.mailer = "CustomUserMailer"

Finally, change app/mailers/custom_devise_mailer.rb to look like this:

class CustomDeviseMailer < Devise::Mailer
  def headers_for(action, opts)
    if Rails.env.production?
      salesforce_bcc_email = "(your Email to Salesforce address)"
    else
      salesforce_bcc_email = "salesforce_bcc_email@mailinator.com"
    end

    super.merge!({bcc: salesforce_bcc_email})
  end
end

If you need to know where your Salesforce BCC email is:

  1. login to Salesforce
  2. In the top bar click your name, choose “Setup” from the menu
  3. Under “Personal Setup” in the left sidebar, click “Email”
  4. Under the email menu you just expanded, click “My Email to Salesforce”
  5. On that page it’s highlighted with a bright yellow box

Kudos to this StackOverflow question for getting me all fixed up in Devise 3.

Women’s Olympic Foil 2012

Congrats to Italy for sweeping Women’s Foil! And congrats to Lee Keifer for making it to 5th – further than any woman from the US has since 1956!

Standings: http://en.wikipedia.org/wiki/Fencing_at_the_2012_Summer_Olympics_%E2%80%93_Women’s_foil

Yes, I’m schilling, what of it?

Ok, technically I’m not schilling because I’m not even pretending I’m not involved.

Luke and I are paying for the bulk of our wedding costs… and we’re coming up a bit short. If you’re interested in buying any of Luke’s music, now would be the helpful time to do it. “WHAT A RIPOFF! VOLUME 2”, an odds-and-ends compilation was just released, as well as the “GREATEST HITS VOLUME 1” 2-CD. Also, he’s always looking for more work as a caricature artist & cartoonist – he’s for hire at parties as well as for individual caricatures/cartoons for gifts, as well as promo art.

I’m pretty much booked for website work for now, but I’ll be available after the wedding for more freelance.

Ready for Zombies.

Remember my last post about how I was starting an herb garden, about two months ago, and I wasn’t expecting anything to actually grow?

my-herbs-2010-05-21-23-44-50

 

Stuff grew! The big foof of green you see on the left is parsley; I had to separate it out from the others so they didn’t hog all the sun. The rest in the tray is oregano, basil, tarragon, and catnip. The plant in the soda bottle bottom behind the parsley is a marigold I got from the UU church’s earth day service. Thinking tomorrow will be a good day for planting outside.

1,2,3, There are zombies on the lawn…

Seedling starter tray: $4
Seedling soil: $4
Seeds: $6

Being prepared for zombies on my lawn: Priceless.

Well, here’s yet again another attempt at me starting an herb garden. Difference this time is that I actually have land to plant on. Yay, home ownership! I’ve got parsley, catnip, oregano, thyme, tarragon, and basil. Any tips from you green thumbs out there? ‘Cause generally anything I plant dies pretty horribly. Black thumbs run in my family. I know I need to keep them watered, but not too watered or I’ll get root rot. When should I water them? Every other day? Every second day? I have them at a west-facing window so they’ll get some sunlight filtered through the pine tree back there every day.

Any useful advice appreciated!

Ebay auction for MarsCon Dementia Track

This is my 3rd re-listing of this item. I’ve dropped the starting bid to $35. If this doesn’t work, I give up.

I’m auctioning off a white 1000 thread count king-size sheet set, proceeds to go to the MarsCon Dementia Track Fund Raiser. If you are local to Chicago I can deliver. 🙂
http://bid-url.com/h06fdu

Recycling Christmas Trees in Villa Park, Illinois

This isn’t posted anywhere on the web so I thought I’d toss it up on here:

If you live in Villa Park, IL and want to recycle your christmas tree, just leave it out on the curb anytime during the first 2 weeks of January (bare – not in a bag). Waste Management will pick it up and take it to be recycled.

I wish

…for an end to world hunger, but that’s a long-term goal.

If you were wondering, here’s my Amazon Wish List for the short term.
My Amazon.com Wish List

(And I like used books just fine.)

Blog at WordPress.com.

Up ↑