Skip to content

Instantly share code, notes, and snippets.

View mejedi's full-sized avatar

Nick Zavaritsky mejedi

  • Berlin, Germany
View GitHub Profile
@mejedi
mejedi / inertial.js
Created February 21, 2013 11:26
Inertial: the state that doesn't change instantly. Inertial.set(value, cb, apply) — register intent to change the state to the value. Cb gets called as soon as the state was changed to the value *OR* when the operation failed *OR* when the state did change to another value due to completion of a more recent request. The later requires some clari…
function inertial(v) {
var self = this;
self.value = v;
var q = null;
self.set = function(value, cb, apply) {
if (!q && value == v) {
process.nextTick(function() {
safeCall(cb, null, value);
});
} else {
#include <stddef.h>
enum T_field_enum { amount_of_money_e, gender_e, age_e, code_e, height_e, /*<<<<<- add fields here */ last_e };
struct T_cash_account_row {
unsigned code:20; // 0 - 1000000
unsigned gender:1; // 0 - 1
unsigned age:7; // 0 - 100
unsigned amount_of_money:20;// 0 - 1000000
unsigned height:9; // 0 – 300
@mejedi
mejedi / gist:5875719
Last active December 19, 2015 01:28
// Here be dragons
template <typename Visitor>
struct VisitorBase {
template<typename T>
void visit(T &c) {
T::template VisitorContinuation__<Visitor,0>::invoke(static_cast<Visitor&>(*this), c);
}
};
#define STRUCT(name) \
#include <cstddef>
template<size_t n>
struct cn {
char data[n+1];
};
template<typename id, size_t index, size_t val>
cn<val> magic(id, cn<index>, cn<val>);
"""
http_read(f) - read HTTP request or response from a file or a file-like object.
http_parse(f) - like http_read(), returns parsed data
This is a stripped down httplib.py from Python standard library with small
changes.
"""
from array import array
/*
* ====== About Performance Counters ======
*
* Technically a performance counter is an ordinary C/C++ variable.
* It needs a declaration
*
* DECLARE_PERF_COUNTER(int, my_counter, "my_counter"),
*
* ...and the definition:
*
@mejedi
mejedi / gist:4143a4d0ca3aa31f5675
Last active August 29, 2015 14:27 — forked from reidransom/gist:6042016
Auto-starting VirtualBox VMs on OS X

Auto-starting VirtualBox VMs on OS X

After finding a lot of other posts on the topic that didn't work out for me this one did the trick so I'm reposting for my own sense of self preservation.

Link to original article.

Copy the Virtualbox autostart plist template file to your system's LaunchDaemons folder.

sudo cp \

/Applications/VirtualBox.app/Contents/MacOS/org.virtualbox.vboxautostart.plist \

@mejedi
mejedi / abstract_example.lua
Last active October 7, 2015 18:37
RFC: Cfg module
cfg = require('config').new()
cfg.reg('foo', 42)
cfg.reg('bar', 'example.org')
cfg.reg('bazz')
cfg.load{}
print('Adding listener (monitors foo and bar)')
cfg.add_listener(function (cfg_data)
print('<...> foo: ' .. tostring(cfg_data.foo) .. ', bar: ' .. tostring(cfg_data.bar))
@mejedi
mejedi / osx-installer.sh
Created October 19, 2015 08:24
Building tarantool installer for osx
cmake .. $1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 && \
make -j16 && DESTDIR=`pwd`/destdir make install && \
productbuild --root `pwd`/destdir tarantool.pkg
diff --git a/sophia/database/sd_scheme.h b/sophia/database/sd_scheme.h
index 960e5c1..7ecb8df 100644
--- a/sophia/database/sd_scheme.h
+++ b/sophia/database/sd_scheme.h
@@ -53,8 +53,9 @@ sd_schemeu32(sdschemeopt *o) {
static inline uint64_t
sd_schemeu64(sdschemeopt *o) {
+ struct __C { uint64_t __v; } sspacked;
assert(o->type == SS_U64);