Skip to content

Instantly share code, notes, and snippets.

View ecoologic's full-sized avatar

Erik ecoologic

View GitHub Profile
@ecoologic
ecoologic / basic_oo_principles.md
Last active August 29, 2015 14:06
Slides about basic principles to code Object Oriented

class: center, middle

@net_engine

@erikecoologic

Slides available at ???????


class: center, middle

Boundaries

@ecoologic
ecoologic / x.md
Last active August 29, 2015 14:05
Template Inheritance

Similarly to the Layout Inheritance logic, if a template or partial is not found in the conventional path, the controller will look for a template or partial to render in its inheritance chain. For example:

# in app/controllers/application_controller
class ApplicationController < ActionController::Base
end

# in app/controllers/admin_controller
@ecoologic
ecoologic / cc.coffee
Created May 2, 2014 06:28
credit card validation
cardType = (cc) ->
result = "unknown"
result = "mastercard" if /^5[1-5]/.test(cc)
result = "visa" if /^4/.test(cc)
result = "amex" if /^3[47]/.test(cc)
result
luhn = (cc) ->
sum = 0
alt = false

POODIR (Sandi Metz)

In this post I'm going to answer the question: Why should every ruby developer read Practical Object Oriented Design In Ruby by Sandi Metz?

In short: two reasons:

  1. As correctly suggested by the title, it's about useful everyday choices of design, arguably your most important skill as a developer

  2. It's easy and useful to read cover to cover

App = Em.Application.create() # use App for every app and Em as a shortcut
window.h = # h a hash with all the non oo helpers
formatDate: (date) ->
date = new Date unless date?
[date.getDate(), (date.getMonth() + 1), date.getFullYear(), ].join('/')
$ ->
$('.datepicker').datepicker()
$('.tab').tabs()
$('form#new_invoice:not(".invoice-project-select")').submit ->
$form = $('form#new_invoice')
$tasks = $form.find('.task-checkbox')
$flatFees = $form.find('[data-flatfee]')
confirmCheckAll = 'You have not selected a single item. Please take note that all items that are unbillable are unchecked by default.\n\nDo you want to check them all and create the invoice?'
confirmInvoiceWithFlatFees = "There are either tasks or projects that have a fixed fee set. If you would like to instead invoice these by hours logged, please set them to 'hourly' before creating the invoice.\n\nDo you still wish to create the invoice now?"
# $tasks.find(':not(:checked)').click() # this keeps the graphic in sync
$tasks.attr('checked', true) if $tasks.find(':checked').length == 0 && confirm(confirmCheckAll)
@ecoologic
ecoologic / conventions.rb
Last active August 11, 2020 09:47
My Conventions
{}.as_json # {}
{}.to_json # "{}"
# query / command
user_params # query, no get_params etc, prefer queries over commands, leads to more declarative code, which is simpler
remote_document # Query, not get_document, more declarative
buy_document! # Exception to the above, it's probably a POST and I want to express that it's not a free call
prepare_document! # Bang to express imperative behaviour (?)
compact_params(params) # command - takes args and can be reused
compacted_user_params # YES, a noun is better
[user]
name = erik
email = erikecoologic@gmail.com
[color]
ui = auto
[core]
whitespace = trailing-space,space-before-tab
editor = vim
excludesfile = /Users/netengine/.gitignore_global
[diff]

What is Earth Day

Every year, the 22nd April (since 1970) is known as Earth Day! It is a day where everyone is encouraged to think a little bit more of the environment. We asked to mindful of catastrophic changes which might result if our society continues to disrespect the earth.

NetEngine

NetEngine is very happy to exist on this planet and in order to minimize our collective impact to our environment we already have in place some simple practices, which we encourage others to adopt if you aren't already adept to them. They include, recycling or providing showers so people can come to work by bike.

We are always thinking of how to take this further. In the meantime, to show our respect for Mother Earth on its day we're taking some simple steps like, inviting everyone to avoid using the car; keeping the aircon off for the entire day; minimising the use of lights and other polluting devices, and given we'll likely survive the day without these things, we'll likely adopt them as common practice.

What is Earth Day

Every year, the 22nd April (since 1970) is known as Earth Day! It is a day where everyone is encouraged to think a little bit more of the environment. We asked to mindful of catastrophic changes which might result if our society continues to disrespect the Earth.

NetEngine

NetEngine is very happy to exist on this planet and in order to minimize our collective impact to our environment we already have in place some simple practices, which we encourage others to adopt if you aren't already adept to them. They include, recycling or providing showers so people can come to work by bike.

We are always thinking of how to take this further. In the meantime, to show our respect for Mother Earth on its day we're taking some simple steps like, inviting everyone to avoid using the car; keeping the aircon off for the entire day; minimising the use of lights and other polluting devices, and given we'll likely survive the day without these things, we'll likely adopt them as common practice.