Skip to content

Instantly share code, notes, and snippets.

import React from 'react';
import { ContentBox } from '@core_js/ui_elements';
import { money } from '@core_js/utils';
import SubscriptionPlan from '../../shared/SubscriptionPlan';
const BillingState = ({ state }) => {
switch (state) {
case 'overdue':
return <div className="yellow">Overdue</div>;
case 'delinquent':

Outline:

Idea: Seek to establish similarities between Machiavelli and Hobbes, talk about some important differences, then conclude with some remarks on how both authors failed to anticipate what would promote peace and liberty as we see in the modern world.

THESIS STATEMENT: On the surface, Hobbes and Machiavelli appear to advocate for polar opposite forms of government. Although their ideologies are different in paper, there are surprising similarities in how they believe liberty and peace are maintained in practice. However, in the end, but both of these thinkers failed to forsee what has proven to secure liberty and peace in the modern world.

Main Point #1: Hobbes and Machiavelli have conflicting definitions of liberty, which creates the illusion that their beliefs on how society should be ordered are incompatible with one another.

@laspluviosillas
laspluviosillas / comprehension_examples.py
Created June 13, 2017 04:00
Using python comprehension to analyze enron data. (udacity machine learning)
# ===========================================
# Output first entry from dict to see values.
# ===========================================
# print enron_data[enron_data.keys()[0]]
# =============================
# Get # of persons of interest
# (uses dict comprehension)
# ============================
@laspluviosillas
laspluviosillas / polymorphic.rb
Created April 13, 2017 19:50
Issue with polymorphic associations
class Task < ActiveRecord::Base
has_one :notification_preference, as: :notifee
end
class NotificationPreference < ActiveRecord::Base
belongs_to :notifee, polymorphic: true
end
# Code above keeps on looking for notifee_id on Task.
# The foreign keys are obviously in the NotificationPreference table (notifee_id and notifee_type)
@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 / 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 / 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/'
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,

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
@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.