Skip to content

Instantly share code, notes, and snippets.

<?php
//start a session -- needed for Securimage Captcha check
session_start();
//add you e-mail address here
define("MY_EMAIL", "jmb@jonbake.com");
define("EMAIL_SUBJECT", "Feedback Form Results");
//a map of fields to include in email, along with if they are required or not
//aparently in PHP, arrays (maps) can't be constants?
@jonmbake
jonmbake / sendmail.php
Last active August 29, 2015 14:02
Do not wait for mail to return in order to notify user of success
<?php
//start a session -- needed for Securimage Captcha check
session_start();
//add you e-mail address here
define("MY_EMAIL", "your-email@foo.com");
define("EMAIL_SUBJECT", "Feedback Form Results");
//a map of fields to include in email, along with if they are required or not
//aparently in PHP, arrays (maps) can't be constants?
@jonmbake
jonmbake / index.html
Last active August 29, 2015 14:03
Multiselect options
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A contact form using the Bootstrap 3 framework.">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.png">
<title>Bootstrap 3 Contact Form</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" >
@jonmbake
jonmbake / sendmail.php
Created October 7, 2014 12:07
sendmail.php with mb_mail
<?php
//start a session -- needed for Securimage Captcha check
session_start();
//add you e-mail address here
define("MY_EMAIL", "<<!! YOUR-EMAIL-ADDRESS-HERE !!>>");
define("EMAIL_SUBJECT", "Feedback Form Results");
//a map of fields to include in email, along with if they are required or not
//aparently in PHP, arrays (maps) can't be constants?
@jonmbake
jonmbake / gist:7b40d085b1b9f367e7a1
Last active August 29, 2015 14:16
Rails/Angular Pre-Commit Hook
#!/usr/bin/env bash
#
# Rails/Angular pre commit hook.
#
# This should live in your rails config folder and a symbolic link should be created from .git/hooks/ to this file. You
# should also set the FRONT_END_PATH/BACK_END_PATH env. variable so the script knows where to pull in the front-end code from.
#
# This pre-commit hook does the following:
# 1. Runs rspec (and fails the commit if any tests fail)
# 2. Runs grunts default task on the Front-End project (which should minify and run karam tests). Fails the commit if any tests fail.
@jonmbake
jonmbake / gist:0e5b175a72ad9ba64167
Last active January 27, 2018 23:58
Example of sendmail.php w/o environment variables
<?php
/**
* Sets error header and json error message response.
*
* @param String $messsage error message of response
* @return void
*/
function errorResponse ($messsage) {
header('HTTP/1.1 500 Internal Server Error');
die(json_encode(array('message' => $messsage)));
@jonmbake
jonmbake / contact-form.js
Last active September 29, 2015 22:29
Navigate to home page on sucess
(function () {
var contactFormUtils = {
isValidEmail: function (email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
},
clearErrors: function () {
$('#emailAlert').remove();
$('#feedbackForm .help-block').hide();
$('#feedbackForm .form-group').removeClass('has-error');
@jonmbake
jonmbake / contact-form.js
Created October 4, 2015 17:15
Passing in Global jQuery Variable to contact-form's self executing function
(function ($) {
var contactFormUtils = {
isValidEmail: function (email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
},
clearErrors: function () {
$('#emailAlert').remove();
$('#feedbackForm .help-block').hide();
$('#feedbackForm .form-group').removeClass('has-error');
@jonmbake
jonmbake / sendmail.php
Created December 19, 2015 02:50
Without env. variables and without SMTP authentication
?php
/**
* Sets error header and json error message response.
*
* @param String $messsage error message of response
* @return void
*/
function errorResponse ($messsage) {
header('HTTP/1.1 500 Internal Server Error');
die(json_encode(array('message' => $messsage)));
@jonmbake
jonmbake / gist:2eaa48f71b5f95a12ba3
Last active December 21, 2015 18:23
Creating a Checkstyle-Tester DIFF-REPORT steps taken
  1. Did a clean/install of checkstyle before my change
cd ~/projects/git/checkstyle
git checkout c0a664c25194ef7be3b59ce200a9fcd88fbc5c2d
mvn clean install
  1. Cloned checkstyle-contribution and cd'ed cd ~/projects/git/checkstyle-contribution/
  2. Uncommented all projects in projects-to-test-on.properties