Wednesday, 15 May 2013

c++ - CComBSTR memory leak and assignment -



c++ - CComBSTR memory leak and assignment -

i debugging old c++/com code without having much com experience.

is right code below leak (the empty string lost)? is right , safe assign value of ctext myccombstr in way?

code:

tchar ctext[max_path] = {0}; ccombstr myccombstr(l""); functionthatfillsdataintextbuffer(&ctext[0]); myccombstr = ctext; // empty string leaked?

when assign array ccombstr free holding, can in header see how things implemented:

ccombstr& operator=(_in_opt_z_ lpcolestr psrc) { if (psrc != m_str) { ::sysfreestring(m_str); if (psrc != null) { m_str = ::sysallocstring(psrc); if (!*this) { atlthrow(e_outofmemory); } } else { m_str = null; } } homecoming *this; }

c++ memory-leaks com

Is RDF/OWL a representation or the database? -



Is RDF/OWL a representation or the database? -

the rdf defined representing info related semantic web , info exchange on web. used database. so, rdf ?

the owl similar rdf, why rdf used in database , not owl ?

asking rdf exclusively broad of question, there a lot in regard. i'll effort briefly reply specific question.

an rdf database, graph database, stores rdf graph can utilize sparql query. rdf isn't the database, it's info model.

owl has mapping rdf, generally, used define logical constructs reasoner can utilize infer new info existing data. rdf databases include reasoner can take advantage of owl, serialized rdf, perform reasoning either @ query time, or eagerly during info updates, expose new, inferred information, users via sparql.

database rdf semantic-web owl

java - Why Spring throws exceptions when No default constructor is found -



java - Why Spring throws exceptions when No default constructor is found -

a simple test shopping application have 2 classes clothing , offers. on calling formalshirt bean, throws next exception

caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'diwalioffer' defined in class path resource [spring.xml]: instantiation of bean failed; nested exception org.springframework.beans.beaninstantiationexception: not instantiate bean class [offers]: no default constructor found; nested exception java.lang.nosuchmethodexception: offers.<init>()

now if comment offers constructor, app runs successfully. query why spring looks default constructor when there constructor?

clothing class

public class clothing { private int price; private list<offers> offer; public void setoffer(list<offers> offer) { this.offer = offer; } public void setprice(int price) { this.price = price; } }

.

offers class

public class offers { private int discount; private string promocode; public offers(int val1, string val2) { this.discount=val1; this.promocode=val2; } //public offers(){} /*default constructor added due spring exception in below */ /* caused by: org.springframework.beans.beaninstantiationexception: not instantiate bean class no default constructor found */ /* caused by: java.lang.nosuchmethodexception: com.test.shopping.offers.<init>() */ public void setdiscount(int discount) { this.discount = discount; } public void setpromocode(string promocode) { this.promocode = promocode; } }

spring.xml

<bean id="formalshirt" class="com.test.shopping.clothing"> <property name="price" value="800"></property> <property name="offer"> <list> <ref bean="diwalioffer" /> </list> </property> </bean> <bean id="diwalioffer" class="com.test.shopping.offers"> <property name="discount" value="10"></property> <property name="promocode" value="diwali"></property> </bean>

you need alter spring xml configuration of offers to:

<bean id="diwalioffer" class="com.test.shopping.offers"> <constructor-arg value="10"></constructor-arg> <constructor-arg value="diwali"></constructor-arg> </bean>

the way have configured it, spring first attempts phone call default constructor , phone call setters. of course of study there no default constructor, , there fore spring reports exception.

another alternative if using spring 3+ utilize java config, instead of xml config. have

@configuration public class appconfig { //add other beans @bean public offers diwalioffer() { homecoming new offers(10, diwali); } }

in case java config has benefit configuration not compile if didn't phone call constructor, ie. fail instead of fail late xml configuration

spring extremely flexible how creates beans, need declare how done

java spring

Get running python server IP address in Javascript -



Get running python server IP address in Javascript -

i have python flask app running on server:

if __name__ == '__main__': port = int(os.environ.get("port", 6600)) app.run(host='0.0.0.0', port=port)

and have js script getting info app, don't want alter manually th ip or domain in js script every time deploy or alter domain i'm asking there way js know ip or hostname of python app ? here's structure: index.py <= main app static **index.html **script.js

thanks

register domain name , stick it. utilize domain name in javascript and/or config.

make sure registrar provides interface updating "a record" (ip address) , point @ server. whenever alter ip address, update record domain.

javascript python flask

c# - DataTable HTML in Add Rows new object[] -



c# - DataTable HTML in Add Rows new object[] -

i created datatable , adding new rows new object[].

datatable dt = new datatable(); dt.rows.add(new object[] { "hello", "world", "<i>test</i>" });

in object[] array got values shown in datatable.

i add together html styling, possible above? have test shown italic.

thanks in advance.

the datatable stores data, it not responsible format or styling. depends on want diplay it, if it's asp.net-gridview utilize rowdatabound event. httputility.htmldecode should work prevent html encoded:

protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { e.row.cells[0].text = server.htmldecode(e.row.cells[0].text); } }

c# html asp.net gridview datatable

css - twitter bootstrap align tables side by side -



css - twitter bootstrap align tables side by side -

is there anyway can lineup tables side side in twitter bootstrap, want accomplish this:

thank much in advance!

never mind googled span* class in twitter bootstrap depreciated , replaced col-md-* function , it's other counterparts.

i have solved problem wrapping 2 tables in

<div class="col-md-*">

i have used first table:

<div class="col-md-3"> <table>....</table> </div>

and sec table

<div class="col-md-9"> <table>....</table> </div>

css twitter-bootstrap asp.net-mvc-4

sql - Huge amount of updates and postgresql -



sql - Huge amount of updates and postgresql -

currently have situation, makes me scared. have 20k rows in db, isn't 1% of data, have in next 3 months. each row represents object(let's phone call object1) data. also, have table stats each object1, let's phone call object1stats, located in mongodb. have object1stats each day, get, example, total stats, should sum every object1stats object1.

the problem is: need have info precalculated. example, display user, ability sort object1 collection stats. load , sort in code, with, example, 5 millions object1, expensive.

so, came thought of precalculating stats each hour(object1stats updated twice in hour), each object1. process makes me afraid of time need perform everything... should take each object1, send query mongodb sum object1stats, create sql update object1. repeat at least 3 1000000 times.

i have 2 bottlenecks here: calculation of sum(mapreduce) in mongodb , sql update queries in postgre. can't speedup mapreduce now(i assume good), i'm thinking sql updates.

any thoughts or suggestions? take anything, suggestions utilize different db or approach.

also, can't add together new stats info object, because lastly day stats can changed often, , previous days stats can changed too.

some ideas on postgresql end:

use copy load fresh info temporary table, update objects single query. it's faster issuing every update separately. see this answer. (if driver allows it, besides re-create , multi-valued insert options there's alternative pipeline).

keep updated part of object (the stats) in separate table.

if sure all objects updated, might want load updated stats copy , switch tables (drop table stats; alter table new_stats rename stats).

if, on other hand, updating stats in well-defined batches (e.g. first update stats of objects 1..99999, update stats of objects 100000..199999, , on), might partition stats table according these batches.

another angle load stats straight mongodb, on demand, using foreign table wrapper. might want utilize stored procedure accessing stats cache stats in local table. updating stats paramount truncating cache. downside of approach postgresql issue separate mongodb request every stat fetches, if queries need touch lot of stats approach might worse hourly batch update.

yet way create mongodb "river", driver force stat changes postgresql occur in mongodb. way you'll pay use, updating postgresql objects indeed changed in mongodb. load less rough. imo preferred way, don't know how hard create "river" driver.

p.s. here's blog post using notify update es: http://evol-monkey.blogspot.ru/2014/08/postgresql-and-elasticsearch.html

sql database mongodb postgresql optimization