Skip to content

Instantly share code, notes, and snippets.

$.ajax({
type: "POST",
url: "form.php",
data: $('#form').serialize(),
beforeSend: function() {
$('#form').append('<div class="alert alert-success save-message">Saving...</div>');
},
success: function(data) {
$('.save-message').remove();
}
@GiovanniK
GiovanniK / gist:11378562
Created April 28, 2014 17:27
CSF firewall configuration (Directadmin)
###############################################################################
# SECTION:Initial Settings
###############################################################################
# Testing flag - enables a CRON job that clears iptables incase of
# configuration problems when you start csf. This should be enabled until you
# are sure that the firewall works - i.e. incase you get locked out of your
# server! Then do remember to set it to 0 and restart csf when you're sure
# everything is OK. Stopping csf will remove the line from /etc/crontab
#
# lfd will not start while this is enabled
@GiovanniK
GiovanniK / nginx-vhost
Last active July 10, 2023 16:24
Nginx config - PHP 7.2 + certbot compatible
server {
listen 80;
root /var/www;
index index.php;
server_name domain.dev;
# Do nice rewrite stuff in here
location / {
#try_files $uri $uri/ /index.php?$args;
@GiovanniK
GiovanniK / gist:10002378
Created April 6, 2014 06:57
Make Apache work the CPU
<?php
// make sure the trackback ping's URL links back to us
$handle = fopen($url, "r");
$tb_page = '';
while (!feof($handle)) {
$tb_page .= fread($handle, 8192);
}
fclose($handle);
$pos = strpos($tb_page, "http://imgur.com");
if ($pos === false) {
@GiovanniK
GiovanniK / gist:9250569
Created February 27, 2014 13:59
Simple captcha
<?php
session_start();
if (empty($_SESSION['captcha']))
{
$captcha = mt_rand(10000, 99999);
$_SESSION['captcha'] = $captcha;
}
else
{
@GiovanniK
GiovanniK / gist:8823425
Created February 5, 2014 13:18
Montessori college rooster
<?php
$url = 'http://beheer.e-poc.nl/onderwijs/plugins/montessori/website/rooster_groesbeek.php';
preg_match_all("/<tr>(.+)<\/tr>/siU", @file_get_contents($url), $matches);
preg_match_all("/<td colspan=\"5\" class=\"title\">(.+)<\/tr>/siU", @file_get_contents($url), $titles);
$titles_count = count($titles);
$changes = $matches[0];
$changes = str_replace ('<td colspan="5">&nbsp;</td>', '', $changes);