Skip to content

Instantly share code, notes, and snippets.

View kaworu's full-sized avatar

Alexandre Perrin kaworu

View GitHub Profile
(letrec ((abs
(lambda (x)
((if (< x 0) - +) x))))
(display (abs 12)))
==48808== Memcheck, a memory error detector
==48808== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==48808== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==48808== Command: ./perl -D128 t/op.each
==48808==
0x2000220: (00000) malloc 1 bytes
0x2000270: (00001) malloc 2 bytes
0x20002c0: (00002) malloc 10 bytes
0x2000310: (00003) malloc 72 bytes
0x20003a0: (00004) malloc 2 bytes
MongoDB shell version: 2.4.8
connecting to: dev
> db.some_collection.ensureIndex({"sub.id":1}, {unique:true});
> db.some_collection.insert({sub:[{id:42}]})
> db.some_collection.find()
{ "_id" : ObjectId("5321a4b172a13ee462bc5c20"), "sub" : [ { "id" : 42 } ] }
> db.some_collection.update({}, {$push: {sub: {id:42}}})
> db.some_collection.find()
{ "_id" : ObjectId("5321a4b172a13ee462bc5c20"), "sub" : [ { "id" : 42 }, { "id" : 42 } ] }
> db.some_collection.insert({sub:[{id:42}]})
collection.update(
{bookings: {$elemMatch: {
_id: unconfirmed._id,
expire_at: {$gte: now},
confirmed_at: {$exists: false}
}}},
{$set: {'bookings.$.confirmed_at': new Date()}},
callback
);
var fs = require("fs");
function read(path, callback) {
fs.readFile(path, 'utf8', callback);
}
function cat(path) {
read(path, function (err, data) {
if (err)
throw err;
# You can put the following access restrictions that the Postfix SMTP server
# applies in the context of the RCPT TO command
smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_non_fqdn_helo_hostname
reject_invalid_helo_hostname
reject_invalid_hostname
reject_unauth_destination
reject_unauth_pipelining
<?php
print (42 || 0); // output `1'
var util = require("util");
var Factory = require("rosie").Factory;
Factory.define('child')
.sequence('id')
Factory.define('parent')
.sequence('id')
.attr('children', function () {
return [
@kaworu
kaworu / gist:9931919
Created April 2, 2014 10:56
sysctl.c: use the correct (unsigned) type size for CTLTYPE_U64
--- sbin/sysctl/sysctl.c.orig 2014-04-02 12:54:01.000000000 +0200
+++ sbin/sysctl/sysctl.c 2014-04-02 12:54:33.000000000 +0200
@@ -632,7 +632,7 @@
[CTLTYPE_LONG] = sizeof(long),
[CTLTYPE_ULONG] = sizeof(u_long),
[CTLTYPE_S64] = sizeof(int64_t),
- [CTLTYPE_U64] = sizeof(int64_t),
+ [CTLTYPE_U64] = sizeof(uint64_t),
};
@kaworu
kaworu / jail.local
Created May 14, 2014 13:42
partial fail2ban config
[roundcube]
enabled = true
filter = roundcube
action = sendmail-whois[name=roundcube]
pf[tablename=fail2ban_mail]
pf[tablename=fail2ban_www]
logpath = /var/log/maillog
maxretry = 4