Setup your app directory
mkdir rails-5-test-app cd rails-5-test-app
Specify your Ruby version
touch .ruby-version echo 'ruby-2.2.2' > .ruby-version
Setup Gemfile with edge rails, rack and arel
touch Gemfile printf "source 'https://rubygems.org'\nruby '2.2.2'\n\n\ngem 'rails', github: 'rails/rails'\ngem 'arel', github: 'rails/arel'\ngem 'rack', github: 'rack/rack'" >> Gemfile bundle
Use rails generators to create new app, and run server
bundle exec rails new . --dev --force bundle exec rails s
Just give me the gist?
I was recently playing with Google's new Photo application. An incredibly powerful little application, yet has an incredibly simple UI.
Google has gone through my entire library of 30k photos and classified them against their boat loads of data.
It's always nice to get a visual sense of what Machine Learning is doing, and after playing with the photo app it's quite clear how it classifies photos.
For example, if I search for 'festival', it finds photo's of all sorts of festivals, from Glastonbury:
To the Soccer World Cup:
To the Notting Hill Carnival:
To a few incorrect ones like these:
You can understand why machine learning might classify these, and it's not really a problem. When we have more data, those results will continue to get better, they will almost definitely result in more accuracy going into the future.
So, what's the problem?
The problem is here; do a search for something like 'desert', I get this result:
Do a search for 'dessert' and I get this result:
So, through our own stupidity, we have trained the machines to think 'dessert' is the same as 'desert'.
A trivial example, but in a time when we are ramping up our dependence on machine learning, we need to remember that the machine is not always correct and it is for the same reason as the crowd is not always correct.
I've had a few close calls when switching between the Dev/Staging/Prod environments. These will save you from any nasty suprises!
Change the colour of the terminal window when you ssh into your staging or production environments. I use a simple bash script that switches when I ssh into certain hosts.
Banner/Ribbon on Staging/Development
I just used a fork of the Github ribbon
Show App Name and Environment when in console
We used this handy gem Marco-Polo
That looks like this in the console:
~/Sites/myapp$ rails c myapp(dev)>
Difference between 'and' and '&&'
cat = 'meow' dog = false answer = cat && dog => false answer => false answer = cat and dog => false answer => 'meow'
Similarly with 'or' and '||'
cat = false dog = 'bark' answer = cat || dog => 'bark' answer => 'bark' answer = cat or dog => 'bark' answer => false
I generally follow this style guide
Some apis just return a timezone offset from UTC. For example Facebook
Need to convert it to a timezone name?
Rails Active Support to the rescue, you just need to do something like this:
utc_offset_in_hours = 10 time_zone = ActiveSupport::TimeZone[utc_offset_in_hours].name => "Brisbane"
Sometimes I work on a few branches at the same time.
Emergency bug fix branch here, new feature branch there, performance update branch here, update gem branch there, etc...
Within a big project we sometimes have almost 40 branches at any one time.
So, being human I forget the name of the branch that I was working on last week, and also would like to clean up old branches that I no longer need.
So the solution git for-each-ref
Include a sort and formatting that includes last commit date, and author name. This is the command:
git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate) %(authorname)'
Recently I have been investigating what the cheapest/easiest setup could be for a home entertainment system would be.
I have an old Macbook laptop that doesn't have a working touchpad and keyboard - but everything else works, so am using that as a media server.
So, my favourite combination of Software/Hardware is:
- Plex Server, easy to setup, works on all operating systems. You can add your own specific custom plugins, for example ABC iview in Australia, just look on GitHub.
- Chromecast - best $30 spent ever. Really simple device that works insanely well. Even without a media server, you can get some fantastic apps on your mobile - and cast from there.
- Plex mobile app ~$6, enables you to browse your Plex channels, and cast to your TV. Works on iPad, iPhone and Android.
Now all I need is a decent live sports channel, and I'll be set.