Skip to content

Instantly share code, notes, and snippets.

View JamesDullaghan's full-sized avatar
🎯
Focusing

James D JamesDullaghan

🎯
Focusing
View GitHub Profile
@JamesDullaghan
JamesDullaghan / gdal_fail_10_8_3
Created May 26, 2013 00:58
gdal failed to build on 10.8.3
brew doctor
Your system is ready to brew.
brew: superenv removed: -L/usr/local/lib -arch x86_64
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
CPLRecodeIconv(char const*, char const*, char const*) in cpl_recode_iconv.o
CPLRecodeFromWCharIconv(wchar_t const*, char const*, char const*) in cpl_recode_iconv.o
"_iconv_close", referenced from:
CPLRecodeIconv(char const*, char const*, char const*) in cpl_recode_iconv.o
@JamesDullaghan
JamesDullaghan / Devise_form_helper
Created June 14, 2013 00:58
Devise Sign in form anywhere in app
module HomeHelper
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@JamesDullaghan
JamesDullaghan / Bulletproof_foods.md
Created June 15, 2013 22:41
Dave Aspreys bulletproof diet food list

How many servings should I eat per day?

  • Fruit = 1-2 servings
  • Animal protein = 4 - 6 servings
  • Healthy fats = 5 - 9 servings
  • Healthy vegetables = 6 - 11 servings

How should I allocate my calories per day?

  • Healthy fats = 50%
def index
# Sleep.all for current_user
@sleeps = current_user.sleeps
# Sleep grouped and sorted in order by month
@sleep_months = @sleeps.group_by { |s| s.beginning_of_month }.sort { |a,b| a[0] <=> b[0] }
@array_for_average_sleep_months = @sleep_months.map { |month, sleep| month.strftime("%b") }
@array_for_hours_slept_per_month = ?????
@JamesDullaghan
JamesDullaghan / sleep_counter_irc_help.md
Created June 24, 2013 23:02
sleep counter irc help

How would I go about mapping an array of hashes that are nested inside of an array??? I need to get an array returned for each :hours for each month, so I can then use the median method and get an average for each month. I can do it in the views, but using

<% @sleep_months.each do |month, sleep| %>
  <ul><%= month.strftime("%B") %>
  <% for sleeps in sleep %>
    <li><%= sleeps.hours %></li>
  <% end %>
  </ul>
<% end %>
@JamesDullaghan
JamesDullaghan / digitalocean.md
Created July 6, 2013 20:54
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@JamesDullaghan
JamesDullaghan / foundation_willpaginate.rb
Created September 19, 2013 21:32
Foundation will_paginate
require 'will_paginate/view_helpers/link_renderer'
require 'will_paginate/view_helpers/action_view'
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= FoundationLinkRenderer
super.try :html_safe
end
var PurdyPercent = function (num, options) {
this.settings = {
hide_decimal_on_whole : true,
decimals : 2,
truncate : false, // (soon)
match_decimals: true, // forces floats to match defined decimal count
rounding : 'default', //default, up, down (soon)
postfix : '%'
};
@JamesDullaghan
JamesDullaghan / calendar_helper.rb
Created October 1, 2013 23:10
calendar helper
module CalendarHelper
def calendar(date = Date.today, &block)
Calendar.new(self, date, block).table
end
class Calendar < Struct.new(:view, :date, :callback)
HEADER = %w[SUN MON TUE WED THU FRI SAT]
START_DAY = :sunday
delegate :content_tag, to: :view
@JamesDullaghan
JamesDullaghan / _calendar.scss
Created October 1, 2013 23:11
calendar helper scss
.month {
font-family: 'ProximaCond';
background: $primary-color;
font-size: 28px;
letter-spacing: 2px;
text-align: center;
padding: 10px 0;
margin-bottom: 0;
color: #fff;
a {