Skip to content

Instantly share code, notes, and snippets.

# POST
def check_assignation
@inventory_ids = params[:inv]
@inventories = OleCore::Inventory.includes(:course, account: {subscription: :subscription_plan})
.where(id: params[:inv])
prevent_empty_trainees_and_courses
# If this assignation doesn't require addons, no confirmation required either.
if !CourseAssigner.requires_addons?(@inventories, @checked_users, current_user)
@laspluviosillas
laspluviosillas / example.rb
Created February 7, 2014 23:04
Example loading chargify statements to get subtotal.
s = Chargify::Statement.find(27478308)
transactions = s.transactions.reject { |t| t.type == "Payment" }
total_cents = transactions.sum(&:amount_in_cents)
total = total_cents.to_f/100 # to_f necessary otherwise decimals are truncated.

Problem with Products & Offerings

  • These products are included in the wsProducts script, but not in wsOfferings script. As a result, the home page shows the following products with a price of zero:

Total: 48 from 117

OSG ID Name
247 Office Ergonomics
215 Defensive Driving Course
214 Front End Loader Training
class Project
mount_sf_api :sf_setup do |s|
s.api "https://cs18.salesforce.com/services/apexrest/ProjectApplication"
s.fields [
:agree_memo, :agree_to_transport, :challenges_description,
:created_at, :culture_description, :description,
:dining_location, :guidelines_description, :housing_description,
:housing_type, :internet_distance, :location_city, :location_country,
:location_description, :location_private, :location_state_or_province,
:location_street_address, :location_type, :max_students,
@laspluviosillas
laspluviosillas / index.html
Created September 18, 2014 16:27
box.com HTML viewer debug.
<!DOCTYPE html>
<html>
<body>
<link rel="stylesheet" href="crocodoc.viewer.min.css" />
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="crocodoc.viewer.min.js"></script>
<div class="viewer" style="height: 400px"></div>
<script type="text/javascript">
var viewer = Crocodoc.createViewer('.viewer', {
url: 'https://view-api.box.com/1/sessions/3c6abc0dcf35422e8353cf9c27578d5c/assets/'
@laspluviosillas
laspluviosillas / example.rb
Created February 4, 2015 15:06
myeyeballs
params[:q][:created_at_gt] = params[:q][:created_at_gt].to_datetime if params[:q][:created_at_gt]
params[:q][:created_at_lt] = params[:q][:created_at_lt].to_datetime.end_of_day if params[:q][:created_at_gt]
@q = sessions.search(params[:q]) # search is perfomed by ransack
sessions = @q.result
params[:q][:created_at_gt] = params[:q][:created_at_gt].to_date if params[:q][:created_at_gt]
params[:q][:created_at_lt] = params[:q][:created_at_lt].to_date if params[:q][:created_at_gt]
@laspluviosillas
laspluviosillas / before_action.rb
Last active August 29, 2015 14:16
Pseudo before_action
def before_action(options = {})
if options[:if].present?
return if !send(options[:if])
end
end
@laspluviosillas
laspluviosillas / Questions
Created July 12, 2011 03:05
Magma Rails Give-away
Day Job: Programmer and web designer for small outsourcing firm called Etherpros in Orizaba, Veracruz.
Open source contribution:
Nothing too big. I created FastFM which is a Filemaker (hate the technology but had to use it for a project) PHP ORM. I also host 'chayote', a simple open-source time tracking application. None of my open source projects have taken off (but to be fair I haven't promoted them much).
I've made some contributions to ThinkUp and Canvas.
Tell me about your experience with Ruby/Rails: Been using it since 09. Not only is it based on my favorite language (ruby), but I've found RoR to be the framework that best allows for agile development which keeps clients happy. I love it.
GitHub: I use it as a repo for most of my projects and to contribute to open source projects I find interesting.
strong@jstrong:~$ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Initialized empty Git repository in /home/jstrong/.rvm/src/rvm/.git/
error: RPC failed; result=56, HTTP code = 100
class InventoriesController < ApplicationController
before_filter :authenticate_login!
def index
@page_title = "Course Administration"
@inventories = Inventory.where(:account_id => current_account.id)
.joins(:course)
.select("inventories.*, courses.name as course_name")
end