Posts

Showing posts from February, 2013

Crystal Reports combine fields in string formula, one field no data -

i given formula: if not (isnull({person.last_name})) {person.last_name}+","+" "+{person.first_name} else "no name" this formula seems work fine need add field {person.middle_name} when write formula if not (isnull({person.last_name})) {person.last_name}+","+" "+{person.first_name}+","+" "+{person.middle_name} else "no name" if person has middle name, looks fine. if person not have middle name , there no data in field, report shows no information @ all. apologies beginner question, , thank in advance. you can nest additional if statement evaluate middle name. break criteria multiple formulas. create separate formula fname, lname, mname. each have if statement similar above (if isnull({mname} "" else {mname}). then can create additional formula concatenate them {lastname} + {firstname} + {middlename}

c++ - How can I avoid this code duplication? -

i have 2 methods have same code except 2 methods call (and other details can parameterize). however, method calls have same signature, think can generalize them single method. class a{ iapi* m_papi; void m1(); void m2(); public: void dothings(); } void a::m1(){ int i; bool b; m_papi->method1( &i, &b ); //other stuff... } void a::m2(){ int i; bool b; m_papi->method2( &i, &b ); //other stuff... } void a::dothings(){ m1(); m2(); } i can figure out how "parameterize" "other stuff" code, problem calls method1 , method2 . think have use std::bind somehow, can't this... void a::m( std::function<void(int*,bool*)> f ){ int i; bool b; f( &i, &b ); } void a::dothings(){ m( std::bind( ???, m_papi ) ); //m1 m( std::bind( ???, m_papi ) ); //m2 } the problem here m_papi not concrete class (it's interface implemented bunch of concret

Infinite while loop while renaming file(Qt C++) -

i've made if else structure checks if file exist or not. if should go while loop , add integer , check again if file exist. should work same broswer of windows "filename (1).ext" . have following code: qfile file("messages/" + name + ".txt"); if(!file.exists()) { file.open(qiodevice::writeonly | qiodevice::text); qdebug() << "file doesn't exist, saving complete"; qtextstream message_file(&file); message_file << body; file.close(); qmessagebox::about(0,"succes!","uw bericht opgeslagen en verstuurd!"); } else { int n = 0; qdebug() << "file exist"; while(file.exists()){ n++; qstring nstring = qstring::number(n); qdebug() << "file exists sequence: " + nstring; qfile file("messages/" + name + " (" + nstring +

primes - Python 2.7.6(64-bit) overflow error in primality testing -

i running following code, version of erathosthene's sieve in python 2.7.6 64-bit on win8 on computer 4gb ram. def erathosthenes_sieve2(n): '''tests n>1 primality using improved erathostene's method''' if n==2: return true if n%2==0: return false limit=long(math.floor(math.sqrt(n))) in xrange(3,limit+1,2): if n%i==0: return false return true when call function sufficiently big numbers, example 48112959837082048697(which prime) following error. erathosthenes_sieve2(48112959837082048697) --------------------------------------------------------------------------- overflowerror traceback (most recent call last) <ipython-input-28-b0a5b24a8b94> in <module>() ----> 1 erathosthenes_sieve2(48112959837082048697) d:\repos\primalitytests\eratosthenes2.py in erathosthenes_sieve2(n) 9 return false

rpmbuild - rpm spec file - How to specify multiple package archtypes in the requires -

what have in spec requires: lftp zsh boost db4 db4-devel what need in spec requires: lftp zsh boost db4 db4-devel db4-cxx.i686 db4-devel.i686 but x.i686 doesn't work. when try install package yum, says error: package: blah requires: db4-devel.i686 db4-cxx.i686 is there way install both x86_64 , i686 packages using requires: in spec file? too late, i'll leave here: www.rpm.org/wiki/packagerdocs/archdependencies so, should looks like: requires: db4-devel(x86-32) db4-cxx(x86-32)

php - using phpmailer class to send attachment in email: Could not access file -

i have function below "sendmail", send emails using phpmailer class. , working fine, im sending emails sucess. but im trying add 1 attachment function, added code: $mail->addattachment(base.'/'.'images/2014/05/image4.jpg','image 4'); and im having error: could not access file: localhost/project/images/2014/05/image4.jpg but directory correct directory image, dont understand why error happening. somebody there knows if im missing here? my function send email: function sendmail($subject,$message,$emissor,$emissorname,$receptor,$receptorname, $reply = null, $replyname = null){ require_once('mail/class.phpmailer.php'); $mail = new phpmailer(); $mail->issmtp(); $mail->smtpauth = true; $mail->ishtml(true); $mail->smtpsecure = "tls"; $mail->host = mailhost; $mail->port = mailport; $mail->username = mailuser; $mail->password = mailpass; $

Elasticsearch - Nest - Missing First Character -

i using nest client against elasticsearch. using n-gram index analyzer. noticing odd behavior - when search words beginning not getting results. however, if search second character on, works perfectly. these normal english letters. so, instance, find words containing 'kitty' if search 'itty', 'itt', 'tty', etc. not 'ki', 'kit', etc. it's n-gram skipping on first character. i not sure if being caused nest or if normal behavior n-gram. index settings similar found in post: elasticsearch using nest: how configure analyzers find partial words? except max-gram 10. update i simplified code little bit , verified same behavior. here mapping configuration defined using nest: const string index = "myapp"; const string type = "account"; const string indexanalyzer = "custom_ngram_analyser"; const string searchanalyzer = "standard"; const string tokenizer = "custom_ngram_tokenizer"

jquery - Bind and Unbind Scrolling (using touchmove or difference solution) -

i have simple question how can disable , enable scrolling while @ mobile device? after quick search found jquery("body").bind("touchmove",function(e){ e.preventdefault(); return false; }); works perfectly, how enable again?? have 2 function function mobilepopup() { jquery("body").bind("touchmove",function(e){ e.preventdefault(); return false; }); } and function mobilepopupclose { // there want enable } is posible binding touchmove event returning false? should bind else touchmove know should unbind? maybe implement function name idk. help yes, unbind it. function mobilepopupclose { jquery("body").unbind("touchmove"); }

shell - Lua script over Mikrotic routers -

i new lua take easy me. have following code should ran mikrotik router . possibly tell me does? :local content :local #for each mangle in list :foreach in=[/ip firewall mangle find comment !=""] do={ #pull comment out of queue , divide accordingly :set content [/ip firewall mangle $i comment] :if ([:find $content "!"] != "") do={ :local pos1 [:find $content "!"] :local pos4 [:len $content] :local pos2 ([:find [:pick $content ($pos1+1) $pos4] "!"]+($pos1+1)) :local pos3 ([:find [:pick $content ($pos2+1) $pos4] "!"]+($pos2+1)) this mikrotik script search rules comments in firewall mangle rules, , find comments exclamation points "!". the variables pos1 pos2 pos3 first, second , third location of ! in comments. for instance: if there comment this: a!b!cde!fg variables be: pos1=1 pos2=3 pos3=7 the location starts zero, first location 0 , second 1

c++ - OpenGL scene under Qt qml application -

this should best way how add custom opengl qml app. http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html the problem is, dont want paint on whole window, in rectangle occupied opengl custom qt quick item. thought can call glviewport appropriate parameters, opengl paint rectangle of item. actually, doesn't work me. qml: import qtquick 2.2 import qtquick.controls 1.1 import ge.components 1.0 applicationwindow { visible: true width: 640 height: 480 title: qstr("hello world") color: "red" menubar: menubar { menu { title: qstr("filxe") menuitem { text: qstr("exit") ontriggered: qt.quit(); } } } glviewer { width: 200 height: 200 x: 100 y: 100 } } qt quick item: in paint method, first fill whole window color of applicationwindow , want fill rectangle occup

javascript - Unwrapping objects members with V8/Node.JS -

i'm learning v8/node.js through 1 of project , i'm wondering if there way unwrap c++ object inherited node::ojectwrap (from node.js api) and members @ same time. all examples can found have int members instance , of them try wrap c++ object members. here code explanation of want do: // basic class contains vector member // note not interact v8 or node.js code class b { public: // constructors , methods... size_t getsize(void) { return vec_.size(); }; private: std::vector<int> vec_; } // class instanciate correctly in javascript code class : public node::objectwrap { public: static void init(v8::handle<v8::value> exports); static v8::handle<v8::value> new(const v8::arguments& args); // method use instanciate js object static v8::handle<v8::value> update(const v8::arguments& args); // method call private: a(b b) : b_(b) {}; ~a(void); private: static v8::persistent<v8::function> constru

dart - Waiting for Futures raised by other Futures -

i'm using lawndart library access browser data, , want collect results of set of queries. here's thought should work: numberofrecordspersection(callback) { var map = new map(); db_sections.keys().foreach((_key) { db_sections.getbykey(_key).then((map _section) { int count = _section.length; map[_key] = count; }); }).then(callback(map)); } however, when callback called, map still empty (it gets populated correctly, later, after futures have completed). assume problem futures created getbykey() calls not "captured by" futures created foreach() calls. how can correct code capture result correctly? the code how do jquery pattern in dart? looks similar yours for each entry of _db.keys() future added array , waited of them being finished future.wait() not sure if code works (see comments on answer on linked question) void fna() { fnb().then((_) { // here, keys should have been loaded }

How to compile a python/shell script ? (to hide informations) -

i compile script launch linux. indeed, use babun (shell linux windows) , have scritp password in clear text... i hide use it. use python or shell script because it's easy , quick containing linux commands. thank you. import os os.system("truecrypt /a /p passeword /q /e /v \"c:\users\blabla.tc\"") and use ftp ... (to backup) don't put password file. way hide password. if want obfuscate it, nobody stumble accross accident: import subprocess password = 'cgfzc3dvcmq='.decode('base64') path = "c:\users\blabla.tc" subprocess.popen(['truectypt','/a','/p',password,'/q','/e','/v',path]).communicate()

c++ - binary search a std:map -

using c++, if have n integers in std::map , possible efficiently search largest element smaller k in std::map ? for example have {1, 3, 5, 6} , k 4 returned value should 3 i know std::map can search in log(n) , if exact match. use lower_bound , decrement returned iterator one.

java - Is it bad practice to have boolean setters to see whether they executed succesfully? -

is bad practice write setters booleans check if set correctly? for example, following code set whether frame on top , return true if set decided. bad practice this, or should leave no return type? public boolean setalwaysontop(boolean alwaysontop) { frame.setalwaysontop(alwaysontop); return frame.isalwaysontop() == alwaysontop; } bear in mind in example have getter when want check value when not attempting set it: public boolean isalwaysontop() { return frame.isalwaysontop(); } thanks in advance. if more information please feel free ask , provide it. edit: it's wondering if useful because if(setalwaysontop(true)) instead of using void this: setalwaysontop(true); adding of additional conditions check api work not idea in general. frame.setalwaysontop must work. if don't trust api - cover unit tests. if tests fail should think work around solution - find working version of software, report bug or fix issue

javascript - Removing active class if clicking active link a second time? -

i came across question wanted add active link clicked menu item. the solution add: $("a").click(function(){ $("a").removeclass("active"); $(this).addclass("active"); }); now how can remove active class if click active link second time? i'm guessing need use toggleclass() haven't been able make work. note 1 link should have active class @ time. here demo: http://jsfiddle.net/a6dqq/ you can do: $('a').click(function(e){ e.preventdefault(); var $a = $(this); $a.toggleclass('active').siblings().removeclass('active'); });

c# - Reordering methods in ComImport interfaces throws COMException (0x80041001) -

consider following code com interop internet shortcuts: [comimport] [interfacetype(cominterfacetype.interfaceisiunknown)] [guid("cabb0da0-da57-11cf-9974-0020afd79762")] public interface iuniformresourcelocatorw { void seturl([marshalas(unmanagedtype.lpwstr)] string pcszurl, int dwinflags); void geturl([marshalas(unmanagedtype.lpwstr)] out stringbuilder ppszurl); void invokecommand(intptr purlici); } [comimport] [guid("fbf23b40-e3f0-101b-8488-00aa003e56f8")] public class internetshortcut { } the following works expected: var ishort = new internetshortcut(); ((ipersistfile)ishort).load("mylink.url", 0); ((iuniformresourcelocatorw)ishort).geturl(out url); however: if comment out iuniformresourcelocatorw.seturl (which not using), iuniformresourcelocatorw.geturl throws comexception (hresult 0x80041001). if switch between iuniformresourcelocatorw.seturl , iuniformresourcelocatorw.geturl (that place former below latter) same exc

c++ - unresolved external symbol for yyparse() -

my main.cpp looks this: #include <assert.h> #include <fstream> #include <iostream> #include "astgen.h" #include "astexec.h" extern int yyparse(); extern file *yyin; int main() { //yydebug = 0; struct astelement *a = 0; file *fp ; fopen_s(&fp,"example.txt","r"); //std::cout<<fp; if (fp==null) { std::cout<<"error"; } yyin=fp; yyparse(); assert(a); struct execenviron* e = createenv(); execast(e, a); freeenv(e); /* todo: destroy ast */ } when try compile this, error: main.obj : error lnk2019: unresolved external symbol "int __cdecl yyparse(void)" (?yyparse@@yahxz) referenced in function _main i newbie in flex/bison. appreciated. if helps here parser.y file: %error-verbose /* instruct bison generate verbose error messages*/ %{ #include "astgen.h" #define yydebug 1 /* since parser must return ast, must par

issue using cloumnFilter on JQuery datatable -

i'm trying implement jquery datatables plug-in columnfilter ( http://jquery-datatables-column-filter.googlecode.com/svn/trunk/index.html ). working fine when using type="text" or type="date-range" . when using type="select" without specifiyng values function break. if specify values works fine. values text. this html: <table id="datatable50-2"> <thead> <tr> <th>#</th> <th>@resources.leadtype</th> <th>@resources.provider</th> <th>@resources.campaigns_campaignname</th> <th>@resources.firstname</th> <th>@resources.lastname</th> <th>@resources.phone</th> <th>@resources.email</th> <th>@resources.insertiondate</th> <th>@resources.insertiontime</th> @if (v

mysql - Total Price between date range (like hotel reservation seasons) -

id carid date1 date2 price --- ---- --------- --------- ----- 1 1 1000-01-01 9999-12-31 100 2 2 1000-01-01 2014-06-06 100 3 2 2014-06-07 2014-06-07 150 4 2 2014-06-08 9999-12-31 100 5 3 1000-01-01 2014-06-01 150 6 3 2014-06-02 2014-07-01 200 7 3 2014-07-02 2014-07-25 300 8 3 2014-07-26 9999-12-31 100 this price table; want calculate total price dates range. i want display cars total price; for example filter dates: date1: 2014-06-01 date2: 2014-06-22 results carid total ------ ------ 1 2100 2 2150 3 4150 and try , 1 carid. calculate price between given dates this; calculate price between given dates in multiple ranges assuming have variables @date1 , @date2 , can conditional aggregation: select carid, sum(1 + greatest(least(date2, @d

c++ - nm utility to get what is defined in .so file returns error -

i need symbols defined in .so file. use latest mac os , this: /usr/bin/nm -gc libs/armeabi/libhello.so error: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/nm: invalid argument -c usage: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/nm [-agnopruumxjlfap[s segname sectname] [-] [-t format] [[-arch ] ...] [file ...] as understand nm utility? connected xcode? how fix issue? edit: adding code .so file created. #include <android/log.h> #include <stdio.h> #include <jni.h> jint nativeaddition(jnienv *penv, jobject pobj, jint pa, jint pb) { return pa+pb; } jint nativemultiplication(jnienv *penv, jobject pobj, jint pa, jint pb) { return pa*pb; } jniexport jint jnicall jni_onload(javavm* pvm, void* reserved) { jnienv* env; if ((*pvm)->getenv(pvm, (void **)&env, jni_version_1_6

html - Setting height of img tag equal to its width -

well googled lot didn't find useful.is there way achieve ? <img src="1.jpg"height="" width="100%"> use offsetwidth : var img = document.getelementsbytagname("img")[0]; img.style.height = img.offsetwidth + "px"; and have use javascript. working demo

java - How to sequentially numbering files rather than overwriting them when moving -

i writing code move file 1 directory another, have issue having file have same name, decided number them don't want overwrite them. assume have file a.txt, succeed move move file same name call a_1.txt, wondering can if have again a.txt? moreover, feel code not efficient , appreciated if me enhance it. my code is: /* * method move specific file directory */ public static void movefile(string source, string destination) { file file = new file(source); string newfilepath = destination + "\\" + file.getname(); file newfile = new file(newfilepath); if (!newfile.exists()) { file.renameto(new file(newfilepath)); } else { string filename = filenameutils.removeextension(file.getname()); string extention = filenameutils.getextension(file.getpath()); system.out.println(filename); if (isnumeric(filename.substring(filename.length() - 1))) { int filenum = integer.parseint(filename.substring(filena

Use parent pom directory in maven submodules, subsubmodules etc -

i have maven project following structure: /parent |- module1 | |- submodulea | |- submoduleb |- module2 |- testng.xml in parent, every module , every submodule, there of course pom.xml. want parent/testng.xml used in parent, every module , submodule, in surefire plugin configuration. so have surefire configured in parent pom.xml: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.17</version> <configuration> <suitexmlfiles>${basedir}/testng.xml</suitexmlfiles> </configuration> ... </plugin> such configuration not work, because ${basedir} directory of current module or submodule. module1 looks parent/module1/testng.xml , submodulea looks parent/module1/submodulea/testng.xml etc. i want use parent/testng.xml every module , submodule.

html - Scrolling under div in Android browser -

i have set page when scrolling, content div scrolls under header nav menu, 48px high. it's working fine browsers, 1 notable exception android stock browser, scrolling won't happen @ all. my css: #content{position:absolute; top:48px; left:0px; right:0px; bottom:0px; overflow-y:auto;} nav { display: table; width: 100%; border-collapse: collapse; border: none; } nav ul { display: table-row; } nav li { display: table-cell; margin: 0; } nav { height:48px; display: block; border: 0px solid red; text-align: center; margin: 0 1px; padding:10px; background: #444; text-decoration:none; color:#fff; } if leave out overflow-y, scrolling works again, whole page including header scrolls. is right way go having header div stay static on page, , content scroll under it, , if so, there way android behave? thanks time , help. this might android issue... older versions of android require have 1 scrolling pane.

symfony - How to insert datetime into `created` column only when a record is created first time -

i need solution insert datetime created column only when record created first time . i've found example works onupdate style updates updated column every time when record updated. /** * @var datetime $updated * * @orm\column(type="datetime") */ protected $updated; /** * @orm\prepersist */ public function setupdatedprepersist() { $this->updated = date('y-m-d h:i:s'); } an easy , reliable solution require following extension in composer: https://github.com/stof/stofdoctrineextensionsbundle/blob/master/resources/doc/index.rst and update entity adding this: <?php // src/yourcompany/yourbundle/entity/demo.php namespace yourcompany\yourbundle\entity; use gedmo\mapping\annotation gedmo; use doctrine\orm\mapping orm; /** * @orm\entity */ class demo { // .... /** * @var datetime $created * * @gedmo\timestampable(on="create") * @orm\column(type="datetime") */ private $c

javascript - Only show columns that are filled from external JSON in ExtJS 3.x -

i parsing external json source in extjs , want display data in extjs grid. works perfectly. there maximum set of fields predicitable, in cases of fields empty/not in json. if field not filled @ all, should not hidden. is there functionality hide dynamically in extjs 3.x? my code far: var store = new ext.data.jsonstore({ url : '/data/all.json', storeid : 'mainstore', fields : ['name', 'company', 'country'] }); store.load() var columns = []; var colmodel = new ext.grid.columnmodel([ {header: 'name', sortable: true, dataindex: 'name', filterable: true, hidden: false, filter: {type: 'string'}}, {header: 'company', sortable: true, dataindex: 'company', filterable: true, hidden: false, filter: {type: 'string'}}, {header: 'country', sortable: true, dataindex: 'country', filterable: true, hidden: false, filter: {type: 'string

css - Why does the button element allow vertical-align: middle? -

as far i've been able read, vertical-align: middle; css attribute works on elements display option set table-cell . so why vertical-align accepted on button element? have missed something? the reason question of cause want mimic button behaviour, avoid using structure: <div style="display: table"> <div style="display: table-cell; vertical-align: middle;">vertically aligned</div> </div> according css 2.1 specification, vertical-align property applies “ inline-level , 'table-cell' elements”, , inline-level elements “ inline-level elements elements of source document not form new blocks of content; content distributed in lines (e.g., emphasized pieces of text within paragraph, inline images, etc.). following values of 'display' property make element inline-level: 'inline', 'inline-table', , 'inline-block'.” the button element has display: inline-block in default style

python library pygame: centering text -

i have code: # draw text font = pygame.font.font(none, 25) text = font.render("you win!", true, black) screen.blit(text, [screen_width / 2, screen_height / 2]) how can text width , height methods in java, can center text like: screen.blit(text, [screen_width / 2 - text_w / 2, screen_height / 2 - text_h / 2]) if not possible, way ? i've found this example, didn't understand it. you can dimensions of rendered text image using text.get_rect() , returns rect object width , height attributes, among others (see linked documentation full list). i.e. can text.get_rect().width .

python - how to find a selected vert's symmetrical pair on a maya mesh -

what best (fastest) method find given vertex's symmetrical pair (ie , vert on left side of mesh , right hand side equivalent) possible use open maya api in python or there better way? you don't want check position of every vert against every other on , over, extremely slow. a simple approach hash value - simple comparison operation - every vertex identical 2 verts symmetrical. luckily tuples - not lists!! - hashable. algorithm be: get position tuple each vert make dictionary (position: vertex) verts on 'left' (or 'up' or 'back' etc) side. make second dictionary (position: vertex) verts on opposite side, symmetry axis flipped: if doing left/right axis, left list { (x, y, z) : "pcube1.vtx[0]" } #etc and right list { (-1 * x, y, z) : "pcube1.vtx[99]" } # , on any key duplicated in both dictionaries symmetrical, need collect keys show in both , verts each side represent: duplicates = [j j in leftdictionar

templates - sorting a list containing circles c++ -

i'd run simple code: #include <cstdlib> //std :: rand () #include <vector> //std::vector<> #include <list> //std::list<> #include <iostream> //std::ostream_iterator #include <iterator> //std:: cout std::ostream_iterator #include <algorithm> //std::reverse, std::generate #include <map> #include "colorrgb.hpp" #include "point2d.hpp" #include "circle.hpp" #include <cmath> int main(){ std::list<circle>lk; point2d a(7.5,3.2); point2d b(6.5,2.2); point2d c(5.5,1.2); colorrgb d(0, 0, 0); colorrgb e(0, 1, 1); colorrgb f(1, 1, 0); circle c1(a, 2, d); circle c2(b, 1, e); circle c3(c, 0.4, f); lk.push_back(c1); lk.push_back(c2); lk.push_back(c3); sort(lk.begin(), lk.end(), [] (circle const& lhs,circle const& rhs) ->bool{return(lhs.getrad() <= rhs.getrad())}; return 0; } but compile message: juliuss-macboo

Edit specific listview item in C# WPF -

is possible edit specific listview item @ runtime? for (int = 0; < listviewservers.items.count; i++) { if ( listviewservers.items[i].columnname == "my column name") { listviewservers.items[i].columnname.data = "new cell text"; } } yes, there way. should it? no. in wpf, should use data binding bind controls actual data, then, if right, can change data , ui update automatically. if not doing fancy graphics or interactions, code-behind (*.xaml.cs) should have no code apart autogenerated constructor , should not access controls c# code. i suggest reading on data binding , mvvm pattern, example here , here or here . that said, can access listview items, have know you're putting items collection or in itemssource (controls via xaml? controls via code? viewmodel classes datatemplates?). when know this, can do: foreach (yourclass obj in listviewservers.items.oftype<yourclass>()) { //do stuff obj }

django - Neo4Django - How to define relationships dynamically? -

i don't have static lists of nodes , relationships between them. users enter own data db, along relationships. example, after registration have person node name , userid properties, , after adding personal data, such birth date, hold information in separate nodes relationship user enter. how can achieve neomodels?

c++ - Is it valid to use boolean literals in preprocessor conditionals? -

consider following code, results in boolean literal true being evaluated in preprocessor conditional: #define some_macro true int main () { #if some_macro return 1; #else return 0; #endif } clang 3.4 , gcc 4.8 both accept code, -pedantic -std=c++11 -wall -wextra . visual studio 2013 rejects it, fatal error c1017: invalid integer constant expression . my reading of n3376 § 16.1 regular c++ rules evaluating constant expressions should apply. if so, code valid, , it's bug if msvc not accept it. but don't find standardeze particularly clear. confirm this? yes, valid. see c++11 §16.1/4 (emphasis mine) prior evaluation, macro invocations in list of preprocessing tokens become controlling constant expression replaced (except macro names modified defined unary operator), in normal text. if token defined generated result of replacement process or use of defined unary operator not match 1 of 2 specified forms prior macro replacement, behavi

android - How to start chat screen in Skype from my app? -

i need open skype chat screen skype id app. saw similar questions open chat screen skype other app http://developer.skype.com/skype-uris/skype-uri-tutorial-android the above tutorial explains how open app.but can't find out how pass skype id , start chat screen. is there way or not ? if there way how ? edit i followed below solution.it opens skype app not loading chat screen.can tell me did mistake ? public class extends mainactivity implements android.view.view.onclicklistener { button fb; static string tag = "remote it"; string myskypeuri = "skype:aruzev?chat"; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); layoutinflater inflater = (layoutinflater) this.getsystemservice(context.layout_inflater_service); view contentvi

c - Why "*(&arr+4)" is different then "&arr[4]"? -

int arr[] = { 0, 1, 2, 3, 4, 5 }; i performing address operation tests, increase understanding of ref , deref. here lot of confusion. i found out &*(arr+4) uses same address &arr[4] but never met such assignment &* also figured *(&arr+4) uses same address &arr+4 doesn't make sense me. i couldn't find info that, ask here, why *(&arr+4) uses same address &arr+4 , why *(&arr+4) different &arr[4] ? arr array: arr: int[6] [0|1|2|3|4|5] when used in expression other sizeof arr or &arr , array decays pointer first element of array: (arr+0): int * [*] | v [0|1|2|3|4|5] when integral value added pointer, pointer address (sizeof (t)) * n bytes later in memory (where t type pointed pointer, , n integral value added pointer): (arr+4): int * [*] | v [0|1|2|3|4|5] when pointer dereferenced, value pointed to: *(arr+4): int 4 /* specifically, 4 in fifth position in `arr` *

c# - RestSharp no response when Transfer-Encoding: chunked -

i trying use simple restsharp client this restclient client = new restclient(@"http://hostname:28000"); restrequest request = new restrequest(method.get); request.addparameter("action", "getstatus"); var res = client.execute(request); however, fails with system.io.invaliddataexception: block length not match complement. so response not contain data. what noticed when execute request in webrowser network tracer, shows transfer-encoding "chunked". somehow seems hinder restsharp. running same request standard httpwebrequest works fine. ideas how solve restsharp? //edit: response should valid xml.

How to calculate the frequency of a list of symbols in Python -

i trying calculate frequency of amount of times each symbol shown in list. far have code doesn't seem work correctly because shows error message below... uniques = set(words.split()) attributeerror: 'tuple' object has no attribute 'split' this code far... def calculate_frequency(): words = () uniques = set(words.split()) freqs = [(item, words.split.count(item)) item in uniques] print(freqs) the symbols want know frequency of , stored in variable 'words' shown below... for frequency counts, use collections.counter() , , feed whole text; can remove newlines splitting , rejoining. i'm assuming words global string newlines it; split on newlines str.splitlines() : from collections import counter def calculate_frequency(): freqs = counter(''.join(words.splitlines())) symbol, count in freqs.most_common(): print symbol, count this produces frequency list sorted common least c

sparql - Using semantic ontologies to convert a Relational Database to RDF -

i have been lately trying describe given rdb(relational database) specific semantic ontologies, using virtuoso. ontologies want use are: dc,foaf,dct,bibo,cito(i new didnt quite understand if dc , dct same thing). have been following tutorial on how this: http://virtuoso.openlinksw.com/whitepapers/relational%20rdf%20views%20mapping.html problem in tutorial classes created 0 while need use existing ones. unfortunately not allowed post links of ontologies too. in particular want describe: an "author" table(a published paper author) has following columns: authorid, authorname, authormiddlename, authorsurname, authorurl, authoremail, department a "keywords" table(publication's keywords) columns: publicationid, keyword(type of string), keywordorder(type of integer), a "publications" table columns: publicationid, publicationtitle, mediatype(type of string), publicationtype(integer), mediatitle, mediapublisher, mediaeditors, mediavolinfo, p

c++ - std::nothrow pretty much useless? -

this question has answer here: will using new (std::nothrow) mask exceptions thrown constructor? 3 answers nothrow constant: constant value used argument operator new , operator new[] indicate these functions shall not throw exception on failure, return null pointer instead. but here in simple example, instead of returning null, new throws exception: struct somestruct { somestruct() { std::bad_alloc exception; throw exception; } }; int _tmain(int argc, _tchar* argv[]) { somestruct* somestruct; somestruct = new (std::nothrow) somestruct; return 0; } any explanation please? indicates, despite having (std::nothrow) parameter new still need put code in try...catch block. std::nothrow means instead of std::bad_alloc being thrown on failure acquire memory, new expre

Firefox addon submission gives error unable to contact server -

i built first forefox addon , trying submit when try submit if gives error your add-on failed validation 1 error. there problem contacting server. it doesnt give other error or warning. above error mean. did 1 else face problem? sounds temporary outage. or add-on crashes validator. having said this, isn't amo support forum... better suited places the amo forums , amo editors mailing list amo-editors@mozilla.org or #amo and/or #addons irc channels on irc.mozilla.org . you may run validator locally if you're adventurous, correct setup of tool can quite hurdle...

ruby on rails - Permission denied @ dir_s_mkdir /users/avatars | Localhost -

i used paperclip previous projects, first time i'm getting error permission denied @ dir_s_mkdir path = remove_tailing_slash(path) if mode dir.mkdir path, mode file.chmod mode, path else dir.mkdir path end i have absolutely no idea why happening. changed folders permission, still same. log user load (0.3ms) select "users".* "users" "users"."id" = 1 order "users"."id" asc limit 1 user load (0.1ms) select "users".* "users" "users"."id" = ? limit 1 [["id", 1]] (0.1ms) begin transaction command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/5y/y3_ztj_n1f1bd0rb5hz8v13h0000gn/t/ae5b47338477b229e55830edfaf08bce20140602-37437-ab9fw5.jpg[0]' 2>/dev/null command :: identify -format %m '/var/folders/5y/y3_ztj_n1f1bd0rb5hz8v13h0000gn/t/ae5b47338477b229e55830edfaf08bce20140602-37437-ab9fw5.jpg[0]' command :: id

java - Get Key-Value pairs in SimpleFormController from HTML table generated by jsp -

i have jsp page html table. table has 2 colums key-value. value input field , can changed user. <table> <tr> <td>key</td> <td>value</td> </tr> <tr> <td>property1</td> <td><input value="value1"/></td> </tr> <tr> <td>property2</td> <td><input value="value2"/></td> </tr> <!-- etc... --> </table> when submitting form onsubmit of simpleformcontroller triggered. here want to retrieve key-value pairs. preferably in map. i know how select parameters request through name attribute using getparameter() . don't see how can map keys corresponding values using name attribute. @override protected modelandview onsubmit(httpservletrequest request, httpservletresponse response, object command, bindexception errors) throws exception {

bookmarks - .CHM Help Files and Their Favorites -

i have huge list of favorites in big .chm file , know favorites attached hh.dat file in each users appdata folder. have found , see bookmark links when open hh.dat file in notepad. problem cannot find out how copy these computer. if try edit file, incorrectly , lose bookmarks on second computer. tips/tricks/help of kind? notepad doesn't seem program in, can't find else works better. in advance. the unofficial chm spec seems indicate hh.dat archive of same type(itsf) chm itself. if want write utility merge bookmark files, best place start studying. to best knowledge, open source write support these archives chm package free pascal .

authentication - Keep dropbox users authenticated in an OPA application -

i'm working on dropbox database example check out how authentication process works. see authentication retained long initial opa cookies valid. delete or cookie expires dropbox user no longer authenticated. it possible keep dropbox token quit long time , make service user friendly. is there way keep users authenticated in opa application. i've read code in opa dropbox api.

google bigquery - SQL Count the distinct values that accomplish two condition for a single row -

hello i'm using google bigquerry , i'm trying table total number of distinct values accomplish 2 values row. let's explain it: i have table like: userid | platform 123 | ios 123 | android 123 | other 124 | android 124 | ios 125 | android 125 | other 126 | other i want total number of users (distinct userid) have platform ios , android, both platforms not per separate. result should 2 in case. i tried with: select count(distinct a.grupo1) mytable b join each (select userid grupo1 mytable platform = 'ios' group grupo1) on a.grupo1=b.userid doesn't work :( i don't know bigquerry, since tagged question sql assume sql work. select count(distinct userid) ( select userid mytable platform in ('ios', 'android') group userid having count(distinct platform) = 2 )

magento attribute add error -

Image
sorry english bad. my problem: magento add attribute button gives error after. after pressing add button happening passive how can solve error check if nay module have inserting js on admin page, happened me couple of weeks ago.

c# - Update step in scenario in Add-in for Enterprise Architect -

i want update field "results" (ui) 1 of scenario steps defined element, not working. method "update()" (api) updated filed "results" instead "result". value "result" (database, t_objectscenarios.xmlcontent=>result) shown in ui. true? way updated field "results" (ui) using api? foreach (ea.idualscenario es in element.scenarios) { foreach (ea.idualscenariostep ess in es.steps) { if (ess.name.trim().length == 0 && ess.uses.trim().length == 0 && ess.results.trim().length == 0 ) { ess.name = "test_name"; ess.uses = "test_uses";

Cassandra read Column -

string cqlstatement = "select * local"; (row row : session.execute(cqlstatement)) { system.out.println(row.tostring()); } how each column value selected row ? if using cassandra ds-driver following should work you. string cqlstatement = "select * local"; (row row : session.execute(cqlstatement)) { row.getstring("columnname"); // string data type // row.getbool("columnname"); boolean data type // row.getuuid("columnname"); uuid type // row.getvarint("columnname"); int type // row.getlong("columnname"); long type // row.getdate("columnname"); date type // row.getbytes("columnname"); bytes/anonymous type }

reporting services - Why do some multiselect parameters show the selected values, and some don't -

Image
i'm @ loss here. i've got report multiselect parameters, , works, can't figure out why of parameters show selected values , don't. take following example: parameters dropdowns: notice par1 shows selected values "00400", "00540", etc in dropdown, par2 doesn't show anything, though items selected. both parameters properties pretty identical different queries. i've used same dataset available values , default values, each dataset doesn't return nulls. else can check? users confused i'm sure. thanks!

node.js - mapReduce not calling map nor reduce -

i started working mongodb , having troubles using mapreduce function. reason seems not calling map , reduce functions. here code: @getmonthlyreports: (req, res) -> app_id = req.app.id start = moment().subtract('years', 1).startof('month').unix() end = moment().endof('day').unix() console.log(start) console.log(end) map = -> geotriggers = 0 pushes = 0 console.log("ok") date = moment(@timestamp).startof('month').unix() campaign in @campaigns if campaign.geotriggers? geotriggers += campaign.geotriggers else if campaign.pushes? pushes += campaign.pushes emit date, geotriggers: geotriggers pushes: pushes reduce = (key, values) -> console.log("ok") geotriggers = 0 pushes = 0 value in values geotriggers += value.geotriggers

image - Convert RGB to HSV -

i want convert rgb values hsv values . if devide 9 28, octave calculate 0. can explain me reason?? function [hsv] = rgbtohsv() im = imread('picture.png'); r = im(:,:,1); g = im(:,:,2); b = im(:,:,3); len = length(r); % r, g, b should have same length = 1:len max = max([r(i),g(i),b(i)]); min = min([r(i),g(i),b(i)]); s = 0; if max == min h = 0; elseif max == r(i) disp(g(i) - b(i)); % 9 disp(max - min); % 28 h = 0.6 * ( 0 + ( (g(i) - b(i)) / max - min) ); % 0 disp(h) % why 0 if try calculate ( 0 + ( (g(i) - b(i)) / max - min)? .... end return; end endfunction rgbtohsv() chris :d you must cast image double doing: im = double(imread('picture.png')); this solve issues happens since image type uint8 .

Perl script to parse a text file and match a string -

i'm editing question add more details the script executes command , redirects output text file. the script parses text file match following string " standard 1.1.1.1" the output in text file : host configuration ------------------ profile hostname -------- --------- standard 1.1.1.1 standard 1.1.1.2 the code works if search either 1.1.1.1 or standard . when search standard 1.1.1.1 below script fails. this error "unable find string: standard 172.25.44.241 @ testtest.pl #!/usr/bin/perl use net::ssh::expect; use strict; use warnings; use autodie; open (hostrules, ">hostrules.txt") || die "could not open output file"; $hos = $ssh->exec(" typed command here "); print hostrules ($hos); close(hostrules); sub find_string { ($file, $string) = @_; open $fh, '<', $file; while (&