Skip to content

Instantly share code, notes, and snippets.

View baudehlo's full-sized avatar

Matt Sergeant baudehlo

View GitHub Profile
"use strict";
var fs = require('fs');
var path = require('path');
fs.readdirSync(__dirname + '/model').forEach(function (model_file) {
if (/\.js$/.test(model_file)) {
var key = model_file.replace(/\.js$/, '');
exports[key] = require(path.join(__dirname, 'model', model_file));
}
#!/usr/bin/perl
# use 'swaks --help' to view documentation for this program
#
# Homepage: http://jetmore.org/john/code/swaks/
# Online Docs: http://jetmore.org/john/code/swaks/latest/doc/ref.txt
# http://jetmore.org/john/code/swaks/faq.html
# Announce List: send mail to [email protected]
# Project RSS: http://jetmore.org/john/blog/c/swaks/feed/
# Google+: https://plus.google.com/u/0/110270727761256449657
@baudehlo
baudehlo / uni.pl
Last active December 29, 2015 14:29
Run with: perl -C uni.pl
// Fixup the email (TODO: we should probably clone the transaction here because we don't want it changed for every RCPT TO)
trans.remove_header('List-Unsubscribe');
trans.add_header('List-Unsubscribe', list.email.replace('@', '-unsub@'));
trans.remove_header('List-ID');
trans.add_header('List-ID', list.name + " <" + list.email.replace('@', '.') + ">");
trans.remove_header('List-Message-Id');
trans.add_header('List-Message-Id', id);
if (list.reply_to_set) {
trans.remove_header('Reply-To');
trans.add_header('Reply-To', list.email);
"use strict";
var fs = require('fs');
var cache = {};
var timers = {};
var times = 0;
function leak_test (name, cb) {
if (cache[name]) {
$ echo 'process.removeAllListeners("uncaughtException");' > /tmp/foo.js
$ node /tmp/foo.js
[exits normally]
select start_date, end_date from employees where company_id=10; start_date | end_date
------------+----------
2013-05-31 |
2013-07-09 |
2013-07-17 |
2013-05-31 |
2013-05-31 |
2013-05-31 |
@baudehlo
baudehlo / 2.diff
Last active December 28, 2015 05:59
diff --git a/connection.js b/connection.js
index 3be5f70..c0fa9b8 100644
--- a/connection.js
+++ b/connection.js
@@ -1105,7 +1105,7 @@ Connection.prototype.cmd_mail = function(line) {
var results;
var from;
try {
- results = rfc1869.parse("mail", line);
+ results = rfc1869.parse("mail", line, config.get('strict_rfc1869') && !this.relaying);
diff --git a/rfc1869.js b/rfc1869.js
index f7835fc..d007bea 100644
--- a/rfc1869.js
+++ b/rfc1869.js
@@ -21,14 +21,16 @@
var chew_regexp = /\s+([A-Za-z0-9][A-Za-z0-9\-]*(?:=[^= \x00-\x1f]+)?)$/;
+exports.strict = false;
+
SELECT periods.end, sum(opportunities.amount)
FROM (
SELECT d as start, ((d + CAST('1 month' AS interval)) - CAST('1 day' AS interval))::date as end
FROM (SELECT generate_series(date_trunc('month', CAST('2013-01-01' AS date)),
date_trunc('month', CAST('2014-01-01' AS date)),
CAST('1 month' AS interval))::date AS d) as p
) as periods
LEFT JOIN Opportunities ON (opportunities.close_date >= periods.start
AND opportunities.close_date <= periods.end)
WHERE opportunities.employee_external_id='005F0000002PLrBIAW'