Craic Computing Tech Tips

A collection of computer systems and programming tips that you may find useful.
 
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Tuesday, May 13, 2014

Amazon Prime is a ripoff

My wife has Amazon Prime on her Amazon account - it costs $79 / year but offers free shipping.

I had seen reports that prices were higher if you had a Prime account http://abcnews.go.com/Business/amazon-customers-accuse-commerce-giant-cheating-prime-members/story?id=22882043

Today I priced several items on my account (without Prime) and my wife's (with Prime)

#1
Without Prime     289.28
With Prime         314.99   - 25.71 more expensive

#2

Without Prime    254.82
With Prime        288.75    33.93 more expensive

#3 

Without Prime    119.99
With Prime        142.49   22.50 more expensive


What an absolute ripoff ! 

So I thought let's cancel the Prime membership...


The End Now button is Disabled !!! Why even have the button if it is disabled ???

Read that quote "...will not benefit from canceling your membership at this time"

That is not true... if I continue to purchase items on this account I will be charged higher prices than on accounts that do not have Prime 

I am absolutely appalled that a company like Amazon plays this scam. I will be sure to sign up when the class action lawsuits show up and I encourage anyone else to do the same.


Monday, March 10, 2014

Private Wi-Fi Networks, Raspberry Pi and Mac OS X Mavericks

I ran into two problems connecting to my Wi-Fi network recently - both turned out to be the result of the network being private and not broadcasting its SSID (Service Set Identifier) - the 'name' of the network.

My network runs on an Apple Time Capsule using WPA2 encryption. It has worked fine with other machines - MacBook, Win PC, Chromebook, iPhones...


#1 Getting W-Fi running on a Raspberry Pi

I was not able to get Wi-Fi running on a Raspberry Pi linux machine, despite trying a range of configurations that I found on the web.

When I changed the network to make its SSID public then it connected just fine with the basic configuration.

#2 Setting up a new MacBook Pro

When you start up a brand new Mac it walks you through several setup steps, including connecting to a network. The new MacBook Pro only has Wi-Fi so connecting to the network is essential. But in my case it did not see the private network and so I was unable to get through the regular setup.

The work around was to skip those steps until I got to the regular desktop. Then going into Preferences and Network and configuring the network manually I was able to get in.

I think that if the SSID were broadcast then I would not have had any problems.


The reason to keep an SSID private is to make it more difficult for someone to break into your network. If they don't know the network exists then they won't try and break in. In reality, however, it not that simple. A serious hacker will still be able to detect packets on all networks in the area including the 'hidden' ones and then attempt to break in. So a private network is a good idea but it does not offer great protection.



Monday, February 10, 2014

Using Ping to find machines on your network

The UNIX command ping is used to test if specific machines are active on a network

$ ping 10.0.1.9
PING 10.0.1.9 (10.0.1.9): 56 data bytes
64 bytes from 10.0.1.9: icmp_seq=0 ttl=255 time=0.619 ms
[...]

I have been using ping for years but last week I found out that you can ping the broadcast address of a network (x.x.x.255) and see all the machines on that network that are configured to respond to ping:

$ ping 10.0.1.255
PING 10.0.1.255 (10.0.1.255): 56 data bytes
64 bytes from 10.0.1.10: icmp_seq=0 ttl=64 time=0.071 ms
64 bytes from 10.0.1.9: icmp_seq=0 ttl=255 time=0.534 ms
64 bytes from 10.0.1.1: icmp_seq=0 ttl=255 time=0.544 ms
[...]

Really useful if you need the IP address for a machine that used DHCP to assign its address

A complementary command is arp -a 

This displays information of all the network interfaces for a machine and reports the interface, the IP address and the MAC address of each entry in the address resolution tables.

$ arp -a
? (10.0.1.1) at b8:8d:12:5a:ad:77 on en0 ifscope [ethernet]
? (10.0.1.2) at b8:8d:12:5a:ad:77 on en0 ifscope [ethernet]
? (10.0.1.6) at 70:56:81:ad:b6:d1 on en0 ifscope [ethernet]
? (10.0.1.7) at b8:8d:12:5a:ad:77 on en0 ifscope [ethernet]
? (10.0.1.9) at 70:56:81:c5:fb:2d on en0 ifscope [ethernet]
[...]

Note that these addresses are not necessarily active. You can see link reachability information using arp -al


Tuesday, December 24, 2013

Web Site for Lakou Lapè - working to end violence in Haiti

Lakou Lapè is a non-profit organization based in Port-au-Prince, Haiti, that is working to end violence and conflict in some of the impoverished communities in that country.

Lakou Lapè was created to extend the achievements of the past few years in the Port-au-Prince neighborhood of St.Martin. Starting in 2004, members of that community, the charity Concern Worldwide, and the Irish group Glencree Center for Peace and Reconcilliation, came together to limit and reduce the level of gang violence within that community.

By using the approaches of reconcilliation, dialogue and respect that helped bring peace to Northern Ireland, the community was able to work together and greatly reduce the violence that was holding the entire community back.

Lakou Lapè is applying the same approach to other communities in Haiti. Through training, dialogue and engagement with the people that live in these communities, their goal is to reduce conflict and enable people to improve their lives.

I have been working with the group over the past year as it has started its work and I am proud to have helped build their web site http://lakoulape.org/ which describes their plans and their acheivements in French, Haitian Keyol and English.

It has been a pleasure to work with old friends from Ireland and new friends in Haiti and I wish Lakou Lapè the best of luck in 2014.

Thursday, November 14, 2013

Web Apprentice - Tutorials on Web Technologies

The range of web technologies that are available to web designers and developers is just incredible right now - from maps and graphs to translation and speech recognition.

Many of these are easy to incorporate into your sites but getting started can be confusing. There are examples and tutorials that are obsolete or needlessly complex - I've written some of them myself !

I want to help people get up and running with simple examples that they can use in their work today.

So I have created Web Apprentice (http://apprentice.craic.com) - a site that contains clear, straightforward tutorials on web technologies across the spectrum.

Tutorials range from simple embedding of Twitter feeds or Maps through to Typography, Translation and Geolocation.

Each tutorial has a self-contained live demo and all the code is available and free to use. Tutorials walk you through all the steps and explains what is going on in the code.

There are three levels of tutorial:

Basic - embedding widgets into your pages - no need to know JavaScript
Intermediate - involve some JavaScript
Advanced - complex JavaScript and Server side programming - may involve new technologies that are not in all browsers.

The goal is to add new tutorials every couple of weeks at least and over time build the site into a destination for learning and applying web technologies.

Please check it out at http://apprentice.craic.com and let me know what you think.



Monday, November 11, 2013

Setting up a new Application on Heroku

You can set up a new web application on Heroku in several ways. Here is my preferred way:

1: Build and test your application locally

2: Set it up as a git repository and commit all changes

3: Go to your account on the Heroku web site and cerate your new app there with your preferred name.

4: In your local git repo run:

$ heroku git:remote -a <your-app-name>

The response should be 'Git remote heroku added'

5: Upload your code with:

$ git push heroku master

6: Finish up your Heroku configuration on the we b site

7: Import any existing database as directed by this article.


Tuesday, November 5, 2013

HABTM relationships in Rails 4

Rails 4 has changed the way has_and_belongs_to_many (HABTM) relationships are handled as well as introducing strong parameters in the controller as a replacement to having :attr_accessible in your model.

Here is how you set up HABTM with a joining table.

My models are Tutorial and Category - a tutorial can have more than one category and vice versa.

Both models already existed and I wanted to create the relationship between them.

1: Create a migration for the joining table

The default table name should be the plural of the two models, in alphabetical order, separated by an underscore. (You can give it any name you want - you just need to include that later in the model)

class CreateCategoriesTutorials < ActiveRecord::Migration
  def change
    create_table :categories_tutorials do |t|
      t.belongs_to :tutorial
      t.belongs_to :category
    end
  end
end

2: Add the relationships to the models

Previously you would have done this (in the Tutorial model):

has_many :categories_tutorials, :dependent => :destroy
has_many :categories, :through => :categories_tutorials, :uniq => true

That is now simplified to this:

has_and_belongs_to_many :categories

If you have a custom table name then specifiy it like this:

has_and_belongs_to_many :categories, join_table: :my_category_tutorial_table

The Category model has:

has_and_belongs_to_many :tutorials

The CategoryTutorial model has:

belongs_to :category
belongs_to :tutorial

In my example I want to specify Categories when I create a Tutorial. 

In order for this to work I need to allow the tutorials_controller to accept the category_ids parameter which is passed from the tutorial form.

At the bottom of the controller Rails has created this:

def tutorial_params
    params.require(:tutorial).permit(:title, :description, :status)
end

I need to add category_ids and have it set up as an array 

def tutorial_params
    params.require(:tutorial).permit(:title, :description, :status, :category_ids => [])
end

That last step is critical - if you miss this then the associated rows are not created in the database.

For more information on HABTM take a look at:

http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association