Skip to content

Instantly share code, notes, and snippets.

@Macagare
Macagare / caldera-core.php
Created March 26, 2019 09:52
add CORS to caldera forms
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'] ) {
@Macagare
Macagare / .htaccess
Created March 25, 2019 16:50
alpes CROS
<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>
$(function(){
$("button.navbar-toggle").removeAttr( "data-toggle" );
$("button.navbar-toggle").click( function(){ $("#navbar-collapse-1").toggleClass("in"); } );
})
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 April 3, 2017 11:19
compare two table for missing ids
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 August 29, 2015 14:23
Shell URL request runner
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 June 24, 2015 09:01
SVN remove unversioned files like "git clean -f"
svn st | grep '^?' | awk '{print $2}' | xargs rm -rf
@Macagare
Macagare / tag_regex
Created February 13, 2015 10:54
Find Tags
<.*?(\>)
@Macagare
Macagare / split_string.sql
Created November 27, 2014 12:36
convert comma separated string into temporary table with individual rows
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 November 26, 2014 10:10
update table autoincrement offset
ALTER TABLE tbl AUTO_INCREMENT = 5;