Skip to content

Instantly share code, notes, and snippets.

View jmadden's full-sized avatar
☘️

Jim Madden jmadden

☘️
View GitHub Profile

Ruby Basics – A Quick Reference Guide

Introduction

This document is meant to server as a jumping off point and reference guide for anyone that is new to programming in Ruby. This document will have some very basic concepts and may be useful for anyone needing a quick jog of the memory when first branching out(Git pun intended) into the brave new world of developing with Ruby. This document is not a complete review of Ruby and everything the language offers.

NOTE: If you are using this document you should have a rudimentary understanding of how to use terminal/commandline, irb and how to install Ruby Gems.

Working with variables

String interpolation vs. concatenation

In the following example we declare an age variable and then print it out to the screen in two different ways. The first way uses string interpolation, the second uses string concatenation.

age = 40

Rails Basics – A Quick Reference Guide

This document is meant to server as a jumping off point and reference guide for anyone that is new to programming in Rails. This document will have some very basic concepts and may be useful for anyone needing a quick jog of the memory when developing apps on Rails. This document is not a complete review of Rails and everything the framework offers.

NOTE: If you are using this document you should have a basic understanding of how to use terminal/commandline, irb and how to install Ruby Gems and Rails.

Table of Contents

Spree Commerce Notes

Run the following when Spree has made updates: bundle exec rake railties:install:migrations

Sizing with rem

CSS3 introduces a few new units, including the rem unit, which stands for "root em". If this hasn't put you to sleep yet, then let's look at how rem works.

The em unit is relative to the font-size of the parent, which causes the compounding issue. The rem unit is relative to the root—or the html—element. That means that we can define a single font size on the html element and define all rem units to be a percentage of that.

html { font-size: 62.5%; } 
body { font-size: 1.4rem; } /* =14px */
h1   { font-size: 2.4rem; } /* =24px */

I'm defining a base font-size of 62.5% to have the convenience of sizing rems in a way that is similar to using px.

@jmadden
jmadden / heroku_notes.md
Last active August 29, 2015 14:03
#Heroku Notes – Configurations and commands through the Heroku Toolbelt

#Heroku Notes ######Configurations and commands through the Heroku Toolbelt

Setting Environment Variables

Variables can be set and accessed on Heroku Dynos. To review your Dyno's configuration type the following in your toolbelt.

$ heroku config

Folloing is an example of how your results may look:

<?php
// PHP Helper Library was dinstalled using Composer.
// Required if your envrionment does not handle autoloading
require __DIR__ . '/vendor/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
@jmadden
jmadden / record-status.php
Last active June 9, 2017 19:44
Send an SMS message through Twilio and record the message status to a log file using a Status Callback URL
<?php
$sid = $_REQUEST['MessageSid'];
$status = $_REQUEST['MessageStatus'];
$logfile = "status_callback_log.txt";
$log = fopen($logfile, 'a+');
fwrite($log, date('Y-m-d H:i:s')." SID = " . $sid . "\n");
fwrite($log, date('Y-m-d H:i:s')." Status = " . $status . "\n");
fwrite($log, "\n");
fclose($log);
<?php
use Twilio\Twiml;
class TwimlWrap
{
/** @var TwilioTwiml */
protected $twiml;
public function __construct()
@jmadden
jmadden / forward_to_first_number.xml
Last active September 1, 2022 22:28
TwiML Incoming Calls - Forward call to numbers in order. Fire off VMail and send SMS on no answer
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<!-- Forward to first number and if no answer, action URL points to second number to try -->
<Dial timeout="15" action="forward_to_second_number.xml">
<Number url="whisper_instructions.xml">+15554441212</Number>
</Dial>
</Response>
@jmadden
jmadden / 1-outbound-call.php
Last active August 14, 2022 03:24
Twilio PHP Outbound Call and Gather Example
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "YOU_ACCOUNT_SID";
$token = "YOUR_AUTH_TOKEN";
$client = new Client($sid, $token);