Skip to content

Instantly share code, notes, and snippets.

View jackreichert's full-sized avatar

Jack Reichert jackreichert

View GitHub Profile
@jackreichert
jackreichert / my_cforms_action
Created August 16, 2011 15:07
cforms II custom function
/* <--- move or remove this line to uncomment functions below (and check the end as well!)
function my_cforms_action($cformsdata) {
### Extract Data
### Note: $formID = '' (empty) for the first form!
$formID = $cformsdata['id'];
$form = $cformsdata['data'];
### triggers on your third form
if ( $formID == '3' ) {
### Do something with the data or not, up to you
$form['Your Name'] = 'Mr./Mrs. '.$form['Your Name'];
@jackreichert
jackreichert / my_cforms_action_salesfoce
Created August 16, 2011 15:09
Integrate cforms II and Salesforce
function my_cforms_action($cformsdata) {
$formID = $cformsdata['id'];
$form = $cformsdata['data'];
$curl_connection = curl_init('https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
object(stdClass)#131 (25) {
["ID"]=>
int(13)
["post_author"]=>
string(1) "1"
["post_date"]=>
string(19) "2011-07-31 12:45:36"
["post_date_gmt"]=>
string(19) "2011-07-31 12:45:36"
["post_content"]=>
@jackreichert
jackreichert / roundedCorners.less
Created August 30, 2011 17:44
LessCSS Rounded Corners
.rounded-corners (@radius: 5px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}
@jackreichert
jackreichert / gradient.less
Created August 30, 2011 17:54
LessCSS Gradients (including ms-filter)
.gradient(@from: #cfe0ec, @to: #d1e4ef) {
background-color: @from;
background-image: -webkit-linear-gradient(top, @from, @to);
background-image: -moz-linear-gradient(top, @from, @to);
background-image: -ms-linear-gradient(top, @from, @to);
background-image: -o-linear-gradient(top, @from, @to);
filter: ~"progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=@{from}, endColorstr=@{to})";
-ms-filter: ~"'progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=@{from}, endColorstr=@{to})'";
}
@jackreichert
jackreichert / jQuery.fontBefitting.js
Created September 13, 2011 21:34
jQuery function to resize fonts to fit a containing element.
$.fn.fontBefitting = function() { // This resizes fonts to make them fit in an element
return this.each(function() {
var fontSize = parseFloat($(this).css('fontSize'));
this.style.overflowY = 'scroll';
// This is if the font too big to fit an enclosing element
while (this.clientHeight < this.scrollHeight && fontSize > 1) {
fontSize *= 0.99;
$(this).css('fontSize',fontSize + 'px');
}
// This is if the font is too small
@jackreichert
jackreichert / mediawiki-nofollow
Created January 19, 2012 00:26
Adds global NOINDEX,NOFOLLOW meta to site headers
## Adds global NOINDEX,NOFOLLOW meta to site headers
$wgExtensionFunctions[] = 'globalNoIndex';
function globalNoIndex(){
global $wgOut;
$wgOut->addMeta ( 'ROBOTS' , 'NOINDEX,NOFOLLOW') ;
}
@jackreichert
jackreichert / upload-insert.html
Created February 15, 2012 01:08
WordPress Upload/Insert Button
<a id="content-add_media" class="thickbox add_media" title="Add Media" onclick="return false;" href="http://www.jackreichert.com/wp-admin/media-upload.php?post_id=1239&amp;TB_iframe=1&amp;width=640&amp;height=83">Upload/Insert <img src="http://www.jackreichert.com/wp-admin/images/media-button.png?ver=20111005" alt="" width="15" height="15" /></a>
@jackreichert
jackreichert / gist-shortcode.php
Last active September 27, 2017 15:44
WordPress Gist ShortCode
// github gist Shortcode Usage: [gist un="" id=""]
function gist_shortcode( $atts ) {
extract(shortcode_atts(array(
'un' => '',
'id' => ''
), $atts));
return '<script src="https://gist.github.com/' . $username . '/' . $id.'.js"></script>';
}
add_shortcode('gist', 'gist_shortcode');
@jackreichert
jackreichert / jquery.activatePlaceholders.js
Created March 1, 2012 21:50
Polyfill for the Input "Placeholder" Attribute.
function activatePlaceholders() {
var detect = navigator.userAgent.toLowerCase();
if (detect.search("msie") > 0 ) {
$('input[type=text],input[type=email]').each(function(ind,elem) {
if ($(elem).attr('placeholder') != ""){
$(elem).val($(elem).attr("placeholder"));
$(elem).click(function() {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val("");