Skip to content

Instantly share code, notes, and snippets.

View rmontagud's full-sized avatar

Rafael Montagud rmontagud

View GitHub Profile
@rmontagud
rmontagud / dranor-spamassasin.cf
Last active October 25, 2016 11:02
Personal spamassasin rules, might contain profanity, out-of-the-line refferences and offensive comments but it's all you can get from someone annoyed of receiving too much spam
# dranor.cf a set of rules made due to major annoyance when checking my personal accounts
# WARNING: It can contain profane language and offensive opinions
# Deals Are Us bullshit
header __DEALSAREUS_1 Subject =~ /deals are us/i
header __DEALSAREUS_2 From =~ /deals-are-us/i
meta DEALS_ARE_US ((__DEALSAREUS_1 + __DEALSAREUS_2) >= 1)
describe DEALS_ARE_US Spanish bulk mailer, i just hope their servers burn
score DEALS_ARE_US 7.0
<?php
// Simple DNSBL/RBL PHP function - trust me, it's better than checkdnsrr, fsock, socket_create, Net::DNSBL and Net::DNS
// Here's a [better] way to quickly check if an IP is in a DNSBL / RBL. It works on Windows and Linux,
// assuming nslookup is installed. It also supports timeout in seconds.
function ipInDnsBlacklist($ip, $server, $timeout=1) {
$response = array();
$host = implode(".", array_reverse(explode('.', $ip))).'.'.$server.'.';
$cmd = sprintf('nslookup -type=A -timeout=%d %s 2>&1', $timeout, escapeshellarg($host));
@exec($cmd, $response);
@rmontagud
rmontagud / exportexample.php
Last active September 4, 2022 03:24
Export a MySQL dataset to CSV using php://output stream and fputcsv
<?php
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment;filename="export.csv"');
header('Cache-Control: max-age=0');
// See: http://es2.php.net/manual/en/wrappers.php.php
$fpcsv = fopen('php://output', "a+");
// Put your SQL query here
$exportcsv_q = mysql_query($query);
if (@mysql_num_rows($exportcsv_q) > 0) {
$campos = mysql_num_fields($exportcsv_q);
/**
* Spanish Bank Account Number validation
*/
function saneaFormato(str, num) {
return '' + new Array((num - str.toString().length)+1).join('0') + str;
}
function mod11(x) {
var pesos = [ 1, 2, 4, 8, 5, 10, 9, 7, 3, 6 ], control = 0, i, offset = pesos.length - x.length;
for (i = 0; i < x.length; i++) control += x.charAt(i) * pesos[i+offset];
@rmontagud
rmontagud / tooltip.js
Created October 6, 2009 11:03
Tiny jQuery tooltip
// Credit goes to Ashley Ford, since the idea of this snippet
// was taken from his blog article at http://papermashup.com/experimental-jquery-tooltips/
// this is a "self-sustained" tooltip, and i stripped the AJAX
// part since i don't need it for now
$(document).ready(function() {
// Tooltip, probando
$("[rel^='tooltip']").bind('mouseover', function(){
var theMessage = "Tooltip: "+$(this).attr('rel').split(":", 2).slice(1, 2);
$('<div class="tooltip">' + theMessage + '</div>').appendTo('body').fadeIn('fast');