Posts

c# - Store DBContext Log in other EF table -

i want store logs in db table (imported ef code). my code looks this: public pmcontext() : base("myentities") { configuration.proxycreationenabled = false; configuration.lazyloadingenabled = false; this.database.log = s => logstore(s); } private void logstore(string message) { tlog log = new tlog(); log.description = message; log.insertdate = datetime.now; logs.add(log); savechanges(); } public virtual dbset<tlog> logs { get; set; } i cannot use savechanges() (get error "sqlconnection not support parallel transactions") , if remove line nothing stored in db table. how can fix this? i think happens during savechanges call anywhere in app, because sql generated call logged, triggers nested savechanges call tries start own transaction. and there thing: savechanges call in logstore method trigger logging itself, you'd end starting infin...

python - Scrapy spider memory leak -

Image
my spider have serious memory leak.. after 15 min of run memory 5gb , scrapy tells (using prefs() ) there 900k requests objects , thats all. can reason high number of living requests objects? request goes , doesnt goes down. other objects close zero. my spider looks this: class externallinkspider(crawlspider): name = 'external_link_spider' allowed_domains = [''] start_urls = [''] rules = (rule(lxmllinkextractor(allow=()), callback='parse_obj', follow=true),) def parse_obj(self, response): if not isinstance(response, htmlresponse): return link in lxmllinkextractor(allow=(), deny=self.allowed_domains).extract_links(response): if not link.nofollow: yield linkcrawlitem(domain=link.url) here output of prefs() htmlresponse 2 oldest: 0s ago externallinkspider 1 oldest: 3285s ago linkcrawlitem 2 oldest: 0s ago request ...

c# - SetBinding not registering for PropertyChanged event -

in application i'm working on, programmatically create several frameworkelements differing data sources. unfortunately, data binding failing. i managed distill problem following program: using system.collections.generic; using system.componentmodel; using system.runtime.compilerservices; using windows.ui.xaml; using windows.ui.xaml.controls; using windows.ui.xaml.data; namespace testbinding { public class bindingsource : inotifypropertychanged { public event propertychangedeventhandler propertychanged; protected virtual void onpropertychanged(string propertyname) { propertychangedeventhandler handler = propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); } protected bool setfield<t>(ref t field, t value, [callermembername] string propertyname = null) { if (equalitycomparer<t>.default.equals(field, value)) return false; ...

java - Creating signature with HMAC_SHA1 - Secret key expected exception -

i want create digital signature of signaturemethod.hmac_sha1, referred below program package com.sampel.test; import javax.crypto.mac; import javax.crypto.spec.secretkeyspec; import javax.xml.crypto.*; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dom.*; import javax.xml.crypto.dsig.dom.domsigncontext; import javax.xml.crypto.dsig.keyinfo.*; import javax.xml.crypto.dsig.spec.*; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.outputstream; import java.security.*; import java.util.collections; import java.util.formatter; import java.util.iterator; import javax.xml.parsers.documentbuilderfactory; import javax.xml.transform.*; import javax.xml.transform.dom.domsource; import javax.xml.transform.stream.streamresult; import org.w3c.dom.document; /** * simple example of generating enveloped xml * signature using jsr 105 api. resulting signature * (key , signature values different): * * <pre><code> *<envelope xmlns="ur...

php - How can I access an array/object? -

i have following array , when print_r(array_values($get_user)); , get: array ( [0] => 10499478683521864 [1] => 07/22/1983 [2] => email@saya.com [3] => alan [4] => male [5] => malmsteen [6] => https://www.facebook.com app_scoped_user_id/1049213468352864/ [7] => stdclass object ( [id] => 102173722491792 [name] => jakarta, indonesia ) [8] => id_id [9] => el-nino [10] => alan el-nino malmsteen [11] => 7 [12] => 2015-05-28t04:09:50+0000 [13] => 1 ) i tried access array followed: echo $get_user[0]; but displays me: undefined 0 note: i array facebook sdk 4 , don't know original array strucutre. how can access example value email@saya.com array? to access array or object how use 2 different operators. arrays to access ...

Android Google Analytics - App version reporting -

we integrated libgoogleanalyticsservices.jar in our app , working fine. default includes 'version_code' buildconfig.java when sending messages google analytics service. i'd include 'version_name' instead of 'version_code'. 1. there way project libgoogleanalyticsservices.jar? 2. there way configure libgoogleanalyticsservices class send version_name instead of version_code?

How to make an Webview based IOS app and being able to publish it -

i have website responsive. built app on android webview loads website. i same on ios know fact there lot of restrictions publishing web-view based application on app store. what can add webview in order gain approval sure ? i'm looking extremly lazy on this, there alternative may think of ? to answer or comments why bothering creating app if website enough. answer : commercial reason , user friendliness reasons add native controls or small features site doesn't have. add in native social sharing options, native navigation controls, etc. uber hybrid app , of instagram believe. however review process comes down reviewer, lax , not.

sqlite - using spinner on ListView with Sql lite in android -

my android app contains list view shows data base context. want: 1-when list view row gets clicked (itemclicklistener),the custom spinner shows. 2-when spinner item selected, title of shown in list view fields. 3-at last: color of rows change, when item selected. i've found solution no.1 in link don't know other two. please me solve these problems ?

java - NullPointerException when parsing XML data with geocoding API in Processing -

i using processing , loading data csv table, 1 column includes country names. each country trying use google geocoding api respective latitude , longitude values, getting nullpointerexception error. here code: import processing.xml.*; bubble[] bubbles; table table; void setup() { size(displaywidth, displayheight); loaddata(); } void draw() { background(255); (int = 0; < bubbles.length ; i++) { bubbles[i].display(); bubbles[i].rollover(mousex, mousey); } } void loaddata() { table = loadtable("terroristattacks.csv", "header"); bubbles = new bubble[table.getrowcount()]; (int = 0; < table.getrowcount(); i++) { tablerow row = table.getrow(i); float estimate = row.getfloat("estimate"); float diameter = estimate*0.17; string name = row.getstring("name"); string country = row.getstring("country"); int year = row.getint("date"); api_key = "my_api"; string...

python - Accessing BeautifulSoup elemets in django template -

i'm trying display results of soap request in django template. the results in xml i've used beautifulsoup process data , access beautifulsoup object in django template, looping through each element , calling child elements name so {% item in bs_data %} {{ item.child1.text }} {{ item.child2.text }} {% endfor %} i can in python, django template seems treat beautifulsoup elements if have no children, although loop through items in bs_data item.child1 empty item.0 i can't iterate through sub elements of each element. i've looped through elements in view , created nested lists achieve same result if knows how persuade django template parse beautiful soup objects i'm dying know. cheers edit ok below example xml can print different elements , step through elements printing text. below code: b = beautifulsoup.beautifulsoup("<note>\ <to>tove</to>\ <from>jani</from>\ <heading>reminder</heading...

apache - .htaccess 301 redirect http://olddomain.com/post/post-title to http://newdomain.com/story/post-title -

i trying redirect http://olddomain.com/post/post-title http://newdomain.com/story/post-title my .htaccess rule is: rewriteengine on rewriterule ^post/(.*)$ http://newdomain.com/story/$1 [l,r=301] but isn't working reason. can me out? you may need use rewritebase in code: rewriteengine on rewritebase / rewriterule ^post/(.*)$ http://newdomain.com/story/$1 [r=301,l]

How do I sum the total calculated values in a loop (Python 2.7) -

i trying sum total yearly rent period, using code shown below. any appreciated. rent_rate = input('please enter price per square foot:') # price sq/ft lease_rate = input('please enter rate of lease:') # interest rate lease_term = input('please enter tenor (in years) of lease:') size_of_space = input('please enter size(in square feet) of space:') print "year %25s" % "rent rate%25s" % "rate%25s" % "square feet%25s" % "yearly rent%25s" % "monthly rent" year in range( 0, lease_term ): rent_rate = principal * ( 1.0 + rate ) ** year yearly_rent = rent_rate * size_of_space monthly_rent = yearly_rent/12 print "%4d%21.2f%21.2f%21.2f%21.2f%21.2f" % ( year + 1, rent_rate, rate, size_of_space, yearly_rent, monthly_rent) i think need few things! should assign 'principal' 'rent_rate' because came out of thin air! also, if user inputs...

css - bootstrap icons not displaying -

i downloaded image bootstraps icons , use them in web page i have image, , correct css but arent displaying @ all. css .icon-home { background-image:url(../img/glyphicons-halflings.png); background-position: 0 -24px; } html <div class="col"> <span class="icon-home"></span> <p>pittsburgh, pa 15276</p> </div> fiddle https://jsfiddle.net/jwct6rmk/ i uploaded image imgur account. you'r missing styling.. display:block on span element. try this: .icon-home { background-image:url(http://i.imgur.com/umalj55.png); background-position: 0 -24px; width: 12px; height: 12px; display:block; } or better: .icon { background-image:url(http://i.imgur.com/umalj55.png); width: 12px; height: 12px; display:block; } .icon-home { background-position: 0 -24px; } .icon-car { backgrou...

c# - Selecting items in an ordered list after a certain entry -

i have ordered list of objects. can find item in list using following code: purchaseorders.firstordefault(x => x.ourref.equals(lastpurchaseorder, stringcomparison.ordinalignorecase)) what want select items in list appear after entry. how best achieve this? to index of item , select range? it sounds want skipwhile : var orders = purchaseorders.skipwhile(x => !x.ourref.equals(...)); once iterator has stopped skipping, doesn't evaluate predicate later entries. note that code include entry doesn't match predicate, i.e. 1 given reference. give entries order onwards. can use .skip(1) if want skip that: // skip exact match var orders = purchaseorders.skipwhile(x => !x.ourref.equals(...)).skip(1); this linear, mind you... if list ordered x.ourref find index binary search , take range there onwards... wouldn't unless find simpler code causes problems.

node.js - How do I route some URL patterns to a specific port? -

i have node server running on port 3000. i'll using handle apis, don't want urls in format example.com:3000/api/xyz i want in format: example.com/api/.. how route /api/ calls port 3000? example.com serving html pages, have nothing node. node used apis now. found varnish, looks overkill. an easy way put nginx in front of node server. you can setup nginx serve static media based on url patterns. can register non-static requests sent upstream node.js server on port 3000 node.js + nginx - now?

oop - Scala, how do I replace static members? -

i wan't build class animal can find number of animals created. in scala there no option static variable, how can implement such functionality in scala (i looking non-specific solution)? thanks! for example in java: public class amimal { static int number_of_aminals = 0; public animal() { number_of_animals++; } } one option be: import animal class animal { animal.increment() } object animal { private[this] var _count = 0 def increment(): unit = { _count += 1 } def count: int = _count } though might want use atomicint.

c++ - Destructor called twice causes crash -

i implemented constructor takes string argument, causes destructor called twice , program crashes (the program contains raw pointer). know has copy constructor somehow gets called when type of constructors used. below simple code illustrates problem. i appreciate comments on how fix program avoid crash. need use kind of constructors. understand why copy constructor gets called. didn't explicit assignment. #include <iostream> #include <fstream> #include <string> using namespace std; class debugclass { public: debugclass(void) { data = null; } debugclass(std::string str) { data = new double[2]; data[0] = 1.0; data[1] = 2.0; } debugclass(debugclass const& other) { cout << "copy construction\n"; } ~debugclass(void) { if (data) { delete [] data; data = null; } } double* data; }; int main() { debugclass ob...

spring - Issue with writing named sql query with hibernate -

i trying access database fk using named sql query hibernate, idea query customer table contains name, , companyid,etc. companyid fk commpany table. query wrote follows: @namednativequery(name="getcustomer", query="select customer.* customer,company customer_first_name = (?1) , customer_last_name= (?2) , customer_company_id_fk = (?3) ",resultclass=customer.class) the issue having follow: exception in thread "main" org.hibernate.queryparameterexception: position beyond number of declared ordinal parameters. remember ordinal parameters 1-based! position: 2 @ org.hibernate.engine.query.spi.parametermetadata.getordinalparameterdescriptor(parametermetadata.java:89) @ org.hibernate.engine.query.spi.parametermetadata.getordinalparameterexpectedtype(parametermetadata.java:109) @ org.hibernate.internal.abstractqueryimpl.determinetype(abstractqueryimpl.java:507) @ org.hibernate.internal.abstractqueryimpl.setparameter(abstractqueryimpl.j...

xml - How to select nodes with conditions based on attributes -

i want use xpath in xslt select nodes conditions based on attribute values. to illustrate question, have short example xml instance below: <?xml version="1.0" encoding="utf-8"?> <root> <elementa fid="2013_4_20150722_0" datetime="2015-07-13t01:04:20+02:00"/> <elementa fid="2013_4_20150721_0" datetime="2015-07-13t01:04:20+02:00"/> <elementa fid="2013_4_20150721_0" datetime="2015-07-20t14:14:22+02:00"/> </root> and want select elementa nodes following conditions: the attribute fid unique if there multiple elementa nodes same fid attribute value, 1 newest datetime selected. so in example want select first , third elementa . how can achieve xpath 2.0 in xslt 2.0? here pure, single , efficient (no sorting) xpath 2.0 expression , selects wanted elements: $fid in distinct-values(/*/*/@fid), $maxtime in max(/*/*[@fid eq $fid]/@...

php - Laravel parent/children relationship on it's own model -

i want vouchers have @ least 1 child, voucher can have multiple voucher children, voucher can have 1 parent. i set following models , calls, , query generates desired, until part: 'vouchers'.'parent_id' = 'vouchers'.'id' wanted functionality: $vouchers = voucher::has('children')->get(); or $vouchers = voucher::has('parent')->get(); resulted query select * `vouchers` `vouchers`.`deleted_at` null , (select count(*) `vouchers` `vouchers`.`deleted_at` null , `vouchers`.`parent_id` = `vouchers`.`id` , `vouchers`.`deleted_at` null ) >= 1 models: class voucher extends basemodel { public function parent() { return $this->belongsto('voucher', 'parent_id'); // return $this->belongsto('voucher', 'parent_id', 'id'); <- attempted din't work } public function children() { return $this->hasmany('voucher', 'p...