Posts

Showing posts from July, 2014

c - ERROR: variable "string" is not initialized -

i wrote code reads .txt string , settles in char *, gives me error variable "string" not initialized, if initialized inside fscanf, can u tell me wrong? thanks! char *string; file *fp = fopen("words.txt", "r"); fscanf(fp, "%s", string); that's normal, didn't allocate string. c needs allocate in memory before use it. have know size. in code, string points memory doesn't exist (to exact points somewhere have lot of chance can't access it) see how malloc works.

ios - receiving response from json webservice using unknown key -

this question has answer here: nsdictionary order not match allkeys order 2 answers i receiving response json web service , able parse it. when parsing json data using [mydic allkeys] (as unknown keys parse using allkeys method) gives me response changes order of receiving keys. so want order should not changed. if knows solution please help. thanks. this known behavior. documentation states: allkeys property a new array containing dictionary’s keys, or empty array if dictionary has no entries the order of elements in array not defined.

android - How to disable key preview in popup keyboard (not in main softkeyboard layout)? -

it's easy disable key previews: call setpreviewenabled(false) , these annoying tiny previews won't show anymore. if attach popup keyboard key these previews show inside popup: qwerty.xml: <key android:codes="101" android:keylabel="e" android:popupkeyboard="@xml/popup" android:keytextsize="60sp"/> popup.xml: <row> <key android:codes="-10000" android:keylabel="test" android:keyoutputtext="test"/> </row> <row> <key android:codes="-10001" android:keylabel="test2" android:keyoutputtext="test2"/> </row> can't post images, if long press letter 'e' , press test or test2 button show white key preview. is there way disable these key previews too? create customkeyboard setpreviewenabled(false) add rows inside customekeyboard in popup.xml below <customkeyb

javascript - TinyMCE editor in WordPress is not loading correctly -

Image
i've encountered problem yesterday when uploaded files testing website. website running on wordpress version 4.2.2. , i'm using own theme i've been developing 1 client. now problem tinymce editor in wordpress started acting weird. here picture of local deployment of site: on local works fine. no problems or anything. here picture of online deployment: as can see there problem it. text , visual buttons not rendered correctly , they've switched places. when click on visual nothing in editing area , on text there 1 small part of post's content. now i've tried know solve problem. here list of have tried far: uploaded theme , tried switching theme check if problem in theme. no luck. problem remains. i've tried disabling parts in theme check if solve problem. still no luck. today i've deleted live database , whole wordpress folder on web server , uploaded again. problem still remains. i have no clue caused problem @ all. have 1 pl

associations - Where should I add data for an associated model in cakephp-3 -

i create few default entities users when register account, example being profile, there no data user registration form, user entities should have profile still seems fitting create it. before 'but there no data, cope in controller/views' - yes know, not use cases allow it, , require empty/default data. is should added data register form in controller, before doing save? me seems more logical there should in model says valid user has profile, , if there no data there create (perhaps using username profile full name). is achievable in beforesave callback or controller? is there minimum need have in patchentity related entity save (my current attempts have profile in debug, none of data thought setting, nothing saves) many thanks i hope got questions right. yes why shouldn't possible? create associated( http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-with-associations ) entry , make fields nullable. to save related should follow conventio

oracle10g - org.hibernate.HibernateException: Dialect class not found when using custom Dialect -

hello i'm trying find solution oracle conversions problem (doesn't accept "number" double) jboss 7.1 , hibernate. so, best suggested solution make custom dialect way : public class myoracle10gdialect extends oracle10gdialect { public myoracle10gdialect() { super(); } protected void registernumerictypemappings() { super.registernumerictypemappings(); registercolumntype( types.double, "number" ); }} in hibernate.cfg.xml added : <property name="hibernate.dialect">com.d2i.sssim.hibercommun.myoracle10gdialect</property> but got : org.hibernate.hibernateexception: dialect class not found: com.d2i.sssim.hibercommun.myoracle10gdialect it's same project, hibernate connection. should create project 1 class (myoracle10gdialect) , include in project lib? why hibernate.cfg.xml can't see classes in it's own project? help? you may using hibernate jboss module , such cannot see custom class in applic

javascript - jQuery resizable synch resize -

Image
i ask if how can fix resizable jquery. want if resize parent element resize children inside of parent element. here's current code: <div id="img_holder" style="width:100px;height:120px;float:left;margin:5px;"> <a href="#" target="_blank" class="thumbnail" style="text-decoration:none;height:120px;"> <img src="suits.jpg" style="height:110px !important;" /> </a> </div> $("#img_holder").resizable({alsoresize: "#img_holder a, #img_holder img"}); here's output when resizing thank you! the anchor , images in example have preset height , not going resize height larger set height. notice img height set using !important .

iphone - Missing icon and storyboard files, iOS 7 and 8, Xcode 6 -

Image
i'm trying submit ios app made xcode 6 using application loader. app works in simulator , in iphone , passes validation in organizer. however, application loader errors missing icons , storyboard files: missing required icon file. your binary not optimized iphone 5. storyboard file 'main~iphone.storyboardc' not found. storyboard file 'main~ipad.storyboardc' not found. i've gone through stackoverflow , googling, nothing far has helped. i'm targeting ios >= 7.0 i'm not sure why these errors icon files. have ticked off icons ipad , ios < 7.0 , provided sizes of rest of icons in image.xcassets folders appicon , launchimage. far know, don't need specify particular filenames long i'm using asset catalogs, drag , drop icon files. provided icons ios 6, didn't remove error. tried add default* files in here , without luck. last url in error message doesn't work. missing in info plist? i tried rename storyboard file main~i

Clicking an email verification link using jmeter -

i have test plan in jmeter following: uses mail reader sampler retrieve email gmail account. uses regular expression extractor grab verify email link , set variable 1-3 work fine problem having when verify mail link captures protocol https:// once try using http sampler link http:/"https:followed url. how can either exclude http: protocol regular expression or there sampler can use click link response parsing: href="https://qa4.iqnavigator.com/routing/ytmzythjyzctnjiyny00mwrmltlhogitotdinwvjmdy1ywfm"> the regular expression using: "([^"]+?)" , captured: https://qa4.company.com/routing/ytmzythjyzctnjiyny00mwrmltlhogitotdinwvjmdy1ywfm any ideas i believe solution issue careful use of character groupings , jmeter's "template" feature of regular expression extractor. for example, regex: https://([^/]*)/ using template: $1$ this match urls, not include "https://" part or path after host, in actual

nginx basic auth don't work on windows -

this part of nginx conf (window2003 server) server { listen 80; server_name xxx.example.com; access_log logs/example.com.log; location / { auth_basic "restricted"; auth_basic_user_file c:/xxx/password_file; proxy_set_header authorization ""; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-server $host; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:3000/xx/; } } visit xxx.exmaple.com site tips input username & password(correct), repeat tips again , again。 password_file created htpassword command on mac os. http://127.0.0.1:3000/xx/ proxy tomcat application . nginx version 1.7.12 window. may httpbasicauthmodule nginx not support windows platform ? its; auth_basic "restricted"; auth_basic_user_file c:/xxx/password_file; see http://forum.nginx.org/read.php?2,254125,254187#msg-254187

javascript - Adding a button dynamically with JQuery without using .append -

i've got scenario in want button appear, scenario looped over. my code @ moment looks like: var r = $('<input type="button" value="done swapping"/>'); $('#doneswapping').append(r); i want button appear once, due using .append keeps getting added during each iteration, resulting in several buttons. is there way around this? maybe removing button again @ end of loop? did try .remove seems remove entire 'doneswapping' reference rather button. thank :) you need use .empty() not destroy structure content in side it. $('#doneswapping').empty(); .remove() destroy container.

symfony - Big form collections with Symfony2 -

i'm having trouble big form in symfony2. let me explain situation: a client of me offers one day courses , i'm building application participants can sign particular course. process simple: participant logs in, selects course, selects date , signs up. this involves multiple entities: course , ~20 required properties, onetomany coursedate coursedate , ~1 required property, onetomany couredateparticipant coursedateparticipant , ~20 properties, manytoone participant the properties of coursedateparticipant same als course , of them used override property of course in cases. of times majority of coursedateparticipants properties null . in backend i'm having 1 form admin can add , edit whole course @ once. form similar entities i.e. coursetype collection of coursedatetype collection of coursedateparticipanttype . everything working fine, except big courses. course can contain 50 coursedate , coursedate can contain 1000 coursedateparticipant . every p

AngularJS lazy loading components with ngNewRoute -

i want make application uses angularjs new router . decided wrap every component new module , lazily load component (module, controller , template) oclazyload when user changed route component. think have load module oclazyload don't know write code!

How does Composer know what MediaWiki extensions to load? -

we've switched using semantic bundle install extensions using composer. can skip, extensions, manually including entry points @ localsettings.php file ( http://www.bn2vs.com/blog/2013/11/24/introduction-to-composer-for-mediawiki-developers ). how mediawiki know extensions load. read composer.json? the answer, stated in www.mediawiki.org/wiki/composer : composer creates autoloader @ vendor/autoload.php, included webstart.php i verified - webstart.php this: # load composer's autoloader if present if ( is_readable( "$ip/vendor/autoload.php" ) ) { require_once "$ip/vendor/autoload.php"; }

html - Javascript: display an alert when a form is checked? -

i have created simple web app has 2 form selections, when user makes selection each want alert display showing them choices made. i have attempted below when both forms checked alert not displayed. missing? note see comment: //below not being displayed should current code: <!doctype html> <html> <body> <h1>calculator</h1> <p>select importance of this:</p> <form method="get"> <input type="checkbox" name="severity" value="negligible"> negligible<br> <input type="checkbox" name="severity" value="minor"> minor<br> </form> <p>select probability of this:</p> <form method="get"> <input type="checkbox" name="probability" value="improbable"> improbable<br> <input type="checkbox" name="probability" value="remote"> remo

c# - Embedding Pdf with OpenXml in PowerPoint fails for newer versions -

i need progammatically embed pdf documents in powerpoint via openxml. according this: embedding files open xml documents using c# possible via ole32.stgcreatestorageex methods create necessary picture oleobject. unfortunately doesn't work current versions of pdf. on 64 bit os, seems work abobe version 9.higher version fails error code 0x8000ffff translates catastrophic failure. actual true after testing it. version 9 not work reliable. as fallback, used pdfium google create png first page. unluckily half way, incorporated oleobject different original one. not hurt until user tries open embedded document via doubleclick within powerpoint. error message comes up, saying application of document cannot found. here questions: has information how improve procedure make working never versions? does know changes pdf document are necessary incorporate similar object pdf it? any hint highly appreciated finally made running. have here explanation. actually ther

need to pass variable from javascript to php without refreshing or submitting -

i need screen size of visitors. use javascript. <script> var screenwidth = window.screen.width, screenheight = window.screen.height; alert (screenwidth); </script> <?php $value = $_post['val']; echo "i got value! $value"; ?> now, need pass value in php code, without refreshing page , don't want click on submit button high level: browser sends request server, server responds (in case dynamically generated html), browser parses html , makes , dom. can script against dom @ point javascript. usually time you're in browser scripting in javascript, can't pass value php without making new request. at least 2 options make request: if want send data server without page refresh, you're looking ajax. you'll have response dump dom. you'd have on every page reload. another option in case: since want serve different html based on users screen since on multiple requests can set cook

How do you pass parameters to the constructor when creating an anonymous class in D -

i how create anonymous class class {} class b { anonymous = new class { ... }; } but if has constructor, , no default constructor. class { init(string somearg) { } } class b { anonymous = new class { ... };??? } how pass parameter constructor? just implement default constructor calls parent constructor super : class { this(string somearg) {} } void main() { anonyomus = new class { this() { super("hello"); } }; }

jquery - Can't set automatically TimeZone in TimePicker -

using timepiker want set timezone: $('#timestart').timepicker({ showtimezone: true, timeformat: "hh:mm tt", timezonelist: [ { 'value': '-720', 'label': '(gmt-12:00) international date line west' }, { 'value': '-660', 'label': '(gmt-11:00) midway island, samoa' } .... { 'value': '+840', 'label': '(gmt+14:00) time in samoa' } ] }); timepiker initialized , zones added in selector selected value first list not detected if set manually option timezone: '+840' work why timezone not detect automatically? i found solution,instead of { 'value': '-720', 'label': '(gmt-12:00) international date line west' } is need use { value: -720, label: '(gmt-12:00) internationa

How can I generate a unique JavaScript variable name from a JSF clientId? -

i want define javascript function every instance of jsf composite component. for this, inside component, i'm trying like: <h:outputscript> function myfunction_#{component.clientid}(day) { //do instance specific stuff } </h:outputscript> specifically trying use function in richfaces calendar this: <rich:calendar id="calendar" ... dayclassfunction="myfunction_#{component.clientid}"> but clientid doesn't contain characters valid in javascript variable names. is there way calculate md5 hash or pseudo-unique clientid (or else!) inside jsf el expression? i need instance-specific because return value relies on instance values , dayclassfunction attribute doesn't accept function takes clientid or likewise specific argument. i've done before this: window['#{cc.clientid}'] = { myfunction1 : function() { ... }, myfunction2 : function() { ... } }; then call need with dayclassfunction="wi

c++ - Boost Connect Signal From one class to another -

i need emit signal child class it's parent class when asynchronous operation finished using boost signal, for example parent class class { void dotask(){ class b child; child.asynchtask(); } void onfinished(){ //invoke when async task finished } }; and second class class b { void asynchtask(){ //async task start here } void asynchtaskfinished(){ // emit signal here invoke onfinished() of parent class } }; how can using boost signal, found example , post complete example using boost::signals c++ eventing , couldn't figure out how implement in case. any appreciated. thanks haris

java - == vs equals vs XOR benchmark -

i doing benchmark find out of == , equals , ^ (xor) potentially faster while comparing objects. purpose wrote program, , got following results: first iteration: equals took : 345 == took : 625 xor took : 284 second iteration: equals took : 346 == took : 182 xor took : 254 total after 100 iterations: average equals: 305 average ==: 164 average xor: 246 i have couple of questions here: using equals method faster using hashcode() first time using hashcode becomes faster after second iteration. safe if i'm using same dataset on time calculation faster use hashcode() rather equals() ? after checking string.hashcode() implementation know why hashcode() becomes faster second time, why xor gets faster? can't see logic that. here program refrence: public static void main(string... args) throws exception{ string[] set1=new string[10000000]; string[] set2=new string[10000000]; random r=new random(); for(int i=0;i<10000000

XML Validation with XML-Reader in PHP -

i've got errors during validation of generated xml string. loaded xml-string xml-reader , assigned xsd-file validation. there object ids , urls validate against pattern of allowed characters. think ids , urls correct. why validation process generates errors? i've got error messages this: element 'objectid': [facet 'pattern'] value 'ffc89' not accepted pattern '^[a-z]{1,1}[a-z0-9.-]{3,14}$'. element 'objectid': 'ffc89' not valid value of local atomic type. element 'originurl': [facet 'pattern'] value 'http://domain.com/images/89/f972c66982290125.jpg' not accepted pattern '^(http|https){1}(://){1}[a-za-z0-9\-\./#?&_]+'. element 'originurl': 'http://domain.com/images/89/f972c66982290125.jpg' not valid value of local atomic type. here code snippet: $reader = new xmlreader(); // enable user error handling libxml_use_internal_errors(true); // load xml sructure testing a

bash - Output of SQL query and command to a file in shell script -

i have following shell script runs sql query , command sends output email. issue able send sql output. not output of loop. tried give "eof" after loop gives syntax error. please let me know how send both output in email. thanks & regards, akhil #!/bin/bash source $home/.bash_profile cd /home/cron wfvar="red blue green" echo " " > /home/cron/output.lst sqlplus -s user/test@db <<eof set linesize 55 pages 500 spool output_temp.lst; set head off; select sysdate dual; set head on; spool off; eof name in ${wfvar}; pmcmd getworkflowdetails -sv repository ${name} | grep -e "workflow:" -e "workflow run status:" -e "end time:" done sed -e 's/ *$//' output_temp.lst > output.lst cat /home/cron/output.lst | mail -s "output - `date '+%d-%m-%y'`" akhil@gmail.com rm output_temp.lst you overwriting file. echo moo >output.lst echo bar >output.lst now, output.lst con

excel - Copy and paste entire sheet from different workbook -

does me copying whole sheet instead of c3:d4? wb.worksheets(2).range("c3:d4").value = wb2.worksheets(1).range("a1:b2").value wb2.worksheets(1).cells.copy wb.worksheets(2).range("a1")

ruby on rails - How to test content of Devise emails with email_spec gem and cucumber? -

i learning how test email generation , delivery cucumber , th email-spec gem. i have installed gem , generated email_steps.rb file. however actionmailer::base.deliveries array appears empty not able test email. my scenario looks this: background: given visit user registration page scenario: happy path - seccessful sign , fill in user registration form correctly , click register redirected users index page , can see email confirmation notification , "john89@example.com" should receive email when open email subject "confirmation instructions" , follow "confirm account" in email , redirected sign in page , fill in sign in form correctly , click log in redirected home page , can see "signed in successfully" notification and failing on and "john89@example.com" should receive email subject "confirmation instructions" i have checked email sent in development

node.js - PM2 cluster mode only starts one instance -

i'm using pm2 clustering. worked fine when using nodejs 0.10.31 , pm2 0.12.14. upgraded nodejs 0.12.4 , pm2 0.12.16 , when launching following command : pm2 start app.js -i 5 i : [pm2] spawning pm2 daemon [pm2] pm2 daemonized [pm2] process app.js launched │ app │ 0 │ cluster │ 1372 │ online │ 0 │ 0s │ 30.500 mb │ disabled │ i expected 5 clusters 1 (one row in table). didn't see in logs far. idea ? you should not use cluster mode node 0.10.x

bootstrap template with meteor -

i trying use bootstrap template https://almsaeedstudio.com/preview meteor. have managed move css, js etc files public folder , broken page down templates such: <head> <meta charset="utf-8"> <title>thooslo backend</title> <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> <link href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" /> <!-- theme style --> <link href="/dist/css/adminlte.min.css" rel="stylesheet" type="text/css" /> <!-- adminlte skins. have chosen skin-blue starter page. however, can choose other skin. make sure apply skin class body tag changes take effect. --> <link href="/dist/css/skins/skin-blue.min.css" rel="stylesheet" type="text/cs

excel - How to add times in VBA? Getting Type Mismatch -

below of code in i'm trying add time value part of loop. sheet parámetros has cell b1 accepts times (i made sure using data validation tool). i'm confused why keep getting error of "type mismatch." want convert time string can concatenate text, , i'm not sure how either.. appreciated :) sheets("parámetros").range("b1").value = sheets("parámetros").range("b1").value + time(0, 5, 0) replace: time(0, 5, 0) with: timeserial(0, 5, 0)

Get list of users in liferay -

i want display users list on liferay. , having problem it. here action class. public void userlist(actionrequest actionrequest, actionresponse actionresponse) throws systemexception { // todo logic user code try { int countuser = userlocalserviceutil.getuserscount(); log.info("user present in db" + countuser); list < user > users = userlocalserviceutil.getusers(0, countuser); portletsession sessions = actionrequest.getportletsession(); sessions.setattribute("users", users); log.info("session set portlet" + sessions.getattribute("users")); (user user: users) { if (user != null) { log.info("userid--:" + user.getuserid() + "usercompanyid-:" + user.getcompanyid() + "useremail-:" + user.getemailaddress() + "userscreenname--:" + user.getscreenname()); } } and how trying

What's the best way to get members of an Akka cluster? -

if have akka cluster, best way access list of members of cluster? i can listen events , manage own registry on each node in cluster. can use cluster(system).state according docs isn't in-sync published events. 1 of these preferred/better? my use case this: i have cluster of various services (different roles). when need service of particular role i'd filter on list of nodes in cluster nodes having role need, randomly select 1 of these communicate with. that's why want list of nodes in cluster. is best way achieve use case? members of cluster available through jmx if activated. guess can write small piece of code access mbean server , retrieve information there. also, there additional information in jmx object useful such unreachable nodes.

Edit Xcode color scheme for line number background -

Image
anyone knows how change line number background color in xcode, referring area in red box below? access setting by: xcode -> preferences... -> fonts & colors i read through .dvtcolortheme file haven't found hint. unfortunately seems line number/gutter area given background colour automatically based on background of editor is. can seen changing editor's background colour white or black, , chooses both darker colour white, , lighter colour black.

ios - p12 certificate is always incorrect at Pushwoosh -

Image
i'm using pushwoosh along cordova app have problem activate it. when want enable pushwoosh ios have provide 'certificate file (.cer)' , 'push certificate (.p12)'. problem pushwoosh always says .p12 file incorrect (please have @ screenshot). don't know why. follow this instructions in exact manner! think documentation of pushwoosh broken? ok, works. no mentioned , in order right .p12 file have unfold private key certificate in keychain access program, , must select both (the certificate , key). right click -> export.

bash - Unique entry set in the first column of all csv files under directory -

this question has answer here: is there way 'uniq' column? 8 answers i have list of comma separated files under directory. there no headers, , unfortunately not same length each row. i want find unique entry in first column across files. what's quickest way of doing in shell programming? awk -f "," '{print $1}' *.txt | uniq seems uniq entries of each files. want files. shortest still using awk (this print row) awk -f, '!a[$1]++' *.txt to first field awk -f, '!a[$1]++ {print $1}' *.txt

Result set in java returning columns in an order different from ms access table order -

am using ucanaccess jdbc driver application, @ moment able connect ms access database columns ordered differently, e.g in database table "id" column second return last. there 1 has encountered same problem? use columnorder=display connection paramenter, e.g. jdbc:ucanaccess://c:/db/cico.mdb;columnorder=display

model - Laravel 5 Eloquent belongsTo() foreign key won't work -

i found out naming of column in schema::create() can affect creating constrains, can't found model in later queries. schema (simplefied): schema::create('page_elements', function(blueprint $table) { $table->increments('id'); $table->integer('page_element_type_id')->unsigned(); $table->foreign('page_element_type_id')->references('id')->on('page_element_types')->onupdate('cascade')->ondelete('restrict'); $table->timestamps(); }); and when call pageelement::find(1)->first()->type()->get() i empty collection. after changing 2 lines in shema (only change page_element_type_id type_id ): $table->integer('type_id')->unsigned(); $table->foreign('type_id')->references('id')->on('page_element_types')->onupdate('cascade')->ondelete('restrict'); i got 1 element in collection, should. anyone

Only function definitions covered by unit testing python/flask backend -

i start saying beginner @ both flask , unit testing in python, bare in mind. i writing unit testing backend building android app. trying write tests functions communicate android client when write them, definitions of each function i'm testing registered covered. my registration function example, looks this: @app.route("/register", methods=['post']) def register(): register_args = request.get_json(force=true) if not ('username' in register_args , 'email' in register_args , 'password' in register_args): abort(406) new_username = register_args['username'] new_email = register_args['email'] new_password = register_args['password'] if user.query.filter_by(username=new_username).all() or user.query.filter_by(email=new_email).all(): abort(406) else: u = user(username=new_username, email=new_email, password=new_password) db.session.add(u) db.ses

linux - GNU make - making one task do another task as well -

here makefile: z : echo "redoing z" ; touch z : b b2 touch touch a2 touch z # should disable z doesn't b : c c2 touch b touch b2 when make a , z touched twice, want touched once, how do that? the targets , recipes in disconnect here: recipes should produce targets, not other targets. e.g.: z : touch z : b b2 touch b : c c2 touch b # add rules b2, c , c2

K2 blackpearl: Create DateTime[] from data fields -

Image
i cannot figure out how use datetime maximum function multiple data fields. have 2 (datetime) data fields want maximum value. the "values" field lets type literal or drop in 1 field. how can create array of 2 fields? thank you! ob i think problem having input not date array of dates: datetime[] i don´t think function typically made find biggest between 2 dates in 2 datafields . the way function works need give array , of course second param date. to so, can use smartobject return list of datetime (when call list, make sure don´t return first, default value). the function work fine , tell of dates in list 'maximum'. now, if have to use dates in datafields, first need convert 2 datetime array of datetime. unfortunately, not aware of function able (i may wrong...). i see 3 options nonetheless: you write custom function that: take 2 input , return array of them (there knowledge base article explaining how that) you use stored proce

python - How can I use beautiful soup to get the current price of a stock on Google Finance? -

i have following python code , goal current price of stock, $110.80. import urlparse import urllib2 import pdb bs4 import beautifulsoup pprint import pprint url = "https://www.google.com.hk/finance?q=0001&ei=yf14vyc4f4wd0asb64cocw" def webcrawl(url): htmltext = urllib2.urlopen(url).read() soup = beautifulsoup(htmltext) p = soup.find() print p webcrawl(url) now when print soup , number 110.80 appears in multiple places, example: {u:"/finance?q=hkg:0001",name:"0001",cp:"-1.07",p:"110.80",cid:"164573760542896"} and <span id="ref_164573760542896_l">110.80</span> and <meta content="110.80" itemprop="price"/> first question : right place within html text current price of stock, since seems price occurs in multiple areas within html text ? second question : should put in soup.find() or soup.find_all() field such can obtain current price of

Do while loops have local variables in Python? -

i trying use while statement so: o = 0 while o == 0: try: n = int(raw_input("which number want begin with?")) o = 1 except: o = 0 print "please use valid number." however, when try use variable n later, gives me "local variable 'n' referenced before assignment' unboundlocalerror. means n cannot recognized variable in def using, because exists in while statement? possible? whole code: import time sys import argv import os os.system("cls") print "welcome number counter 2.0!" = true def program(): global if == false: os.system("cls") o = 0 while o == 0: try: n = int(raw_input("which number want begin with?")) o = 1 except: o = 0 print "please use valid number." if n == "/historykeep false":

regex - Regular expression match issue -

i have simple regular expression: .} , simple text: {}} why single match: {} i expecting two: {} }} please see here code snippit. regex matches non-overlapping. maybe closer want: /(?=})}/g i think want behind not ahead isn't supported on regexr.com because it's not supported in java script /(?<=})}/g

java - Spring form validation using annotation and @Valid -

i having issues form validation. controller: @requestmapping(value = register_url, method = requestmethod.post) public string registerpost(@valid registerform registerform, bindingresult result) { if (result.haserrors()) { return register_view; } system.out.println(registerform.getpassword()); return login_view; } view: <form:form action="register" commandname="registerform" method="post"> <table> <tr> <td>username:</td> <td><form:input path='username' /></td> <td><form:errors path="username"/></td> </tr> <tr> <td>password:</td> <td><form:password path='password'/></td>

java - Why use a wild card capture helper method? -

referring : wildcard capture helper methods it says create helper method capture wild card. public void foo(list<?> i) { foohelper(i); } private <t> void foohelper(list<t> l) { l.set(0, l.get(0)); } just using function below alone doesn't produce compilation errors, , seems work same way. don't understand is: why wouldn't use , avoid using helper? public <t> void foo(list<t> l) { l.set(0, l.get(0)); } i thought question boil down to: what's difference between wildcard , generics? so, went this: difference between wildcard , generics . says use type parameters: 1) if want enforce relationship on different types of method arguments, can't wildcards, have use type parameters. but, isn't wildcard helper function doing? not enforcing relationship on different types of method arguments setting , getting of unknown values? my question is: if have define requires relationship on different types of

c# - Why it is possible to assign partial methods to delegates in spite of other constraints? -

i know title might not totally clear, didn't want make long. one thing boggles me when thinking restrictions placed on partial methods. seems me rules inconsistent. know: partial methods must have return type of void, , cannot have parameters marked out modifier. these restrictions in place because @ run time, method may not exist , can’t initialize variable method might return because method might not exist. similarly, can’t have out parameter because method have initialize , method might not exist. [1] it sounds sensible me. @ same time: if there no implementing partial method declaration, cannot have code attempts create delegate refers partial method. again, reason method doesn’t exist @ run time. [1] at first, these rules seem follow same compiler logic. there difference, though. stated in second quotation, compiler issues error when there no method implementation of partial method. why can't check implementation @ compile-time

php - Laravel 5: Send a response first, then process request in controller -

i'm working classic paypal api , i'm stuck on problem of responding before process request data. public function store() { // send empty http 200 ok response acknowledge receipt of notification response("", 200); // build required acknowledgement message out of notification received // once hits point, nothing sent client. } i know in order client receive http 200 response, need add return keyword in front of it. however, if return response immediately, processing of request not occur. looked before , after middlewares, unfortunately not asynchronous. there way of accomplishing send process in laravel 5? i found hack solution problem: try { return response("", 200); } { // controller logic here }

Algorithm to find the minimum value point of a function -

i find lowest value of function least number of trials. function f(x) must have point minimum value. given input x , can calculate f(x) , not other direction. don't have explicit expression of function, blackbox. i find input x such minimizes f(x) , least number of trials (one trial when choose specific x, , plug in output). there algorithms achieve that? the result doesn't need absolute minimum, since derived real problem. should less of values. if function constrained convex, there better way achieve that? thanks! assuming function convex , derivative of f(x) exist points => there 1 minima. reason stressing derivative constrain in case when function looks 2 convex functions 1 next @ point of intersection derivative doesn't exist, function still convex , there 2 local minima. the derivative have opposite signs left , right of minima (the slope changes directions) can see visualization of here . having in mind can simple binary search on domain

excel - Show all unique elements in a list and how many times they appeared -

Image
i trying make formula return me list of unique elements in list , how many times each appeared. can't predict going added list, list of strings. example: car car bike car bus bus would result in: bike 1 bus 2 car 3 thanks! create unique list, paste below formula c2 , enter array formula, ctrl+shift+enter . drag down copy. =index($a$2:$a$7, match(0, countif($c$1:c1, $a$2:$a$7), 0)) then use countif, paste d2 , drag down copy: =countif($a$2:$a$7,c2)

html - How can I centre multiple images that are floated across more than one line? -

i using bootstrap , have div "col-md-8 col-md-offset-2" in centre of page. using php loading images (film posters) database in while loop until images loaded. have floated them , given them margins space them out little, , load on multiple lines. above them centred h2 (the genre). how horizontally centre images each line? @ moment align left of div. have tried combination of things centre them none have affect. here code. <div class="col-xs-8 col-xs-offset-2" id="genrecontent"> <?php //get genre name $genres = $db->query('select name genre id = '.($_get['id'])); $genre = $genres->fetch_object('genre'); ?> <h2><?=$genre->name?></h2> <br/> <?php // films genre dealing // ensuring escape string $films = $db->query('select * film genre_id = '.$db->real_escape_string($_get['id'])); whil

asp.net - ASP .NET MVC CSHTML - DropDownList -

im trying retrieve data localdb in cshtml file this: @html.labelfor(model => model.tipocliente, "tipo cliente", new { @class = "control-label col-md-2" }) <div class="col-md-10"> @{list<selectlistitem> listitems = new list<selectlistitem>(); foreach (var item in model.tipoclientenamespace.tipoclientevalor) { listitems.add(new selectlistitem { text =(string) item.descricao }); }} @html.dropdownlist("tipo cliente", listitems, new { @class = "form-control" }) @html.validationmessagefor(model => model.tipocliente) </div> but error "object reference not set instance of object." on line foreach (var item in model.tipoclientenamespace.tipoclientevalor) anyone can me?

Implicit Conversion: Nullable(Of T) => T | VB.NET LINQ Query Syntax Vs Method Syntax -

the method syntax blocking implicit conversions, query syntax not. option strict on. how can force errors appear when using query syntax? whole (completely runnable) program: option strict on module module1 sub main() dim custlist new list(of cust)() custlist.add(new cust() {.name = "mr. current", .deleted = false}) custlist.add(new cust() {.name = "mrs. deleted", .deleted = true}) custlist.add(new cust() {.name = "miss null", .deleted = nothing}) dim querysyntax = c in custlist c.deleted = false 'no error (the problem) dim methodsyntax = custlist _ .where(function(c) c.deleted = false) 'compiler error (desired effect) each c cust in querysyntax console.writeline("q: " & c.name & " " & c.deleted) next each c cust in methodsyntax console.writeline("m: " & c.name & " " & c.deleted) nex

Adding column to existing pentaho reports -

Image
i pretty new pentaho tool. have existing *.prpt generates excel report file me. need add new column it. guys suggest me way it. thanks in advance note :- these assumption. after open *.prpt file in pentaho report designer . in right side data tab click tab , check data sets , expand one. below image show sample structure of data sets . in image query 1 main report data source open query 1 data source paste sql1 in there , press ok button. after drag , drop column1, column2, column3 report designer in details header . after save prpt file show result below sql1 output. sql1:- select column1, column2, column3 table_name ------------------------------- output:- | column1 | column2 | column3 | ------------------------------- | 1 | 12 | 13 | ------------------------------- | 2 | 22 | 23 | ------------------------------- => now, want a

javascript - x Axis Labels are cut off from Highcharts Column Chart -

i attempting full label displayed in x axis, highcharts keeps on cutting off. tried using crop, overflow, , margin options discussed in other posts no avail. option worked make div height of chart absurd size. $('#da-expulsions').highcharts({ chart: { type: 'column', renderto: 'da-expulsions', }, data: { googlespreadsheetkey: '1nx8zcii0ulxytlmra0a9n11-llzjcdvh2-7sbk_k5-u', startcolumn: 0, startrow: 0, googlespreadsheetworksheet: 19, }, title: { text: 'expulsion rates @ campuses highest expulsion rates on time' }, yaxis: { min: 0, max: 30, breaks: [{ from: 12, to: 24, breaksize: 1 }], tickinterval: 3, title: { text: 'expulsions rate (%)' }, labels: { formatter: function() { return this.value + '%'

multithreading - How to run functions on different threads? -

i need functions below run on different threads. think have use concurrent dispatch queue, i'm not sure how hoping help! first function: func respondtoswipegesture(sender: uiswipegesturerecognizer) { switch sender.direction { case uiswipegesturerecognizerdirection.left: if self.imageview.tag == 1 { println("1 point!") } else { if self.imageview.tag == 5 { println("1 point!") } else { println("game over!") } } case uiswipegesturerecognizerdirection.down: if self.imageview.tag == 2 { println("1 point!") } else { if self.imageview.tag == 8 { println("1 point!") } else { println("game over!") } } case uiswip

angularjs - Angular - How to properly handle an HTTP error from server? -

currently i've got this: $http({ method: 'post', url: 'http://api-endpoint/somescript/', data: formdata, headers: { 'content-type': 'application/x-www-form-urlencoded' } }) .then(function (response) { console.log(response); }); if script on other end works out ok, then gets called. however, let's script on server end has sort of error that's not caught. if make error tossing in garbage call asdfasdf() , then function isn't called, , instead in browser console: cross-origin request blocked: same origin policy disallows reading remote resource @ http://api-endpoint/somescript/. (reason: cors header 'access-control-allow-origin' missing). how catch in angular code can handle in user-friendly manner? edit: not duplicate, specific angular. the $q.then() method accepts 3 function parameters, first being handler successful callbacks, second being

mysql - Trying to separate 2 items in a column for listview wpf -

i quite newbie wpf...any appreciated. started small project listview displays content mysql. far had no problems except column has 2 items in it. need separate each item in own column. easy date , time 1 beyond skills. the display of listview (i can't post images yet): date |time |callerid |from|to |duration 10 june 2015 |22:45|"alex" <210555555>|101 |201|234 the callerid column contains 2 values distinct "" , <>. need separate did date , time . help. <listview x:name="datalist" grid.column="1" grid.row="4" itemssource="{binding path=ds}" background="white" foreground="black" fontsize="16" grid.columnspan="4" fontfamily="segoe ui" margin="1,0,8,0"> <listview.view> <gridview allowscolumnreorder="false"> <gridviewcolumn header="date" displaym