Monday, 25 August 2014

Life at 38

When I was 5 I liked to do jigsaw puzzles upside down (to make it harder) and blow bubbles off the balcony -- watching them drift over the street. I liked to walk to school by myself (one block) and learn Origami from the lady in the flats behind us.

When I was 7 I wished on every star that I could have a baby sister. When I was 8, I got one.

When I was 10 I liked to explore the backways of Oyster Bay, picking flowers to make perfume (which smelled terrible). I played fantasy make-believe games with my cousins - involving magic and unicorns, where we saved the world.

When I was 12 I got another sister.... I stopped wishing. :)

When I was 13 I liked to play make-believe with my sisters and all the younger cousins. Gordy and I plotted adventures for us all, in-amongst the bamboo.

When I was 15 I liked to climb up on the roof and watch the clouds drift by. I liked to ride my bike home from school and play LARP in the park across the road.

When I was 17 I liked to swim in the backyard pool, drifting underwater with my hair floating loose around me. I liked to frantically scribble in my diary and day-dream about movies; making up adventure stories or inserting myself as a character in my favourites.

When I was 20 I loved the freedom of being independent, waking up in my own flat to the sound of Cockatoos in the pine-trees. I liked being free to wake up in the afternoon and go for a walk in the twilight, or in the quiet time after the curfew painted the streets with night. I liked staying up all night, having coffee with friends, as television got progressively more idiotic. As the sky began to warm with first light - I went out again. I liked feeling the expectant hush of the cool dawn, then retiring before the hustle woke up.

When I was 22 I loved my writing diary - pouring out my heart or playing with words, crafting new worlds on a page. I liked learning new things -- drifting from subject to subject. I liked psychology, programming and the occult. I loved my cats. I liked it that I got married and was somebody's wife. I liked meditating with my husband -- humming toneful chords without meaning. I liked learning martial arts with him.

When I was 24 I loved my garden. I spent days drifting through it and tending to the plants. I liked picking silver-beet and herbs and cooking up a meal that I'd taken from seed to table. I liked shopping at Bunnings for fruit trees. I liked spending Saturday nights with the Druids, singing, meditating, drinking mead and telling stories. Then the morning-afters, skinny-dipping in the wading-pool as the sun climbed the sky.

When I was 26 I moved interstate by myself, to see the Big City. I liked exploring the back-areas of Chatswood in search of great food. I loved hacking together brilliant solutions for colleagues desperately late on their projects. I liked rock-climbing with my work-mates and playing network games in the training room until late at night. I wrote a dictionary of elvish (quenya).

When I was 28 I loved freedom. The freedom to choose my own time, to choose what to learn, to work on my own projects. I liked smiling at my young class-mates who complained about the work - knowing this was easy compared with Real Work. I liked the meditation of archery. I liked spending my time reading while sipping coffee, or eating noodles at the local hole-in-the-wall. I liked long walks in the evening, scoping out my local territory.

When I was 30 I liked building my own small business, knowing I owned it and I could achieve whatever I wanted. I liked learning medieval crafts alongside eager students, and feasting with friends in a medieval campsite. I liked reading books, sipping coffee after a good workout at the gym. I liked watching myself learn how to walk again.

When I was 32 I enjoyed being a senior developer, being at the top of my form as well as earning high pay. I enjoyed choosing my first major investments in shares and buying my first property. I loved planning what to do with my life, and choosing to gather interesting experiences around me - New Zealand, the Northern Territory, Thailand. I learned photography, spanish and investing. I watched a *lot* of DVDs.

When I was 34 I moved internationally by myself. I loved exploring in a new country: visiting ancient ruins and watching Shakespeare at the Globe. I enjoyed getting better at photography, meeting new people and seeing new places. I built my own startup with friends. I enjoyed my morning coffee at the local in Windsor, and walking past a castle on my way to work in the morning. I loved pottering around in my allotment late into the long, english summer nights.

When I was 36 I loved getting about europe in my first car; learning French, and then eating my way around the French countryside. I enjoyed picking fresh fruit/veg from my allotment and making blackberry pie. I loved the lazy schedule allowed by working from home, and lazy Sunday afternoons drinking velvety latte with a Cranberry-and-orange muffin at my local cafe in Windsor, in view of the castle.

When I was 38 I loved being in the thick of things in the medieval group - I was president of the NSW branch (200 paid members, 10 direct and 8 indirect reports). I helped coordinate others who were running feasts and balls and camps and craft classes. I taught a class of newbies to build websites in Rails in 12 intense-but-rewarding full-time weeks. I enjoyed dinners with my cousins, and weekends going to the markets with them and then spending the day cooking preserves, jams and soups to feast upon in the weeks to come.


This post began as an exercise: "for every five years, write what you enjoyed doing". It helps you find out what you most enjoy - and how your tastes change over time. I also like to do it to remind me of the good things in life - which can be so easy to forget sometimes.

Tuesday, 19 August 2014

STOP YELLING! or how to validate a field isn't in ALLCAPS

TuShare lets people give away things they no longer need. It turns out that some people think that putting their headings in ALLCAPS will get more attention... but we think it just annoys people (nobody likes to BE YELLED AT!). Here's a quick snippet that lets you validate that your users aren't YELLING AT YOU! in any given field.

1) create a custom validator in app/validators/not_allcaps_validator.rb with the following code:

# we don't want our users YELLING AT US!
class NotAllcapsValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    if value.present? && (value.upcase == value)
      record.errors[attribute] << (options[:message] || ""is in ALLCAPS. Please don't YELL AT US (we're sensitive types). Instead, just use normal sentence case. I promise we'll still hear you from over here. :)")
    end
  end
end

2) use it in your model like this:

   validate :name, :description, :not_allcaps => true

3) Add a custom matcher for rspec:

# validates that this field has the "not_allcaps" validator
RSpec::Matchers.define :validate_not_allcaps do |attribute|
  match_for_should do
    match do |model|
      model.send("#{attribute}=", "AN ALLCAPS VALUE")
      !model.valid? && model.errors.has_key?(attribute)
    end
 
    failure_message_for_should do |model|
      "#{model.class} should validate that #{attribute.inspect} cannot accept ALLCAPS VALUES"
    end
 
    failure_message_for_should_not do |model|
      "#{model.class} should validate that #{attribute.inspect} can accept ALLCAPS VALUES"
    end 
  end
end

4) test each field in your model specs with:

    it { should validate_not_allcaps(:name) }
    it { should validate_not_allcaps(:description) }

Wednesday, 13 August 2014

Link: Why I am leaving the best job I ever had

an awesome post by Max Schireson to remind us of our priorities in life: Why I am leaving the best job I ever had

"Earlier this summer, Matt Lauer asked Mary Barra, the CEO of GM, whether she could balance the demands of being a mom and being a CEO. The Atlantic asked similar questions of PepsiCo’s female CEO Indra Nooyi. As a male CEO, I have been asked what kind of car I drive and what type of music I like, but never how I balance the demands of being both a dad and a CEO..."

Thursday, 7 August 2014

Link: Guidelines for growing a stable codebase

"Software projects need to evolve over time, but they also need to avoid collapsing under their own weight. This balancing act is something that most programmers understand, but it is often hard to communicate its importance to nontechnical stakeholders. Because of this disconnect, many projects operate under the false assumption that they must stagnate in order to stabilize.
"This fundamental misconception about how to maintain a stable codebase has some disastrous effects: it causes risk-averse organizations to produce stale software that quickly becomes irrelevant, while risk-seeking organizations ship buggy code in order to rush features out the door faster than their competitors. In either case, the people who depend on the software produced by these teams give up something they shouldn't have to."

Guidelines for growing a stable codebase covers six useful techniques for keeping your codebase stable while it increases in size. Well worth a read.

Friday, 1 August 2014

10K on Stack Overflow

w00t!

This morning I finally got the 10k moderator tools privilege on StackOverflow. You can see it here: Taryn East on Stack Overflow

Pardon me while I blow my horn for a moment, but it's taken me nearly five years to get here...

Tuesday, 24 June 2014

Link: Getting rid of intermittent feature spec failures

Intermittent feature spec failures are the bane of testing experience.

They cause builds to fail at random (which really screws with you when you have continuous deployment based on master-branch merges). But more insidiously, they lead to bit-rot in your test suite - because once you get used to tests failing at random, you tend to overlook it when they do... which leads to bad code falling through the cracks at the worst times.

Patrick Bacon's article: These Intermittent Test Failures Will Not Stand, Man has a small selection of useful things you can do to address these failures and root them out for good.

Wednesday, 18 June 2014

Rails migrations for zero-downtime sites

At TuShare we have a zero-downtime site with continuous deployment (ie, you merge to master, and away it goes to production...)

The zero-downtime part means that as the new code goes out, the old servers are still up and running until the new code is fully loaded and ready to roll... and they only then get pulled down.

This is great for uptime, but does mean you have to be extra careful about any migrations. The database must work with both the old code and the new code.

My colleague pointed me at this article: Rails migrations with no downtime. which has some in-depth coverage of the topic. What kinds of things cause errors, what you can do to reduce the pain of change-over.

Thursday, 12 June 2014

Working with TuShare

So, I've got a job at TuShare.

TuShare are a little like FreeCycle - people login to either give away their excess clutter, or get some free stuff from others.

But there is one main difference - instead of having to pick the items up yourself, TuShare offers seamless integration with a courier system for any items smaller than 5kg. You still have the option of going out to pick the item(s) up (which you still have to do for furniture and large objects), but you also have the option of a door-to-door courier service for only $10 within your capital city, or $25 for city-city service.

Personally, that extra convenience is extremely appealing to me, and I used it about a month ago to get myself a brand new-to-me juicer. Since then I've put up 6 items of my own, from random old computer bits to a futon left with me by a friend who moved house.

TuShare has a small dev team, but there's a lot to work on - especially after the boom in users following the Global Sharing Day events held last week.

The people are lovely and I'm really looking forward to working with them.

Tuesday, 3 June 2014

Link: Open-plan offices don't work

Just read an interesting article by Maria Konnikova called The open-office trap

The TL;DR version is that while open-plan offices give employees a feeling of belonging to an open, laid-back company. The actual measured performance of employees shows that they are "damaging to the workers’ attention spans, productivity, creative thinking, and satisfaction."

Wednesday, 14 May 2014

Link: Service Objects in Rails

Steve Lorek has written a nice overview of Service Objects: What They Are, and When to Use Them.

"There has been a lot of discussion within the Ruby community around the service objects pattern. The term "service objects" may be unfamiliar to even seasoned Rails developers, because Rails itself implements the Model-View-Controller design pattern. There is no concept of a 'service' in a new Rails application. So it's understandable that this concept may seem foreign, and indeed non-obvious. However, I believe that the service objects pattern is well worth considering for any non-trivial Rails application."

It's a quick read, and gives a very good introduction/overview to when and why to use service objects in Rails.


Further to the above. If you have a Railscasts-pro account, you can watch this video on Service Objects.

It starts with an example of modularising out the functionality of a FAT model, using concerns. He then describes why he doesn't prefer that approach (my first introduction to the brilliant phrase "grep-driven-development") and finishes up with an alternative using service objects instead.

It's Rails-3 oriented - so you know you don't have to do anything special to include the concerns directory anymore... but otherwise his examples are still quite relevant and a great intro to the practicalities of how to actually go about a simple service-object and/or modularisation refactor.


Finally, don't forget some of the classic articles on this subject from DHH's Put chubby models on a diet with concerns to Bryan Helmkamp's 7 Patterns to Refactor Fat ActiveRecord Models

Thursday, 8 May 2014

Thursday, 1 May 2014

Link: programming sucks

Programming sucks

"Every friend I have with a job that involves picking up something heavier than a laptop more than twice a week eventually finds a way to slip something like this into conversation: "Bro, you don't work hard. I just worked a 4700-hour week digging a tunnel under Mordor with a screwdriver."
"They have a point. Mordor sucks, and it's certainly more physically taxing to dig a tunnel than poke at a keyboard unless you're an ant. But, for the sake of the argument, can we agree that stress and insanity are bad things? Awesome. Welcome to programming."

:)

Tuesday, 22 April 2014

Classic: The Law of Leaky Abstractions by Joel Spolsky

Joel Spolsky's classic: The Law of Leaky Abstractions is still well worth a read today.

Many of today's high-level tools abstract away the low-level details to such an extent that 99% of the time, you don't even need to know they're there. But it's that 1% of the time that's the doozy. When everything suddenly blows up because you accidentally crossed an invisible line you didn't know was there... how can you figure out what went wrong and how to fix it?

The low-level detail leaks through.

So often, even though you're using an abstracted, high-level tool, you often still have to learn all the lower-level stuff it was helpfully abstracting way.

An example would be a need to learn sql in order to understand joins and includes (and how they go wrong) in Rails' Active Relation

Wednesday, 16 April 2014

Link: Female Founders by Paul Graham

Paul Graham (of Y-Combinator) writes some amazingly worthwhile essays. One of his recent ones is about what he's learned about Female founders

Read to discover:
Is YC anti-female (spoiler: no)
Do female founders fare differently in startup culture (spoiler: sometimes, but that should rapidly improve)
What can we do to encourage more females to be founders?

Thursday, 10 April 2014

Heartbleed: openSSL has been compromised test your site!

So, you may have read that there's a security vulnerability in OpenSSL called Heartbleed. It's pretty serious and potentially affects everyone. You should change all your passwords right now.

Read more about it here: Here's How To Protect Yourself From The Massive Security Flaw That's Taken Over The Internet

You can use this site to test any site you care to try: Heartbleed test

Friday, 4 April 2014

Quit being so negative!

Interacting with other people is all about perceptions. For better or worse, we can't see inside of other peoples' heads and have to infer what's inside of them based on their actions... and also on (get this) *our* past behaviour.

You thought it would be *their* past behaviour, yes? but actually unless you've known somebody a really long time - your perceptions of another person are more based on what you have done in the past, than on what they have.

It's way too easy to totally miss this point when it comes up in reality - because what you think another person is doing... just seems so obvious. Surely they're doing X, it's just obvious they are...

What you don't see are all the subconscious micro-decisions that got you to that point. What exactly did you base your observation on?

Could you be mis-interpreting something? Just because you (or your sister, your boyfriend or your old teacher back in high school) used to do X and that meant they thought Y - doesn't mean that this person you're talking to right now... thinks Y - even if they're quite clearly doing X.

This all stems from a bit of an example from my own life (I'm T):

P comes up to T and tells her all about a friend of his who's developing a new javascript library.
"it's gonna be awesome!" P enthuses.
"interesting," T says. "so what does it offer over jquery?"
"what do you mean?", P asks, looking taken aback.
"well, jquery is pretty bog-standard in the web-world right now. What does your friend's library do, that would make me choose to use it over jQuery?" T replies.
"why are you asking me that? It's a great library, it's going to be the best!", P asks

We'll stop here and see where everybody stands, because I know from later discussion that P is thinking that I'm not interested in hearing about this new project. He thinks that *I* think it's only worth doing a project if it's better than jQuery. Why else would I demand what this new project had to offer and whether or not it was worth pursuing? How dismissive of me!

Hang on a tick... what did I *actually* say?

None of the above, it turns out. From my perspective, I was curious about the project and wondering what it might have to offer.

It think it all hinges on what part we both assume the role of questions plays.

I assume that questions are to elicit information on something of interest.
P assumed that questions were a way of poking holes in an idea and dismissing it.

Both of these are assumptions based on our own past history of using questions.

Perhaps when P questions something it's because he has strong reservations about it, or because he's decided it's a bad idea and he wants to highlight all the flaws in it... but assuming that that's the reason why *another* person asks questions... will lead to very great misunderstandings.

No doubt there are downsides to my own assumption - obviously that other people will get the wrong idea about my reasons for doing so... perhaps thinking that I'm attacking their idea instead of finding out more about it.

The biggest part of the problem is that that these assumptions are pretty-much invisible to us. To us it just feels like "the way it is"... not "my perspective". it's only when we brush up against somebody else's different perspective that we even notice they're there at all (like two people with different-coloured sun-glasses finally swapping notes about the colour of objects they see).

I haven't got a solution to this problem yet... I'd be curious if any of you readers out there do. feel free to comment and let me know.

Saturday, 29 March 2014

Speaking Eloquent Javascript - learn javascript (and programming) for free

Eloquent javascript seems a nice site for learning programming for free, by working your way through a free textbook.

I've only skimmed it myself - I've been working my way through Code School's Javascript path.

Another that's just come out is Speaking javascript (an O'Reilly book that's also online for free)

I've heard good things about both of these.

Have you tried either one? If so, tell me what you think, or if you have a better (free) source, let me know in the comments.

Sunday, 23 March 2014

Link: Australia's top female programmers

Pollenizer has posted a list of what they call Australia's top female programmers.

I apparently made the grade... but it's a little scary to see my name amongst some of the most awesome women coders I've met over the years...

Tuesday, 11 March 2014

The failure of the ruby community - and what we can do about it

Sam Peters holds up a dark mirror in which our community reflects more poorly than I'd have hoped to see.

Her post on ruby meetups and the developer community is particularly worth a read for those of us happily ensconced inside that echo chamber.

Some representative quotes:

"[at ruby meetups] people who knew one another would connect, catch up, and spend the time excitedly discussing the latest news. To one another. Exclusively."
"Upon my attendance [at ROROSyd] I was immediately struck by the small, tight groups of people scattered across the venue – something that felt quite intimidating as a new learner"
"My more unorthodox theory implies that this community is merely an illusion"

The words "scathing indictment" spring to mind.

Clearly this is not the kind of community that we want.

As a mob, we can be pretty intimidating - and we need to work on better outreach and inclusiveness at our meetups.

I remember the earliest days of the rails community in Sydney. I remember when everybody was a beginner, and we came together to share our solutions to the hard problems we faced, to welcome newbies and help each other grow into skilled rubyists.

One particular observation of hers at rubyconf gives an example of what we can do better:

" I also experienced a bit of community on a personal level too – one particular lunch time, a pair of developers invited me to their table with no pretence or expectation. It resulted in a rather pleasant lunch, and opened my eyes a little. I felt a little more welcome."

In other words - it doesn't take much.

If there are people at your local meetup looking new and alone, go over and say hi. Ask them about their experience in ruby, invite them to sit at your table. Just start the conversation and include them.

I'm personally hoping to help break down that barrier-to-entry with Ruby Women - to provide at lest one extra avenue into the scene via a smaller, more beginner-friendly meetup and more open network of friend

The full article is well worth a read and some careful self-reflection. We should take note and work hard to build something better.

My Students

So, I've been teaching the General Assembly Immersive Web Development course for the past two months now.

It's going great and has been a really rewarding (if highly challenging) experience for me

They've recently finished their second (of three) projects, and the results are pretty amazing - especially considering that most of them had never touched a line of code, two months ago.

Here are links for some of their blogs to see how they've been coping over the past two months...

Sam Peters

Sam is a creative developer and her humour punctuates her work. Her blog showcases her particular mix of creativity and humour, with quite pointed insight into the development process and community

Her first project was: Forage, a website built to let gardeners swap their excess produce with others.

Alberto Forni

Alberto moved here all the way from Italy with his girlfriend in order to learn development. He's studying full-stack development, and his girlfriend is in the classroom next door studying User Interface Design. So I expect them to make a formidable development team when they're done.

His first project was: Alfred lets you keep track of expenses and wishlists - and share your wishlists with your friends.

Luke Schoen

Luke is always overflowing with ideas. No sooner do I describe some new topic and he thinks of five new applications for it in various combinations with other things he's learned.

His first project was TrendMyHunch, a site to share your ideas, pick your favourites and see if they're currently trending on google.

I have plenty more students, but they haven't shared their blog-urls with me yet... I'll come back and add them if/when they do :)

Here are the links to their recent, group-projects:

Expense Tracker

Split and track expenses with your friends or housemates

Autism Connect

A community for carers of the Autistic, allowing sharing of autism-related events, documents, links etc

Rick Rampage

A javascript, scrolling shooter game (the scores are stored in the rails backend)

Saturday, 8 March 2014

Classic: Making Wrong Code Look Wrong by Joel Spolsky

The article Making Wrong Code Look Wrong by Joel Spolsky is a classic take on a programming concept that you should still, always keep in mind when writing your code:

You should try to write your code so that it's more difficult for things to go wrong...or at least more obvious when things do.

It was written Some Time Ago - so take his prescriptions with a pinch of salt and apply your intelligence and ingenuity.

It's the vibe of the thing that matters here :)

Sunday, 2 March 2014

Ruby Women - a new meetup group

TL;DR: come to the Ruby women Sydney meetup (if you're a woman in Sydney and into ruby and/or rails), and please spread the word


I've been kicking around this idea for a while now.

You see, once upon a time I was a regular at the Sydney Linux Users Group - a formidable group of uberhackers. I knew almost nobody there, and due to the high skill-level of the members found it overwhelmingly scary to even think about presenting.

I was simultaneously looking into issues that women face in the workplace, and came across a couple of different books that pointed out that women, in general, tend to be more self-critical and less self-confident than their male counterparts.

It helps to have a network of other women to support you... but where can you get one in the traditionally male-dominated arena of IT uber-geekery?

Well - shortly thereafter, a number of us women in linux geekery began organising a local version of Linux chix. We just got together about half an hour before the SLUG meetup - and chatted and gave mini talks on interesting and basic linuxy topics... (nothing special)... and then all walked en masse to the SLUG meetup.

It doesn't seem like much, but it made a huge difference.

It provided a safe, conducive environment to women-geeks to introduce them to the linux community, without diving right into the deep end. It also provided a network of other women to serve as colleagues and role-models.

A couple of short years later, Sydney hosted a Linuxconf(.au) that had a remarkably large percentage of women for conferences of the kind - along with a whole mini-conf on topics relating to women in IT.

Linux-geekery was now something that women participated in too - in large (if not yet equal) numbers, and I'm quite certain that the strong networks formed at linuxchix helped with this

then I went away to the UK for three years...

Coming back to Sydney again, now part of the ruby community... I went to my first rubyconf.au and was overjoyed to hear of RailsGirls - a hackday-style initiative designed to help non-dev women get their first Rails site up and running.

...but it has come to the attention of many, that there's not much to keep interested women going after this. RailsGirls is currently working on RailsGirls-Next - to help Rails Girls participants continue working on their apps and slowly improve their skills... and alongside that - I've been working on something much more akin to the linuxchix concept:

Ruby women

It will be a group dedicated to women in the ruby/rails community - providing exactly the kind of supportive network and easy transition into the ruby/rails community that I think women still need.

Our first dinner meetup/discussion will be held on Wednesday 19th of March in Sydney

Please feel free to publicise the meetup far and wide, and to invite any and all women you may know.


To head off a couple of obvious responses:

What about a ruby men group?

Feel free to start one. There's nobody stopping you, and I'd certainly welcome that too.

I'd be really interested in hearing about the issues facing men in the IT industry too. I've heard especially about issues regarding fatherhood and balancing concerns of needing to appear dedicated to your job, as well spending time with your children... and also tales of unfair paternity laws (ie women are more likely to get time off for children than men are).

Can men come too?

Good question. We probably won't drive you away with pitchforks...

Personally, I'd be curious why you wanted to come. If you're there to pick up chicks - I'd be strongly against you coming. If you're there to support the needs of women in another group you run I'd happily welcome you...

but this won't be just *my* group, so others may have differing ideas about that.

Isn't it kind of exclusionary?

Yes. So is a group catering only to the interests of ruby programmers (as opposed to, say, python programmers)

Meetup is being DDOSed

I just checked meetup.com - it appears to be under a DDOS attack right now.

Check the meetup blog for ongoing details

Friday, 28 February 2014

Startups for the unexotic underclass

If you're an entrepreneur looking for ideas, consider looking beyond the city-centric, navel-gazing, youth-obsessed mainstream.

The unexotic underclass in a fascinating read for startups looking for meaningful ideas for new apps.

It's a call to action for us to stop wasting our time developing the next fashion-hunting twitter-app for our manicured dogs...
and instead start looking at solving some real problems that affect real people that we tend to mostly overlook, because they're just not treated as *interesting* enough by our society.

Really worth a read

Friday, 21 February 2014

Vale David E.

There's too much death going around right now.

The ruby world has been rocked by the death of of Jim Weirich (kind man, great teacher and original writer of rake)...

But for me, I have to say this is overshadowed by two deaths much closer to home.

About 3 weeks ago, my grandfather died.

I was never really close to him, but his passing sent ripples through my family. Even my close family came back from the states to attend the funeral and be with my grandmother.

But my grandfather had made it to 96. He was well-travelled and had managed to complete his book on lay evangelism - which was the end result of his life's work in his church. He lived a long, full life.

This morning, my uncle gave up his struggle with cancer.

He was only 70, and the world is that much less bright without him in it.

He was kind and generous, and always made me laugh. He brought joy and love back to my aunt - whom he married only a few short months ago (right after the diagnosis).

He was way too young to die.

Monday, 17 February 2014

Link: Stack Overflow Goes Down, Programmers Around The World Panic

StackOverflow went down on Sunday. It's back up now, but it sure serves as a reminder of how much we've come to rely on this truly awesome resource.

The article above shows some of the (inevitable) humour that flowed from the event... but it does leave me with that feeling that we're whistling nervously in the dark - what if it went away for reals?

Sunday, 9 February 2014

Link: a deeper look at ruby's enumerable

Have you ever needed to load a VERY large file in ruby? No I don't mean your 500 line rails model. I mean a several gig binary or text file.
Try it. Watch your machine become unresponsive. Cry a little inside. Then reach for enumerable.
Ruby's Enumerable module gives you a way of iterating over collections in a lazy manner, loading only what you need, when you need it. But it gives us so much more than that.

rubylove has written a great, in-depth look into enumerable with: A Deeper Look at Ruby's Enumerable

Sunday, 2 February 2014

Gamification on coursera

Kevin Werbach's coursera course on gamification is restarting again!

He's the bloke who wrote For the Win: How Game Thinking Can Revolutionize Your Business - and the gamification course had amazing reviews.

I started it too late last time to fully participate - and now I get another chance!

it's only just begun - so there's still time to sign up without missing out on any of the assignments or the option to get a certification.

Tuesday, 28 January 2014

Teaching at fishburners

If you're wondering why I've been so quiet... I'm currently teaching the "Immersive web development" course for General Assembly at fishburners, in Ultimo

This is a 12-week course covering the full stack of web development. Students learn ruby, HTML, CSS, SQL, sinatra, rails, javascript and several javascript frameworks.They complete three personal projects as well as many small homework projects. They also get an introduction to the ruby/rails and startup communities (especially via fishburners).

I'm teaching the course - and teaching is, for me, a brand new skill. While they learn rails, I get to learn how to structure and plan lessons, and how to deal with multiple levels of understanding.

It's tough - which is what I expected. I have to plan 40 hours of talking... every weekend - and brush up on every aspect of what I'm teaching so I can answer the tricky questions.

This essentially means I'm working 6 days a week, and the teaching itself drains a fair bit out of me.

So if you're wondering why I'm a bit quiet atm... that's why

Monday, 16 December 2013

Open Source Software is Anarchism*

There is No Governing body

People come together purely through enlightened self-interest to build something useful

Yes there are freeloaders
yes there is chaos
yes standards vary

But some amazing stuff gets built despite all that.


* Note: anarchism != anarchy... go look it up, if you've never heard of it before...

No. it wouldn't work as a form of government for obvious reasons (ie people are still people)... but that isn't the point I'm trying to make here.

Monday, 9 December 2013

In the land of the blind

In the land of the blind
the one-eyed man is burnt at the stake
for asserting the heresy of light in our land of blessed darkness

Tuesday, 3 December 2013

Twitter bootstrap - for quick and easy design

If you're anything like me, for a graphics designer you make a great web developer.

My past attempts at design have run the gamut from "geocities" to "unicorn vomit", and I've become increasingly minimalist in an attempt to rectify that

-> less design == less unicorn-puke == win!

But it still leaves my sites looking like crayon-drawn whitesites

It's a long way from there to the current industry requirements of a clean, flexible, responsive design - able to handle mega-huge desktop-monitors and tiny smart-phones alike while looking sleek and professional... and I had resigned myself to basically just not sucking too badly and hoping my sites were useful enough for people to get past the ugly-duckling look.

but now I've found bootstrap. It lets you quickly and easily build a fully-responsive all-devices-ready design with very little graphic-design nous required. From a full grid-based system (to easily build columns that will nicely collapse on smaller screens), to all sorts of components - navbars, breadcrumbs, panels, lists of linked thumbnail images... the list is pretty huge.

Don't be put off by the "oh my god PURPLE" look of their website - this is a tool worth using.

The getting started guide is where to begin.

There's a number of pre-built templates on bootply templates that even if you don't like, you can cannibalise for the various pieces you want.

You can also buy a whole bunch of pre-packaged, professional themes (for about $12 each) from WrapBootstrap to kickstart your website design. Though be aware they are mostly built on Bootstrap 2

If you're building this stuff in rails, there's a whole bunch of bootsrap-related gems - which mean you don't have to download the css/js versions of bootstrap and mix them all into your assets directory.

Ryan Bates' railscast (see below) uses seyhunak / twitter-bootstrap-rails, which seems to have a whole bunch of neat generators for quickly throwing up layouts. I prefer not mixing bootstrap's Less with the existing SASS, and so have gone for the sass-based gem: bootstrap-sass gem.

I suspect you can combine these two powers for good by using the generators of twitter-bootstrap with the sass-based assets of bootstrap-sass... but have yet to try it (let me know if you do).

There's also a great overview of rails and twitter bootstrap with a related RailsApp that goes into far more depth (I haven't had a look at that yet).

and Ryan Bates has done a railscast on twitter bootstrap basics, and a pro-only railscast: more on twitter bootstrap

enjoy...


Note: Bootstrap version 3 has recently been released, and a lot of the tutorials, railscasts etc are based on version 2. Bootply has a Bootstrap 3 migration guide if you want a reference to what has changed.

Wednesday, 27 November 2013

Link: loading-icon generator

Load info is a neat website that lets you generate your own loading icon.

The first page has a hypnotising array of load-icons to choose. Click on one and it'll bring up a box that lets you choose the size and colours you want and it'll generate you a customised animated gif you can use.

Tuesday, 19 November 2013

Thursday, 14 November 2013

Zen and the Art of Western Rationality

Zen seems to have, as central to its dogma, a mystery tradition. ie it makes all its teachings appear incredibly mysterious in what appears to be an effort to make it seem harder to attain - and thus weed out those not willing to work for the enlightenment it proffers.

at least this is how it seems to western thinking. I've known a number of people who have fallen into what I believe is the trap of thinking that zen actually *is* a mysterious hidden secret that can only be approached in a non-rational way...

The reality is that zen is a very good way of switching off that part of the mind that gets in the way of thinking about the things that zen teaches... however, its not the only way.

As they say in zen - zen is not the way, but it approaches the way.

ie it's a good way of starting out, but it won't get you all the way there.

and (unlike the smugness of certain woo-woo types would lead you to believe) it's not the *only* way of reaching The Way.

It's my contention that it is just as possible to work your way there, starting with traditional western rationality/philosophy.

Here's an example pulled from zen:

A teacher once said "this is my short staff. If I call it a short staff, I deny its reality, but if I do not call it a short staff, I deny its fact, so what do I call it?"

It sounds incredibly mysterious. It's a mind-puzzle that you must work out for yourself - and if you are starting from scratch, it may take years of meditation to get to an answer... or you may grasp it in a second.

This is why it seems mysterious, like a great hidden secret that must be very valuable and thus you can feel all smug about knowing...

However, this koan contains some truths which are quite easily expressed in Western rationality also, and I believe it's more valuable to share those truths than to remain "terribly mysterious".


This koan, to me, expresses the map vs territory problem.

The map is not the territory, and yet it is the territory - just not *all* of the territory. The territory is represented by the map, but it is not defined by the map. Change the map (say, pencil in a new road) and the territory will not change (the new road does not spontaneously appear). Change the territory, and the map must be changed to match or lose it's connection with the territory.

Yet the map (if properly drawn) is the territory also - that road connects to this one in just such a way. If you follow the pattern of roads on the map, you will arrive at the destination that the map says you will.

The territory contains those facts that are within the map, but it *is not* the map itself. The map contains facts which are defined in the territory. You can recognise the territory by looking at the map - but the territory is so much more. It contains trees and roof-tiles and many other things that are not in the map.

The map is not the territory, and the territory is not the map

If I look at a map of england and say that this is england I will deny the reality of england. But if I look at the map and say that it is not england, then I deny the fact that the map is of england.

The map is the territory and is not the territory

but using the map you can approach the territory, but it is not the territory.

It does and does not have "england-nature"...


To get back to the koan... the object that the teacher is holding out is a short staff - that is the fact. If he said "this is not a short staff" then he would be denying the fact of it actually being a good example of a short staff.

However - if he broke it in half (so that it was no longer a short staff), it wouldn't be like there was no longer any short staves in the world. Thus you cannot say that is is "the" short staff. Other short staves are not defined by the properties of the object in the teacher's hand.

The name "short staff" is just a reference to it... but not a definitive one. It is not the same short staff as, say another one lying on the floor over there. If I can point to each and say "this is a short staff" then you are not naming a thing, only categorising it.

Therefore if you name it "short staff" you deny the reality of it being something *more* than a short staff.

The phrase "short staff" is the map that lets us recognise "things that have the short-staff property"... but it is not the short staff itself.

Now - perhaps you got something different from the short-staff koan. If so, instead of being "all zen and mysterious" about it, I implore you to figure out what it is you've learned... and share it with the rest of us.

Thursday, 7 November 2013

Link: Awesome guides to building a functional rails app

Rails girls is a group dedicated to training up the next generation of Rails developers... who happen to be women.

They tend to run over a weekend and get women of all backgrounds (but without rails experience) to build a rails app from scratch.

They have a set of materials that is brief, but quite impressive - and if you follow them through step-by-step it's a quick tutorial on how to get a pretty decently functional Rails app off the ground.

Start with the App tutorial to get it up and running with a simple scaffold, to add some basic styling with bootstrap, and add picture-uploads with carrierwave.

Then follow the set of guides (links are at the bottom of the app-tutorial page) to get it up on heroku, to add authentication with devise, to use geocoding to add your widgets to a map, to create thumbnails for your uploaded images and more.

With just the above you can get a fairly decent rails app built for most purposes in a day or so.

Friday, 1 November 2013

Putting your heroku repo on github

When I set up a new quick-and-dirty app on heroku... I often also want to put my code up on github.

I was really surprised this simple process wasn't covered in the otherwise pretty excellent Getting started with Rails 4 post on heroku.

It's pretty straightforward, so here it is.

If you follow the instructions as per the getting started guide (above), you'll have a local git repo, and it'll be tracking the heroku remote as "heroku". which means there's no problem with using the bog standard "origin" for your github repo version.

So from there

Step 1 create a new repo on github

  1. Go to your github page eg this is the github page for me: taryneast's github
  2. Click on the "repositories" tab
  3. Click the green "new" button
  4. Give it a name and, optionally, a description
  5. Click "create repository"

Step 2 - link it to your heroku app

  1. Go to your heroku app's settings page. this will be something like: https://dashboard.heroku.com/apps/<myapp>/settings
  2. About halfway down you can add your repo-name. It'll be <mygitusername>/<mygitrepo>
  3. Click save

Step 3 - link your local repo to the github remote

  1. open a terminal in your rails app's root directory
  2. type git remote add origin git@github.com:<mygitusername>/<mygitrepo>.git
  3. git push -u origin master

Your heroku app is now on github.

You can continue to push to heroku with:
git push heroku master
and to github with:
git push origin master

Wednesday, 16 October 2013

Levelling up in Ruby/Rails - for free.

So, I've recently found myself back on the job market... at least I will be, but I first want to re-sharpen my skills. I've been working in legacy Rails for a while now, and I want to make sure I'm au fait with the latest and greatest the ruby+rails world has to offer.

But when I went looking for courses - there's not a lot on offer for experienced rails devs. Most rails courses are pitched at complete beginners wanting to become a rails dev. Fair enough, but what can I do to polish my existing skills?

Thankfully, some more digging produced a nice set of related online tutorials and screencasts that will get me ship-shape in no time, and for far less than I expected

NewRelic CodeSchool offer

NewRelic currently has an offer whereby if you deploy a new site with NewRelic installed, you can get a free month of CodeSchool. Now, NewRelic is an awesomely useful tool for giving you extremely useful metrics for your site. They even have a free account - and to set this all up, you can roll out a simple site to heroku (also for free) with the new_relic gem installed and away you go.

You can then sign up for a free CodeSchool account (which will give you access to the basic level free courses), and sometime in the near future - you'll get an email from NewRelic with a special promotion code to give you your free month at CodeSchool.

CodeSchool = Rails for Zombies!

So once you've got a month of code school - you can start to work your way through the courses. Starting with the simple "Try ruby" course and through their funny "Rails for Zombies" courses all the way through Rails testing and best practices and some advanced topics of Ruby.

I was happy to discover that even in the simplest ruby course there was one or two things I'd never seen before - so they're all worth the time (but you can skip ahead to the challenges if they're too simple for you).

But the courses don't just cover Ruby/Rails, they also have a series for Javascript, HTML5, CSS3 and even iOS development. Which I'll be availing myself of for the next month - and will almost certainly spring for longer until I've done them all!

From zombies to RailsCasts

I was even happier to discover, that as a "prize" for finishing the "Rails for zombies 2" course, you get one month of a Railscasts Pro account.

Now RailsCasts was where I was planning on heading next anyway - I followed RailsCasts religiously in my early years of developing Rails, and learned a hell of a lot thereby. The number of screencasts that Ryan Bates has done by now is simply staggering. They cover a huge range of topics from detailed aspects of developing Rails (eg tagging or nested forms), to most of the commonly-used tools, and it's great place to go if you want help on a particular topic. To get access to a free month of these on a pro account is wonderful icing on top of the CodeSchool month.

Other CodeSchool courses give you other freebies, and discounts on books etc too, along with lots of links to other amazingly useful resources - so my reading list has suffered a cambrian-explosion this week. I'll keep you tuned if I dig out any further fabulous free offers.


Update: you can now get 3 months of code school for free

It's a limited offer... here's a link: 3 months of codeschool

Saturday, 5 October 2013

Putting a price on your technical debt

Ben Orenstein has written an interesting article: How much should global variables cost?.

It's basically a price-list for different kinds of technical debt, and you can use it to calculate the "cost" that each of your commits adds to your codebase. By actually putting a dollar amount on each "violation" - you can get a good, visceral feel for what you're doing.

As he points out - you can still choose whether or not to keep something (sometimes you really do need to do something that would otherwise be considered a no-no), as long as you can "afford" it.

I think it's an interesting way of looking at the problem. I'd like to see you regaining points for fixing/refactoring similar code-violations out of the project too :)

Saturday, 28 September 2013

Link: don't publish your secret keys on github

I probably don't really need to tell you that it's dangerous to publish secret keys on a public website... but which key am I talking about here?

  # this one...
  MyApp::Application.config.secret_key_base = 'fb636477f014943b9cf2d202f9da4349a580fbb9521ef38d8dc0111ae933a10bfec732ce7d563a854db1663ba00af1db21d06d6764d84a88d0a6286bcd2299e2'

It's one of those things that often gets overlooked...

  rails new
  git add .
  git push

Bam!

But if you're on heroku, rather than deploying to your own hosted site (where you can easily drop config files into a shared directory), how do you have a secret key?

Here's a great little gist that will show you how to set it up on an environment variable.


Update/gotcha

Don't forget, that if you put more than one of these into your .env file... you need to append to the file or you just overwrote your secret key (oops)


Further update

If you're on heroku and putting one of these environment variables into code that will be evaluated at compile-time (eg config/initializers/devise.rb for instance) you will need to switch on heroku's "compile time environment variable" option: user-env-compile or you will not even be able to deploy your site.

This feature allows your environment variables to be available during compilation of the slug (which is when things like bundler, asset-compilation etc are run)

Note that this is an experimental heroku:labs feature - so blah blah use at your own risk blah...

Friday, 16 August 2013

Gotcha: irb, multi-line strings and "Display all 309 possibilities? (y or n)"

Small thing I figured out. I was in irb and trying to copy/paste some text into a multi-line string to play with gsub, and it kept exploding halfway through and showing the message:

Display all 309 possibilities? (y or n)

instead of actually allowing me to create a multi-line string.

Turns out, irb still responds to tab-completion even if you're halfway through creating a multi-line string.

This kinda sucks if you want a string that contains tabs - but don't want to manually type the whole string (including tabs) yourself as you go along.

To fix it, I copy/pasted the text into vim and used :retab to replace the tabs with spaces before copying it back into the string in irb... its a hack, but it worked for my purposes.

Any thoughts on a better solution?

Wednesday, 7 August 2013

Link: alias vs alias_method

If you ever wondered what the difference was, this quick post by Neeraj Singh will show you the difference between alias and alias_method

TL;DR:

  • alias_method is slightly more flexible accepting strings or symbols
  • alias_method will redefine local methods at runtime - which means you can override the aliased method in a subclass and alias_method will pick this up
  • alias will keep the original scope when aliasing - so even if you override the method in a subclass, the aliased method will refer to the parent's original method
  • alias works nicer with rdoc

Don't forget to use a comma for alias_method

Tuesday, 30 July 2013

Link: ruby-warrior : a fun way to learn a little ruby

I just came across ruby-warrior.

I can thoroughly recommend it as a couple of hours of fun diversion while picking up a few lines of basic ruby.

Its byline is:

"A triumphant quest of adventure, love & destiny all within a few lines of code."

Tuesday, 23 July 2013

Link: Your boss, the invader from Mars (or how agile transitions can become unhinged by poor buy-in)

If you've ever tried to implement an agile transition in a traditional workplace, you'll know there are many stumbling blocks - one of the greatest being that of the existing stakeholder: Your boss, the invader from Mars explains how change can and should be dealt with by both the SCRUM and kanban approaches to agile development - and how that can easily be messed up by your boss.

The case-study especially strikes a chord with my experiences, describing a shop wanting to "become more agile" but not actually implementing agile processes, instead trying to add the "agile" on top - with a rather apt simile where the agile process are described as "layered over existing dysfunctions as a sort of veneer".

The article then goes on to show various ways in which a boss who is not fully vested in the agile approach can unhinge the transition process... but also lets us learn the various lessons from that so a we can hopefully improve upon it in our own attempts.

Thursday, 18 July 2013

Gotcha: rvm and No binary rubies available for: ubuntu/12.04/x86_64/ruby-1.8.7

I'm working with a legacy rails system. We're still stuck on Rails 2.3.2 (yes really) and ruby 1.8.7 (it's better than 1.8.6 which we were on only a few months back).

I've just been given a new computer at work (finally) and it has ubuntu 12.04 - and I was trying to set it up with a rails stack. For which I can strongly recommend Ryan Bigg's howto article: Ubuntu, Ruby, RVM, Rails, and You

I got through the tutorial ok, happily installed ruby 1.9.3... but when I tried to install 1.8.7, I hit a snag.

    triton:[~]% rvm install 1.8.7
    Searching for binary rubies, this might take some time.
    No binary rubies available for: ubuntu/12.04/x86_64/ruby-1.8.7-p374.
    Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
    You requested building with 'gcc-4.4' but it is not in your path.

According to rvm, you can list the set of available rubies using rvm remote which gave me:

    # Rubies available for 'ubuntu/12.04/x86_64':
    
       ruby-1.9.3-p194
       ruby-1.9.3-p286
       ruby-1.9.3-p327
       ruby-1.9.3-p362
       ruby-1.9.3-p374
       ruby-1.9.3-p392
       ruby-1.9.3-p429
       ruby-1.9.3-p448
       ruby-2.0.0-p0
       ruby-2.0.0-p195
       ruby-2.0.0-p247

Ruh-roh!

Now, I know 1.8.7 is ancient news, but I didn't think they'd drop support for it so entirely.

I went wandering about looking for a way to specify an older repository - perhaps the 10.04 repo would still have 1.8.7 in a useable format...

Turns out I'd just made a simple mistake, easily rectified.

The important clue was in the last line of the result for rvm install:

You requested building with 'gcc-4.4' but it is not in your path.

I'd copied a whole bunch of things across to the new 'puter, including my .zshrc file - which is what was specifying the gcc version (can't remember why). And on the new 'puter I had gcc version 4.6 but my .zshrc (copied from my previous computer) was pointing at this older version.

Because of this small mistake, rvm thought I didn't have a c-compiler. Which means that rvm wasn't able to install any rubies from source - only pre-compiled rubies - which means it was restricted to only those already pre-compiled for my platform (ie 64-bit ubuntu 12.04).

oops.

When I fixed the gcc line in my .zshrc - rvm was able to figure out how to install+compile source-code rubies - including v1.8.7

Sunday, 30 June 2013

How to shop at Ikea...

Step 1. recognise that you have a problem.
Decide that ikea has the perfect solution.

Step 2. Find a time where you know you have four hours spare (just in case), but convince yourself that you're only likely to be there for an hour or so.

Step 3. struggle for two hours through a labyrinth of perfect mini-houses and dawdling shoppers trying to find the thing you know is there somewhere... you've *seen* it the last time you were here...

Step 4. Along the way discover solutions for five other problems you'd forgotten you had. Write down prices and numbers for ALL the Things!!!

Step 5. You reach the end. Stop for meatballs.

Step 6. Spend a few minutes adding it all up on paper to discover that you'd be spending the next five pay-checks paying back the credit card debt to cover it. Cut it down to only two or three things you most need.

Step 7. Refreshed and ready. Head downstairs to pick up your things... and suddenly re-discover the kitchen section... and remember that you needed some wine glasses, and you loved that metal bowl and could do with another one... and oh! memory-foam pillows, you need a spare! etc etc...

Step 8. Get to the warehouse section and discover there's no flat trolleys, there's a queue of ten people waiting already and they're somehow closing in fifteen minutes. wait... and wait... and wait... plan the order-of-attack for hitting the aisles at a run.

Step 9. Eventually get to the first aisle... and discover you wrote down the wrong number for this item, and without it, almost all the others are useless.
Give up and decide you'll just get the original item *only*. try not to feel bad about the additional two hours of lost time spent choosing these items.

Step 10. Get to the aisle and discover that it comes in a set of *three* huge boxes. Heave them onto the trolley. Think to yourself... holy shit, I don't remember the boxes being that long... how the hell are they going to fit in the hatchback?

Step 11. navigate the trolley towards the checkout... as you try to turn it, remember that these trolleys work on hovercraft-physics, and have about the same leeway... try desperately to stop five times your own bodyweight of flat-packed MDF as it begins to slew into a pair of inattentive shoppers that are drifting about in front of you without looking... discover that the best course of action is to yell maniacally "I can't stop this thing!!!" while they stare at you in horror and clutch small children to their shaking breast.

Step 12. When you're finally waiting in the queue, remember that they do deliveries! You won't have to fit the boxes in the car after all! ... Get to the deliveries desk and re-discover that Ikea assumes that *everybody* has a house-wife willing to be there from 12-noon to 8pm for when they decide to show up... and they will *only* do next day delivery. Decide you want to keep your job, and go fetch your car.

Step 13. break a nail off and bleed profusely getting the first long box in the car... realise that even with the back seats down and the front seat far forward, it's still sticking out by 5cm... of course you knew this was going to happen.

Step 14. use the remaining shreds of your undergrad maths to figure out a topologically viable solution that will allow you to slam the hatchback closed before the carpark closes for the night... When you do, realise you have zero side-vision on your left, it's pouring with rain and pitch dark outside... hope to god that nobody does anything stupid on that side of you tonight. Decide to see the silver lining - if you die, at least you won't see it coming.

Step 15. get to the exit gates and discover that you were in the carpark for your free three hours... and 15 minutes - about the same time you spent struggling to get the boxes into the car... and for which you now owe $8.
Don't forget to drop your credit card on the ground after the *first* time the machine rejects it... apologise to the three cars behind you in time for it to reject you a second time.

Step 16. discover you have to turn left when leaving the carpark. You know this when twice your bodyweight in MDF suddenly slides off the passenger seat onto your left shoulder. Resolve to drive like a granny until you get home...

Step 17. as you continue to drive... try to repress the sinking feeling that accompanies your realisation that you don't have a trolley at the other end...

Wednesday, 5 June 2013

Gotcha: undefined method `render' for SomeTemplate

I recently had to scratch my head over a strange exception message I'd never seen before:

undefined method `render' for #<SomeTemplate:0xb17da594>

The problem was, it came with *no* application trace at all... just the usual Rails stack-trace.

I had to guess at where the problem came from by grepping for SomeTemplate in the controller-action that had exploded, and came across the following line of code:

  @template = SomeTemplate.new(params[:some_template])

Now SomeTemplate is a model of ours, and prior to this error occurring that line of code had been:

  @temp = SomeTemplate.new(params[:some_template])

I have a strong aversion to calling any variable "temp", because my reaction to seeing a variable called temp is to say "a temporary what?" not "oh, that's an instance of a template", and if I'm getting the wrong idea when I look at a variable name - that's an indication it should be changed.

So I renamed it...

Unfortunately, it turns out that @template is a magic variable in Rails that refers to the template to be rendered in a given controller action.

So Just Don't Do That.

The code has now been rewritten to the following, and works just fine:

  @some_template = SomeTemplate.new(params[:some_template])

Thursday, 30 May 2013

Your Open Source Report Card

Have a look at your own Open Source Report Card. It dives into your github commits and generates a description of your coding propensities - skills and habits.

You might even find out something you never knew about yourself - apparently I'm a Tuesday tinkerer!

Here's mine for a comparison taryneast

Tuesday, 21 May 2013

Backporting "in_array" to older versions of should'a "ensure_inclusion_of"

Here's another shoulda backport I added recently. If you're still stuck using a legacy Rails system, this backport will let you use "in_array" in the "ensures_inclusion_of" Matcher.

Save it into something like: config/initializers/shoulda_monkeypatches.rb, then use it like this:

   should ensure_inclusion_of(:widget_status).in_array(Widget::VALID_STATUSES).allow_blank.with_message(:is_invalid).use_integer_test_value
  # backport the "in_array" method for the ensure_inclusion_of matcher
  # While we're at it, add allow_blank and allow_nil too
  module Shoulda # :nodoc:
    module ActiveRecord # :nodoc:
      module Matchers
        class EnsureInclusionOfMatcher
          ARBITRARY_OUTSIDE_STRING = 'shouldamatchersteststring'
          ARBITRARY_OUTSIDE_INT = -999999999

          # to initialize the options
          def initialize(attribute)
            super(attribute)
            @options = {}
          end

          # add the method we want to allow us to pass in arrays instead of
          # just ranges
          def in_array(array)
            @array = array
            self
          end          

          # might as well also add the allow_blank and allow_nil methods too
          def allow_blank(allow_blank = true)
            @options[:allow_blank] = allow_blank
            self
          end

          def allow_nil(allow_nil = true)
            @options[:allow_nil] = allow_nil
            self
          end

          # This is a method of my own addition to point out that the
          # test-value must be an Int, not a String... because a string can
          # evaluate to 0 which is a valid Int... which will make the test
          # pass where it shouldn't :P
          def use_integer_test_value(only_integer = true)
            @options[:use_integer_test_value] = only_integer
            self
          end

          # override description so it doesn't just try to inspect the range
          def description
            "ensure inclusion of #{@attribute} in #{inspect_message}"
          end

          # override the matches method to allow arrays as well as ranges
          def matches?(subject)
            super(subject)

            if @range
              @low_message ||= :inclusion
              @high_message ||= :inclusion

              disallows_lower_value &&
                allows_minimum_value &&
                disallows_higher_value &&
                allows_maximum_value
            elsif @array
              if allows_all_values_in_array? && allows_blank_value? && allows_nil_value? && disallows_value_outside_of_array?
                true
              else
                @failure_message_for_should = "#{@array} doesn't match array in validation"
                false
              end
            end
          end

 
        private

          # provide the message-inspect method to use either array or range
          def inspect_message
            @range.nil? ? @array.inspect : @range.inspect
          end          

          # array helper methods
          def allows_all_values_in_array?
            @array.all? do |value|
              allows_value_of(value, @low_message)
            end
          end

          def disallows_value_outside_of_array?
            disallows_value_of(value_outside_of_array)
          end

          def value_outside_of_array
            test_val = @options[:use_integer_test_value] ? ARBITRARY_OUTSIDE_INT : ARBITRARY_OUTSIDE_STRING
            if @array.include?(test_val)
              raise CouldNotDetermineValueOutsideOfArray
            else
              test_val
            end
          end

          # blank and nil helper methods

          def allows_blank_value?
            if @options.key?(:allow_blank)
              blank_values = ['', ' ', "\n", "\r", "\t", "\f"]
              @options[:allow_blank] == blank_values.all? { |value| allows_value_of(value) }
            else
              true
            end
          end

          def allows_nil_value?
            if  @options.key?(:allow_nil)
              @options[:allow_nil] == allows_value_of(nil)
            else
              true
            end
          end         




        end

      end
    end
  end

Tuesday, 30 April 2013

Enforced computer-free time

Gah - I've been computer-free for the past week, and not by choice.

My ageing macbook suddenly started to switch off... at random. This was ok for a while... but when it took four times for it to even get through the boot process - I had to take it into the Apple shop. meanwhile I finally set about getting a new desktop, and work gave me a new macbook to try and use.

I couldn't get the monitor to work on the desktop, and the macbook is too new to run the current ubuntu LTS (though I somehow managed to get 9.10 to install... but it won't find the ethernet port)...

I've finally got the desktop working (I was using the wrong video connection) but I still can't get mail to work properly (the joys of mail on a linux machine...), and my macbook is back from the shop... but the ethernet isn't working.

soooo.... still no email and it's been a week. But at least I have google now.

You realise just how dependant on something you've become when you suddenly don't have it anymore.

You also find just how stuck you can be. How do you find the location of a good internet shop if you don't have access to google to look one up? There used to be a directory-services phone number, but I have no idea what that is anymore, and of course I don't have a copy of the yellow pages anymore (who bothers with those when you have google)?

Wednesday, 24 April 2013

Ubuntu without the Unity!

For some time now my ageing (and now quite flaky) Macbook Pro has been running Lucid Lynx (an older version of Ubuntu). I've been biding my time and avoiding upgrading since, well, April 2010, I guess.

For most of the time it was because upgrading your only machine that you rely on for 100% of your income, to a potentially unstable, non long-term release version is generally a bad idea; but then, when I went to a new employer, I tried a new install of the new long term release... and slammed headlong into the weirdness that is the Unity Interface.

To sum up my experience: when I buy a desktop, I want it to *be* a desktop... not a iPad.

Now - maybe I'm just being backwards and should embrace the new unified interface which I'm told is meant to be amazing... if a little bloated.. and sometimes corrupts your file system if something goes wrong... but this is still my only machine (for now) and I need to be sure it's ok. I don't want to upgrade to Unity.

Of course, there is now a new long-term-release version, and sadly, the old one is now no longer supported, so I'm feeling a bit like a sprite in an old platform game, being relentlessly pushed towards the future by the scrolling screen...

Thankfully, I've malingered just long enough for the Ubuntu Gnome project to have been officially blessed by . it's not an LTR version yet, but it will be.

Until then - it's also possible to upgrade to the LTR but keep gnome. I've been putting it off because I'm ultra-busy and kept finding other, much more important things to do than figuring out how to do it myself... but I've just found a neat article on how to change your ubuntu interface to gnome.

Just what the doctor ordered

Friday, 12 April 2013

Huge medieval camping event - come and join in!

war at Rowany festival

The reason it's been so quiet around here this month is that I've been crazy busy in my main hobby due to our major event for the year (run by our local group).

Rowany Festival is the largest Medieval re-enactment event in the Southern Hemisphere. I've heard it described as "kind of like Burning Man but with a medieval theme" - we prepare all year for this!

This year 800 of us all got together at Peats Ridge and camped medieval-style, fought wars, sang, danced, drank a *lot* of booze (some of it made by me) and generally had a great time...

Needless to say not a lot of Ruby got written... but that'll pick up again now I've got most of my washing done and camp kit packed away again.

If you'd like to join me on this stuff - I'm the president the NSW branch of the SCA, known as Rowany. The Australian kingdom is called Lochac (and also covers NZ too).

The whole Society is huge: 100,000 worldwide, and we all run regular events (camping roughly once a quarter, and feasts/tourneys once a month and just general hanging-out and learning fun stuff every week) and it's a great deal of fun.

Come along to our casual fighter-practice which is held on Tuesday nights at Petersham Town Hall on Crystal St (near to Petersham Station). We regularly get 30-50 people every week and they're running beginners fighting classes right now*. We also have regular singing, Calligraphy fibre-craft and costuming days every month.


* its $5 a night for non-members, or you can join for a year for $30 - but you have to do your membership online here (we're not allowed to take payment directly for that)

Picture Credit: Enough Wealth: Rowany Festival