Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Macagare

  • Germany
View GitHub Profile
@Macagare
Macagare / gist:4603792
Last active Oct 18, 2019
Coldfusion: strip tags from html
View gist:4603792
<!--- strip tags --->
<cfset stripedString = ReReplaceNoCase(source,"<[^>]*>","","ALL") />
@Macagare
Macagare / gist:4134400
Last active Apr 22, 2019
Javascript: Google Analytics Snipper + Google Analytics JS Logging
View gist:4134400
var _gaq = _gaq || [['_setAccount', 'UA-xxxxxxx-1'], ['_trackPageview']];
; (function ($, n, d, t, w, s, undefined) {
//Google Analytics Snipper
var g = d.createElement(t); g.type = 'text/javascript'; g.async = true;
g.src = ('https:' == d.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var b = d.getElementsByTagName(t)[0]; b.parentNode.insertBefore(g, b);
@Macagare
Macagare / caldera-core.php
Created Mar 26, 2019
add CORS to caldera forms
View caldera-core.php
add_action( 'init', 'handle_preflight' );
function handle_preflight() {
// Set the domain that's allowed to make the API call.
header("Access-Control-Allow-Origin: " . get_http_origin());
// Set the methods
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: Origin, Content-Type, Accept");
if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
View .htaccess
<ifmodule mod_headers.c="">
SetEnvIf Origin "^(.*\.alpes\.ch)$" ORIGIN_SUB_DOMAIN=$1
Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN
Header set Access-Control-Allow-Methods: "*"
Header set Access-Control-Allow-Headers: "Origin, X-Requested-With, Content-Type, Accept, Authorization"
</ifmodule>
View navigation quickfix
$(function(){
$("button.navbar-toggle").removeAttr( "data-toggle" );
$("button.navbar-toggle").click( function(){ $("#navbar-collapse-1").toggleClass("in"); } );
})
View gist:db22cb2a4ef621511fe38224bf18c591
https://www.zuerioberland-tourismus.ch/de/kontakt-service/veranstaltungskalender?id=588548364
https://www.zuerioberland-tourismus.ch/de/kontakt-service/veranstaltungskalender/event-588548364
@Macagare
Macagare / gist:3999346
Created Nov 2, 2012
HTML: HTML template
View gist:3999346
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
@Macagare
Macagare / gist:3999349
Created Nov 2, 2012
Coldfusion: paypal api
View gist:3999349
<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "&#LCase(TheField)#=#URLEncodedFormat(Form[TheField])#">
</CFLOOP>
<CFIF IsDefined("FORM.payment_date")>
<CFSET str = str & "&payment_date=#URLEncodedFormat(Form.payment_date)#">
</CFIF>
<CFIF IsDefined("FORM.subscr_date")>
<CFSET str = str & "&subscr_date=#URLEncodedFormat(Form.subscr_date)#">
@Macagare
Macagare / compareTables.sql
Created Apr 3, 2017
compare two table for missing ids
View compareTables.sql
SELECT table1.ID
FROM table1
LEFT OUTER JOIN table2 ON table1.ID = table2.ID
WHERE table2.ID IS NULL
@Macagare
Macagare / gist:4502095
Created Jan 10, 2013
JavaScript: Limit the number of characters in a textarea
View gist:4502095
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Code source: http://www.devcurry.com/2009/08/limit-number-of-characters-in-textarea.html THANKS -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Limit Number of Characters in a TextArea</title>
<script type='text/javascript'
src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
You can’t perform that action at this time.