Skip to content

Instantly share code, notes, and snippets.

@emilsedgh
emilsedgh / gist:5844406
Created June 23, 2013 09:26
strace output for libuv/issues/838
{{EPOLLIN, {u32=10, u64=10}}}, 1024, 38245320) = 1
[pid 30788] accept4(10, 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = 63
[pid 30788] accept4(10, 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
[pid 30788] epoll_ctl(5, EPOLL_CTL_ADD, 63, {EPOLLIN, {u32=63, u64=63}}) = 0
[pid 30788] epoll_wait(5, {{EPOLLIN, {u32=63, u64=63}}}, 1024, 119997) = 1
[pid 30788] read(63, "POST /login HTTP/1.1\r\nHost: loca"..., 65536) = 676
[pid 30788] write(11, "*2\r\n$3\r\nget\r\n$29\r\nsess:FnQJJWh5Y"..., 49) = 49
[pid 30788] epoll_ctl(5, EPOLL_CTL_MOD, 11, {EPOLLIN, {u32=11, u64=11}}) = 0
[pid 30788] epoll_wait(5, {{EPOLLIN, {u32=11, u64=11}}}, 1024, 119985) = 1
[pid 30788] read(11, "$76\r\n{\"cookie\":{\"originalMaxAge\""..., 65536) = 83
This file has been truncated, but you can view the full file.
{"snapshot":{"title":"","uid":1,"meta":{"node_fields":["type","name","id","self_size","edge_count"],"node_types":[["hidden","array","string","object","code","closure","regexp","number","native","synthetic"],"string","number","number","number","number","number"],"edge_fields":["type","name_or_index","to_node"],"edge_types":[["context","element","property","internal","hidden","shortcut","weak"],"string_or_number","node"]},"node_count":18361,"edge_count":99871},
"nodes":[3,1,1,0,3
,3,2,3,0,12
,3,3,9,0,193
,3,4,11,0,1
,3,5,31,0,1
,3,6,15,0,33
,3,7,17,0,3
,3,8,19,0,2
,3,9,21,0,11
@emilsedgh
emilsedgh / gist:8987b4e580dd2e1b792a
Created January 23, 2016 01:57
Domains helping atomic endpoints
var db = require('./db.js');
var Domain = require('domain');
function transaction(req, res, next) {
db.conn(function(err, conn, done) {
var domain = Domain.create();
if(err) {
return next(Error.Database(err));
}
@emilsedgh
emilsedgh / atomic.js
Created January 23, 2016 01:58
Atomic endpoints using domains
var db = require('./db.js');
var Domain = require('domain');
function transaction(req, res, next) {
db.conn(function(err, conn, done) {
var domain = Domain.create();
if(err) {
return next(Error.Database(err));
}

Keybase proof

I hereby claim:

  • I am emilsedgh on github.
  • I am emilsedgh (https://keybase.io/emilsedgh) on keybase.
  • I have a public key whose fingerprint is E26F E6FA B023 0AC7 B61A CAE7 1E77 9FF7 23B7 D6F2

To claim this, I am signing this object:

a = cb => {
cb()
}
b = cb => {
a(cb)
}
a.promisified = promisify(a)
// This is a method I have that ideally should look like this:
Token.create = async token => {
const result = await query.promise('token/insert', [
token.client_id,
token.user_id,
token.type,
])
return 'something'
CREATE OR REPLACE FUNCTION get_brand_users(uuid, uuid) RETURNS
setof uuid
AS
$$
WITH brand_users AS (
SELECT DISTINCT users.id FROM users
LEFT JOIN agents ON users.agent = agents.id
LEFT JOIN offices ON agents.office_mui = offices.matrix_unique_id
LEFT JOIN brands_offices ON offices.id = brands_offices.office
LEFT JOIN brands_agents ON agents.id = brands_agents.agent
CREATE OR REPLACE FUNCTION get_brand_users(uuid, uuid) RETURNS
setof uuid
AS
$$
WITH brand_users AS (
SELECT DISTINCT users.id FROM users
LEFT JOIN agents ON users.agent = agents.id
LEFT JOIN offices ON agents.office_mui = offices.matrix_unique_id
LEFT JOIN brands_offices ON offices.id = brands_offices.office
LEFT JOIN brands_agents ON agents.id = brands_agents.agent
emilsedgh@debian ~/P/r/server> git push alpine develop:master
Counting objects: 166, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (166/166), done.
Writing objects: 100% (166/166), 17.24 KiB | 0 bytes/s, done.
Total 166 (delta 135), reused 0 (delta 0)
-----> Cleaning up...
-----> Building alpine from dockerfile...
-----> Setting config vars
DOKKU_DOCKERFILE_PORTS: 3078