Posts

Showing posts from August, 2013

parsing - urllib2 returning nothing in python -

i confused !!! can tell me problem is??? code used work started returning nothing since yesterday !! did not make changes on !!! have idea??? import re re import sub import time import cookielib cookielib import cookiejar import urllib2 urllib2 import urlopen import difflib import requests def twitparser(): try: cj = cookiejar() opener = urllib2.build_opener(urllib2.httpcookieprocessor(cj)) res=opener.open('https://twitter.com/haberturk') html=res.read() splitsource=re.findall(r'<p class="js-tweet-text tweet-text">(.*?)</p>',html) print len(splitsource) item in splitsource: atweet = re.sub(r'<.*?>','',item) print atweet except exception, e: print str(e) print 'error in main try' twitparser() if code did not change,...

java - I would like to add (insert) column numbers (from 1 to 1000) at first column in the .CSV file -

for example my input.csv contains data this.. row_no ,user , actions john , sql transaction suman , transaction failed ram , button pressed retrieve details and looking for.. advance each 1 of have tried this output.csv row_no ,user , actions 1 ,john , sql transaction 2 ,suman , transaction failed 3 ,ram , button pressed retrieve details please me this have tried public class mapwriter { public static void main(string[] args) throws ioexception { csvmapreader mapreader = null; icsvmapwriter mapwriter = null; try { csvpreference prefs = csvpreference.standard_preference; mapreader = new csvmapreader(new filereader("d:\\input.csv"), prefs); mapwriter = new csvmapwriter(new filewriter("d:\\output.csv"), prefs); // header used read original file final string[] readheader = mapreader.getheader(true); // header used write new f...

SQL Update command getting more than expected -

i'm trying update on sql db (2008 r2), reason it's updating more expected. think there's issue where, join, , update commands i'm having trouble finding info on scope , order of operations. fortunately, i'm practicing on db backups restored before make change in production one! i've found this link seems similar (join , update), it's tough me apply case. for testunitcount of 15578, i'm trying change unitno 05101 05088. reason, it's moving unitno of them testnumber. it's olap db (cubes), may seem more complicated tables people used to. thought had command correct time: select dashboarddata.testnumber, testunits.unitno, testunitcounts.testunitcount dashboarddata inner join testunitcounts on dashboarddata.testunitcountid = testunitcounts.testunitcountid inner join measurementdata on testunitcounts.testunitcountid = measurementdata.testunitcountid inner join ...

c# - The type initializer for 'OSGeo.MapGuide.MapGuideApiPINVOKE' threw an exception -

i'm developing web application on mapguide open source 2.5.2 64bit asp.net. when try create user session login.aspx page error: the type initializer 'osgeo.mapguide.mapguideapipinvoke' threw exception i using following code create session: try { mapguideapi.mginitializewebtier (string.format ("{0} \ \ {1}", serverpath, "webconfig.ini")); var site = new mgsite (); site.open (new mguserinformation (username, userpassword)); var sessionid = site.createsession (); session.add ("mgsessionid", sessionid); return true; } catch (mgexception exmg) { this.lblmessage.text = exmg.message; } does have ideas how fix it? don't found solutions on web. thanks

Line plot of rows in a Matlab matrix with the x-axis is the maximum value -

i new here , new matlab. i have matrix file in matlab , want make plot of average rows. however, want plot few data points (about 20) of values before, , after, maximum value within row. matrix file has 550 columns. i have worked out how identify maximum value , column number of maximum value using; [maxvalue maxindex] = max(filename, [], 2) as maximum never in same column, need in calculating average values each row (before , afer max value), , how plot maximum value 0 on x-axis. for example - have matrix this; 14 51 623 23 4 1 4 5 0 0 3 5 67 37 37 5 0 0 0 0 574 4 5 6 and max value = 623 67 574 and max index = 3 5 5 so to, plot average of 3 rows, 2 data points before , after max values...so plot average of; 14, 51, 623, 23, 4, 1 3, 5, 67, 37, 37 0, 0, 574, 4, 5 thanks help! data = [14 51 623 23 4 1 4 5 0 0 3 5 67 37 37...

jquery - Sum checkboxes and select options together -

i hoping add values of multiple select options , checkboxes using jquery have got little stuck. primary issue receive nan combined answer. i summed dropdowns worked (an example can found @ http://pure.evolvedublin.com/phone ) need add checkboxes mix (as seen @ http://pure.evolvedublin.com/broadband-phone ). when click start button on both pages, values become available. i have tried using solutions found in jquery checkbox , select - sum values , add in var , jquery update initial price on click on checkbox has data-price attribute have not been able them working. my jsfiddle sample of code here: http://jsfiddle.net/damienoneill2001/77hhd/ i using following code add checkboxes, dont have right: jquery('input:checkbox').change(function(){ tot=0; jquery('input:checkbox:checked').each(function(){ tot+=parsefloat(jquery(this).val()); }); tot+=parsefloat(document.getelementbyid("broadband_package").value)+parsefloat(document.getelemen...

java - About JOptionPane CANCEL_OPTION -

i not imply cancel option method twice. (both first input dialog box , second input dialog box football) when click cancel button, nullpointerexception error occurs. idea? public void randomdistribution() { string[] gametypes = {"nba", "euroleague", "ncaa", "nhl", "football" }; string question = "choose game"; string title = "memory game"; imageicon entry = new imageicon(getclass().getresource("background.jpg")); string c = (string) joptionpane.showinputdialog(null, question, title, joptionpane.plain_message, entry, gametypes,gametypes[4]); if (c.equals("football")) { string[] f_level = {"easy", "normal", "hard"}; string question_f = "choose level"; string title_f = "memory game - football"; string c2 = (string) joptionpane.showinputdialog(null, question_f, title_f, ...

sql - Time difference in minutes between two times -

been struggling difference in minutes between 2 times. 1 time comes field of data type time in sql server. other value string added sql query. i'm running in ssrs 2008 r2 looks this: datediff(mi, convert(time, '23:59:59'), _travel.start_time) time_difference i error: conversion failed when converting date and/or time character string i've tried casting '23:59:59' time type 'as time' similar error. have tried declaring variable ssrs won't allow it. try give similar error. time 23:59:59 same, _travel.start_time whatever in field in db. output _travel.start_time in format 00:00:00 any ideas how can difference in minutes between 23:59:59 , db value? ta added: can't believe it. _travel.start_time varchar not time. have tried datediff(convert(time, '23:59:59'), convert(time, _travel.start_time)) but still getting same error. however, have noticed there nulls/empty fields in _travel.start_time field i see no issu...

php - Multiple upload buttons on one page -

i wanted have multiple upload buttons on 1 page keeps giving me error on first upload "query empty". second uploader works (s2). here code: <? if(isset($_post['s1'])) { $qset = "select frontimg1 cat"; $rset = mysql_query($qset) or die(mysql_error()); $aset = mysql_fetch_array($rset); unset($aset); $imagename = $_files['images']['name']; if(!empty($imagename)) { $t = time(); $newimagename = "$t$imagename"; copy($_files['images']['tmp_name'], "../img/header_images/$newimagename"); $q1 = "update cat set frontimg1='$newimagename'"; } mysql_query($q1) or die(mysql_error()); echo "<div class=alert fade in><b>website settings updated successfully!</b> </div>"; } elseif(isset($_post['s2'])) { $qset = "select frontimg2 cat"; $rset = mysql_query($qs...

c# - SharpSsh: Restart file transfer if current file transfer too slow? -

my code downloads file remote server our server. usually, 1 file takes, @ most, minute complete download. there times download takes on 5 minutes. is possible restart download if current download takes, say, on 5 minutes? tamir.sharpssh.sshtransferprotocolbase sshcp; sshcp = new scp(sessionoptions.hostname, sessionoptions.username); sshcp.password = sessionoptions.password; sshcp.connect(); foreach (umtsfilesstruct u in array) { try { sshcp.get(u.remotefilepath, u.localfilepath); } catch (exception ex) { using (streamwriter w = file.appendtext(logger._logname)) { string error = string.format("error downloading file [{0}], remote: {1} & local: {2} ", ex.message, u.remotefilepath, u.localfilepath); logger.log(error, w); } } } you can try use system.diagnostics.stopwatch timer. when timer.elapsed >= timespan.fromminutes(5) close connection , run posted cod...

python - reading port number as an argument and do stuff -

i wrote following script in python: #!/usr/bin/python import socket import sys import os host=sys.argv[1] port=sys.argv[2] if len(sys.argv) != 3: print 'usage: python %s <hostname> <portnumber>' % (sys.argv[0]) sys.exit(); try: s=socket.socket(socket.af_inet, socket.sock_stream) except socket.error, msg: print 'failed creat socket. error code: ' + str(msg[0]) + ' error message: ' + msg[1] sys.exit(); try: host_ip=socket.gethostbyname(host) except socket.gaierror: print 'host name not resolved. exiting...' sys.exit(); print 'ip address of ' + host + ' ' + host_ip + ' .' try: s.connect((host_ip, port)) #or s.connect((host_ip, sys.argv[2])) except socket.error, (value,message): if s: s.close(); print 'socket connection not established!\t' + message sys.exit(1); print 'socket connected ' + host + 'on ip '...

java - @ComponentScan not working in test with spring-boot-starter-test -

i attempting test @service , @repository classes in project spring-boot-starter-test , @autowired not working classes i'm testing. unit test: @runwith(springjunit4classrunner.class) //@contextconfiguration(classes = helloworldconfiguration.class, initializers = configfileapplicationcontextinitializer.class) @springapplicationconfiguration(classes = helloworldrs.class) //@componentscan(basepackages = {"com.me.sbworkshop", "com.me.sbworkshop.service"}) //@configurationproperties("helloworld") @enableautoconfiguration //@activeprofiles("test") // class in src/test/java/ , builds target/test-classes public class helloworldtest { @autowired helloworldmessageservice helloworldmessageservice; public static final string expected = "je pense donc je suis-testing123"; @test public void testgetmessage() { string result = helloworldmessageservice.getmessage(); assert.assertequals(expected, resul...

image processing - Get the object position by using bwconncomp in Matlab -

for segmentation, there function in matlab bwconncomp . can calculate number of detected objects. im=imread('mountain.ppm'); [seg_im] = normalize_segmentation(im); im_filt=medfilt2(seg_im,[3 3]); se=strel('disk',2); seg_im = imclose(im_filt,se); obj_im= bwconncomp(seg_im,6) obj_im = connectivity: 6 imagesize: [30 32] numobjects: 1 pixelidxlist: {[129x1 double]} and when acces pixelidxlist , maximum value 834. what 834? because image size 30x32. and how can positon of object using pixelidxlist / bwconncomp information? a @ manual tell linear index: pixelidxlist: 1-by-numobjects cell array kth element in cell array vector containing linear indices of pixels in kth object. if want them in x , y format, use ind2sub function: [x,y]=ind2sub(size(im), obj_im.pixelidxlist) one example: [x,y]=ind2sub(size(im), 834) x = 24 y = 28

Java - Possible that socket data transfer is blocked by too little memory? -

i'm testing software (several applications) on vserver. applications connected central server using tcp. after hours time out means no longer send keep alive packet. do, not arrive @ server. seconds after application timed out exits outofmemoryerror. so possible socket communication between applications "blocked" because of less memory? edit: exception before oome ioexception broken pipe. actually relevant exception broken pipe. means have written connection had been closed peer. in other words, application protocol error. the rest of post mere guesswork. have memory leak somewhere, , application protocol mis-implementation. find them , fix them.

javascript - How do I build an array in JS where some elements are conditional? -

i want build array may or may not contain elements, depending on user roles. can achieve @ "build time", or have first create array without conditional elements, , manually add them splice option? order matters! this want achieve...: var mylist = [ { obj1 }, { obj2 }, if userrolex==true { { obj3 }, } { obj4 }, ]; any thoughts? you can build array elements needed: var = 0; var mylist = []; mylist[i++] = obj1; mylist[i++] = obj2; if (userrolex) { mylist[i++] = obj3; } mylist[i++] = obj4; you can skip indexes or provide non-numeric indexes so: mylist[42] = obj5; mylist['foo'] = 'bar'; javascript's arrays can used maps. can "clear" entry setting undefined .

hyperlink - jQuery: select all internal links EXCLUDING links to downloadable files -

i'm using following piece of jquery code select internal links ... var siteurl = "http://" + top.location.host.tostring(); var $internallinks = $("a[href^='"+siteurl+"'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']"); and works fine. problem i'm facing don't want select internal links directly points downloadable files (e.g. http://www.example.com/downloadable.pdf ) extension (pdf, mp3, jpg, gif, webm ... etc) now question is, how exclude such internal links above criteria? or if use .not() function exclude such links, question be, how select internal links directly points such downloadable files? a simple solution use filter or not regular expression reject links don't want: var $internallinks = $("a[href^='"+siteurl+"'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']"); $internallinks = $...

Rails 3.2, Ruby 1.9 and Unicorn - The First Request is Very Slow - How to debug? -

i've got large 2.3 rails app running on unicorn. i'm using unicorn, can have 0 downtime deployments. however, i've noticed first request after restart very slow. first request: completed 304 not modified in 2771.8ms (activerecord: 98.6ms) second request: completed 304 not modified in 94.4ms (activerecord: 26.9ms) i have preload_app true , re-establishing db-connection in after-fork. i have no idea how explain 2600ms divergence between these 2 values. does have thoughts? really, looking ways debug issue. update here unicorn.log after restart: i, [2014-05-16t13:46:26.529305 #11637] info -- : executing ["/data/app/current/ey_bundler_binstubs/unicorn", "-e", "staging", "-c", "/data/app/shared/config/custom_unicorn.rb", "-d", "/data/app/current/config.ru", {12=>#<kgio::unixserver:fd 12>}] (in /data/app/releases/20140516184210) i, [2014-05-16t13:46:27.566115 #11637] info -- : ...

Running a java profiler -

i trying run java based java profiler find out uses resources on java application on dedicated machine. profiler trying use called warmroast. i following error running. java -jar warmroast.jar exception in thread "main" java.lang.noclassdeffounderror: com/sun/tools/attach/attachnotsupportedexception @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(unknown source) @ java.lang.class.getmethod0(unknown source) @ java.lang.class.getmethod(unknown source) @ sun.launcher.launcherhelper.validatemainclass(unknown source) @ sun.launcher.launcherhelper.checkandloadmain(unknown source) caused by: java.lang.classnotfoundexception: com.sun.tools.attach.attachnotsupportedexception @ java.net.urlclassloader$1.run(unknown source) @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassl...

Webview in Android which works in 4.2+ and not in 2.3.3 -

application works in android 4.2.2 using webview javascriptinterface not working in android 2.3.3. it has targetsdkversion="19" and build property 4.2 i have created emulator 2.3.3 , device 3.7" wvga. oncreate here - @javascriptinterface @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); vwebview = (webview) findviewbyid(r.id.vwebview); btnview = (button) findviewbyid(r.id.btnview); txtview = (textview) findviewbyid(r.id.txtview); vwebview.setwebchromeclient(new webchromeclient()); vwebview.setwebviewclient(new webviewclient()); try { if ("2.3".equals(build.version.release)) { javascriptinterfacebroken = true; } } catch (exception e) { // ignore, , assume user javascript interface working correctly. } // add javascript interface if it's not broken if (!javas...

javascript - asp.net Ajax submit event displays the json result returned from controller instead of alert -

i have view contains javascript code submit data controller the data processed @ controller page display json result returned controller instead of alert. idea ? here code <code> @using (@html.beginform()) { //some thing <input id="btsavedetails" type="submit" name="btnsave" value="save" /> } javascript <script type="text/javascript"> $("#btsavedetails").submit(function (e) { $.ajax({ type: "post", cache: false, async: true, url: '@url.action("groups", "user")', data: $('form').serialize(), datatype: "json", success: function(response) { alert(response.status); }, error: function (xmlhttprequest, textstatus, errorthrown) { if (errorthrown == "forbidden") { ale...

ios - this class is not key value coding-compliant for the key findContact -

this question exact duplicate of: this class not key value coding-compliant key setoutput [duplicate] 1 answer i new iphone , trying connect iphone sqlite. please me short out problem or suggest me basic step connecting example. thankfull act of kindness. error : 2014-05-17 13:06:20.537 sqlite5[1083:11303] * terminating app due uncaught exception 'nsunknownkeyexception', reason: '[ setvalue:forundefinedkey:]: class not key value coding-compliant key findcontact.' * first throw call stack: (0x2090012 0x119de7e 0x2118fb1 0xc4a711 0xbcbec8 0xbcb9b7 0xbf6428 0x3020cc 0x11b1663 0x208b45a 0x300bcf 0x1c5e37 0x1c6418 0x1c6648 0x1c6882 0x115a25 0x115dbf 0x115f55 0x11ef67 0xe2fcc 0xe3fab 0xf5315 0xf624b 0xe7cf8 0x1febdf9 0x1febad0 0x2005bf5 0x2005962 0x2036bb6 0x2035f44 0x2035e1b 0xe37da 0xe565c 0x1b7d 0x1aa5 0x1) libc++abi.dylib: terminate called throwing e...

java - Android sign in button in a fragment -

Image
i'm trying have google sign in button android application. i googled , found quickstart tutorials , them created following code. in androidmanifest.xml add following: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> my fragment xml (fragment_main_menu.xml): <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context="com.tuxin.myalcoholist.myalcoholist.myalcoholist.mainmenuactivity$placeholderfragment"> <button ...

ruby on rails - Share enum declaration values with multiple attributes -

i want have class several attributes saves weekdays numeric values. summary_weekday :integer collection_weekday :integer i thought map integers values using enum 2 declarations: enum summary_weekday: %w(monday tuesday wednesday thursday friday saturday sunday) enum collection_weekday: %w(monday tuesday wednesday thursday friday saturday sunday) but rails doesn't accept that, cannot define same value twice in same class. you tried define enum named "summary_weekday" on model "questioncategory", generate instance method "monday?", defined enum. how can solve this? as of rails 5.0 can use _prefix or _suffix options when need define multiple enums same values. if passed value true, methods prefixed/suffixed name of enum. class invoice < activerecord::base enum verification: [:done, :fail], _prefix: true end it possible supply custom prefix. class invoice < activerecord::base enum verification: [:done, ...

npm - Build Error when Compiling Cordova Project in Visual Studio 2013 (Update 2) -

i having following error whenever try build cordova project in visual studio 2013 (update 2). error 11 cannot find module 'config-chain' error 12 command ""c:\users\joseph\appdata\roaming\npm\node_modules\vs-mda\vs-cli" prepare --platform android --configuration debug --projectdir . --projectname "blankcordovaapp2"" exited code 8. i followed instructions msdn install required files. any ideas? thanks i think installation of npm broken, because config-chain npm core module. try reinstall it.

.htaccess - Rewrite with htaccess -

here i'm trying do. i've got these urls, old form , new form site.com/video.php -> site.com/video site.com/index.php?cat_id=1 -> site.com/some-cat-name here htaccess file working if 1 of last 2 commented. options +followsymlinks rewriteengine on rewritebase / rewriterule ^\.htaccess$ - [f] rewritecond $1 !^(index\.php|img|js|css|admin|robots\.txt) rewriterule ^video$ /videos.php/$1 [l] #rewriterule ^(.*)$ /index.php/$1 [l] if 2 active server returns error 500 rewriterule ^video$ /videos.php/$1 [l] rewriterule ^(.*)$ /index.php/$1 [l] my logic if first matched video in url redirect videos.php , forget under line, seems in other way. can 1 explain how have predifined urls , others go on index.php, tnx in advanced. you getting 500 (internal server error) because rule looping in rule: rewriterule ^(.*)$ /index.php/$1 [l] to fix rule have .htaccess this: options +followsymlinks rewriteengine on rewritebase / rewriterule ^\.htac...

windows - Why in address space's private regions so many zero bytes? -

i'm examining process's address space under windows. when see content of private regions, wonder, because there many 0 bytes (in regions more 95%). if more of private regions don't used while application running, why aren't reserved or free? thanks all. multiprocessing systems tend initialize memory security purposes. usually, zero. aix @ 1 time liked initialize memory 0xdeadbeaf.

javascript - How to pause in an array after each reaching some count -

i have array of symbols in javascript . for each element of array , sending server , , doing operation continously every 10 seconds using settimeout . my requirement , once process half of symbols in array , want give pause operation 3 seconds . (the size of array fixed 100 , can directly use condition if reached 50 ) i have tried sample program , i observed when page loaded first time , affter reaching 2 symbols , ausing 2 seconds . , next iteartion not pauisng . could please me <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"...

c# - Linking bootstrap Code with .aspx.cs file -

can tell me how link code written in bootstrap 3.1.1 code in aspx.cs file. want to access different elements(of bootstrap design) in .aspx.cs file using id's. for example, have html code: <div class="panel panel-success" style="margin-top:100px;margin-left:50px"> <div class="panel-heading" style="font-size:16px"> to-do list </div> <ol class="list=group" id="list1"> <li class="list-group-item"> complete hci assignment </li> <li class="list-group-item"> complete assignment </li> <li class="list-group-item"> complete programming task </li> <li class="list-group-item"> send code correction </li> </ol> <div class="panel-body"> <button class="btn btn-default btn-success bt...

c# - Route mapping doesn't fine controller action method, when using areas. Err: The resource cannot be found -

i've tried searching , read several answers, can't route mapping working. i'm sure i'm missing simple. i want pass optional 'tab' string through url can pre-select tab on rendered page. desired url example: http://localhost/manufacture/job/view/1234/process-route-tab/ other possibly relevant info can think of is: i using areas this route mapped the mapping below works fine url: http://localhost/manufacture/job/view/1234/ but including tab part in example url above gets 'the resource cannot found' error. global.asax.cs excerpt public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( "default", // route name "{controller}/{action}/{id}/{tab}/", // url parameters new { controller = "account", action = "index", id = urlparameter.optional, ...

java - can we process a view for a bad request? -

i'm unable render form error message if request bad using spring controller , jquery-ajax jsp page. if response code 200 i'm able see page not other response codes. please code snippets ' /* jsp page */ statuscode: { 200: function(response) { $("#${tablediv}").empty(); $("#${tablediv}").html(response); }, 400 :function(response){ showerrormessage("oops! donor code assigned"); $("#${adddonorcodeform}").empty(); $("#${adddonorcodeform}").html(response); //can't load response here } } /*spring controller snippet *? if (result.haserrors()) { modelandview.setviewname("donors/donorcodes/adddonorcodeform"); modelandview.addobject("adddonorcodeform",form); response.setstatus(httpservletresponse.sc_...

php - Upload image to this domain and also a subdomain -

i have image uploading script works fine when uploading image domain it's on, need upload same image alternate subdomain. here's bit of code i'm having trouble with. $filename = "../../images/home-features/" . $imagename; $filename2 = "/var/www/vhosts/domain.org/httpdocs/images_home/features/" . $imagename; imagejpeg($tmp,$filename,60); imagejpeg($tmp,$filename2,60); it's second of 2 not uploading. don't errors - it's if has worked image not there. any ideas? i dont know why second image isnt coming through same resource. maybe resource needs rewinding/resetting. but why let server same work on again? copy first file second! copy($filename, $filename2); ps. did check directory second file writable?

c - Accessing struct field within another struct -

so data structure supposed hash table, array of linked list. inside each of linked list holds linked list. , inside linked list book. book contains book name, , linked list of library ids hold book. i'm having trouble searching within linked list see if book->name exists. know how access called "shelf" it's on by: int index = hashfunction(char* nameofbook) % this->size; and searching within hash array find this: this->chain[index] but how can access book struct once i'm inside linked list? in list.h typedef struct nodestruct { void *data; struct nodestruct* next; struct nodestruct* prev; } nodestruct; typedef struct liststruct { nodestruct* first; nodestruct* last; int elementtype; } liststruct; in hash.c: typedef struct book { liststruct* libid; // each book has own list of library ids char* name; // each book has name. } book; // hashset contains linked list of books. typedef struct hashstruct { ...

c# - Writing \t to a file from user input -

i have started learning c# , i'm experimenting file io. having problem writing tab ( \t ) character file. this code far: static void main(string[] args) { string[] input = console.readline().split(' '); console.writeline(string.join("\n", input)); file.writealllines(@"c:\users\shashank\desktop\test.txt", input); console.readkey(); } when run script , input text: hello \twhat \tis \tyour name the following gets written file: hello \twhat \tis \tyour name but, want file output like: hello name i have looked online cannot find solution gives me desired result. tried using streamwriter no avail. there method unescaping strings in .net, although perhaps not expect it: regex.unescape(string) console.writeline(regex.unescape(@"\thello\nworld")); will result in (depending on tab indentation setting): hello world so, if want unescape input string , split individual strings (line...

java - Define Parallel Processing Thread Pool Count and Sleep time -

i need update 550 000 records in table jboss server starting up. need make update backgroundt process multiple threads , parallel processing . application spring, can use initializing bean this. to perform parallal processing planning use java executor framework. threadpoolexecutor executor=(threadpoolexecutor)executors.newfixedthreadpool(50); g how decide thread pool count? think depends on hardware hardware. 16 gb ram , co-i 3 processor. is practice thread.sleep(20);while processing big update background. i don't know spring processing specifically, questions seem general enough can still provide possibly inadequate answer. generally there's lot of factors go how many threads want. don't want multiple threads on core, that'll slow things down threads start contending cpu time instead of working, core count ceiling, or maybe core count - 1 allow 1 core other tasks run on (so in case maybe 3 or 4 cores, tops, if remember core counts i3 proce...

Adding Python to C++: not finding Python.h -

i want add functions written in python c++ program: #include <iostream> #include <python.h> using namespace std; int main(){ int = 0; cout << a; return 0; } but when compile program using commend g++ main.cpp -wall -o main have error: fatal error: python.h: no such file or directory i trying solve problem installing python2.7 -dev sudo apt-get install python2.7-dev , didn't help. can suggest more can fix problem? you need tell compiler find python headers. example, on systems you'd this: g++ -i /usr/include/python2.7 ...

magento - While adding product attribute "Use is product listing" option setting as "Yes" -

i have added code in installer in custom magento module. $installer->addattribute('catalog_product','size_guide',array( 'group' => 'general', 'type' => 'tinyint', 'label' => 'enable sizechart', 'input' => 'boolean', 'source' => 'eav/entity_attribute_source_table', 'global' => mage_catalog_model_resource_eav_attribute::scope_global, 'visible' => true, 'required' => false, 'user_defined' => true, 'used_in_product_listing' => true, 'default' => '', 'unique' => false, enter code here 'apply_to' => '' )); after installing module attribute "size_guide" added "used in product listing" dropdown in attribute still set no seen in code have set used in product listing true. 'used_in...

Display PDF on my Android device -

i have couple of ebooks in pdf format, need display application user. best options ? there inbuilt pdf viewers available, or need user have 3rd party applications installed ? kind regards are there inbuilt pdf viewers available not built os. many devices ship third-party pdf viewing app can launch using action_view intent startactivity() . if want pdf rendering within app, need third-party library -- can find options searching android pdf library on major search engine.

list - Limiting the number of combinations /permutations in python -

i going generate combination using itertools, when realized number of elements increase time taken increase exponentially. can limit or indicate maximum number of permutations produced itertools stop after limit reached. what mean is: currently have #big_list list of lists permutation_list = list(itertools.product(*big_list)) currently permutation list has on 6 million permutations. pretty sure if add list, number hit billion mark. what need significant amount of permutations (lets 5000). there way limit size of permutation_list produced? you need use itertools.islice , this itertools.islice(itertools.product(*big_list), 5000) it doesn't create entire list in memory, returns iterator consumes actual iterable lazily. can convert list this list(itertools.islice(itertools.product(*big_list), 5000))

css3 - Make element always at center of element in bootstrap 3? -

Image
i have center navigation has need in center, not problem, problem have element has right of element, how add have now, goes in accordian head here boostrap 3 code <div class="panel-heading"> <h4 class="panel-title text-right"> <a data-toggle="collapse" data-parent="#accordion" href="#collapseone"> click me </a> </h4> </div> what need this the problem dont know how many icons have, , have need @ center of panel, , click me need @ right? if want achieve this , not complicated. have set default bootstrap accordion , set text-center insted of text-right. in way if place icons aligned center , after use <p style="float: right;">click me</p> in order place click me text in right. here code: <div class="panel-group" id="accordion"> <div class="panel panel-default">...

eclipse - biuld path - the declared path does not meet the expected package -

i'm still learning develop , totally new i'm having lot of troubles. i've managed clone running-app github friend developed. however,on eclipse, did not run , showed many errors, "build path" error. these build path errors occurred due open source java projects, such "actionbarsherlock" , "slidingmenu-library" so imported them well, build path error remains. what's worse, when hovered mouse on these open sources, said the declared package "com.jeremyfeinstein.slidingmenu.lib.app" not match expected package "library.src.com.jeremyfeinstein.slidingmenu.lib.app i clueless on start. many comments i've read told me clean projects - did not work. tried edit "sources" path, failed. can please tell me steps should follow deal these errors? why these build path errors occur? apk file worked on phone. any informative sites regarding these errors helpful too! thank you! if right click ...

python - Matplotlib RegularPolygon collection location on the canvas -

Image
i trying plot feature map (som) using python. keep simple, imagine 2d plot each unit represented hexagon. as shown on topic: hexagonal self-organizing map in python hexagons located side-by-side formated grid. i manage write following piece of code , works set number of polygons , few shapes (6 x 6 or 10 x 4 hexagons example). 1 important feature of method support grid shape 3 x 3. def plot_map(grid, d_matrix, w=10, title='som hit map'): """ plot hexagon map each neuron represented hexagon. hexagon color given distance between neurons (d-matrix) scaled hexagons appear on top of background image whether hits array provided. scaled according number of hits on each neuron. args: - grid: grid dictionary (keys: centers, x, y ), - d_matrix: array contaning distances between each neuron - w: width of map in inches - title: map title returns matplotlib subaxis instance ...