Thursday, December 8, 2011

30 Day Voice Over Trial - Day 1


I read http://expertenough.com/778/practice-like-an-expert and http://expertenough.com/658/becoming-an-expert and it re-inspired me to try my hand/voice at doing voice over work.  These articles emphasized having an expert mentor.  I think that's what I've skipped in other pursuits.  

So I started by googling 'las vegas voice over'.  I found http://www.courvo.biz/ which made me excited about doing audio books.  They're mostly done from home, but the money doesn't get that good until you're pretty established.  I need to ignore the money for the 30 day trial though.  

His site also directed me to http://patfraley.com/ who is a top voice over coach in LA.  He has a ton of free videos and a bunch of training stuff you can buy.  In some of the videos I watched, I learned some good stuff:
  • Skills + Personal Style + Demo + Marketing = $$$
    • Demo is 3 x 1 min excerpts
  • Mimic/Matching might be a good fit, because I already do that and it can pay well.
  • Learn the rules, but use your limitations to make money.  For me, my scientific, slightly monotone voice could work better than a trained actor for non-fiction books (or stuff like that).
  • Its important to train the entire vocal range for injury prevention (like stretching).


I have a few ideas:
  • Start a blog (or just post links to some sound sharing site) of me reading some popular blogs (4hww, seth godin, steve pavlina, etc).  I need to look up the legal on that.
  • Find a local voice over mentor.
  • Definitely post recordings publicly (daily if possible) and get as much feedback as possible.
  • Find out what gear I can borrow.

I created a SoundCloud.com account http://soundcloud.com/jeremyjbarth and recorded a couple words.  It actually didn't sound that bad, so maybe I can skip the hardware stuff for this trial.

Monday, October 10, 2011

Rails 3.1 Simple Custom Authentication and CanCan Authorization

After adding a simple blog to my Rails 3.1 app, I needed to add security to lock it all down. I'm writing this app for someone else, so a degree of user-friendliness was desired.

My 'requirements' were login with admin account. Anyone can read posts, read comments, and add comments. Admins can add, update, and delete posts. Admins can also remove comments. For usability, the links for these actions should be hidden unless the user is an admin. Of course the urls and actions should be locked down as well.

I decided to write the authentication part from scratch following railscasts Authentication in Rails 3.1 and Authentication from Scratch. For my purposes, I just need one admin account. I don't need to sign up users or any other ui for managing users. I figure, I can create the admin account from the command line, and that'd be about it. So, I skipped the parts from railscasts above that created views for User. I did create a login page of course (no logout).

Here are the authentication commands and code:

User
rails g model user email:string password_digest:string

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :email
      t.string :password_digest

      t.timestamps
    end
  end

end

class User < ActiveRecord::Base
  has_secure_password
end
Sessions
rails g controller sessions new

class SessionsController < ApplicationController
  def new
  end
 
  def create
    user = User.find_by_email(params[:email])
    if user && user.authenticate(params[:password])
      session[:user_id] = user.id
      redirect_to posts_path
    else
      flash.now.alert = "Invalid username or password"
      render "new"
    end
  end

end
views/sessions/new.html.erb

<h1>Login</h1>
<%= form_tag sessions_path do %>
<div class="field">
  <%= label_tag "Username" %>
  <%= text_field_tag :email, params[:email] %>
</div>
<div class="field">
  <%= label_tag :password %>
  <%= password_field_tag :password %>
</div>
<div class="actions">
  <%= submit_tag "Login" %>
</div>
<% end %>
BlankRailsMysql::Application.routes.draw do
  resources :sessions
  resources :posts do
    resources :comments
  end

  get "login" => "sessions#new", :as => "login"
end
At this point, a user (if one existed) could go to localhost:3000/login and it would authenticate them and save their user id to the session. By the way, here's the command to add a user:
rails c
User.create(:email => "admin", :password => "password", :password_confirmation => "password")

If you need to run this in your heroku environment, just do:
heroku run rails c --app your_app

Sunday, October 9, 2011

Rails 3.1 Asset Pipeline on Heroku

After updating my Rails 3.0.4 app to 3.1 on Heroku, I wanted to use the built in SASS functionality.  What I didn't realize was that you have to also use the asset pipeline to get the built in support.  I had skipped this in my previous step.  Using the same railscast, I converted my app to use the asset pipeline.  This did not work on heroku.

Long story short, you need to use the cedar stack on heroku for the asset pipeline to work well.  Here are the commands I saved for creating new apps on heroku in the future:

heroku create app_name --addons custom_domains -r git_remote -s cedar
heroku run rake db:migrate --app app_name
heroku domains:add www.your_domain.com --app app_name
change dns entry to point to app_name.heroku.com

Heroku References:
http://devcenter.heroku.com/articles/custom-domains
http://devcenter.heroku.com/articles/rails31_heroku_cedar

Friday, September 30, 2011

Upgrading to Rails 3.1 from Rails 3.0.4 with MySQL on Heroku

I ran into a few issues when trying to update my Rails 3.0.4 app to Rails 3.1.0.  I was using a MySQL database (all vanilla stuff) and heroku.  This all worked fine.  I wanted to try SCSS and found that Rails 3.1 has built in support for it; so, I decided to upgrade.  Here's what I did:


Watched the railscast for upgrading: http://railscasts.com/episodes/282-upgrading-to-rails-3-1  Which instructed me to follow these steps:

  1. Change Gemfile rails version to 3.0.10
  2. bundle update
  3. make sure it still works
  4. Change Gemfile rails version to 3.1.0
  5. Comment out line in development.rb: config.action_view.debug_rjs
  6. bundle update
  7. make sure it still works
This is where I got my first issue.  It said the mysql2 gem was too old (mine was < 0.3).  I change the Gemfile to use the newest version and ran 'bundle update' again.  

Then there was another issue related to the mysql2 bundle pointing to the correct library.  This is a common issue running on OS X I guess.  Here's the fix and the link where I got it: http://freddyandersen.wordpress.com/2010/10/03/mysql-5-5-snow-leopard-and-rails/

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle
At this point I can run the app as normal locally.  The next step was to push to heroku.  I created a separate heroku location in case I ran into issues or if they used a different stack for 3.1 vs 3.0.x.  I'll skip those steps.  The error I got when I pushed was: `rescue in establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (RuntimeError)
Unbeknownst to me, heroku actually uses postgress and not mysql.  I guess it just worked before.  I didn't really want to change my local stuff if I didn't need to so I found a solution here: http://stackoverflow.com/questions/6410623/heroku-error-when-launch-rails3-1-app-missing-postgres-gem
The actual fix was to just add the below to the Gemfile and run bundle with the '--without production' flag:
group :production do
  gem 'pg'
end
After that pushing to heroku worked fine.
P.S. I must have run heroku db:migrate at some point, but I can't remember when.  I think it was before I got the postgress error.

Pretty Print XML in Java

I got my solution from http://stackoverflow.com/questions/1264849/pretty-printing-output-from-javax-xml-transform-transformer-with-only-standard-ja

import javax.xml.transform.OutputKeys;

import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

Transformer transformer = TransformerFactory.newInstance().newTransformer(); 
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");

Source xmlInput = new StreamSource(new StringReader(xml));


StreamResult xmlOutput = new StreamResult(new StringWriter());
transformer.transform(xmlInput, xmlOutput);
System.out.println(xmlOutput.getWriter().toString());

Thursday, August 4, 2011

Simple Session Timeout Handling with Seam/JSF/Facelets

I took Christian's great post http://relation.to/Bloggers/ImplementingGracefulSessionTimeoutWithSeamJSFAndJQuery and simplified it for my use.  My solution uses the same session checking mechanism, but assumes all pages should be handled the same, and that we just want to kick the user back to the landing page instead of the fancy stuff Christian did. Leave a comment if you need any of the code explained.

I'm assuming you're using Facelets, so you have some layout.xhtml (or whatever) that all your pages are using.  Just add this to the <head>:

<s:remote include="httpSessionChecker"/>
<script type="text/javascript">
var sessionChecker = Seam.Component.getInstance("httpSessionChecker");


   function alertTimeout(newSession) {
       if (newSession) {
           clearInterval(sessionTimeoutInterval);
           window.location = '#{facesContext.externalContext.request.contextPath}';
           alert('Your session has expired.  You have been logged out.');
       }
   }


        var sessionTimeoutInterval = setInterval('sessionChecker.isNewSession(alertTimeout)', '#{httpSessionChecker.timeout}'*1000+3000);
</script>


For Seam Remoting, add the jboss-seam-remoting.jar to your project and this to your web.xml:

 <servlet>
  <servlet-name>Seam Resource Servlet</servlet-name>
  <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>Seam Resource Servlet</servlet-name>
  <url-pattern>/seam/resource/*</url-pattern>
 </servlet-mapping>



Create the HttpSessionChecker (modified from Christian's):


@Name("httpSessionChecker")
@Scope(ScopeType.APPLICATION)
public class HttpSessionChecker {

@WebRemote
    public boolean isNewSession() {
return ServletContexts.instance().getRequest().getSession().isNew();
    }

public int getTimeout() {
return ServletContexts.instance().getRequest().getSession().getMaxInactiveInterval();
}
}

For simplicity and safety, your best bet is to match all of the timeout times.  You want to match your web.xml, components.xml, and the server timeout.  Here's 30 minutes for all of them (a normal default):

  • your web.xml
 <session-config>
  <session-timeout>30</session-timeout>
 </session-config>
  • components.xml
<core:manager concurrent-request-timeout="500"
conversation-timeout="1800000" conversation-id-parameter="cid"
parent-conversation-id-parameter="pid" />
  • C:\jboss-5.1.0.GA\server\default\deployers\jbossweb.deployer\web.xml
   <session-config>
      <session-timeout>30</session-timeout>
   </session-config>

That should be it.  Now if they leave any page for 30 minutes, it will redirect them to the landing page, and alert them that their session expired.  Its not fancy, but its a good default to start with.

Wednesday, June 29, 2011

Las Vegas Startup Weekend June 2011

http://lasvegas.startupweekend.org/

I attended on the Technical track.  I think it was about 50% Technical and the rest were mixed backgrounds.  It was a lot of fun and I learned a lot.  I even got to meet Tom from MySpace and Kevin Rose (milk.com, digg.com, etc).  Kevin is much taller than you might expect.  I've only seen him on The Random Show with Tim Ferriss.

It was interesting to be in demand.  Many of the folks pitching ideas were vying for me to work with them.  Initially, it didn't seem like there were any standout ideas; so, I struggled to pick where I wanted to work.  I was proven wrong by presentation day.  I think I just didn't get the other ideas.

I ultimately chose to work with bloomworlds.com on a Family Friendly Android App Store.  They had already done a good amount of work on the business model and website for this prior to the weekend; so, we were not eligible for the competition :(  The main piece that they wanted me to fill was the app store client, which is an android app.  This was an exciting challenge to learn how to write android apps in 2 days.  We eventually got the functionality we wanted working by presentation time, but constant internet connection issues killed the demo.  It was great working with them, and I'll likely continue to work with them to finalize a beta release.

The main purpose for this post was to list out my lessons-learned.

  • Kill the presentation.  The groups that really jazzed up the presentation got the best crowd reaction.  This didn't necessarily translate into winning however, but it gives a great sense of accomplishment.
  • If you want to win, target the judges.  This kind of sucks, but the judges are going to be interested in stuff they're involved in.  If you look at stuff they don't get or don't care about, nothing else really matters.
  • You don't need a flushed out idea to pitch.  A lot of folks did, but many just had an idea and went with it.  The more you have the better, but it is relatively low risk to pitch.  If you don't get any takers, you can scrap the idea and work with another group.
  • Make sure you have some environment stuff ready.  My group had everything already, but other groups had to set all that up.  
  • Keep the group together.  My group split for a while so they could get better internet.  This made it more difficult to fix communications between theirs and my stuff.
  • Along with environment setup, internet was a killer.  The WiFi was constantly breaking and slow.  It also killed our demo.
  • The amount that was able to be built when focusing the entire weekend on one thing was amazing.  I plan to use this same method for my own en devours from now on.
  • Have business cards.
  • Don't get distracted by other people or stuff that doesn't matter for the presentation.  This is not a problem for me, because I'm laser focused.  Everyone else reminded me of the chumps in my old CS lab the day before the FTP Client/Server project was due for Dr. Tan.  Maybe stop worrying about the other teams' html and worry about fixing your database.
Overall, I met great people, got inspired, and learned a ton.  Well worth $75.