Skip to content

Instantly share code, notes, and snippets.

View bobrik's full-sized avatar

Ivan Babrou bobrik

View GitHub Profile
@bobrik
bobrik / rmatein
Created August 10, 2012 08:26
rmate as $PAGER shell variable (instead of less or whatever you use)
#!/bin/sh
# EDITOR should be set to rmate
# Usage: git diff | rmatein
# First arg may be set to file extension to hint rmate about file type
if [ -n "${1}" ]; then
POSTFIX=".${1}"
fi
// /mnt/sdd/testfile is 4Gb file
// we read this file in 50 "threads"
// node.js results: ~1700 ops/s 7 Mb/s
// randomio results: ~290 ops/s 19 Mb/s
var fs = require("fs"),
fd = fs.openSync("/mnt/sdd/testfile", "r"),
i = 0,
l = 1204 * 64;
// for some reason from time to time it may output WTFs
// the way i run it: trace -f node buggy.js 2>&1 | grep '\(pwrite\|pread\|WTF\)'
// all reads come after writes
var fs = require("fs"),
file = fs.openSync("aa", "a+"),
bufs = {},
off = fs.fstatSync(file).size,
offs = {};
var fs = require("fs"),
file = fs.openSync("aa", "a+"),
bufs = {},
off = fs.fstatSync(file).size,
offs = {};
Object.keys(offs).forEach(function(o) {
offs[o] += off;
});
// rm aa; node buggy3.js | fgrep WTF | wc -l
// different results for each run
// writes are sequential
function FileWriterQueue(file) {
this.file = file;
this.queue = [];
}
FileWriterQueue.prototype.write = function(buffer, offset, callback) {
// writing 3 buffers starting from offset 0
// 3 bytes | 5 bytes | 10 bytes
// second | first | third
// last byte of the last buffer should be at offset 18
// file should be 18 bytes long
// this is WRONG on linux, file grows up for 18 bytes after each run
// and every single written buffer can't be read properly
//
// holy fuck, the whole day lost.
web # id; npm config ls -l; npm config get user
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),26(tape),27(video)
; cli configs
long = true
registry = "https://registry.npmjs.org/"
; default values
always-auth = false
browser = "google-chrome"
cache = "/root/.npm"
web372 backpack # npm install --verbose aligned-buffer
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli '/usr/bin/npm',
npm verb cli 'install',
npm verb cli '--verbose',
npm verb cli 'aligned-buffer' ]
npm info using npm@1.1.61
npm info using node@v0.9.2
npm verb read json /opt/backpack/package.json

This happens only on node 0.9.x, 0.8.11 works just fine.

To check: npm install aligned-buffer + require it in node.js repl.

<?php
// observable user
class User {
const EVENT_TYPE_AFTER_LOAD_FOR_UPDATE = 'afterLoadForUpdate';
const EVENT_TYPE_AFTER_SAVE = 'afterSave';
private $Foo;