Posts

Showing posts from April, 2010

python - How to use Beautiful Soup's find() instead of find_all() for better runtime -

i writing webscraper using python's bs4. trying find first image has attribute 'data-a-dynamic-image'. far have code below, , works. but, prefer only use find() not find_all . because care first item on page attribute. don't want use find_all , waste time sifting through entire webpage. def siftimage(soup): try: line in soup.find_all('img'): if line not none: if line.has_attr('data-a-dynamic-image'): return line['src'] except: return 'no image ' this second function made return result want, if first image on page image want, otherwise return nothing. but, has runtime looking for. def siftimagetwo(soup): try: line = soup.find('img'): if line.has_attr('data-a-dynamic-image'): return line['src'] except: return 'no image ' i looking way have functionality of top script timing of bo

fortran - Type * error in gfortran -

when run code following error statements have following format. there problem type statement? if yes kindly provide me solution. running code on ubuntu 14.10 system. program long hence not posting if required can surely send it. recfunk_ascii.f:622.12: type *,'enter back-azimuth limits ib1,ib2 (integers!)' 1 error: invalid character in name @ (1) type obsolete , non-standard statement (see http://docs.oracle.com/cd/e19957-01/805-4939/6j4m0vnbi/index.html ). not portable because many compilers not recognize it. should changed print statement, @francescalus suggest in comment. print *,'enter back-azimuth limits ib1,ib2 (integers!)'

c++ - "Use of plus() is ambiguous" error -

i trying write function takes 2 numbers , prints out sum. #include <iostream> using namespace std; int plus(int, int); int main () { int a, b, result; cout << "2 numbrs"; cin>>a>>b; result = plus(a,b); cout << result; return 0; } int plus(int a,int b) { int sum; sum = a+b; return sum; } and error get: use of `plus' ambiguous it´s first c++ program , in fact getting blind finding error. either do result = ::plus(a,b); or rename function. lesson on why using namespace std not considered practice.

php - Symfony 2, switching language does not work -

i wonder why when click links on view switch language doesn't work. if set default locale en or km, show english language or khmer language respectively. wrong me, can not click links below switch language? please me ! many in advanced answer. in view <div class="col-sm-3 language-switcher"> <a href="{{ path('ngs_locale', {locale: 'en'}) }}">english</a> | <a href="{{ path('ngs_locale', {locale: 'km'}) }}">ខ្មែរ</a> </div> routing.yml ngs_locale: path: locale/{locale} defaults: { _controller: ngshomebundle:locale:locale } localecontroller.php namespace ngs\homebundle\controller; use symfony\component\httpfoundation\request; use symfony\bundle\frameworkbundle\controller\controller; class localecontroller extends controller { public function localeaction(request $request, $locale) { /** ======== dump ========== **/ dump($locale); //&qu

python - How to get output as a list after removing the duplicates in list? -

below python program remove duplicate ip addresses in list: dup_ip = ['1.1.1.1','2.1.1.1','1.1.1.1','3.3.3.3','2.1.1.1','1.1.1.1','3.3.3.3',] empty_list=[] in dup_ip: if not in empty_list: empty_list.append(i) print i getting output shown below: c:\users\test\desktop>python dup_list.py 1.1.1.1 2.1.1.1 3.3.3.3 c:\users\test\desktop> but want output list shown below: ['1.1.1.1', '2.1.1.1','3.3.3.3'] how this? you can print empty_list or better way is transform original dup_ip set , list if needed: >>> dup_ip = ['1.1.1.1', '2.1.1.1', '1.1.1.1','3.3.3.3', '2.1.1.1', '1.1.1.1', '3.3.3.3'] >>> unique_ip = list(set(dup_ip)) >>> print unique_ip ['2.1.1.1', '1.1.1.1', '3.3.3.3']

regex - How can Python's regular expressions work with patterns that have escaped special characters? -

is there way python's regular expressions work patterns have escaped special characters? far limited understanding can tell, following example should work, pattern fails match. import re string = r'this string ^g\.$s' # string search pattern = r'^g\.$s' # pattern use string = re.escape(string) # escape special characters pattern = re.escape(pattern) print(re.search(pattern, string)) # prints "none" note: yes, question has been asked elsewhere (like here ). can see, i'm implementing solution described in answers , it's still not working. why on earth applying re.escape to string ?! want find "special" characters in that! if apply pattern , you'll match: >>> import re >>> string = r'this string ^g\.$s' >>> pattern = r'^g\.$s' >>> re.search(re.escape(pattern), re.escape(string)) # nope >>> re.search(re.escape(

sql - Select multiple values from two tables using horizontal relation with other table -

Image
all experts pardon me subject not able figure out thing else explains scenario. i working old database has lot of crappy database issues. table structure table: brand id name muid (lpmap table lpid , same rest of four) mid wid bid gid table : lpmap lpid name asscoiate id (fk lpmapconfig) table : lpmapconfig > id lpid datecreated data posting images tabular representation of data desired output so wanted is- write sql query fetches id, name , count of (mid,meid, gid ,wid bid) if 5 have value count 5 1 of them null 4. select name, id, case when mid not null 1 else 0 + case when meid not null 1 else 0 + case when gid not null 1 else 0 + case when wid not null 1 else 0 + case when bid not null 1 else 0 end count brand

vb.net - Populate dropdown box from SQL Server using a function -

i trying follow video written in c# , convert vb (to populate dropdown box sql server using function) here working c# code: private list<product> getallprodcuts() { try { using(propsolwebdbentities db= new propsolwebdbentities()) list<product> products = (from x in db.product select x).tolist; } catch(exception) { return null; } } and vb cant work: private function getallproducts() list( of<product>) try dim db new propsolwebdbentities dim products list <product> = (from x in db.product select x).tolist return products catch ex exception return vbnull end try end function what doing wrong? list should translated list(of product). return null should translated return nothing. use using instead of declaring db variable. i don't compile code, it's this: private function getallproducts() list(of

CSV file seen as 'data' rather than 'ASCII' by OS after written via Python -

i'm using python 2.7.5 read in csv file (input.csv), ignore lines, , write result new csv file (output.csv). i've made many different attempts, result in output file being seen operating system (both red hat , mac os x) 'data', rather 'ascii text'. input.csv: cat -v input.csv (truncated) hkey_local_machine\software\microsoft\windows nt\currentversion\windows\spooler,yes,1^m hkey_local_machine\software\microsoft\windows nt\currentversion\windows\appinit_dlls,no,a^m hkey_local_machine\system\currentcontrolset\control\session manager,seed,0x714b3c99^m file input.csv input.csv: data script.py (latest attempt): import io input_file = '/users/spork_user/desktop/input.csv' output_file = '/users/spork_user/desktop/output.csv' io.open(input_file, 'r', newline='\r\n') infile, io.open(output_file, 'w', newline='\n') outfile: line in infile: #filters lines don't want, example: if &qu

scala - Play Framework: Logging time -

i've been using play framework many things, haven't come across in defining logging templates add timestamp log. services handle many requests/akka messages per minute, renders logging useless. example, use play logger bit this; logger.error("could not fulfil request", someexception) which how documentation goes. documentation specify, possible define own logging headers like; val exceptionlogger = logger("exception") // , exceptionlogger.error("while handling some/request", someexception) the log entries resulting above don't contain timestamp of sort; [error] exception - while handling some/request ... there's no mention of time whatsoever. now, workaround (not prettiest) like; def exceptionlogger = { val dt = new datetime logger(s"$dt exception") } which job, i'm not convinced. there better way format play's default logging behaviour? play uses logback, can configure log format in co

sockets - Python decoding UDP -

code: import socket, binascii, struct s = socket.socket(socket.af_inet, socket.sock_raw, socket.ipproto_udp) while true: print s.recv(2048) output: ek�9@@�f5��w�jq��� stackexchangecom� electronics � h h stackexchangecomda�scifi et@@�<���� stackoverflowcom���meta ,��� stackoverflowcom�a���meta ,��� stackexchangecomg��security ee@@�+���� stackexchangecom���scifi as can see of data has been decoded/interpreted rest isn't not sure why can help? you're printing raw udp packets, contain arbitrary binary data. of bytes in printable range, aren't in range converted �. you can better @ data printing representation , shows printable bytes normal , shows unprintable ones hexadecimal escape codes. that, change print statement to: print repr(s.recv(2048)) i suspect you'd decode packets. that's quite possible, it's bit technical, , should study topic bit first. :) artic

javascript - How to see if inner UL is expanded or collapsed -

<li class="setrelative"> <a class="tflink clickme current" data-toggle=".tflink1" id="current" href="javascript:void(0);"><img src="theimages/imgplus.png" id="imgfirstm" class="imgexpcol">header 1</a> <ul class="uspstyle uspinner" style="width: 80%;"> <li><a class="tflink clickme" title="sub-page" data-toggle=".tf1slink1" href="javascript:void(0);">sub-page</a></li> <li><a class="tflink clickme" title="test" data-toggle=".tf2slink1" href="javascript:void(0);">test</a></li> </ul> </li> by default uspinner class unordered list not displayed , expanded when clickme link clicked: $('.clickme').click(function () { var $this = $(this); $this.closest("li").find(&

core audio - IOS, AVAudioSession and Novocaine: how to set the sample rate dynamically? -

for pitch detection, use novocaine framework in order process data captured microphone. initially - overwrote original novocaine class in order set own (reduced) sample rate: _inputformat.msamplerate = preferred_sampling_rate;// own value _outputformat.msamplerate = preferred_sampling_rate; // own value i reduced sample rate 44100.0 / 4.0 in order capture low frequencies (s.th. between 20 hz , 100 hz). works fine! when try higher frequencies (s.th. starting 500 hz), deviations due low sample rate. need increase sample rate 44100.0 in order achieve more precision. my question: novocaine singleton, there way change sample rate dynamically within output block? as novocaine relies on avaudiosession, i've tried in vain following: [audiomanager setoutputblock:^(float *data, uint32 numframes, uint32 numchannels) { self->ringbuffer->fetchinterleaveddata(data, numframes, numchannels); [[avaudiosession sharedinstance] setpreferredsamplerate:new_sampling_rat

android - How can i save the image taken from camera intent to be used as a profile image? -

in app user can take image camera , use profile picture. works, except when user leaves app , returns image isn't there anymore. how can save image stay there when user exits app? code camera intent: intent cameraintent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, camera_request); and onactivityresult : protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == camera_request) { bitmap photo = (bitmap) data.getextras().get("data"); getlayoutinflater().inflate(r.layout.custon_header,null); imageview profimg = (imageview) findviewbyid(r.id.roundedimg); profimg.setimagebitmap(photo); could please assist me this? thanks data.getextras().get("data"); only returns thumbnail of image on low quality. have specify on camera intent location image saved: file outputfile = new file(environment.

mfc - CButton gets send WM_SETSTYLE to BS_DEFPUSHBUTTON Message when clicked -

i have several cbutton objects. when click them, send wm_setstyle message changing style bs_pushbutton bs_defpushbutton . change permanent , not go away when push button. cbutton* button = new cbutton; button->create(l"button", ws_child | ws_visible , crect( 10,10,100,100), this, idc_button); what cause behaviour? for testing purposes created new project scratch. there buttons don't changed. not able figure out, differently. in dialog or window child windows states handled wm_nextdlgctl respective cwnd::gotodlgctrl , cwnd::nextdlgctrl/prevdlgctrl you should never use setfocus in dialog when buttons involved.

php - Woocommerce email after product is out of stock -

is possible email people ordered product when product becomes out of stock? example: product has 15 in quantity. when reaches 0 sent emails people ordered product. i've found woocommerce_email_recipient_no_stock hook, i'm not sure how or if can use it. example appreciated. this has configured in woocommerce admin, go woocommerce > notifications , click on “add notification” button:enable notifications purchases,low stock,out of stock,backorders etc.

php - working with associations doctrine -

how can information form associating doctrine. here example ---- "entityuser" join "entityapartment" . many "user" can stay in same "apartment" . now user have unique id. all "apartment" values been set dynamically, apartmentid can set many user. so if want apartment name "entityapartment" how can information, because in "entityapartment"** there id, name, value , etc. how can associations value. if understand correctly, think want create manytoone relashionship between 2 entities. once created, not have think foreign keys, managed doctrine. can use property other. example : $user = new user(); $apartment = new apartement(); $apartment->setaddress('12 xxx street'); $user->setapartement($apartment); and can access user's appartment : // displays '12 xxx street' $user->getapartment()->getaddress(); hope helps.

wordpress - jQuery conflict? Using WPL -

typeerror: jquery('ul.tabs').tabs not function. (in 'jquery('ul.tabs').tabs('> .tabs_content')', 'jquery('ul.tabs').tabs' undefined) the gallery isn't showing here . i have updated theme , i'm using latest version of wpl. not jquery guru, it's kind of conflict. thoughts? much appreciated!

ios - What's the best approach to storing User Notifications in Parse? -

new parse backend , coding together... developing first ios app , i'm contemplating how should store data in parse. so want advice lovely, experienced developers. what's best way structure parse class(es) if want store comments, follow requests, favorites, etc. make simple when querying in alert tab within app. you don't want store alerts on parse rather send 1 alert via notification , it's payload , store locally.

c++ - Difference in constructors with X() = delete; and private X(); -

this question has answer here: which difference between declaring constructor private , =delete? 7 answers let assume have class x , want wo explicitly forbid, let standard constructor. used long time in header file: private: x(); // 1. so, contructor disabled outside class, anybody. have learned in c++11 follwoing recommended: x() = delete; // 2. both achive wish forbid standard contructor. but exact difference bewteen them? why c++11 recommend last one? there other flags, signals set in 2. way? example 1 way before had = delete came out in c++11. have = delete rid of constructor. making constructor private still use constructor in member function if try default object in member function = delete compiler error. #include <iostream> class foo { foo(); public: static void somefunc() { foo f; } }; class bar { public: ba

android - Run function depending on selected phone language -

is possible run function depending on selected phone language? i have 3 supported languages. have 3 different functions want run. thanks yes, it's possible that. first, system language using following snippet: locale.getdefault().getdisplaylanguage(); you'll string result, "en", "ru", "pt". , can use if statement call functions accordingly, or suggested on comments, can create generic function , call snippet inside of it. something like: void myfunction() { string mylocale = locale.getdefault().getdisplaylanguage(); if (mylocale.equals("en")) { // something. } else if (mylocale.equals("ru")) { // else. } } for more info on locale , please refer docs .

HTML/CSS problems table display -

i'm not able find way have 1 table 4 rows having same height (without using table tag). table included in div has table-cell display. i created jsbin: https://jsbin.com/jejupogodi/edit?html,output i want pink part take available height , each row inside should have 25% of height (whatever content length is). i tidied code bit. used vh (vertical height) instead of percentage. can run code snippet here fiddle .container { display: table; width: 100%; height: 100vh; background: lightgreen; } .focus { height: 500px; } .slidercontainer { display: table-cell; width: 40%; height: 100%; vertical-align: top; background-color: white; } .slider { margin: 0px; padding: 0px; list-style-type: none; display: table; height: 100%; width: 100%; } .slider li { display: table-row; cursor: pointer; heig

java - getting below exceptions when try to print bitmap from brother printer in android -

when try print bitmap brother printer ql-710w using net port in android facing below exceptions, if me on issue, grateful 07-23 18:11:16.752: e/androidruntime(15071): java.lang.unsatisfiedlinkerror: couldn't load createdata loader dalvik.system.pathclassloader[dexpathlist[[zip file "/data/app/com.splan.android-1.apk"],nativelibrarydirectories=[/data/app-lib/com.splan.android-1, /vendor/lib, /system/lib]]]: findlibrary returned null 07-23 18:11:16.752: e/androidruntime(15071): @ java.lang.runtime.loadlibrary(runtime.java:365) 07-23 18:11:16.752: e/androidruntime(15071): @ java.lang.system.loadlibrary(system.java:553) 07-23 18:11:16.752: e/androidruntime(15071): @ com.brother.ptouch.sdk.printermodel.(printermodel.java:30) 07-23 18:11:16.752: e/androidruntime(15071): @ com.brother.ptouch.sdk.communication.createprintermodel(communication.java:498) 07-23 18:11:16.752: e/androidruntime(15071): @ com.brother.ptouch.sdk.comnet$communicationthread.run(comnet.ja

jenkins - Not getting the coverage on new code in sonar dashboard -

i trying use scm activity plugin 1.8 clearcase , using sonar 4.3.3 , got blame information in sonar did not getting coverage on new code in dashboard you should add code coverage tool build process. if use maven, can add: <build> ... <plugins> ... <plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <version>0.7.5.201505241946</version> <executions> <execution> <id>jacoco-initialize</id> <goals> <goal>prepare-agent</goal> </goals> </execution> </executions> <configuration> <rules> <rule> <element>class</element>

Is Grails (using GGTS & MySQL) supposed to create a database -

i'm newbie , trying connect mysql database, i'm getting error "error 2015-07-23 07:53:55,288 [localhost-startstop-1] error pool.connectionpool - unable create initial connections of pool. message: unknown database 'mytest'" i understand need have database called mytest , don't know how ggts. advice appreciated! http://compiledammit.com/2012/08/12/connecting-grails-to-mysql-and-others/ perfect solution question. each , every step link ggts mysql mentioned.

php - Removing question mark from query string -

my goal: rewrite url host.com/?abc host.com/abc , able request via $_server['query_string']. found following rules: rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /?$1 [l,qsa] but whatever reason, $_server['query_string'] empty, unless put '?' in front of query string. when print_r( $_server ) or print_r( $_get ), query string not present anywhere. suggestions i'm doing wrong? thanks! update; i'm using nginx 'front' proxy , redirect requests apache using following rule: server { listen 80; root /var/hosts/hostcom; index index.php index.html index.htm; server_name host.com; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $remote_addr; proxy_set_header host $host; proxy_pass http://127.0.0.1:8010; } l

C++ Valgrind error Conditional jump or move depends on uninitialised value(s) -

i have problem c++ code valgrind giving me error (conditional jump or move depends on uninitialized value(s)) @ lines highlighted below. tried initializing " type " empty string, doesn't seems working. here appreciated. many in advance. nandanator int ab_cd::checktype(string & str) { int tmp = 0; string type; while (getnextsubstring(str, type)) { if (type == "aaa") <<<<< ----- valgrind error pointing here { tmp |= static_cast<int>(type_aaa); } else if (type == "bbb") <<<<< ----- valgrind error pointing here { tmp |= static_cast<int>(type_bbb); } else if (type == "ccc") <<<<< ----- valgrind error pointing here { tmp |= static_cast<int>(type_ccc); } else { //print warning } } return tmp; } bool ab_cd

Is it possible to set two website which are on different different hosting but with the single magento? -

is possible manage 2 websites on different hosting using single magetno? no, because if using different hosting means on separate servers , therefore not share single installation of magento.

php - Encapsulate instantiation arguments or make them explicit? -

my question regarding instantiation options... (i've written in php, question applicable general oop) take example domain object: class user{ private $id; private $name; private $email; ... etc } it instantiated in 2 places. controller: request comes in client side. controller extracts post variables, instantiates user object , passes down stack. data access layer: getuser() method called service. user data pulled db, , dal instantiates user object , passed stack. we have 2 options constructor option 1 public function __construct($id, $name, $email,...){ $this->id = $id; $this->name = $name; $this->email = $email; ... } in case controller instantiates object so: parse_str($_post['data'], $data); $user = new user($data['id'], $data['name'], $data['email'],...); and dal instantiates object so: $row = ...get row db... $user = new user($row['id'], $row['name'],

javascript - How to add an option to a html select, from input received from the user -

i have select client names populated sql database, part works fine, necessary add new client. want button displays popup user can provide new client name , have added select new option. below relevant code have tried. problem when either button pressed on prompt causes form submit , reloads page. in advance. <form action = "addnewjob.php" method = "post"> ... <td><?php echo $dropdown3 ?><button onclick="myfunction()">add new client</button> <script> function myfunction() { var client = prompt("please enter client name", "new client"); if ((client != null) && (!client.equals("new client"))) { var select = document.getelementbyid("client"); select.options[select.options.length] = new option(client, client); document.getelementbyid('newclientfield').value = client; } } </script></td> ... <p><input type=&q

sybase privileges grant from one shcema to another -

i have 2 schemas database1@server , database2@server . i want know how grant priveleges database2 read database1. example executing in database2: select * database1..table1 you have make sure user in database2 added database1 ( sp_adduser or sp_addalias ). you can find current user doing select user_name() , list of users within database executing sp_helpuser in database. assuming have db_user1 , dbuser2, add alias this: use database1 go sp_addalias db_user2, dbuser1 go from point forward, when db_user2 accessing database1, db_user1's credentials, rights , privileges. if add user, instead of adding alias, have grant privileges tables in schema user (or group user member of).

javascript - AngularJs: Calling Service/Provider from app.config -

i call service within app.config. when searching this, found this question solution tried follow (not accepted answer, solution below title " set service custom angularjs provider ") however solution , suggested alternative run problems when trying call service within app.config (the service not seem called @ all). new angular , javascript , don't know how debug (i using firebug). hope can me pointers , possibly solution. current code (trying implement "possible alternative" linked question: angular.module('myapp', [ 'ngroute', ]) .config(['$routeprovider', '$locationprovider', '$provide', function($routeprovider, $locationprovider, $provide) { $provide.service('routingservice',function($routeparams){ var name = $routeparams.name; if (name == '') {name = 'testfile'} var routedef = {}; routedef.templateurl = 'pages/' + name + '/' + name + '.html&#

Magento - Backend error after deleting store view -

i deleted store view in magento backend , since see message in backend: there has been error processing request exception printing disabled default security reasons. error log record number: 163892354656 the log file reads: a:5:{i:0;s:29:"invalid website id requested.";i:1;s:3722:"#0 /var/www/web18/html/hamburg/app/code/core/mage/core/model/app.php(950): mage::exception('mage_core', 'invalid website...') #1 /var/www/web18/html/hamburg/app/code/core/mage/core/model/store.php(469): mage_core_model_app->getwebsite('3') #2 /var/www/web18/html/hamburg/app/code/core/mage/tax/block/adminhtml/notifications.php(150): mage_core_model_store->getwebsite() #3 /var/www/web18/html/hamburg/app/design/adminhtml/default/default/template/tax/notifications.phtml(31): mage_tax_block_adminhtml_notifications->getwebsiteswithwrongdiscountsettings() #4 /var/www/web18/html/hamburg/app/code/core/mage/core/block/template.php(241): include('/var/www/w

c# - How to check the System.Net.Mail.SmtpClient.Credential -

i want check if have input right senderemail , mailpassword.what should do?the code : //邮箱地址//emailaddress string server = combobox.text; string sendermail = emailname.text.tostring().trim()+server; messagebox.show("邮箱地址为:" + sendermail); //邮箱密码//emailpassword string mailpassword = emailpassword.text.tostring().trim(); //发送服务器//senderserver server = server.substring(1); string sendserver = "smtp."+server; messagebox.show(sendserver); //新建smtp客户端实例//create smtpclient system.net.mail.smtpclient client = new system.net.mail.smtpclient(sendserver, 25); client.credentials = new system.net.networkcredential(sendermail, mailpassword); if (?????) { messagebox.show("success!"); } to check if senderemail correct can use mailaddress class try { new mailaddress(senderemail); } cat

c# - Regex to include and exclude by multi characters -

Image
i have string want remove negative values example, var mystring = "+colour:black +year:2015 -model:golf"; i tried using following regex doesn't work. var reg = "[+a-z:0-9]"; you can use var result = regex.replace(mystring, @"\s*[-][^\s]*\s*", string.empty); for positive values: var result = regex.replace(mystring, @"\s*[+][^\s]*\s*", string.empty); for both positive , negative: var result = regex.replace(mystring, @"\s*[+-][^\s]*\s*", string.empty); this way, handle stray hyphens no characters whitespace after them, , \s* trim output string remanining spaces. notes on regex : [-+] matches either - or + once, \s* matches 0 or more whitespace, , [^\s]* matches 0 or more characters other whitespace. see demo

linux - How to connect MongoDB with Qt c++ ? -

i trying connect mongodb qt c++. wrote simple application runs without error. mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); try { connectmongo(); qdebug() << "connection done"; } catch (const mongo::dbexception &e) { qdebug() << "failed : " << e.what(); } } void mainwindow::connectmongo() { mongo::dbclientconnection c; c.connect("127.0.0.1"); } however, when type "127.0.0.1" or "localhost" cannot connect , in debug windows says: the program has unexpectedly finished. when type value c.connect("0.0.0.0"); it goes in catch block , exception : failed : can't connect couldn't connect server 0.0.0.0:27017 as far understand works correct port number, describing on mongodb api default. why cannot use mongodb , cannot connect it? here output of

c# - SMTP mail to pickup and send from exchange -

i have created simple mail service c# connects smtp , sends mail. connecting smtp slow method. changed delivery settings web.config specifiedpickupdirectory. <system.net> <mailsettings> <smtp deliverymethod="specifiedpickupdirectory" > <specifiedpickupdirectory pickupdirectorylocation="c:\myemails"/> </smtp> </mailsetting> ... </system.net> my application writes email contents *.eml files disc. is there way sending these emails automatically exchange server service. yes, it's simple. download exchange webservice dll(s) here: https://www.microsoft.com/en-au/download/details.aspx?id=35371 reference dll(s) in projects , send emails using code that's smtp client.

excel - Find last filled row without opening file and with conditions -

what wish : i. locate excel document using path , doc name √ ii. obtain last filled row’s number spreadsheet name without opening file x iii. obtain last filled row's number before row number, x ex: last filled row before row 40. there may filled cells between 45-52, function return "32" , not "52" me what have: the path file classic directory + file name, written in 2 separate cells in spreadsheet has macro. it's irrelevant, show file_path = path ... file_path = chr(34) & server & "\" & range(workbook_loc).value 'that's step 1 in file located @ file_path, wish go in spreadsheet named month year (ex: file_path("july 2015")) , find last filled row's number. in 3rd line, try fill cell last row's value in b. know there lot online this, can't work somehow...: set wb = workbooks.open(file_path) ' should open workbook lastrow = wb(chr(34) & month & " " &

html - Links not working in my error page -

i have created personalised error 404 page , redirected through htaccess file. when error tiped main folder, links work perfectly. ex: www.domain.com/tipingerror.hmlt but when error tiped subfolders, links not work. ex: www.domain.com/folder/tipingerror.lhtm links in 404 page like: <li> <a href="../ordenador/castellano/contacto.html">contact</a> </li> does have solution problem? relative paths don't work if url has different folder depth. change them absolute paths like <li> <a href="/ordenador/castellano/contacto.html">contact</a> </li> here cool article relative / absolute paths. might if have more issues.

wso2esb - Xerces error while processing IDocs with WSO2 -

i have problem processing idocs wso2 esb 4.8.1. each time idoc empty segments (which seems valid idoc) incoming xerces throw error: error - axis2idochandler error while processing idoc through axis engine java.lang.nullpointerexception @ com.sun.org.apache.xerces.internal.impl.xml11nsdocumentscannerimpl.scanstartelement(xml11nsdocumentscannerimpl.java:351) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next(xmldocumentfragmentscannerimpl.java:2756) @ com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl.next(xmldocumentscannerimpl.java:647) @ com.sun.org.apache.xerces.internal.impl.xml11nsdocumentscannerimpl.next(xml11nsdocumentscannerimpl.java:852) @ com.sun.org.apache.xerces.internal.impl.xmlstreamreaderimpl.next(xmlstreamreaderimpl.java:554) @ org.apache.axiom.util.stax.wrapper.xmlstreamreaderwrapper.next(xmlstreamreaderwrapper.java:225) @ org.apache.axiom.util.stax.dialect.disallowdoctypedecl

eclipse jdt - Find MethodInvocation method bindings in JDT ASTVisitor -

i have java file uses java.sql.statement.execute below. public class dummy { public void execute(string q) throws sqlexception { ... statement stmt = conn.createstatement(); ... stmt.execute(q); ... } } my use case want identify classes , method names use "statement.execute(string)" using jdt astvisitor. possible? i found below entry using eclipse astview plugin. method binding: statement.execute(string) how can method binding value in astvisitor. i tried this. @override public boolean visit(methodinvocation node) { imethodbinding imethod = (imethodbinding) node.resolvemethodbinding(); if(imethod != null) system.out.println("binding "+imethod.getname()); return super.visit(node); } but node.resolvemethodbinding() returns null. ... want identify classes , method names using "statement.execute(string)" this sounds job org.eclipse.jdt.core.search.searche

c# - WCF The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025) -

Image
i have simple update method below: public static void execute() { var conn = new sqlconnection(connectionstring); conn.open(); var cmd = new sqlcommand(updatequery, conn); cmd.executenonquery(); } case 1 when call method console application works expected. since not complete transactionscope update rollbacked. using (new transactionscope()) { testupdate.execute(); } case 2 i create wcf service , call method inside wcf operation below. again works expected. since not complete transactionscope update rollbacked. // interface [operationcontract, transactionflow(transactionflowoption.allowed)] void dowork2(); // implementation public void dowork2() { using (new transactionscope()) { testupdate.execute(); } } // console app var client = new staticserviceclient(); client.dowork2(); case 3 i start transaction in console application , call service console application in transaction. when debug can see transaction.current not nu

Error when generate APK in Android Studio -

i want generate apk , use proguard obfuscate project. when generate apk, error progurad. attached error picture in under link, please see , me : error image link : image link highlights different parts bookmarks

r - Comparing plot variables with average results -

Image
provided following dataframe have been able create following plot: library(ggplot2) df = read.csv("http://pastebin.com/raw.php?i=mltkev3z") ggplot(df, aes(x = factor(identificación.con.el.barrio), fill = nombre.barrio) ) + geom_histogram(position="dodge") + ggtitle("¿te identificas con tu barrio?") + labs(x="grado de identificación con el barrio", fill="barrios") resulting in following plot: however, add new column average results per each observation "grado" variable (with no stratification per neighborhood - aka"barrio"), able compare each neighborhood result city's. could me in how achieve that? not elegant, works. involves changing original data around make frequency table, adding group averages. necessitates using geom_bar() in ggplot instead of geom_histogram(). result identical. # make frequency table of data library('plyr') df2 <- ddply(df, .

sql server - How to modify my T-SQL UPDATE query by adding a CONDITIONAL clause? -

i'm using sql server 2014 , have update query runs on table called "resstaydate" (extract shown below): id staydate rateamount ----------------------------------- 256 2015-11-28 248.00 256 2015-11-29 248.00 256 2015-11-30 248.00 256 2015-12-01 0.00 256 2015-12-02 0.00 256 2015-12-03 0.00 i need update rateamount column , update query follows: use mydatabase update resstaydate set rateamount = case resid when 256 155.00 else rateamount end my problem if run query "as is", update rows 155.00. need update rows staydate in december 2015. output should this: id staydate rateamount --------------------------------- 256 2015-11-28 248.00 256 2015-11-29 248.00 256 2015-11-30 248.00 256 2015-12-01 155.00 256 2015-12-02 155.00 256 2015-1

Cannot post to asp.net MVC controller -

here request definition: params = typeof params !== "undefined" ? params : {}; var deferred = $q.defer(); var response = $http({ method: "post", datatype: "json", data: json.stringify(params), headers: { 'content-type': "application/json; charset=utf-8", }, url: 'apiurl' + 'mvccontrollername' + '/' }); and c#: public class mvccontrollername : controller { public actionresult index(int? id = null) { ....... i not getting id parameter in controller class. it's null. parameter defined {id:1}. tested post chrome rest client same results. any idea, what's wrong? i see couple of issues here. first name of controller should follow convention of somenamecontroller , might want call mvccontrollernamecontroller the url specify missing slash delimit between path , controller name: url: 'apiurl' + '

Does jQuery .remove() clear out loaded javascript when it is used to remove a script tag? -

as title says, if remove script tag dom using: $('#scriptid').remove(); does javascript remain in memory or cleaned? or... misunderstanding way in browsers treat javascript? quite possible. for interested in reason asking see below: i moving common javascript interactions static script files dynamically generated ones in php. loaded on demand when user requires them. the reason doing in order move logic serverside , and run small script, returned server, clientside. rather have large script contains huge amount of logic, clientside. this similar approach facebook does... facebook talks frontend javascript if take simple dialog instance. rather generating html in javascript, appending dom, using jqueryui's dialog widget load it, doing following. ajax request made dialog.php server generates html , javascript specific dialog encodes them json json returned client. html appended <body> once rendered, javascript appended dom. the javascr

android - Implement a contextual action bar to recyclerview -

how can add contextual action bar recyclerview handle long press on items allow user delete them? have working recyclerview have used library https://github.com/afollestad/material-cab ? you should refer following link http://www.edumobile.org/android/contextual-action-bar-cab-part2/ explain contextual action bar in details it worked me

how to export data from mysql using php -

i wanted fetch data database , data downloadable in text format. for using <?php $filename="abc.txt"; header("content-disposition: attachment; filename=\"$filename\""); header("content-type: text/csv"); echo "php awesome"; ?> the above code providing option download file. but when trying add database connection in code time not getting download option. need solve above problem. my error code: <?php $filename="abc.txt"; header("content-disposition: attachment; filename=\"$filename\""); header("content-type: text/csv"); $name="jone": $db_host =hostname; $db_user =username; $db_pass =password; echo "$name"; mysql_connect( $db_host, $db_user, $db_pass ); $sql_query="select * order"; echo "$sql_query"; $result = mysql_query($sql_query) or die('mysql error' . mysql_error()); while ( $array = mysql_fetch_array($result) ) { echo

javascript - Removing extra characters from name of checkboxes -

iv'e got problem characters in names of checkboxes. there line var string = "<div class="blblb"><input type="checkbox" name="dasdasads"><input type="checbox" name="adsdsada"></div>"; the question is, how remove if exist characters ,,string,, names of checkboxes ? characters " , ' i'm looking on google , can't find anything. var string = "<div class=\"blblb\"><input type=\"checkbox\" name=\"dasdasads\"><input type=\"checbox\" name=\"adsdsada\"></div>"; escape using \

r - Decompose xts hourly time series -

i want decompose hourly time series decompose , ets , or stl or whatever function. here example code , output: require(xts) require(forecast) time_index1 <- seq(from = as.posixct("2012-05-15 07:00"), = as.posixct("2012-05-17 18:00"), by="hour") head(time_index1 <- format(time_index1, format="%y-%m-%d %h:%m:%s", tz="utc", usetz=true) # [1] "2012-05-15 05:00:00 utc" "2012-05-15 06:00:00 utc" # [3] "2012-05-15 07:00:00 utc" "2012-05-15 08:00:00 utc" # [5] "2012-05-15 09:00:00 utc" "2012-05-15 10:00:00 utc" head(time_index <- as.posixct(time_index1)) # [1] "2012-05-15 05:00:00 cest" "2012-05-15 06:00:00 cest" # [3] "2012-05-15 07:00:00 cest" "2012-05-15 08:00:00 cest" # [5] "2012-05-15 09:00:00 cest" "2012-05-15 10:00:00 cest" why timezone time_index change c

Parse xml node children list by tag with any prefix in python -

i got list of items, independently of prefixes. goal create method (please notice me if exist), has 1 argument(tagname) , returns list of elements. for example in case of argument 'item' <media:item> , <abc:item> should part of result of function. it nice use lxml can python dom-based parser. unfortunatuly can't assume, xml has xmlns, that's why need parse prefix. lxml option because has full support xpath version 1.0 via xpath() method besides many other useful utilities. , in xpath, can ignore element namespace using local-name() mentioned in comment. lxml able deal undefined prefix setting parameter recover=true , comes catch; local-name() still return prefixed 'tagname' element having undefined prefix. there hacky way match kind of element, finding element local name contains :tagname -or more precise, find element local name ends with :tagname instead of contains -. the following working example demo. demo uses 2

How to change location of the Application.groovy class in Grails 3.0.3? -

i've created new application in grails 3.0.3 using console: grails create-app hello and it's running fine with: grails run-app but now, change package name application.groovy located (original location hello/grails-app/init/hello/application.groovy) else, eg hello/grails-app/init/foo/application.groovy. when i'm trying start application after change there exception: error: not find or load main class hello.application source of application.groovy file (generated grails, except package name) package foo import grails.boot.grailsapp import grails.boot.config.grailsautoconfiguration class application extends grailsautoconfiguration { static void main(string[] args) { grailsapp.run(application, args) } } any hints should change able rename package? edit: in documentation there fragment: grails-app/init/package_path/application.groovy application class used spring boot start application but still don't know package_path , how set t

java - Spring Data Solr : Unable to locate Attribute from Repository -

this working fine until manage migrate spring boot. before using version spring-data-solr version : 1.4.0.release , boot got version 1.3.3 . i tried remove spring-boot-starter-data-solr , reset static definition got same issue.. update current pom.xml : <project> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.2.5.release</version> </parent> <repositories> <repository> <id>excilys-release</id> <url>http://repository.excilys.com/content/repositories/releases</url> </repository> <repository> <id>repo2_maven_org</id> <url>http://repo2.maven.org/maven2</url> </repository> <repository> <id>maven-restlet</id>