Skip to content

Instantly share code, notes, and snippets.

View JamesChevalier's full-sized avatar

James Chevalier JamesChevalier

View GitHub Profile
@JamesChevalier
JamesChevalier / gist:1221030
Last active September 27, 2015 05:48
dumbly simple debug output ... Just replace VARIABLENAME with the name (without the $) of the variable (probably an array) you want to see the contents of
// Begin Debug Output
echo "Debug Output for VARIABLENAME:<br><pre>";
var_dump($VARIABLENAME);
echo "</pre><br>End of debug output.";
// End Debug Output
@JamesChevalier
JamesChevalier / transparency.html
Created December 21, 2011 15:46
Transparent layers in HTML via three-div structure
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html
{
/* Set background image so that transparency is easy to see */
background: #fff url(http://uhaweb.hartford.edu/CASS/unicorn.jpg) fixed no-repeat;
}
#container
@JamesChevalier
JamesChevalier / transparency.html
Created December 21, 2011 17:29
Transparent layers in HTML via rgba background
<!DOCTYPE html>
<html>
<head>
<!-- Conditional statement because older versions of IE do not support rgba -->
<!--[if IE]>
<style type="text/css">
#container
{
background:transparent;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=70);
@JamesChevalier
JamesChevalier / index.html
Created January 9, 2012 17:47
Zurb's Foundation (v2.1.4), with transparent divs & ToTop JS
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
@JamesChevalier
JamesChevalier / FormatPhoneNumberForSpeech.php
Created January 14, 2012 17:29
Reformat phone number so Twilio speaks it properly
<?php
$CallFrom = $_REQUEST['From']; // Take the phone number that is calling this app
$CallFrom = substr($CallFrom, 2); // Take the country code (+1, for example) off the front of the number
$CallFrom = chunk_split($CallFrom,1,","); // Insert a comma between each digit
echo $CallFrom;
?>
@JamesChevalier
JamesChevalier / pow.rake
Created June 8, 2012 20:37
Rake task to switch sites that Pow serves
# This is for instances where a single Rails app serves multiple domains.
# That is, http://domainA.com and http://domainB.com are both served by the same Rails app.
# When launching these manually, I specify which site I want to see by passing a site variable:
# site=domainB ruby script/server
# This gist allows site switching via a rake task:
# rake pow[SITENAME]
# If no '[SITENAME]' is provided, then it defaults to the 'domainA' site
desc "Switches site that Pow serves"
task :pow, :site_name do |t, args|
@JamesChevalier
JamesChevalier / gist:2914870
Created June 12, 2012 04:11
before_filter to determine which site to serve in a multi-site Rails app
def set_site
if RAILS_ENV == "development"
session[:site] = ENV['site'] || "domainA" # Default to domainA in development
else session[:site].blank?
if RAILS_ENV == "staging"
session[:site] = case request.subdomains.last # *.yourstagingdomain.com
when "domainA" then "domainA"
when "domainB" then "domainB"
end
elsif RAILS_ENV == "production"
@JamesChevalier
JamesChevalier / gist:2914940
Created June 12, 2012 04:22
before_filter to determine which site to serve in a multi-site Rails app with a Pow dev environment
def set_site
if RAILS_ENV == "development"
session[:site] = case request.domain
when "domainA.dev" then "domainA"
when "domainB.dev" then "domainB"
else ENV['site'] || "domainA"
end
else session[:site].blank?
if RAILS_ENV == "staging"
session[:site] = case request.subdomains.last # *.yourstagingdomain.com
@JamesChevalier
JamesChevalier / gist:3656343
Created September 6, 2012 13:39
Custom Bash Prompt
# unstaged (*) and staged (+) changes will be shown next to the branch name
GIT_PS1_SHOWDIRTYSTATE="."
# if there are untracked files (%) will be shown next to the branch name
GIT_PS1_SHOWUNTRACKEDFILES="."
# if something is stashed ($) will be shown next to the branch name
GIT_PS1_SHOWSTASHSTATE="."
# you are behind (<), you are ahead (>), or you have diverged (<>)
GIT_PS1_SHOWUPSTREAM="auto"
# White brackets, yellow path, blue branch name, and cyan dollar sign
@JamesChevalier
JamesChevalier / gist:3881395
Created October 12, 2012 20:44
Watch the Rails log for just Rendered or Completed lines (useful for optimization work)
tail -f log/development.log | grep 'Rendered\|Completed'