Friday, May 6, 2011

Opening up the Box for our Youth and Future

I think it's important that people have the freedom to open up any 'box' they purchase and understand how it works, modify it, and do something new and creative with it. When you lose the ability to change the way something works, you put yourself at an extreme disadvantage.

For example, a Pak 'n-Sav in Hamilton opened on Good Friday... with no employees present. Someone forgot to program the building not to turn on the lights or open the doors as it does normally each day.

Apple II


When I was is school, it was actually mandatory that we learn to program computers. We had a computer lab with a bunch of Apple II machines with green screens. We'd write some simple BASIC programs that had a number in front of each line to control the order of the commands and which one to GOTO next.

GO TO '10'


In college, one of my professors designed a programming language he named after Bacchi which was laid out visually using a mouse. It generated computer code suitable compilation into programs. Fairly novel back in 1994, but it appears we have evolved.

Nowadays, a waterbear isn't just an small animal popular with scientists in labs, it's also a new visual programming language. It just runs in any HTML5 compliant web browser (basically anything pretty recent). You can try it out at waterbearlang.com



So great, now we have a visual language that we can write scripts to run on the web, but what about getting underneath the hood and understanding how to write something more complex. How about giving cheap computers away that can fit on your keychain?

The lead guy over at the software company Frontier Games has designed a new small computer that will cost around $15-25 and can be given away to students to help them learn how computers work. It will probably run Ubuntu and it sounds like we are about 12 weeks away from seeing them on the market.

HDMI/TV out on the left, keyboard on the right. Computer in the middle.


But for the short term, we have some free training next week from some folks that know a bit about programming. Google has a programming event  in San Francisco that you can attend via the net for free next week. They often reveal new technology that may affect the future as we know it.

It's our future. What will we make of it?

I say we start with open minds and boxes.


ps. I'm looking for work in the Tauranga area. If you are a technology company please send me an email or call/txt me at 022-077-5899.

Thursday, March 10, 2011

ChiliProject up in minutes on Heroku w/ Gmail and S3

Requirements

  • Heroku account
  • Gmail account ( or sendgrid account ) if you want to send email
  • Amazon S3 account if you want to store documents and files
The S3 account requires a credit card to setup, but has a free tier
with 5 GB of Amazon S3 storage, 20,000 Get Requests, 15GB of bandwidth
each month.



Walk-through

ChiliProject via git

mkdir groupprojects
cd groupprojects
git init
 
git remote add chiliproject https://github.com/chiliproject/chiliproject.git
git fetch chiliproject
git merge chiliproject/master
 
git add .
git commit -m 'clean version of base code' 

Heroku, Giternal and Rails via Bundler

# create the Gemfile
cat << EOF | tee Gemfile
source :rubygems 
gem 'rails', '2.3.5' 
gem 'i18n', '0.4.2' 
gem 'giternal' 
gem 'heroku' 
EOF
git add Gemfile
git commit -m 'Added Gemfile for rails, i18n, heroku, and giternal' 
 
# install bunlder then use it to install the gems in the Gemfile
gem install bundler
bundle install

Heroku App

Let's configure a place to push the code to! Choose your name well as
it sets up up my-project-name.heroku.com, so choose a good unused name.

heroku create my-project-name
All the configuration should happen with heroku config environment
variables. We'll put the at the beginning of each section, then
install components and configure them to use the ENV variables.

  • Note that this just configures environment variables on the heroku instance. We would need to export these to the local environment to do any local development.

Session Store and Secret

heroku config:add SESSION_SECRET=`ruby -e 'require "rubygems" ; require "active_support" ; \
   puts ActiveSupport::SecureRandom.hex(40)'` 
cat << EOF | tee config/initializers/session_store.rb
ActionController::Base.session = { 
  :session_key => '_redmine_session', 
  :secret => ENV['SESSION_SECRET'] 
} 
EOF
git add -f config/initializers/session_store.rb
git commit -m 'Added session key and secret to be populated via env variables' 

Gmail

heroku config:add GMAIL_SMTP_USER=username@gmail.com GMAIL_SMTP_PASSWORD=your-password
cat << EOF | tee config/giternal.yml
action_mailer_optional_tls: 
  path: vendor/plugins
  repo: http://github.com/collectiveidea/action_mailer_optional_tls.git
EOF
git add config/giternal.yml
 
giternal update
sed -i '' "\:vendor/plugins/action_mailer_optional_tls:d" .gitignore
 
git add vendor/plugins/action_mailer_optional_tls/
 
cat << EOF | tee config/initializers/gmail_tls.rb
if ENV['GMAIL_SMTP_USER'] and ENV['GMAIL_SMTP_PASSWORD'] 
  ActionMailer::Base.perform_deliveries = true 
  ActionMailer::Base.smtp_settings = { 
    :address => "smtp.gmail.com", 
    :port => 587, 
    :authentication => :plain, 
    :domain => ENV['GMAIL_SMTP_USER'], 
    :user_name => ENV['GMAIL_SMTP_USER'], 
    :password => ENV['GMAIL_SMTP_PASSWORD'], 
    :tls => true 
  } 
end 
EOF
git add config/initializers/gmail_tls.rb
git commit -m 'Added support for GMAIL that comes from ENV' 

Amazon S3

heroku config:add S3_ACCESS_KEY=your-access-key S3_SECRET_KEY=your-secret-key S3_BUCKET_NAME=your-bucket
 
cat << EOF | tee -a config/giternal.yml
redmine_s3: 
  path: vendor/plugins
  repo: https://github.com/edavis10/redmine_s3.git
EOF
git add config/giternal.yml
 
giternal update
 
sed -i '' "\:vendor/plugins/redmine_s3:d" .gitignore
git add vendor/plugins/redmine_s3/
 
cat << EOF | tee config/s3.yml
production: 
  access_key_id: <%= ENV['S3_ACCESS_KEY'] %>
  secret_access_key: <%= ENV['S3_SECRET_KEY'] %>
  bucket: <%= ENV['S3_BUCKET_NAME'] %> 
  cname_bucket: false 
 
development: 
  access_key_id: <%= ENV['S3_ACCESS_KEY'] %>
  secret_access_key: <%= ENV['S3_SECRET_KEY'] %>
  bucket: <%= ENV['S3_BUCKET_NAME'] %> 
  cname_bucket: false 
EOF
git add config/s3.yml
 
git commit -m 'Added s3 configuration that pulls keys and bucket from env variables' 

plugin assets

This dir needs to exist on heroku side, and is populated when the
plugins are installed. However git doesn't track directories, only
files.

mkdir public/plugin_assets
echo this must exist >  public/plugin_assets/README
git add -f public/plugin_assets/README
git commit -m 'Added plugin_asset dir for Heroku' 

pushing our code out to the configured heroku instance

First we push our local changes out, this may take a bit as we are uploading all our code.

git push heroku master
Now that our code is up, we want to setup the database and load
the default data set.

heroku rake db:migrate
heroku rake redmine:load_default_data REDMINE_LANG=en
You could login at this point, but it might be interesting to go ahead and disable the default admin account and create our own.

# lock default admin user account
heroku console "x=User.find(1) ; x.lock ; x.save" 
 
heroku console "user = User.new { |u| u.login='hacker'; \
       u.firstname='Hippie'; u.lastname='Hacker'; \
       u.mail='hhh@hippiehacker.org'; \
       u.admin=true; u.language='en'; \
       u.password='XXXXX' } ; \
       user.preference=UserPreference.create!(:time_zone=>'Auckland') ; \
       user.save! " 
There are a few settings you'll probably always want to set right off. Here's how to do it programattically.

# get your hostname and settins your URL value within the app settings
heroku console "setting = Setting.find_or_create_by_name('host_name') ; \
       setting.value=ENV['URL'] ; setting.save! " 
 
heroku console "title = Setting.find_or_create_by_name('app_title') ; \
      title.value='Our Little Cows' ; title.save! " 
 
heroku console "setting = Setting.find_or_create_by_name('welcome_text') ; \
       setting.value='Yet Another Cool Website' ; setting.save! " 
Format the heroku config for use as local variables:

heroku config --long | sed s/\>// | sed s/\^/export\ / | sed s/\ \*\=\ \*/=\"/ | sed s/\$/\"/
Finally launch the site in the browser.

heroku open