Skip to content

Instantly share code, notes, and snippets.

View rianrainey's full-sized avatar

Rian Rainey rianrainey

View GitHub Profile
@rianrainey
rianrainey / settings.php
Last active December 15, 2015 13:29
Drupal 7 settings.php to run on Heroku
$url = parse_url(getenv('DATABASE_URL')); // Be sure to run [heroku config:set DATABASE_URL=mysql://db_username:db_password@amazon_rds_instance_name/db_name]
$databases['default']['default'] = array(
// MySQLi uses the mysql driver.
'driver' => $url['scheme'] == 'mysqli' ? 'mysql' : $url['scheme'],
// Remove the leading slash to get the database name.
'database' => substr(urldecode($url['path']), 1),
'username' => urldecode($url['user']),
'password' => isset($url['pass']) ? urldecode($url['pass']) : '',
'host' => urldecode($url['host']),
'port' => isset($url['port']) ? urldecode($url['port']) : '',
=begin
This program calculates the amount to charge a client using Square as a payment processor.
The variation in cost depends largely on if the credit card is present.
=end
puts "--------------------------------------"
puts "---Welcome to the Square Calculator---"
puts "--------------------------------------"
# Output commas in large number
@rianrainey
rianrainey / Drupal Drush Caching
Last active December 14, 2015 00:09
Drupal Drush Turn Off JS and CSS Caching
drush vset preprocess_css 0 --yes
drush vset preprocess_js 0 --yes
drush cc css-js
@rianrainey
rianrainey / settings.php
Last active December 11, 2015 22:08
Drupal 7 settings.php database snippet
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'dbname_db',
'username' => '',
'password' => '',
'host' => '127.0.0.1',
'port' => '',
/* http://css-tricks.com/snippets/css/truncate-string-with-ellipsis/ */
.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@rianrainey
rianrainey / How to use in_array_r()
Created December 12, 2012 00:34
PHP doesn't make it very easy to recursively look inside a multi-dimensional array. These couple methods make that easier.
$simpsons = array('bart', 'lisa', 'homer');
echo in_array_r("bart", $simpsons) ? 'found' : 'not found';