Posts

c++ - LevelDB TEST_ Prefix for Methods -

i'm reading through code in leveldb , keep running across test_ prefix that's used. expect test_ indicates method used tests able operate on internals wouldn't otherwise public. such, i'd expect none of in critical paths. i'd expect them in none of primary methods. however, test_compactrange example called compactrange apart of main compaction path. test_ prefix mean, , can find info? the authors seem use test_ prefix public methods not intended part of api. methods public make testing easier, , prefixed test_ discourage users calling them. why shouldn't these methods appear in critical paths? private methods, visible testing. other thoughts: i'm not sure whether naming convention best practice. c++ has friend declarations accomplish similar. the naming convention similar java guava library's @visiblefortesting annotation edit: clear, i'm making guess based on handful of methods test_ prefix. grepping codebase shows such...

javascript - Explain the encapsulated anonymous function syntax -

summary can explain reasoning behind syntax encapsulated anonymous functions in javascript? why work: (function(){})(); doesn't: function(){}(); ? what know in javascript, 1 creates named function this: function twoplustwo(){ alert(2 + 2); } twoplustwo(); you can create anonymous function , assign variable: var twoplustwo = function(){ alert(2 + 2); }; twoplustwo(); you can encapsulate block of code creating anonymous function, wrapping in brackets , executing immediately: (function(){ alert(2 + 2); })(); this useful when creating modularised scripts, avoid cluttering current scope, or global scope, potentially conflicting variables - in case of greasemonkey scripts, jquery plugins, etc. now, understand why works. brackets enclose contents , expose outcome (i'm sure there's better way describe that), such (2 + 2) === 4 . what don't understand but don't understand why not work equally well: function(){ alert(2 + 2); ...

c++ - Why can templates only be implemented in the header file? -

quote the c++ standard library: tutorial , handbook : the portable way of using templates @ moment implement them in header files using inline functions. why this? (clarification: header files not only portable solution. convenient portable solution.) it not necessary put implementation in header file, see alternative solution @ end of answer. anyway, reason code failing that, when instantiating template, compiler creates new class given template argument. example: template<typename t> struct foo { t bar; void dosomething(t param) {/* stuff using t */} }; // somewhere in .cpp foo<int> f; when reading line, compiler create new class (let's call fooint ), equivalent following: struct fooint { int bar; void dosomething(int param) {/* stuff using int */} } consequently, compiler needs have access implementation of methods, instantiate them template argument (in case int ). if these implementations not in header, wouldn...

c - How to create an array of size 2^16 blocks consisting of 256 bytes -

so title says all. have create file system simulation operating systems class. still not c why asking help. , 1 of things throwing me off have create storage array of 2^16 blocks of 256 bytes each; block plain sequence of bytes until overlaid structure (use union, of course): directory or file meta-data, index node, or data node; there type of node: this did #include "project1task3.h" int main() { createfilesystem(); } /* * create file system * (i.e., allocate , initializing structures , auxiliary data; * create superblock) * * * */ void createfilesystem() { // setting file system "superblock" fs_node filesystem; node typenode; node* p; // pointer point file or director //typenode.type = dir; int i; int j; size_t nodesize; // allocate space fixed sie , variable part (union) nodesize = sizeof(fs_node) + sizeof(node); if ((memory = malloc(nodesize)) == null) { for(i = 0; < mem;i++) ...

forms - Emberjs live serverside validation -

i've managed input going server, , server responding if input valid, or returning error object if not. i'm not sure how use returned error object something. there many examples around internet of how loop through error object , display message isn't i'm after. i have form component has bunch of fields like: {{input type="text" value=account.twitterid class="input" focus-out="validateinput"}} and validateinput in component looks like validateinput() { let account = get(this, 'account'); account.save().then(() => { console.log('success!'); // add class input field }).catch((adaptererror) => { console.log(account.get('errors')); // add different class input field console.log(adaptererror); }); }, as mentioned above, triggers , either returns successful or error message but how take result , use add classes class key of input field? i did attempt following haserror: fals...

visual studio 2015 - How to deploy Service Fabric application services to different Virtual machines scale sets -

i see possible create different nodes per cluster. every node set virtual machine scale set. created cluster 2 nodes set, 1 frontend, other backend (more nodes , more powerful machines). i have service fabric application 3 services. want 1 service deployed on frontend scale set , other 2 backend set. how do visual studio 2015? if right click application , deploy, deploy successful how specify service deployed where? have @ placement constraints. using these, can influence services run. more info here . paragraph: placement constraints , node properties

php - How to cache the application configs in memory in Zend Framework 2? -

one of must-haves performance optimization of zend framework 2 application caching of configurations. idea merge them 1 big config file (or 2 files, e.g. module-classmap-cache.php , module-config-cache.php ), config files don't need opened , merged on every request. (see info in official documentation , how-to in article of rob allen " caching zf2 merged configuration "): application.config.php return [ 'modules' => [ ... ], 'module_listener_options' => [ ... 'config_cache_enabled' => true, 'config_cache_key' => 'app_config', 'module_map_cache_enabled' => true, 'module_map_cache_key' => 'module_map', 'cache_dir' => './data/cache', ], ]; i'd optimize bit more , load configs in-memory cache (e.g. apcu). provided framework? or have write functionality myself? the caching mechanis...