Skip to content

Instantly share code, notes, and snippets.

View arlukin's full-sized avatar

Daniel Lindh arlukin

View GitHub Profile
# /node_modules/feathers-mongodb/lib/index.js
# Patched version of _get()
_get (id, params = {}) {
const { query } = this.filterQuery(params);
query.$and = (query.$and || []).concat({ [this.id]: this._objectifyId(id) });
let result = null;
if (params.inTransaction)
result = this.Model.findOneAndUpdate(query, {$set: { myLock: ObjectID() }});
@arlukin
arlukin / Result.txt
Last active July 28, 2016 08:26
Benchmark of merging dicts in python.
time 1.6452050209 --- d4 = d1.copy(); d4.update(d2), d4.update(d3)
time 1.69228887558 --- d4 = dict(d1, **d2); d4.update(d3)
time 1.78650903702 --- d4 = {}; d4.update(d1); d4.update(d2), d4.update(d3)
time 1.92449307442 --- d4 = {} for d in (d1, d2, d3): d4.update(d)
time 2.00036215782 --- d4 = dict(d1, **d2); d5=dict(d4, **d3)
time 2.04427695274 --- d4 = dict(d1) for d in (d2, d3): d4.update(d)
time 2.68033099174 --- d4 = reduce(lambda x,y: dict(x, **y), (d1, d2, d3))
time 3.72226691246 --- d4 = dict(chain(*[d.iteritems() for d in (d1, d2, d3)]))
time 4.01872420311 --- d4 = dict(d1.items() + d2.items() + d3.items())
time 4.07779598236 --- d4 = dict(chain.from_iterable(d.iteritems() for d in (d1, d2, d3)))
@arlukin
arlukin / gist:5689526
Created June 1, 2013 06:59
Configure postfix to relay all emails through gmail. Tested on Centos 6.4.
#!/bin/bash
#
# Configure postfix to relay all emails through gmail.
#
# Also install mailx to send testmails.
#
# Based on
# http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html
# http://carlton.oriley.net/blog/?p=31
# http://opentodo.net/2013/03/postfix-smtp-relay-to-smtp-gmail-com/
@arlukin
arlukin / glassfish-3.1.1
Created November 6, 2011 00:39
Startup (/etc/init.d/glassfish) script for Glassfish 3.1 on Centos 6.
#!/bin/env python
#
# glassfish Startup script for the Glassfish java application server.
#
# chkconfig: 2345 85 15
# description: GlassFish is an open source application server project started \
# by Sun Microsystems for the Java EE platform and now sponsored \
# by Oracle Corporation. The supported version is called Oracle \
# GlassFish Server. GlassFish is free software, dual-licensed \
# under two free software licences: the Common Development and \
@arlukin
arlukin / glassfish-3.1.1.sh
Created November 6, 2011 00:32
Startup (/etc/init.d/glassfish) script for Glassfish 3.1 on Centos 6.
#!/bin/bash
# Startup script for Glassfish.
#
# chkconfig: 2345 95 05
# description: Start the java application server, glassfish.
# pidfile: /var/run/glassfish.pid
#
# Used and tested on centos 6
#
# Author: daniel.lindh@fareoffice.com