Skip to content

Instantly share code, notes, and snippets.

Chris Macagare

  • Germany
View GitHub Profile
@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 / 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 / urls.sh
Last active Aug 29, 2015
Shell URL request runner
View urls.sh
for i in `cat testurls.txt`
do
curl -v -o /dev/null $i\&lorem=$RANDOM
done
# testurls.txt simply lists one URL per line
@Macagare
Macagare / gist:768ac1e177e4b1ca3879
Created Jun 24, 2015
SVN remove unversioned files like "git clean -f"
View gist:768ac1e177e4b1ca3879
svn st | grep '^?' | awk '{print $2}' | xargs rm -rf
@Macagare
Macagare / split_string.sql
Created Nov 27, 2014
convert comma separated string into temporary table with individual rows
View split_string.sql
DROP procedure IF EXISTS split_string;
DELIMITER $$
CREATE PROCEDURE split_string (list TEXT)
BEGIN
DECLARE max INT DEFAULT 0;
DECLARE i INT DEFAULT 1;
DECLARE elem INT DEFAULT 0;
SET max = length(list) - length(replace(list, ',', ''));
@Macagare
Macagare / autoincrement.sql
Created Nov 26, 2014
update table autoincrement offset
View autoincrement.sql
ALTER TABLE tbl AUTO_INCREMENT = 5;
You can’t perform that action at this time.