Posts

Showing posts from May, 2015

c++ - Error reporting in Boost Spirit -

i have following error handler @ bottom of parser grammar: qi::on_error<qi::fail>( launch, std::cerr << phoenix::val("paring error in ") << spirit::_4 << std::endl << phoenix::construct<std::string>(spirit::_3, spirit::_2) << std::endl ); the problem parser's input isn't broken-up new lines beforehand, resulting error statement all lines in source code error point until end. there straightforward alternative phoenix::construct<std::string>(spirit::_3, spirit::_2) to print 1 line error occurs on? phoenix semantics giving me trouble if try search '\n' . we need create phoenix function can take spirit parameters. // lazy function error reporting struct reporterror { // result type must explicit phoenix template<typename, typename, typename, typename> struct result { typedef void type; }; // contract string surrounding new-line characters

Rackspace - php-opencloud filters - Documentation for valid ObjectList filters? -

anyone know if/where there documentation valid objectlist filter arrays? the project's entry on github has tiny blurb on directing me api documentation , fails have comprehensive list, , search on 'filters' talks containers only, not object themselves. i have list of videos, each in 4 different formats named same thing (sans filetype). using php-opencloud api, want 1 of video formats (to grab unique filename rather different formats). i figured using filter way go, can't find solid documentation. someone has got have done before. noob out? as glen's pointed out, there isn't support (at moment) service apply filters on objects. thing might interested in supplying prefix, allows refine objects returned based on how filenames start. if sent 'bobcatscuddling' prefix, you'd associated video formats 1 recording. your option, seems, objects , iterate on collection: use opencloud\rackspace; $connection = new rackspace(rackspace_us,

nsdate - Objective-c date difference confusion -

i'm trying number of days between 2 dates , logic seems work fine wide range of dates - august 12, 2012 - august 12, 2013 - returns 364 days, 365 if include end day in calculation. however, if plug in august 8, 2013 - august 12, 2013 0, or 1 if adding end day calculation. not sure doing wrong here: nsstring* strnow = @"august 12, 2013"; nsstring* strthen = @"august 8, 2012"; nsstring* strnumofdays = [datemanager getdatedifference:strthen :strnow]; method - (nsstring*) getdatedifference : (nsstring*) startdate : (nsstring*) enddate { //convert strings dates nsdate* datestart = [self convertstringtodate:startdate]; nsdate* dateend = [self convertstringtodate:enddate]; //check make sure second date later first //get number of days between nscalendar* gregoriancalendar = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents* components = [gregoriancalendar components:nsdaycalendarunit fromdate

Converting a Java byte reader to an InputStream -

consider generic byte reader implementing following simple api read unspecified number of bytes data structure otherwise inaccessible: public interface bytereader { public byte[] read() throws ioexception; // returns null @ eof } how above efficiently converted standard java inputstream , application using methods defined inputstream class, works expected? a simple solution subclassing inputstream to call read() method of bytereader as needed read(...) methods of inputstream buffer bytes retrieved in byte[] array return part of byte array expected, e.g., 1 byte @ time whenever inputstream read() method called. however, requires more work efficient (e.g., avoiding multiple byte array allocations). also, application scale large input sizes, reading memory , processing not option. any ideas or open source implementations used? create multiple bytearrayinputstream instances around returned arrays , use them in stream provides concatenation. instance

android - improving speed performance on a data call -

i making api call web service android application problem returns around 22000 records, loading array after convert each record object assign array listview. fastest/best way fetch data web service? (buffer) ? , best practices type of issues. i recommend using library handle data call... please try using android query ; specifically, see section entitled asynchronous network . this aquery library ( androidquery ) lightweight, , requires 1 jar small jar file. can used maven or gradle android projects well. allows fetch xml or json data remote server in either asynchronous or synchronous fashion. have used many times json back-end, , real timesaver. this library allows specify progressbar automatically appear , disappear during network download process. here example of http call json back-end, asynchronously: public void asyncjson(){ //perform google search in few lines of code string url = "http://www.google.com/uds/gnewssearch?q=obama&v=1.0&q

How to define a utilization function which can be called both by a CUDA kernel and a regular C++ function -

i'm working on project involves lot of mathematics. single target problem( example, gradient calculation), have 2 versions of implementations: 1 cpu version , 1 cuda version. now cpu version written in regular c++ , kernel version written in cuda. if want define small function, example, vec_weight returns weight of vector, have write 1 cpu compiled g++ cpu version , 1 cuda version has "__ device__ " before compiled nvcc. i'm not trying define "__ device__ __ host__ " function here. want kind of library can called regular c++ function , cuda kernel. tried use " __cudacc__ " macro didn't work. because have lot of small utilization functions needed both cpu version , gpu version, think reasonable combine them in one. writing cpu version in .cu instead of .cpp may solve our problem not want. so should do? here code segment: head.h: 1 #ifndef head_h 2 #define head_h 3 #ifdef __cplusplus 4 extern "c"{ 5 #endif

vb.net - Getting remote file size -

what best way remote file size in vb.net? using code: dim request system.net.webrequest dim response system.net.webresponse dim filesize integer request = net.webrequest.create("http://my-url.com/file.exe") request.method = net.webrequestmethods.http.get response = request.getresponse filesize = response.contentlength from time doesn't work because giving invalid file size. putty says: 1.240.214 bytes (valid), vb.net's webrequest says: 1.246.314 bytes (invalid!) it looks webrequest using kind of cache... there better way obtain remote file size? how make head request, this: dim req system.net.webrequest = system.net.httpwebrequest.create("http://my-url.com/file.exe") req.method = "head" using resp system.net.webresponse = req.getresponse() dim contentlength integer if integer.tryparse(resp.headers.[get]("content-length"), contentlength) ' use con

php - Title tag not displaying as expected -

Image
i try style rows css class. mysql data appears on page, , not in title tag anymore. where mistake? <a href="" title=" <?php $abfrage = "select * tester"; $ergebnis = mysql_query($abfrage); while($row = mysql_fetch_object($ergebnis)) { ?> <p><span class="qtip-big"><?php echo $row->name; ?></span></p> <p><?php echo $row->beschreibung; ?></p> <?php } ?> ">testlink</a> the text appears on page , not inside of tooltip. your html wrong :) code this: <a title="<p>paragraph</p>" > anchor </a> html element not allowed in attributes (title attribute, href / src/ alt etc) to multiple lines, can this: <a title="line1 \nline2" > anchor </a> i've added \n character newline. not 'line2' directly attached. though looks stupid, prevents whitespace bevore 'line2' if have html

Rails Bootstrap modal no route matches -

i'm trying use bootstrap modal update taskpriority field in the tasks model. this line in modal isn't working: <%= simple_form_for :task, :url => url_for(:action => 'update', :controller => 'tasks'), :method => 'put' |f| %> the tasks controller has code: # put /tasks/1 # put /tasks/1.json def update @task = task.find(params[:id]) respond_to |format| if @task.update_attributes(params[:task]) format.html { redirect_to @task, notice: 'task updated.' } format.json { render json: @task } else format.html { render action: "edit" } format.json { render json: @task.errors, status: :unprocessable_entity } end end end the error is: no route matches {:action=>"update", :controller=>"tasks"} thanks ! ps - easier way create pop-up change 1 field? update 1 my rake routes tasks tasks /tasks(.:format) t

c++ - Stop carriage return from appearing in stringstream -

i'm have text parsing i'd behave identically whether read file or stringstream. such, i'm trying use std::istream perform work. in string version, i'm trying read static memory byte array i've created (which text file). let's original file looked this: 4 the corresponding byte array this: const char byte_array[] = { 52, 13, 10 }; where 52 ascii character 4, carriage return, linefeed. when read directly file, parsing works fine. when try read in "string mode" this: std::istringstream iss(byte_array); std::istream& = iss; i end getting carriage returns stuck on end of strings retrieve stringstream method: std::string line; std::getline(is, line); this screws parsing because string.empty() method no longer gets triggered on "blank" lines -- every line contains @ least 13 carriage return if it's empty in original file generated binary data. why ifstream behaving differently istringstream in respect? how can

c++ - Is such a downcast safe? -

suppose have following code: #include <memory> #include <vector> struct basecomponent { template <typename t> t * as() { return static_cast<t*>(this); } virtual ~basecomponent() {} }; template <typename t> struct component : public basecomponent { virtual ~component() {} }; struct positioncomponent : public component<positioncomponent> { float x, y, z; virtual ~positioncomponent() {} }; int main() { std::vector<std::unique_ptr<basecomponent>> mcomponents; mcomponents.emplace_back(new positioncomponent); auto *pos = mcomponents[0]->as<positioncomponent>(); pos->x = 1337; return 0; } in t * as() method, should use static_cast or dynamic_cast? there times when the conversion fail? need dynamic_cast instead? auto *ptr = dynamic_cast<t*>(this); if(ptr == nullptr) throw std::runtime_error("d'oh!"); return ptr;

javascript - How to specify a css location except one area ? Rails -

here view : <body > <table class="table canvas" cellspacing=0 > <tr class="twenty"> <th colspan=2>kp</th> <th colspan=2>ka</th> <th colspan=2>vp</th> <th colspan=2>cr</th> <th colspan=2>cs</th> </tr> <tr class="twenty" > <td rowspan=3 colspan=2 > <%= render @blocks[0] %> </td> <td colspan=2> <%= render @blocks[1] %> </td> <td rowspan=3 colspan=2> <%= render @blocks[2] %> </td> <td colspan=2> <%= render @blocks[3] %> </td> <td rowspan=3 colspan=2> <%= render @blocks[4] %> </td> </tr> <tr class="twenty" > <th colspan=2>kr</th> <th colspan=2>ch</th> </tr&g

Remove WordPress auto cropping images completely -

i making custom theme , have site pretty done. using types custom fields use upload images later put carousel. finding when upload image 1069x1060 not cropped or touched , whole content of image visible. when upload picture 850x700 image gets cropped , whole area not visible this can seen @ http://blog.jmrowe.com/portfolio rotating pictures , you'll notice 1 cropped , unable see whole content. also, unchecked option "crop thumbnail exact dimensions (normally thumbnails proportional)" under settings -> media , did not help. did not add custom feature image sizes. what's weird when select image shows in tiny preview screen image un-cropped. however, when site visited image cropped. selected use "full size" can please help? i using types custom fields plugin show these in theme like: <?php if (!((get_post_meta($post->id, 'wpcf-portfoliopicture1', true))=='')): ?> <div class="row">

android - Error inflating class com.google.ads.AdView -

Image
alright, i've been going through tutorial in admob, , after trying compile, first faced annoying run time error. i've been trying past few hours fix , trying solutions, such putting jar file in libs folder , on.. keep getting error. thankfull if problem , figure out doing wrong. first, logcat: http://pastebin.com/4trh31xh here's how looks: my manifest: <?xml version="1.0" encoding="utf-8"?> <uses-sdk android:minsdkversion="9" android:targetsdkversion="18" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.flash" /> <uses-permission android:name="android.permission.flashlight" /> <uses-permission android:name="android.permission.camera" /> <uses-permission android:name="android.perm

ios - CIContext drawImage is very slow -

i trying draw static ciimage using cicontext drawimage in drawrect of glkview, getting 4 frames per second. suggestions improvement? // init code self.backgroundcolor = uicolor.black; self.context = [[eaglcontext alloc] initwithapi:keaglrenderingapiopengles2]; cgcolorspaceref cs = cgcolorspacecreatedevicergb(); self.cicontext = [cicontext contextwitheaglcontext:self.context options:@{ kcicontextoutputcolorspace: (__bridge id)cs, kcicontextworkingcolorspace: (__bridge id)cs }]; self.drawablecolorformat = glkviewdrawablecolorformatrgba8888; self.drawabledepthformat = glkviewdrawabledepthformatnone; self.drawablemultisample = glkviewdrawablemultisamplenone; self.drawablestencilformat = glkviewdrawablestencilformatnone; // draw code - (void) drawrect:(cgrect)r { // clears screen black color glclearcolor(0.0, 0.0, 0.0, 1.0); glclear(gl_color_buffer_bit); glenable(gl_blend); glblendfunc(gl_one, gl_one_minus_src_alpha); [self.cicontext drawimage:self.ciima

php - in_array not finding present items from defined array -

i having issue in_array not seeming find value in array. array constructed of categories , information several tables formed (relatively!). purpose of code is, if row has correct value in $level (supplied in function), , category_id not found in array should added. if found in array should removed array altogether. have been through debugging , seems in_array never returning positive assume have made mistake in implementation here. see code below: $sql = 'select c.category_id, cd.name, cp.level ' . 'from oc_category c ' . 'left join c_category_description cd ' . 'on cd.category_id = c.category_id ' . 'left join oc_category_path cp ' . 'on cp.category_id = c.category_id'; $categories = $mysqli->query($sql); $i = 0; while($row = $categories->fetch_array()) { if ($row['level'] == $level) { if (in_array($row['category_id'], $cat_level_1)) { u

c# 4.0 - Reconstructing an ODataQueryOptions object and GetInlineCount returning null -

in odata webapi call returns pageresult extract requesturi method parameter, manipulate filter terms , construct new odataqueryoptions object using new uri. (the pageresult methodology based on post: http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options ) here raw inbound uri includes %24inlinecount=allpages http://localhost:59459/api/apiorders/?%24filter=orderstatusname+eq+'started'&filterlogic=and&%24skip=0&%24top=10&%24inlinecount=allpages&_=1376341370337 everything works fine in terms of data returned except request.getinlinecount returns null. this 'kills' paging on client side client ui elements don't know total number of records. there must wrong how i'm constructing new odataqueryoptions object. please see code below. appreciated. i suspect post may contain clues https://stackoverflow.com/a/16361875/1433194 i'm stumped. public pageresult<ordervm> ge

php - Cookies sent over HTTP instead of SSL -

i'm using ipb , run site on ssl (https) functional, have issue. cookies not have parameter "https only" / "secure", pretty essential in case ssl turns off, cookie cannot transfered on http (plain text). i've read article on how it, doesn't work way ipb. here's how it's set: line 4227: @setcookie( $_name, $value, $expires, $_path, $_domain . '; httponly' ); line 4231: @setcookie( $_name, $value, $expires, $_path ); line 4236: @setcookie( $_name, $value, $expires, $_path, $_domain, null, true ); line 4241: @setcookie( $_name, $value, $expires, $_path, $_domain ); img http://gyazo.com/bb00b575477dc6bbe42b1b6be9e1c96e.png how can enforce "secure" parameter? it's right in setcookie() documentation . set parameter #6 true : @setcookie( $_name, $value, $expires, $_path, $_domain, true, true ); ^-#6 secure

content management system - Creating a page on CMS -

for example: i create page on joomla or wordpress , save it. i create entry in menu points new page. when select new entry in menu page opens on browser. the url appears points file doesn't exist on server. what mechanism used cms joomla or wordpress accomplish this? this typically done url rewriting module runs on web server (mod_rewrite apache or url rewrite iis on windows). rewrite request url /blog/article-title /index.php/blog/article-title or /index.php?q=blog/article-title before website code sees request. then, code in index.php extracts rest of path , determines content serve based on that. for wordpress, see http://codex.wordpress.org/using_permalinks info how rewrites set up.

javascript - Sort column in a table alphabetically within a ul -

i trying sort column alphabetically. column may have additional list below it, however, factor trying sort in "main-name" class. issue comes targeting specific element, sorting entire tr. thank in advance help! example of problem: http://jsfiddle.net/kg2nu/1/ <ul class="name-wrap"> <li class="main-name">michael johnson</li> <ul class="aka-list"> <li>mike</li> </ul> </ul> there plenty of table sorting libraries out there. have seen example of table contains. might able 1 working you: http://www.javascripttoolbox.com/lib/table/examples.php

ipad - Is it acceptable to dynamically update UI in iOS? -

we creating ipad app connects web service using user's id. depending on profile, need hide ui elements (tabs, toolbars). in hig, under tab bar, says "if tab represents part of app unavailable in current context, it’s better display disabled tab remove tab altogether." this not work app business reasons. able elaborate on whether quote above hard , fast rule or guideline? if business rule, it. apple's human interface guidelines that... guidelines. not hard rule, don't make sense application.

XSLT - Sum based on attribute values -

i have following source xml source xml <?xml version="1.0" encoding="utf-16"?> <propertyset><siebelmessage><listofxrx_spcusco_spccol_spcinvoice_spcar_spcsummary> <fs_spcinvoice type_spccode="20" xcs_spcinq_spcpo_spcnumber="7500020052" xcs_spcinq_spcserial_spcnumber="vdr551061" xcs_spcinq_spccustomer_spcnumber="712246305" xcs_spcinq_spcinvoice_spcnumber="060853967" gross_spcamount="747.06" invoice_spcdate="04/01/2012"></fs_spcinvoice> <fs_spcinvoice type_spccode="20" xcs_spcinq_spcpo_spcnumber="7500020052" xcs_spcinq_spcserial_spcnumber="vdr551061" xcs_spcinq_spccustomer_spcnumber="712346305" xcs_spcinq_spcinvoice_spcnumber="063853967" gross_spcamount="947.06" invoice_spcdate="04/01/2013"></fs_spcinvoice> </listofxrx_spcusco_spccol_spcinvoice_spcar_spcsummary>&l

php - better and more reliable cookies -

i making website can register , login , want user have ability stay logged in on device ( , user if system supports multiple users) know possible cookies, people can or accidentally remove those. wondering whether there better method this? ( in web language, php , javascript or jquery preferred though) thanks in advance people delete cookies, should bew aware of consequences. can use other method web storage , flash cookies . more can combine them, saved on client side , user can clear data well. there no possibility store data (sid, token, whatever) cannot removed.

Not successfully updating multiple records with extjs (500-error) -

the application developed extjs 4 , ext scheduler. want select number of records , update these, records updated many update-request posted (i use json). for example want edit 2 records, 2 post requests update posted, first gets status 200 , other 1 gets status 500 (internal server error). first post smaller in size last 1 (1.9 kb versus 9.2 kb in case) onsaveclick: function () { var selectedevents = grids.scheduler.geteventselectionmodel().getselection(); stores.eventstore.suspendautosync(); (var = 0; < selectedevents.length; i++) { selectedevents[i].set({ customerid: variables.customerfield.getvalue(), customername: variables.customerfield.getrawvalue(), notes: variables.hidefieldsfield.getcomponent('notes').getvalue(), scope: variables.scopefield.getvalue().scope, preliminary: variables.preliminarybox.getvalue(),

Calling to a Sikuli script from Python (Selenium) -

while running selenium tests on website, have flash elements cannot test selenium/python. wanted call out separate terminal window, run sikuli ocr tests, , selenium/python testing. i've not been able figure out exactly. put xxx not know arguments new terminal open , run sikuli script. def test_05(self): driver = self.driver driver.get(self.base_url + "/") driver.find_element_by_link_text("home").click() driver.find_element_by_id("open_popup").click() driver.find_element_by_id("screen_name").send_keys("user") driver.find_element_by_id("password").send_keys("pwd") driver.find_element_by_id("login_submit").click() driver.find_element_by_id("button").click() time.sleep(120) os.system('xxx') os.system('./sikuli/sikuli-script -r test.sikuli') i sure there couple items wrong here. appreciat

c++11 - What is the 'override' keyword in C++ used for? -

this question has answer here: is 'override' keyword check overridden virtual method? 4 answers i beginner in c++. have come across override keyword used in header file working on. may know, real use of override , perhaps example easy understand. the override keyword serves 2 purposes: it shows reader of code "this virtual method, overriding virtual method of base class." the compiler knows it's override, can "check" not altering/adding new methods think overrides. to explain latter: class base { public: virtual int foo(float x) = 0; }; class derived: public base { public: int foo(float x) override { ... stuff x , such ... } } class derived2: public base { public: int foo(int x) override { ... } }; in derived2 compiler issue error "changing type". without override , @ compiler

asp classic - I need to query against a column name using SQL in ASP -

so need make multiple queries based on string name within column. i'm not sure if i'm doing correctly. in divisionnew table there column name jmsday values of "sunday" , "monday" <% set rssun = server.createobject("adodb.recordset") sql = "select * divisionnew jms_updatedatetime >= dateadd(day,-7, getdate()) , jmsday = 'sunday'" rssun.open sql, db capacity = rssun ("suncapacity") %> <% set rsmon = server.createobject("adodb.recordset") sql = "select jmsday divisionnew jms_updatedatetime >= dateadd(day,-7, getdate()) , jmsday = 'monday'" rsmon.open sql, db capacity = rsmon ("moncapacity") %> the query results placed within table. <table> <tr> <th>sun</th> <th>mon</th> </tr> <tr> <td class="sunday"> <input type="text" name=

vim - Gvim ctags Ctrl-] stops working after some time -

i have setup gvim work ctags , cscope. when tag search using ctrl-] works while, , after time stops working same tags resolved earlier (even though there no code changes). not show errors. however, ctrl-t, :ta , cscope command line commands work fine. ctrl-] stops working. way able work again close down gvim window , reopen file again. problem repeats after while. any insights? thanks as other tags commands still working, sounds plugin overrides key mapping. next time happens, investigate via :verbose nmap <c-]> to verify key combination still works, try :nnoremap <c-]> :echomsg "ctrl + ] works!"<cr>

python - Properties and inheriting from instances -

so don't use oop , apparently don't understand thought did. suppose have class (geographic) state: class state(object): @property def population(self): return self._population @population.setter def population(self,value): if value < 0: raise valueerror("population must not negative") else: self._population = value and virtually identical (just @ moment) class town: class town(state): @property def population(self): return self._population @population.setter def population(self,value): if value < 0: raise valueerror("population must not negative") else: self._population = value now suppose instantiate state , give specific population. how create instance of town inherits state instance's population? (temporarily, suppose - it's example.) or should using composition rather inheritance? the way i'm th

javascript - Making JQuery Recognise Newly Added Elements -

this question has answer here: in jquery, how attach events dynamic html elements? [duplicate] 8 answers how make jquery treat new elements in same way original elements in html file treated? example, consider following example: <!doctype html> <html> <head> <title>simple click switch</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $edit = "<div>edit</div>"; $(document).ready(function () { $("div").click(function () { $(this).after($edit); $edit = $(this); $(this).remove(); }); }); </script> </head> <body

gnuplot - Fitting data points to a line on a semi-log plot -

i have semi-log plot (log on x-axis) includes error bars. i'm trying fit line through data points. far i've tried plotting data , separate line , adjusting intercepts of line until (sorta) within data. felt primitive. i'm trying based off of previous posts y0=-12 m=1 f(x) = y0 + m*log(x) fit f(x) "av_bngc6522_hband_chi1p5_ir_10" using 29:35:33:39 w xyerrorbars via m,y0 gnuplot saying "need via , either parameter list or file". don't know means , i'm sure syntax off. need help. with xyerrorbars plotting style , can't used fitting. , can have 1 error value, assumed standard deviation of z value, see help fit . independent variable x can't have associated error value. you script must this: (adapt column numbers) y0=-12 m=1 f(x) = y0 + m*log(x) fit f(x) "av_bngc6522_hband_chi1p5_ir_10" using 29:35:39 via m,y0

sphinx4 - Using streamDataSource -

i tried latticedemo.java. and, result shown in example result. example using "audiofiledatasource" voice data (10001-90210-01803.wav). trying recognize voice data in different way using streamdatasource. but, different result. hear idea. the following steps took: get byte data 10001-90210-01803.wav following code file f = new file(file); bytearrayoutputstream out = new bytearrayoutputstream(); bufferedinputstream in; try { in = new bufferedinputstream(new fileinputstream(f)); return bytestreams.tobytearray(in); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } then, put byte data called "data" bytearrayinputstream following streamdatasource datasource = (streamdatasource) cm.lookup("streamdatasource"); bytearrayinputstream st = new bytearrayinputstream(data); datasource.setinputstream(st, "main stream"); actually, wh

ruby - ElasticSearch - if field is null, treat as 0? -

i using elasticsearch, , running nullpointerexceptions because field basing score on null several documents. how make elasticsearch treat these null fields 0? fwiw, i'm using tire gem , ruby code: s = tire.search "articles" query custom_score :script => "_score < 2 ? 0 : doc['num_likes'].value" match fields, keyword end end end i discovered need this: _score < 2 ? 0 : (doc['num_likes'].empty ? 0 : doc['num_likes'].value)

multithreading - When a process or thread gets blocked, does it wait forever for a notification or just sleep for a while? -

i stumbled question when reading “jvms typically implement blocking suspending blocked thread , rescheduling later” http://www.ibm.com/developerworks/java/library/j-jtp04186/?s_tact=105agx52&s_cmp=cn-a-j when process or thread gets blocked when doing io operations (read, write) or getting access exclusive resource (lock, synchronized), when re-execute? waiting until getting notification somewhere or quit turn , run again after while? has specified platform? os or jvm? that devolve underlying os must provide threading support vm - has way java app can co-exist harmoniously other proceses , threads typically loaded on os - browsers, sidebars, anitvirus, video/audio players, torrent clients, os internal threads etc. etc. the code of blocked thread gets no cpu cycles @ all. thread in state unused-for-now stack allocation , struct/class pointer in container in kernel, waiting else change state. if remains blocked or extended time, stack may swapped out on busy syst

winforms - C# Button loop? -

i'm trying figure out code i'm supposed write in accordance book (head first c#, 3.5 edition). i'm absolutely baffled loop i'm suppose write. here's i'm suppose do: make form, have button, check box, , label. when check box marked, button suppose change background color of label. color suppose switch between red , blue when button pressed. this current code. namespace secondcolorchangingwindow { public partial class form1 : form { public form1() { initializecomponent(); } private void button1_click(object sender, eventargs e) { while (checkbox1.checked == false) // code stop if box isn't checked { messagebox.show("you need check box checked first!"); break;//stops infinite loop } while (checkbox1.checked == true)// code continues "if" box checked. { bool isre

ruby on rails - Access attributes of another model in view -

i have controller (of model aa) , in def view_name end and model b with: def attributes { :a => 'xyz'; } end how access attribute :a inside view of controller a, can display value of attribute :a in view page? more info: model b has attribute :a url image , have display image through view of controller a. i'm wondering how use in <img> tag. <img src="<%= b.a %>" /> . wouldn't have define b.a instance variable in controller use first? or there way? normally if access attribute through instance of model b. something should work in view: <% b.each |test| %> <p><%= test.a %></p><br/> <% end %> this show of each instance of b attribute a but if nice if add context easier you.

How to create a unique property in Azure Table Storage -

in azure table storage possible add unique constraint on column of given table? azure table storage entities don't have columns . each entity may have properties , these properties don't need same each entity. the unique constraint combination of partition key + row key .

google app engine - Trying to connect to Dropbox using its Python API, but failing -

this in google app engine. i'm trying load dropbox api request authorization page @ beginning, redirect otherpage when "allow" button clicked, , use client other purposes. here's code far: import webapp2 import cgi import urllib2 dropbox import client, rest, session # app key , secret dropbox developer website app_key = 'key' app_secret = 'secret' access_type = 'dropbox' sess = session.dropboxsession(app_key, app_secret, access_type) request_token = sess.obtain_request_token() class mainpage(webapp2.requesthandler): def get(self): url = sess.build_authorize_url(request_token, '') self.redirect(url) class otherpage(webapp2.requesthandler): def get(self): try: self.response.write('<html><body>testing:') access_token = sess.obtain_access_token(request_token) client = client.dropboxclient(sess) ...(other code)... self.

loops - Javascript creating a clock -

html <!doctype html> <html> <head> <title>clock</title> </head> <body> <canvas id="canvas" width="500" height="500"> text displayed if browser not support html5 canvas. </canvas> <script type='text/javascript' src='clock.js'></script> </body> </html> javascript var canvas = document.getelementbyid("canvas"), c = canvas.getcontext("2d"), margin = 35, numbersradius = canvas.width/2 - margin, clockradius = numbersradius - 30; //draw circle bound clock function drawcircle() { c.arc(canvas.width/2, canvas.height/2, clockradius, 0, 2*math.pi); c.stroke();} //draw numbers, lie on circle radius: numbersradius function drawnumbers(){ c.font = "25px verdana"; var numbers = [1,2,3,4,5,6,7,8,9,10,11,12], angle; numbers.foreach(function(numbers){ angle = math.pi/6 * (numb

php - ZF2 Zend Tool CLI will not work on Mac -

i attempting use zend tool in zend framework 2 no luck. have installed composer in project directory, , executed composer install command. appears successful. have downloaded zftool.phar file. when attempt command zf.php or zftool.php failure message: -bash: zf.php: command not found but in directory zf.php located. tried copying zftool.phar usr/sbin folder still receive command not found message. have googled on hour , cannot find solution this. if has clue doing wrong appreciate feedback. admittedly amateur @ this. i running os x 10.8.4. it tells command zf.php not found. doesn't file @ point. use zftool.phar need able run php in cli. to check if php enabled in cli type following: php --version it should output this: php 5.3.26 (cli) (built: jun 5 2013 19:16:29) copyright (c) 1997-2013 php group zend engine v2.3.0, copyright (c) 1998-2013 zend technologies also have install/enable phar module php. http://php.net/manual/en/book.phar.php n

extjs - How to get animation with card layout -

i using card layout wizard type application. how can achieve animation effect while clicking on next , previous button. var navigate = function(panel, direction){ var layout = panel.getlayout(); layout[direction](); ext.getcmp('move-prev').setdisabled(!layout.getprev()); ext.getcmp('move-next').setdisabled(!layout.getnext()); }; ext.create('ext.panel.panel', { title: 'example wizard', width: 300, height: 200, layout: {type: 'card' , animation: { type: 'slide', }}, bodystyle: 'padding:15px', defaults: { border: false }, bbar: [ { id: 'move-prev', text: 'back', handler: function(btn) { navigate(btn.up("panel"), "prev"); }, disabled: true }, '->', { id: 'move-nex

vb.net - Refreshing Datagridview From Dataset Issue -

i seem pulling hair out on seems pretty straight forward in eyes. cannot datagridview control update correctly after altering dataset. i populate datagridview dataset , auto generate columns no problem. however, if regenerate dataset new data, datagridview display new data correctly, won't remove old column headers. for example, have query gives me store name , manager , auto populates datagridview. if change query give me store name , supervisor, gives me store name, manager (with blank column) , supervisor. i have tried datagridview.refresh() , datagridview.update() nothing seems work. here code: mysqlconn.open() dim exqry new mysqlcommand(qrystr, mysqlconn) exqry.commandtype = commandtype.text dim da new mysqldataadapter(exqry) dascustomqrydata.clear() 'my dataset called dascustomqrydata da.fill(dascustomqrydata, "qrydata") da.update(dascustomqrydata, "qrydata") dgvcustomquery .datasource = nothing

Save cURL Display Output String in Variable PHP -

is option save outpout of curl request in php variable? because if save $result 1 or nothing <?php $url='http://icanhazip.com'; $proxy=file ('proxy.txt'); $useragent='mozilla/4.0 (compatible; msie 5.01; windows nt 5.0)'; for($x=0;$x<count($proxy);$x++) { $ch = curl_init(); //you might need set cookie details (depending on site) curl_setopt($ch, curlopt_timeout, 1); curl_setopt($ch, curlopt_url,$url); //set url want use curl_setopt($ch, curlopt_httpproxytunnel, 0); curl_setopt($ch, curlopt_proxy, $proxy[$x]); curl_setopt($ch, curlopt_useragent, $useragent); //set our user agent $result= curl_exec ($ch); //execute , results print $result; //display reuslt $datenbank = "proxy_work.txt"; $datei = fopen($datenbank,"a"); fwrite($datei, $result); fwrite ($datei,"\r\n"); curl_close ($ch); } ?> you need set curlopt_returntransfer option true. curl_setopt($ch, curlopt_returntransfer, 1);

HttpWebRequest in c# do not work with .net 4.5 -

i'm working on c# project send xml server , receives xml response. .net framework 4.0 installed works fine. .net framework 4.5 installed throws exception: system.nullreferenceexception: der objektverweis wurde nicht auf eine objektinstanz festgelegt. bei system.domainnamehelper.idnequivalent(string hostname) bei system.uri.get_idnhost() bei system.net.httpwebrequest.getsafehostandport(uri sourceuri, boolean adddefaultport, boolean forcepunycode) bei system.net.httpwebrequest.generateproxyrequestline(int32 headerssize) bei system.net.httpwebrequest.serializeheaders() bei system.net.httpwebrequest.endsubmitrequest() bei system.net.httpwebrequest.checkdeferredcalldone(connectstream stream) bei system.net.httpwebrequest.begingetresponse(asynccallback callback, object state) bei fahrzeugverwaltungsserver.outsideworld.man_integrationsserver.rawcommunication.isserver.dopostandget()` i use method begingetresponse , parameters there not null. know what's