Skip to content

Instantly share code, notes, and snippets.

@BlakeMesdag
BlakeMesdag / acb_calculator.rb
Created April 27, 2020 22:42
USD ACB Calculator for CAD
require 'csv'
require 'bigdecimal'
require 'byebug'
class Transaction
attr_reader :date, :description, :debit_amount, :credit_amount, :balance
attr_accessor :exchange_rate
def initialize(date, description, debit_amount, credit_amount, exchange_rate, date_format:"%m/%d/%Y")
@BlakeMesdag
BlakeMesdag / index.html
Created June 16, 2013 02:38
BaconTracker index template
<h2>Our Bacon</h2>
<table>
<thead>
<th>Name</th>
<th>Quantity</th>
</thead>
<tbody>
<tr data-foreach-bacon="bacons">
<td data-bind="bacon.name"></td>
<td data-bind="bacon.quantity"></td>
@BlakeMesdag
BlakeMesdag / application.html.erb
Created June 16, 2013 02:29
Application Layout for BaconTracker
<!DOCTYPE html>
<html>
<head>
<title>BaconTracker</title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
@BlakeMesdag
BlakeMesdag / bacons_controller.rb
Created June 16, 2013 02:24
BaconTracker BaconsController
class BaconsController < ApplicationController
before_action :set_bacon, only: [:show, :edit, :update, :destroy]
# GET /bacons
# GET /bacons.json
def index
respond_to do |format|
format.html { render text: "", layout: "application" }
format.json { render json: Bacon.all }
end
@BlakeMesdag
BlakeMesdag / bacon.js.coffee
Last active December 18, 2015 13:29
BaconTracker Bacon model
class BaconTracker.Bacon extends Batman.Model
@resourceName: 'bacon'
@persist Batman.RailsStorage
@encode 'name', 'quantity'
@BlakeMesdag
BlakeMesdag / bacon_controller.js.coffee
Last active December 18, 2015 13:29
BaconTracker BaconController.js
class BaconTracker.BaconController extends Batman.Controller
routingKey: 'bacon'
index: ->
@set 'newBacon', new BaconTracker.Bacon
BaconTracker.Bacon.load (err, bacons) =>
@set 'bacons', BaconTracker.Bacon.get('loaded')
createBacon: (bacon) ->
bacon.save (err, bacon) =>
@BlakeMesdag
BlakeMesdag / bacon_tracker.js.coffee
Created June 16, 2013 01:51
BaconTracker application definition
Batman.extend Batman.config,
pathToHTML: "assets/html"
class window.BaconTracker extends Batman.App
@resources 'bacon'
@root 'bacon#index'
@BlakeMesdag
BlakeMesdag / application.js
Created June 16, 2013 01:41
Application.js file for Batman Rails to ensure batman loads before its adapters and extras.
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
@BlakeMesdag
BlakeMesdag / Gemfile
Created June 16, 2013 01:38
Rails 4.0.0.rc2 Gemfile without Turbolinks
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0.rc2'
@BlakeMesdag
BlakeMesdag / jquery-loader.js
Created November 4, 2012 23:56
Script to Inject a jQuery loader using ScriptTags for Shopify
(function () {
function loadScript(url, callback) {
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState) { //IE
script.onreadystatechange = function () {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;