Posts

Showing posts from July, 2015

c++ - Why can't I send data with QTcpSocket's write() method? -

i'm trying learn qt documentation alone, , it's kind of tough. managed simple command-line chat client working, don't know how send things. takes 4 lines of intuitive code read socket in qt, reason can't say qtcpsocket socket; socket.connecttohost("google.com", 80); socket.write("hey"); socket.flush(); flush(); returns false, don't see why. i don't understand why doesn't work , appreciate help. thanks! after calling connecttohost() need have slot handler connected() or call waitforconnected() wait connection host complete otherwise code zooming right through trying write before connection established.

linux - Is the number of processes limited by the size of RAM? -

is number of processes limited size of ram? saw article here said: in 2.3.x, (number of processes) tunable parameter defaults size-of-memory-in-the-system / kernel-stack-size . , since stack size 8kb in linux, can number-of-processes = total-stack-size-in-kernel / 8kb ? the number of processes dependent on amount of ram, think it's processor , number of cores has determines how each process performs.

forms - Classic ASP WebForm Generator -

i'm newbie here , try learn here. i wanna create classic asp program, , it's contain section users can make form ( contact, register , on). now question is, when form created ( inputs have name , id ) how can read , save them in db ( here access db ) is here know example of web form generator? please , guide me thanks you can value of form element using request.form("element_name") . <% username = request.form("input-username") password = request.form("input-password") %> considering know how connect access database , can save above informations database like: <% rs.addnew() rs("username") = username rs("password") = password rs.update() %> update to get, dynamically created form values, need for each... loop in request.form object. <% each item in request.form response.write item & "=" & request.form(item) & "<br />" next %> also suggest read article ....

python - Issues with spawning multiple threads -

are there issues spawning multiple threads using threading.thread ? e.g. everytime wx.spinctrl clicked? don't know of implementation enables keep thread alive , start main method multiple times. ps: think threading.timer implicits it's not bad. 'c++'-like pseudo: thread: tthread::run(){ while(true){ semaphore.wait(); mainmethod(); }; }; gui: myform::onspinctrlclick(control sender){ semaphore.signal(); }; the mainmethod() run many times click.

ruby on rails 3 - I get an empty page with capybara visit method, but response object has content -

ok, i'm working capybara + rails 3 + rspect i'm trying login site, though don't error when use fill_in method, error click_on method, since can't find element i'm trying click. here html code: <form accept-charset="utf-8" action="/" class="filter_form" id="login" method="post"> <fieldset> <div class="modal-body"> <div class="clearfix login-fields"> <label for="user_email">email</label> <div class="input login-inputs"> <input class="input-text" id="user_email" name="user[email]" placeholder="email" size="30" type="email" value=""> </div> </div> <div class="clearfix login-fields"> <label for="user_password">password</label> <div class="input login-inputs"> <input class="input-text...

c# - How to deserialize xml in which a node contains html tags? -

<translation> ( benzene or pyrobenzole or pyrobenzol or &quot;phenyl hydride&quot; or phene or &quot;fenzen czech &quot; cyclohexatriene &quot;coal naphtha&quot; or &quot;benzolo italian &quot; benzole benzol &quot;benzen polish &quot; &quot;benzeen dutch &quot; ) chemical name <b>benzene</b> identified.<br>the following terms added chemidplus:<br><b>pyrobenzole</b><br><b>pyrobenzol</b><br><b>phenyl hydride</b><br><b>phene</b><br><b>fenzen czech </b><br><b>cyclohexatriene</b><br><b>coal naphtha</b><br><b>benzolo italian </b><br><b>benzole</b><br><b>benzol</b><br><b>benzen polish </b><br><b>benzeen dutch </b><br>cas registry number: <b>71-43-2</b><br></translation> i strin...

c# - Google Plus API get photo albums/videos -

how can google plus photo albums user or page? can activities (post/video/photo) together. this code i'm using: var provider = new nativeapplicationclient(googleauthenticationserver.description); provider.clientidentifier = googleidentifier; provider.clientsecret = googlesecret; activitiesresource.collection collection = new activitiesresource.collection(); var service = new plusservice(); service.key = googlekey; activitiesresource.listrequest list = service.activities.list(profileid, collection); foreach (activity activityfeed in list.fetch().items) { var title = activityfeed.title; foreach (activity.objectdata.attachmentsdata attachment in activityfeed.object.attachments) { if (attachment.objecttype == "photo") { //add list of photo } else if (attachment.objecttype == "video") { //add list of video } } } this function gives activity feeds. need list of albums of page. i'm using google-api-dotnet-client . the google+ api doesn't support direct...

jquery - How to let scrollbar keep up with growing height when scroll:auto? -

i have <div> has property scroll:auto . when text added <div> , height exceeds default height, have scroll down see latest lines of text added. want latest line of text visible. if that, use scroll:none instead of auto. how can achieve that? hope understand mean. update: bilgehankorkmaz's solution works, not after while. if enter lot of text scrolling doesn't work anymore. edit: set scroll height value .scrolltop(): $("div").scrolltop($("div").get(0).scrollheight);

php - how to retrive extra HTTP variables using datatables -

i using datatables plugin jquery , using fnserverparams function.i have sent variables not sure how retrieve them ont server_processing file. code : $('#fleetstable').datatable( { "bprocessing": true, "bserverside": true, "sajaxsource": "/server_processing.php", "fnserverparams": function ( aodata ) { aodata.push( { "name": "customerid", "value": "6" } ); } } ); this have tried in server_processing.php file $customerid = ""; if ( isset( $_get['customerid'] ) ) { $customerid = $_get['customerid'] ; } this not seem working.. thaks help andre's comment wrong. datatables requires send parameters in format of aodata.push( { "name": "customerid", "value": "6" } ); this generate url of: ../server_processing.php?customerid=6 in server code, $customerid = $_get['customerid'] ; should return value. you...

Playing music in python with pygame -

i've been trying play music pygame , far i've gotten work code (this entire script way): import pygame pygame.init() screen = pygame.display.set_mode((1,1)) pygame.mixer.music.load("backinblack.mp3") pygame.mixer.music.play(-1, 0.0) while pygame.mixer.music.get_busy: continue however when remove line: screen = pygame.display.set_mode((1,1)) the program loops forever not play song. know way around this? end goal create gui uses pygame playing of music. know trivial answers on stackoverflow similar questions have involved inserting while loop 1 have, doesn't seem trick itself. i don't know how bypass that, have considered using sdl mixer?

java - regex not working as expected for full name -

i have textbox taking input full name. when user enter input my name , don't error. when user enter input my name is , error. regex have is ([a-za-z]+|[a-za-z]+\\s[a-za-z]+) what want is, text should have only (a-z or a-z) , white space... demo inputs are my name xyz pqr stu my name xyz xyz pqr stu how can done using regex? update 1 i using pattern p = pattern.compile("[a-za-z\\s]"); matcher m = p.matcher("dummyname"); boolean matchfound = m.matches(); still getting matchfound false \s whitespace. if want allow whitespace in character class upper , lowercase letters, use [a-za-z\s] .

sql server - compare string from database and from c# -

if have query var query = c in ds.prices select c; datagridcontrol1.autocreatecolumns = true; datagridcontrol1.itemssource = query; datagrid show data table(`ds = new dataset()). when add condition var query = c in ds.prices c.idsticker.equals("goog") select c; datagridcontrol1.autocreatecolumns = true; datagridcontrol1.itemssource = query; datagrid empty. value goog exists in table( idsticker varchar(10) in sql server). when compare int values(for example condition where c.prices > 660 ) works normal. what wrong? all can think of apply trim() it, , possibly toupper() see if 1 or both of makes difference. var query = c in ds.prices c.idsticker.trim().toupper().equals("goog") select c; datagridcontrol1.autocreatecolumns = true; datagridcontrol1.itemssource = query; beyond that, try executing same query using sql against database. select * prices idsticker = 'goog'

Reversing a Wordpress themes date order -

so still haven't been able figure out: reversing order of dates on top , thumbnails of page: http://www.kimsquaglia.com/work/ should behave home page. here code: http://pastie.org/4212608 thanks in advance everyone. you need modify get_terms() . get_terms() can accept order argument. on line 48, try replacing $skills = get_terms('skill'); with $skills = get_terms('skill', 'order=desc');

eclipse - Playing a sound when button clicking in Android -

i'm new android, , i'm trying simple play custom mp3 when button clicked. seems fairly common question , though code follows examples, , i'm not getting errors, don't hear sound in either simulator or real phone. my mainactivity.java: public class mainactivity extends activity { private static final string tag = "myactivity"; public void myactivity(bundle onsavedstateinstance) { log.v(tag, "initializing sounds..."); final mediaplayer mp = mediaplayer.create(this, r.raw.alarma_67560); button play_button = (button)this.findviewbyid(r.id.play_button); play_button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { log.v(tag, "playing sound..."); mp.start(); } }); log.v(tag, "sounds initialized."); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinfl...

Android: snapshot of the root view (with ActionBar) -

i used snap bitmaps of activities taking content view , drawing it: view view = activity.findviewbyid(android.r.id.content) bitmap bitmap = bitmap.createbitmap( view.getwidth(), view.getheight(), config.argb_8888 ); view.draw(new canvas(bitmap)); now i'm using actionbar, , it's not nested under content view, it's left out. how can obtain real root view? or snap picture action bar in other way, if that's not possible? to bitmap entire window including actionbar can use decorview. first need enable drawing cache getwindow().getdecorview().setdrawingcacheenabled(true); get bitmap bitmap bmp = getwindow().getdecorview().getdrawingcache(); use bitmap elsewhere, try imageview , works great. disable drawing cache getwindow().getdecorview().setdrawingcacheenabled(false);

c# - How to return response from webservice -

i have made web service , clients call methods. suppose 1 method takes 4 parameters , want check if 1 of these empty want send response client , want send alert client knows argument empty. can not force client give parameters accurate. possible? [webmethod] public void method1(string str1,string str2,string str3,string str4) { if((str1=="") || (str2=="")) { //send response client in form of alert } } don't reinvent wheel custom objects. @ this msdn article . the easiest thing throw exception (sounds argumentexception appropriate in case) , client receive soapexception . or throw soapexception if want more control, such ability set fault code.

Get multi-line text in between horizontal delimiter with sed / awk -

i multi-line text in between horizontal delimiter , ignore else before , after delimiter. an example be:- some text here before delimiter ---------- line 1 line 2 line 3 line 4 ---------- line 1 line 2 line 3 line 4 ---------- text here after last delimiter and get line 1 line 2 line 3 line 4 line 1 line 2 line 3 line 4 how do awk / sed regex? thanks. you can try this. file: a.awk: begin { rs = "-+" } { if ( nr > 1 && rt != "" ) { print $0 } } run: awk -f a.awk data_file

Blackberry memory limit for a screen? -

i wonder if there memory limit mainscreen in blackberry? mean have garage screen in game , 60 cars + other images initiating , seems loading time causes errors on real device, bold 9700. possible images cause memory errors? total size of images 2mb in /res folder. possibly. 1 work around can try not load images in memory @ time, instead, can load images needed. memory efficient. thanks naveen m

c++ - Member pointer to array element -

it's possible define pointer member , using later on: struct foo { int a; int b[2]; }; int main() { foo bar; int foo::* aptr=&foo::a; bar.a=1; std::cout << bar.*aptr << std::endl; } now need have pointer specific element of array, i'd write int foo::* bptr=&(foo::b[0]); however, compiler complains "invalid use of non-static data member 'foo::b' " possible @ (or @ least without unions)? edit: need pointer specific element of array, int foo::* ptr points second element of array ( foo::b[1] ). yet edit: need access element in array bar.*ptr=2 , pointer gets used somewhere else, can't called bar.*ptr[1]=2 or *ptr=2 . the problem is, accessing item in array level of indirection accessing plain int. if array pointer instead wouldn't expect able access int through member pointer. struct foo { int a; int *b; }; int main() { foo bar; int foo::* aptr=&(*foo::b); // can't either! bar.a=1; std::cout << bar.*aptr ...

c - What the role of libc(glibc) in our linux app? -

when debug program using gdb, see functions strange names defined in libc(glibc?). questions are: is libc/glibc standard implementation of standard c/c++ functions "strcpy","strlen","malloc"? or, not of first usage described above, wrapper of unix/linux system calls "open","close","fctl"? if so, why can't issue syscalls directly, without libc? does libc consist of 1 lib (.a or .so) file, or many lib files (in case, libc general name of set of lib)? these lib file(s) reside? what difference between libc , glibc? libc implements both standard c functions strcpy() , posix functions (which may system calls) getpid() . note not standard c functions in libc - math functions in libm . you cannot directly make system calls in same way call normal functions because calls kernel aren't normal function calls, can't resolved linker. instead, architecture-specific assembly language thunks used call kernel - can o...

asp.net - Binding Data to aspxgridview editform controls -

Image
i have created custom editform devexpress aspxgrdiview.i want bind data data base editform updating grid.when clicking edit button on grid.popup edit form showing data not populating grid. <settingsediting mode="popupeditform" popupeditformmodal="true" popupeditformwidth="500px" /> <templates> <editform> <div> <table> <tr> <td style="width: 150px"> name </td> <td style="width: 200px"> <dx:aspxtextbox id="txtname" runat="server" width="170px"> </dx:aspxtextbox> </td> </tr> <tr> <td> status </td> <td> <dx:aspxradiobuttonlist id="lststatus" runat="server" clientidmode="autoid" repeatdirection="horizontal"> <items> <dx:listedititem text="enabled" value="e" /> <dx:listedititem text="disabled" value="d" /> ...