Skip to content

Instantly share code, notes, and snippets.

View nathanbrauer's full-sized avatar

Nathan J. Brauer nathanbrauer

View GitHub Profile
class ContactPage_Controller extends Page_Controller{
private static $allowed_actions = array('ContactForm');
public function ContactForm(){
return BootstrapForm::create(
$this,
"ContactForm",
FieldList::create(TextField::create("Name")->addHelpText('Enter some text above')),
<?php
$books = array(
1 => 'Genesis',
2 => 'Exodus',
3 => 'Leviticus',
4 => 'Numbers',
5 => 'Deuteronomy',
6 => 'Joshua',
7 => 'Judges',
8 => 'Ruth',
@nathanbrauer
nathanbrauer / Forms1-onFormSubmit.js
Last active August 29, 2015 13:58
Marketo Forms 1.0 onSubmit Function
function onFormSubmit(callback) {
var oldFormSubmit = window.formSubmit;
window.formSubmit = function(elt) {
if (typeof callback == 'function') callback(elt);
if (typeof oldFormSubmit == 'function') oldFormSubmit(elt);
};
}
Index: filesystem/File.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- framework/filesystem/File.php (revision 8518)
+++ framework/filesystem/File.php (revision 8519)
@@ -640,13 +640,29 @@
}
<IfModule pagespeed_module>
ModPagespeed off
</IfModule>
<?php
// Add to framework/model/Image.php
// Ensures all Image URLs have a cachebuster appended so when an image is replaced (same file name), the correct image appears in the browser.
public function getURL() {
$LastEdited = $this->LastEdited;
if (!$LastEdited) {
$Original = File::find($this->getFilename());
if (!$Original || !$Original->LastEdited) return parent::getURL();
@nathanbrauer
nathanbrauer / 1.obscure.js
Last active December 15, 2015 05:29
Obscure data - not a safe way to encrypt data, but useful when you want to bring less attention to the data you're storing.
/**
* 1. Reverse string
* 2. Encode (base36) each character
* 3. Reverse encoding of character (e.g. 2f becomes f2)
* 4. Join each encoded character into a string delimited by "."
* 5. Reverse string
*/
var obscure = function (str) {
if (typeof str !== 'string') return str;
var strEncoded = '', i;
<!-- first -->
<a onclick="window.location.hash='2MinDemo-WatchOverview';mktoMunchkinFunction('visitWebPage', { url: window.location.href });">...</a>
<!-- last -->
<a onclick="window.location.hash='2MinDemo-SeeWhatWeDo';mktoMunchkinFunction('visitWebPage', { url: window.location.href });">...</a>
@nathanbrauer
nathanbrauer / .htaccess
Created September 27, 2012 19:47
gzip portion of .htaccess
# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# force deflate for mangled headers
# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<?php
//Predefined data:
//$Answers = array('1'=>15,'2'=>1,'5'=>21, ..., '1000000000'=>17); //k = answer, v = how many times that answer was chosen
$Question->PossibleAnswers = '{"min":"0","max":"1000000000","default":"2","unit":""}';
$PossibleAnswers = json_decode($Question->PossibleAnswers);
$diff = $PossibleAnswers->max - $PossibleAnswers->min;
$add = ceil($diff/100);
while ($PossibleAnswers->min <= $PossibleAnswers->max) {