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 / balanced_ba_cust_issue
Created July 28, 2014 19:28
Balanced Bank Account Customer issue
# Model:
def create_business_customer(data)
customer = Balanced::Customer.new(
address: {
line1: data[:address],
city: data[:city],
state: data[:state],
postal_code: data[:state]
},
def sticker_image_path
src = "data:image/png;base64,"
src += ActiveSupport::Base64.encode64(File.read("#{Rails.root}/app/assets/images/courses/#{self.slug}-sticker.png"))
src
end
@JamesDullaghan
JamesDullaghan / calendar.html
Created October 1, 2013 23:18
Calendar html
<div class="row">
<div class="large-12 columns calendar-container">
<h3 class="month">
<a href="/admin/analytics?class=cal-larr&amp;date=2013-11-01">&lt;</a>
December 2013
<a href="/admin/analytics?class=cal-rarr&amp;date=2014-01-01">&gt;</a>
</h3>
<section class="calendar" role="main">
<ul class="day-row">
<li class="day">SUN</li>
@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 {
@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
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 / 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
@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 / 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 %>
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 = ?????