Skip to content

Instantly share code, notes, and snippets.

View benhoskings's full-sized avatar

Ben Hoskings benhoskings

View GitHub Profile
dep 'h', :path do
met? {
path.p.tapp.exists?
}
meet {
# install with apt
}
end
dep 'headers' do
@benhoskings
benhoskings / hack.sh
Last active December 19, 2015 09:19 — forked from erikh/hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
def some_action
redirect_to wizard_path_for(@intervention)
end
def wizard_path_for(intervention)
case intervention.wizard
when 100
intervention_expiries_path(intervention)
when 80
intervention_clients_path(intervention)
# Bad because the dependency on ModelClass and ApiClass are hard-coded
module HitTheApi
def self.go
ids_to_update = ModelClass.what_ids_should_I_update
ids_to_update.each do |id|
data = ApiClass.fetch_me_data(id)
ModelClass.persist_data(id, data)
end
# One thing to add:
# * action_has_layout? method (if you have one, combine them)
#
class ApplicationController < ActionController::Base
# ...
private
def action_has_layout?
!request.xhr? && super
# dynamic removal of a dep requirement,
# based on a condition evaluated after previous requires have been processed
dep 'site' do
requires [
'system',
'account',
'site dir',
'site options'
]
git config --global alias.lg "log --graph --since='1 week ago' --pretty=format:'%Cblue%h%Creset %cr %Cgreen%an%Creset %s'"
def value_for_label object, method
(object && object.send(method)) || "-"
end
def conditions_map_for conditions
{
:dp_c => 'Dew point',
:rh => 'Relative humidity',
:feels_like_c => 'feels like',
:wind_dir_and_speed => 'Wind',
________ __ ___ __ __
/ ____/ /__ ____ / |/ /___ _____/ /___/ /__ _________
/ / __/ / _ \/ __ \ / /|_/ / __ `/ __ / __ / _ \/ ___/ __ \
/ /_/ / / __/ / / / / / / / /_/ / /_/ / /_/ / __/ / / / / /
\____/_/\___/_/ /_/ /_/ /_/\__,_/\__,_/\__,_/\___/_/ /_/ /_/
__ __ __ __ __
/ \ |__| _) _) /| /| (__) | / \ |
\__/ | /__ __) | | (__) |___ \__/ |___
%a{{:href => name},{:class => ('selected' if @category == name)}}
%span= name