Posts

Showing posts from May, 2014

scala - Do I need a trailing semicolon to disambiguate this code? -

if omit semicolon, code doesn't compile. def checkradiobutton(xml: dslbuilder): string => xmltree = { val inputs = top(xml).\\*(haslocalnamex("input")); { (buttonvalue: string) => // code omitted } } my guess that, without semicolon, scalac thinks partial function argument \\* method, instead of return value. (it isn't partial function, way, it's total function.) can without semicolon here? i've never had use semicolon @ end of line before in scala. i’d write instead: def checkradiobutton(xml: dslbuilder): string => xmltree = { val inputs = top(xml).\\*(haslocalnamex("input")); (buttonvalue: string) => { // <-- changed position of { // code omitted } }

Sometimes, dojo dgrid does not render the data correctly -

i have dgrid, , use jsonrest data server side. pressed button filter data. here html code: <div data-dojo-type="dijit/titlepane" title="<b>查询</b>"> <div class="row-fluid"> <div class="span12"> <div class="row-fluid"> <div class="span10 offset1"> <table> <tr> <td>批号:</td> <td><input id="simple_store_dgrid_search_batch_no" style="width: 120px; height: 20px" data-dojo-type="dijit/form/textbox" /></td> </tr> </table> </div> </div> <div class="row-fluid"> <div class="span6 offset6"> <button type="but

plot - Matlab,better histogram representation -

Image
this question related enter link description here . have histogram see difficult compare bares. there method better represent information better comparison eyes?thanks. perhaps want logarithmic y/x-axis. possible using workaround, explained here: why histogram become incorrect when change y-axis scaling 'log'? cannot use 'yscale','log' , because: the bars incorrectly displayed; histogram bars either become lines or disappear entirely.

C# Interface to create Optional property -

i have interface written in c# , implemented classes. possible can add 1 more property optional in interface , without modifying exiting implemented classes? e.g public interface ishape { int area { get; } } public class findwindow : ishape { public int area { { return 10; } } } in findwindow written. possible can add 1 optional property , not implementing in existing class. ie, public interface ishape { int area { get; } //optional //string windowname{get;} } public class findwindow : ishape { public int area { { return 10; } } //windowname not implementing here } public class findwindowname : ishape { public int area { { return 20; } } public string windowname { { return "stack overflow"; } } } there's no concept of optional members of interface. what need here define 2 interfaces. 1 con

parsing - I am getting Error 500: java.text.ParseException: Unparseable date: "2013-07-18 16:57:22.0" -

string date = "2013-07-18 16:57:22.0"; dateformat format = new simpledateformat("yyyy-mm-dd hh24:mm:ssss.ff6"); date datetime=format.parse(date); calendar calendar = calendar.getinstance(format.gettimezone()); calendar.settime(datetime); and getting error error 500: java.text.parseexception: unparseable date: "2013-07-18 16:57:22.0" i'm unsure hh24 part of format meant do: hh means need hour of day in 24 hours format. by same token, ff6 bit supposed achieve? according documentation, f day of week in month, there particular reason put after seconds? 6 part meant do? ssss bit odd - want milliseconds on 4 digits number (the maximum value 999, isn't it?), not seconds? try , build format logically documentation - believe you'll end similar @davioooh suggesting.

Google Closure — XhrIO: getting URL of redirection -

i'm using google closure's xhrio facilities send post request url. when response request 302 redirect, i'd redirect user's browser url being redirected to. i've tried calling getlasturi on object passed callback, returns uri of request, rather of subsequent redirection. getstatus returns 200. know request being redirected, because can see in chrome's network request viewer. the temporary redirect (302) handled browser, , javascript never gets see it. we had similar problem, , solved modifying server side code send 401 instead of 302 on encountering header (x-http-method-override) have explicitly set in request. server response can include redirection url in response (along 401 status). this stackoverflow question illustrates server side changes: " cannot handle 302 redirect in ajax , why? "

jquery - How do I make a div width draggable? -

Image
i have div nested inside div used display settings console. nested div has fixed positioned inside parent follows: i'd add draggable handle child div's left border child div can resized on width. need add narrow div left hand border positioned can dragged , position recalculated dynamically resize child divs width property? i'd rather stick vanilla jquery if possible rather relying on jquery ui. i think you're looking handles: handles can used resizing. example: $( ".selector" ).resizable({ handles: "n, e, s, w" }); html: <div class="parent"> <div class="child"></div> </div> css: .parent { position: relative; width: 800px; height: 500px; background: #000; } .child { position: absolute; right: 0; top: 0; width: 200px; height: 100%; background: #ccc; } js: $('.child').resizable({ handles: 'n,w,s,e

In TinyMCE 4.x how do you attach a click event handler to content? -

i have been trying many things attach click event handler selection box in tinymce 4.0.2 content no success. know how in custom plugin? following have tried not functioning. ctr++; var id = 'vnetforms_elem_'+ctr; editor.insertcontent('<select id="'+id+'"><option>x</option</select>'); tinymce.dom.domutils.bind(tinymce.activeeditor.dom.select('#'+id)[0],'click',function() { alert('click!'); }); using jquery may help: $(ed.getbody()).find('#'+id).bind('click', function() { alert('click!'); });

Issue with CSS Shadow -

i having issue shadow displaying incorrectly in css. set drop on on bottom , right of box whatever reason being cut off , can't work out why. js fiddle http://jsfiddle.net/jyb5v/ #content { padding: 0 270px 0 0; margin-bottom: 50px; height: 800px; background-image: url("images/mainbg.jpg"); border:1px solid #000; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px; box-shadow: 4px 4px 2px #000000; } website http://www.debbie.travismoore.co.uk/ any appreciated, thanks remove overflow: hidden; #container { width: 100%; float: left; overflow: hidden; // remove line } demo

excel - How to use InStr function in VBA 2003? -

the code below returned error 5 @ instr call: option explicit sub test() dim wb workbook dim wbs workbooks dim str string dim lposition integer set wbs = application.workbooks each wb in wbs str = wb.name lposition = instr(0, str, "_", vbtextcompare) msgbox lposition next wb end sub could please explain why? start index of instr function 1-based => 0 invalid value. see exceptions section of http://msdn.microsoft.com/en-us/library/8460tsh1%28v=vs.80%29.aspx

audio - How to switch the android music output device -

i'm doing test work on android music playback. have headset , bluetooth headset connect phone @ same time. there 4 output devices can play sound: speaker, handset, headset, , bt_headset. want know is: there way switch audio output 4 device using code? cant switch between speaker , handset if there no headset plugin using audiomanager.setmode() . but, if headset plugin sound can not out handset. then, if headset , bt_headset connect @ same time, sound out later connect one.

ios - About usage CoreData: relationships or id -

i have quick question appropriate usage of framework coredata. introduction: have application few uitableviewcontrollers offering different entities. 1 - list of events - entity "responseeventsitem"     every event had interrelated records:         - spakers (entity "responseeventsspeakersitem") - every record has 1 parent - responseeventsitem         - locations (entity "responseeventsspeakersitem") - every record has 1 parent - responseeventsitem         - schedule (entity "responseeventsspeakersitem") - every record has 1 parent - responseeventsitem, , other related records: responsespeakersitem and/or responselocationsitem          - sponsors (entity "responseeventssponsorsitem") - every record has 1 parent - responseeventsitem 2 - town (entity "responsecityaboutitem") 3 - attractions (entity "responsesightsitem") 4 - hotels (entity "responsehotelsitem") - can related responsebonu

asp.net - Redirect from non www to www and also support subdomain -

i need redirect website when user enters url without non www, , should redirect www. example: abc.com www.abc.com and need support subdomain url too. example: abc.xyz.com www.abc.xyz.com <system.webserver> <validation validateintegratedmodeconfiguration="false" /> <rewrite> <rules> <rule name="non-www www" enabled="true" stopprocessing="true"> <match url=".*" /> <conditions> <add input="{http_host}" pattern="^[^\.]+\.[^\.]+$" /> </conditions> <action type="redirect" url="http://www.{http_host}/{r:0}" /> </rule> </rules> </rewrite> </system.webserver>

xamarin.ios - CLLocation does not have a Coordinates property -

Image
i working way through location services first time , appears working in correctly finds location having trouble extracting coordinates. the docs states cllocation has "coordinates" property , compiler happy piece of code. @ runtime cllocation appears return string description. i start location manager _locationmanager = new cllocationmanager (); _locationmanager.desiredaccuracy = 1000; // handle updated location method , update ui _locationmanager.locationsupdated += (object sender, cllocationsupdatedeventargs e) => { updatelocation (e.locations [e.locations.length - 1], _destinationlatitude, _destinationlongitude); }; if (cllocationmanager.locationservicesenabled) _locationmanager.startupdatinglocation (); the event fires correctly static public void updatelocation (cllocation current, double destinationlat, double destinationlng) { //make start pairing string start = current.coordin

javascript - Why does last popover link in navbar not centre on object? -

Image
i using bootstrap.js build simple ui. part of ui want use navbar. on navbar, have popover under each of items in navbar. works ok. what have noticed, popover on last link item in nav bar not position correctly. it not matter if last item third of three, or sixth of six, last item affected. i can workaround not using popover on last item, not understand why occurring. i have tested in chrome 28 , firefox 21 locally same results. my question is: why last popover in code below cause strange rendering issue? nice example (cursor hovering on middle link) : yucky example (cursor hovering on last link): the code using reproduce behaviour: <html> <head><link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" media="screen"></head> <body> <div class="navbar"> <div class="navbar-inner"> <ul class="nav"> <li><a

php - Echo the 2 last columns of tabel -

i have table , want echo 2 last rows of tabel, used below code last 1 showed, problem. $result1 =(mysql_fetch_array(mysql_query("select * $table order id desc limit 2"))); print $result1['time']; for 2 or more rows need loop it $sql = mysql_query("select * $table order id desc limit 2") while($row=mysql_fetch_array($sql)) { echo $row['time']."<br>"; }

Assigning a variable conditionally inside a SELECT statement on SQL SERVER -

i attempting write select statement on sql server displays items based on condition, provide in subsequent where clause. here simplified version of attempting write. declare @tmpvar varchar(5) .... select @tmpvar, .... some_table .... , @tmpvar = case when (some condition here) 'yes' else 'no' end the code above executes successfully, when check value of @tmpvar , remains unassigned. i'd know if there mistake in syntax using. if so, correct way of assigning variable inside select statement using given condition? prior apologies if question redundant. you can't assign in where clause. can in select clause: declare @tmpvar varchar(5) .... select @tmpvar = case when (some condition here) 'yes' else 'no' end, .... some_table .... but if you're not attempting data retrieval @ same time. also, it's pretty poorly defined row(s) influence

javascript - Backbone Views UI -

i wondering if there better way of doing this. i have html needs events attaching it. question 1: there no data, models or collections behind assume no need render method? question 2: assuming should view in backbone because single piece of ui needs code attaching it? basically have panel show , hide functionality, shows check boxes saving settings. when panel closes save states of check boxes. here html: <div id="panel-holder"> <div id="settings"> <ul class="settingschecks"> <li> <label>display desktop notification popup&nbsp;</label> <input type="checkbox" id="formdisplaypopup" checked="checked"/> </li> <li> <label>play alert sound&nbsp;</label> <input type="checkbox" id="formplaysounds" checked="checked"/> </li> </ul> </div> <

intellij idea - Cannot launch AVD & SDK manager (Android Studio 0.2.1) -

Image
having problems launch avd & sdk manager since latest a/s update. i had same problem , fixed giving write , modify permissions full android studio folder.

Java Hibernate returns null result -

i working on update existing web application. have written classes create table , add/remove data. reason, can insert data cannot retrieve results though there data in table. have created test class using same code return results. however, when calling class service, resultset null every time. note can pull data of other existing tables using code, not table/object created. in addition, have taken sql query debugger , ran against database, , results. here code: public discountcode getdiscountcodedetails(string code) { session session = hibernateutil.opensession(); transaction transaction = session.begintransaction(); string query = "from discountcode isactive = 1 , discountcode = :replace"; **discountcode discountcode** = (discountcode) session.createquery(query).setparameter("replace", code).uniqueresult(); transaction.commit(); session.close(); return discountcode; } discountcode null. this test code works in simple

Add styling rules in pandoc tables for odt/docx output (table borders) -

Image
i'm generating odt/docx reports via markdown using knitr , pandoc , wondering how you'd go formating tables. i'm interested in adding rules (at least top, bottom , 1 below header, being able add arbitrary ones inside table nice too). running following example pandoc documentation through pandoc (without special parameters) yields "plain" table without kind of rules/colours/guides (in either -t odt or -t docx ). +---------------+---------------+--------------------+ | fruit | price | advantages | +===============+===============+====================+ | bananas | $1.34 | - built-in wrapper | | | | - bright color | +---------------+---------------+--------------------+ | oranges | $2.10 | - cures scurvy | | | | - tasty | +---------------+---------------+--------------------+ i've looked through "styles" possibility of

java - How can I make the heading text of an eclipse editor selectable? -

Image
in eclipse editor part, can add text top bar of editor form (see screenshot). how can make text selectable? , preferably copy-able via ctrl+c or context menu? the text added via settext() method of scrolledform in turn generated editor's formtoolkit . browsed api there seems nothing obvious enable text selections. it org.eclipse.swt.widgets.label not selectable text. think add copy text menu action on formheading .

Supporting 2D rendering in Windows Phone 8 -

how can render text , paths, squares-ovals-other-2d-geometry into memory (bitmap, byte*) in windows phone 8 in c++ . bitmap subsequently sent dx3d11. in other words - analogue of gdi required. upd2: no app-store d2d . upd3: possible solution: directxtk contains spritefont "bitmap based text rendering". if want use c++, can try using writeablebitmap , modifying individual pixels. see: writeablebitmap class in order draw shapes want, can borrow methods writeablebitmapex project. written in c#, can modify draw shapes want in c++. these shape extensions

javascript - Three.js WebGL renderer not updating Color property on faces -

i have simple plane mesh want change color of face @ run-time (actually when character walks on "floor tile"). i try following: face.color.setrgb(math.random(), math.random(), math.random()); this works fine canvasrenderer , when switch webglrenderer , stops working. i have tried setting geometry.colorsneedupdate flag, no success, mesh , geometry set dynamic , there else missing? (using three.js r59) thanks, phil. for webglrenderer , here pattern need follow three.geometry . assign color each face. for ( var = 0; < geometry.faces.length; ++ ) { geometry.faces[ ].color.sethex( math.random() * 0xffffff ); } set vertexcolors = three.facecolors in material. material = new three.meshphongmaterial( { color: 0xffffff, vertexcolors: three.facecolors } ); set colorsneedsupdate after color change. mesh.geometry.colorsneedupdate = true; three.js.r.76

emacs - SLIME on Windows 7 -

i'm trying set slime on windows 7 box, running m-x slime gives me error spawning child process: invalid argument i have inferior-lisp-program set "c:\\program files\\ccl\\wx86cl.exe" (which factually correct, , running (comint-run inferior-lisp-program) gives me working ccl prompt), , slime directory added 'load-path . what doing wrong? edit: tried loading same environment through windows edition of lispbox , , runs slime fine. i'd prefer not use 1 because packages older emacs, ccl , slime want. the message received means there's high chance there syntax problem command given shell. caused having characters in file name, can interpreted doing special. so, looks emacs trying call c:\\program "program" argument files\\ccl\\wx86cl.exe . there several ways address error: there has escaping function, like: (shell-quote-argument "c:\\program files\\ccl\\wx86cl.exe") but since cannot affect how file name pas

selenium webdriver - how to get tooltip text which is generated dynamic -

<tbody> <tr class="" style="height:65px;"> <tr class="" style="height:65px;"> <td class="dhx_matrix_scell" style="width:99px; height:64px;">ashmita </td> <td> <div class="dhx_matrix_line" style="width:1181px; height:65px; position:relative;"> <div class="dhx_marked_timespan dhx_matrix_now_time" style="height: 64px; left: 105px; width: 1px; top: 0px;"></div> <div class="dhx_marked_timespan gray_section" style="height: 64px; left: 588px; width: 591px; top: 0px;"></div> <div class="dhx_cal_event_line booked" style="position:absolute; top:2px; height: 17px; left:99px; width:28px;" event_id="1374736442513"> <table class="" cellspacing="0" cellpadding="0" style="width:1181px; height:65px;"> </d

css - html5 tags dynamically added in IE8 -

i have in project html5 tags header , footer , etc... of them added dynamically jquery .clone(...) . problem ie<8 doesn't style html5 tags added dynamically. using modernizr , html5shiv problem still there. know how fix that? i've been thinking in remove html5 tags markup don't idea... thanks! the problem may shiv code being added after styles. you'll need arrange javascript download , execute shiv, or modernizer, before else.

objective c - How to recieve data of a group by sqlite query in iOS ? -

i want data of group query , load them textfields. here table integer id name text duration real time real there few names in in name column tried calling method each name , caused insert failure. i want receive query , load result on specific label: dont know how can response select name,sum (time) cost group name; there current code nsstring *docsdir; nsarray *dirpaths; double totaltime = 1.0; // documents directory dirpaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); docsdir = dirpaths[0]; // build path database file databasepath = [[nsstring alloc] initwithstring: [docsdir stringbyappendingpathcomponent: @"database.db"]]; nsstring *querystring=@"select sum(duration) total records"; sqlite3_stmt *statement; if(sqlite3_open([databasepath utf8string], &mydatabase) == sqlite_ok) { if(sqlite3_prepare_v2(mydatabase, [querystring utf8string], -1,

javascript - Dynamically added select change events not registering -

in site have code follows: - $(function() { $(document).on('change', 'select', function() { var formid = $(this).attr("id"); if((formid.indexof("forms[")>-1)){ var newformid= $(this).val(); var scenarioid = ${testscenarioinstance?.id} getforminformation(newformid, "forms", $(this), scenarioid); } }); }); in part of page user can add additional selects via simple little post , append. trouble newly added selects piece of code doesn't trigger, works fine select there when page loads. ideas why is? it should work have now, here made little example same code event: http://jsfiddle.net/2kcy9/ $(document).on('change', 'select', function () { alert("works well"); });

ios - MONOTOUCH open a viewcontroller on tableview cell is clicked -

i have following viewcontroller tableview , custom cell: using system; using system.drawing; using monotouch.foundation; using monotouch.uikit; using system.linq; using system.threading; using system.data; using system.io; using mono.data.sqlite; using system.collections.generic; using zurfers.mobile.core; using alextouch.mbprogresshud; using system.collections; namespace zurfers.mobile.ios { public partial class iphonehotelsearchviewcontroller : uiviewcontroller { mbprogresshud hud; public string destination { get; set; } public datetime checkindate { get; set; } public datetime checkoutdate { get; set; } public int rooms { get; set; } public iphonehotelsearchviewcontroller (intptr handle) : base (handle) { } public override void viewdidload () {

Windows alert triggered by a linux service? -

we running linux service creates error events time time. notify windows users these events, either pop-up window, or better message on tray icon. i suggest using third party messaging service write client app check message queue. http://www.rabbitmq.com/

jpa - When is an explicit JOIN required in JPQL? -

consider following jpa 2.0-compliant jpql queries: select p postaladdress p join p.constituent c c.id = :constituentid order p.type.displayorder ...and: select p postaladdress p join p.constituent c join p.type t c.id = :constituentid order t.displayorder in both cases, p.type @manytoone relationship entity ( postaladdresstype ). the difference in 2 queries in first 1 there no explicit join postaladdress postaladdresstype . implied, guess, through p.type.displayorder snippet in where clause. in second, there explicit join . are these queries equivalent? are equivalent to: select p postaladdress p p.constituent.id = :constituentid order p.type.displayorder ...? it seems so. in these cases, explicit join s (between postaladdress , constituent , , between postaladdress , postaladdresstype ) in way (other readability , explicitness)? for completeness, understand join required if path expression evaluates collection; i'm not (at mo

callback - Rails public profile creation and determining whether profile is public or not -

in app user has ability create profile, there series of required fields need filled out before user's profile "public". i working on after_update callback runs series of checks see if required fields filled out. here method: # user model after_update :check_public_status def check_public_status if self.name.blank? || self.state.blank? || self.city.blank? || self.high_school.blank? || self.recruit_year.blank? || self.birthday.blank? || self.stat(:height).blank? || self.stat(:weight).blank? self.update_attribute :public, false self.update_attribute :removed_from_listing, true else self.update_attribute :public, true self.update_attribute :removed_from_listing, false end end is there better way of doing without having nasty if/else statement? how this: user model after_update :update_public_status! def update_public_status! required_fields_present = [ name, state, city, h

constructor - Time input from the system in java -

i want display countdown of 10 secs. 10-9-8-7... taking time system in java. how can achieve it? can give me source code it? the combination of decrementing for loop (from 10 1) , thread.sleep should suit needs.

reflection - Is there a way to get the Type for a Column using package database/sql in golang? -

basically, without knowing before hand resulting structure of query might be, i'd query database, , return structure (json-y) // rows [ // row 1 [ { columnname: "id", value: 1, type: int }, { columnname: "name", value: "batman", type: string }, ... ], // row 2 [ { columnname: "id", value: 2, type: int }, { columnname: "name", value: "superman", type: string }, ... ] ] is there way type column using package database/sql in golang? i'm suspecting want is make array of interface{} size of column(), then each column determine it's type, then fill array pointer type, and pass array scan() which little code example sqlx , without first knowing struct data populating. using database/sql? no (as far know). but can use this code arbitrary queries. , json.marshall() json package use reflection determine right way print value, have structur

xml - PHP DomDocument appendChild to end of root -

i've got xml formatted so <things> <thing> <name>foo</name> <id>1</id> </thing> <thing> <name>bar</name> <id>2</id> </thing> </things> and i've created new <thing> element info form. when $dom->appendchild($newthing) , it's appended end of document, after </things>. <things> <thing> <name>foo</name> <id>1</id> </thing> <thing> <name>bar</name> <id>2</id> </thing> </things> <thing> <name>bar</name> <id>2</id> </thing> obviously want new element child of root element, not after it. how do that? $dom->documentelement->appendchild($newthing); from php manual : documentelement convenience attribute allows direct access

How to set the background color of a column in gridview of WPF -

my gridview dynamically generated datatable read sql, want set particular column, say, "salary" have red background color. i've searched many solutions still have no clues. cmdstring = @" select id, firstname, lastname, title, level, salary emplpyees"; sqlcommand cmd = new sqlcommand(cmdstring, con); sqldataadapter sda = new sqldataadapter(cmd); dt = new datatable("employee"); sda.fill(dt); datagridall.itemssource = dt.defaultview; you create converter class public class errorconverters : ivalueconverter { public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture) { solidcolorbrush mybrush = default(solidcolorbrush); if ((bool)value == true) { mybrush = new solidcolorbrush(colors.red); } else { mybrush = new solidcolorbrush(colors.black); } return

Jquery mobile each loop over JSON not working -

i have mobile app, first page shows list of categories, when click on 1 category go second page passing category id on url , showing list of business names under category. data on mysql i'm using json working ok, instead of showing list of business names, shows first business repeated 14 times (each business has 14 fields), instead of looping on 5 business under 1 category, looks looping inside fields of first business of category , repeating business name. here jquery: $('#businesslistpage').live('pageshow', function(event) { var id = geturlvars()["id"]; $.getjson(serviceurl + 'getbusiness.php?id='+id, displaybusiness); }); function displaybusiness(data) { var business = data.item; console.log(business); $.each(business, function(index) { $('#actionlist').append('<li><a href="">' + business.business + '</a></li>'); }) $('#actionli

sql - Storing IP addresses in SQLite using C# and ADO.NET -

i've got database client connect mysql database. mysql workbench, have system in place store connection credentials can called later. i'm implementing feature on own in c#. i have wpf form in these details entered. 1 of these controls takes in ip address, i'd store in sqlite3 database file. problem is, when put txthostname.text form , store in table (the particular column text-type column), trips on "." between digits in ip address. let's i'm using 127.0.0.1. database store 127, come across ".0", , throw error in c#. problem, of course. here's code i'm using create .db file , create table hold information in: private void btnok_click(object sender, routedeventargs e) { string filename = txtconnectionname.text + ".db"; sqliteconnection conn = createconnectionforschemacreation(filename); using (sqlitecommand cmd = new sqlitecommand(conn)) { cmd.commandtext = "cr

Woocommerce Meta_Query for Hidden Products -

i'm using theme has custom product loop on home page. great except "hidden" products showing on home page. provide bit of code fix it, keep getting parse errors. current code index.php: <?php if (of_get_option("cap_show_merch") == true){?> <?php //woocommerce check ?> <?php if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { ?> <h2><?php echo of_get_option("cap_merch_title"); ?></h2> <div class="preview-block"> <?php global $product; $num = 0; $merch = new wp_query( array( 'posts_per_page' => 5, 'post_type' => array( 'product' ) ) ); if( $merch->have_posts() ) : while( $merch->have_posts() ) : $merch->the_post(); $product =

parsing - bison shift/reduce conflict -

in following simple grammar, on conflict @ state 4, can 'shift' become taken action without changing rules ? (i thought default shift bison's preferred action) %token 1 2 3 %% start : a; : x y z; x : one; z : 2 | three; y : 2 | ; %% shift bison's preferred action, , can see in state output shift two in state 4. still report shift-reduce conflict, can take warning if like. (see %expect .) you'd better off fixing grammar: start : a; : x z | x y z; x : one; y : two; z : 2 | three;

java - getHeaders method from SoapHandler interface -

could please explain method getheaders soaphandler interface supposed do? http://docs.oracle.com/javaee/5/api/javax/xml/ws/handler/soap/soaphandler.html#getheaders%28%29 i'm not sure if creates additional headers or if should tell runtime headers message should have. i've been sweeping internet looking detailed information couldn't find any. think is basic , obvious no documentation needed lol :-) thanks the description you're looking can found in jax-ws 2.2 spec in section titled, "10.2.1 soap mustunderstand processing". inbound messages require additional processing step occurs before start of normal handler processing. basically, set of qname instances returned getheaders allows handler contribute full set of soap headers node understands (the other contributors full set documented in spec). if inbound soap header contains mustunderstand attribute value of 1 or true , exception generated if header can't marked understood.

c# - Dispose RX Threads on application exit -

i stuck @ correctly disposing threads, created rx, on application exiting. see in process explorer after application closed, threads still running, causing io exceptions. class program { static void main(string[] args) { compositedisposable subsriptions = new compositedisposable(); subscriptions.add(observable.interval(timespan.fromseconds(15)) .subscribe(_ => { getdata(); })); thread.sleep(timespan.fromseconds(20)); subscriptions.dispose(); } } } if see if uncomment subscription.dispose(), thread terminates without getting data. appreciated. thanks you need sort of delay between subsriptions.add(...) , subscriptions.dispose() . without delay between there, app subscribing , disposing them immediately, no time threads work. (and thread.sleep(1000) doesn't work, since inside subscription function, not part of main function.)

matching - Referencing a CSS class only within a specific element -

i trying find css syntax specific problem. searched couldn't find answer. here problem. html markup follow: <div> <header> <div class="container"> <div class="row"> content want red </div> </div> </header> <div class="container"> <div class="row"> content want blue </div> </div> </header> i display "my content want red" in red, , "my content want blue" in blue, , can use css that. does knows trick make it? sub classes cant work here unfortunately. thanks in advance, there's lots of options. depends on circumstances. here's couple without modifying html: using parent element .row { color: blue } header .row { color: red } using :nth-of-type .column:nth-of-type(1) .row { color: red } .column:nth-of-type(2) .row { color: blue } if you're willing add additional markup, add additional class

css - change visibility of label tag using jquery -

i have label hidden visibility on page load. how can make visible using jquery <label for="error" style="margin:100px auto 60px auto;color:red; line-height:40px;font-size:medium;visibility:hidden">error occured</label> i able hide it. $('label[for="error"]').hide(); this doesn't work $('label[for="error"]').show(); change code follows: <label for="error" style="margin:100px auto 60px auto;color:red; line-height:40px;font-size:medium;display:none">error occured</label> i've replaced visibility:hidden display:none. you can use jquery hide() , show() functions.

php - Laravel queue listener with supervisord results in core dump -

i'm using laravel 4 , queue implementation asynchronous tasks, , want use supervisord manage worker processes (basically artisan queue:listen ), i've done in past other frameworks. when run supervisord manually, starts worker processes fine, when run service, worker processes die message: 2013-07-25 09:51:32,162 info spawned: 'myproject' pid 4106 2013-07-25 09:51:32,875 info exited: myproject (terminated sigsegv (core dumped); not expected) there's no stdout or stderr output. here's supervisord configuration workers (nothing fancy): [program:myproject] command=php artisan queue:listen --queue=queue_name iron --env=staging directory=/home/myuser/myproject stdout_logfile=/var/log/supervisord/myproject.stdout stderr_logfile=/var/log/supervisord/myproject.stderr the server running on centos 6.4 64 bit php 5.3.25 cpanel/whm (not choice, it's server idle , can't much). any ideas on causing problem? i had issue few months back, life o

javascript events - disabling the button and uncheck the checkbox using jquery -

what trying added 2 buttons disabled default.when add item buttons enable once click receipt button checkbox checked should go away working in laptop not in fiddle , if click receipt should removeattr checked check box , buttons should disable because no checkbox checked..here code jsfiddle javascript: // json data object var data = json.parse('{ "122233334444": ["book","three musketters","de7598490587","7584092043857", "03/18/13 11:17:51 am","03/18/13 11:17:51 am", "1" ], "122223355552":["ebook","fall colors","xyz29494949","7584092043857", "03/18/13 11:17:51 am","03/18/13 11:17:51 am", "2" ], "122223355533":["ebook","snowfall","xyz29494949","7584092043857", "03/18/13 11:17:51 am","03/18/13 11:17:51 am", "3" ] }'); $("#submitid&q

node.js - How to get profile data from facebook using passport.js authentication? -

in below code 'console.log('this not print!')' statement not execute. should execute according facebookstrategy. passport.use( new facebookstrategy({clientid: facebook_app_id, clientsecret: facebook_app_secret, callbackurl: "/home"}, function(identifier, profile, done) { process.nexttick(function () { console.log(' not print!'); return done(null, profile); } );})); basically, authentication thru passport-facebook takes place not able recover profile data. app.get('/home', function(req, res){ console.log(req.user); res.render('home', {user: req.user}); }); the above prints 'undefined' means above app.get(...) did not receive facebook profile data. what doing wrong? there anyway save (get) facebook profile data after authentication? above callbackurl: "/home" is wrongly declared. should be: callbackurl: "/auth/facebook/callback" for more on discussion https://github

Cascading Ruby Logic? -

is possible following signed out user without triggering .consumer being called on nil error? if signed_in? && current_user.consumer puts "hello world" end for of site have had nest these types of conditionals like: if signed_in? if current_user.consumer end end ...which doesn't bad, when have lots of other code on page, can hassle.. i want statement signed_in? evaluated , if true second conditional evaluated... in single line. possible? yes! ruby supports short-circuiting logic, first code block want: if signed_in? evaluates false , ruby interpreter lazy , not bother evaluating rest of condition. similarly, if user not signed in, !signed_in? || current_user.banned? short-circuit when realizes !signed_in? true , not bother evaluate current_user.banned? .

How to uninstall my service on Windows XP with WiX -

from understand msi installers, removal of services during uninstallation done via restart manager . restart manager not supported on windows xp. official way remove services in msi there? ps. i'm coding msi markup using wix. the restart manager isn't needed remove service. use serviceinstall , servicecontrol elements , long component removed service removed. restart manager more hibernating process , restoring it's state file locks avoided , availability in maintained.

multithreading - thread safe python dictionaries? -

i have function call starts 10 threads. before start of these threads , have from collections import defaultdict output = defaultdict(dict) and output empty. each thread generate data write dictionary. something like: output['water'] = 'h20' output['fire'] = 'delta of oxygen' .... the threads add items , not iterate on of other items or modify other items. output['water'] being item different output['fire'] . can guarantee no 2 threads going create same item. is, each thread t has unique i. in code: output[i] unique per thread. is dictionary thread safe in regard? yes. if using cpython , strings keys, yes. gil in cpython ensures 1 thread executes bytecode @ time, , setting key value in dict happens in single opcode, store_subscr . if not using cpython, or using key has custom __hash__ , __eq__ , or __cmp__ methods, bets off. if had soapbox, i'd hop on , warn of evils of relying on implementation deta

.show jquery function - not displaying div -

i'm trying make javascript work, want show hidden (display:none) div when user clicks on button. can tell me i'm going wrong? http://jsfiddle.net/tz52u/ example on website above. code i'm using: $(document).ready(function () { $("#show").click(function () { $(".no-show").show(); }); }); thanks help. really appreciated! you're missing }); in fiddle. don't need script tags in fiddle either. didn't include jquery. don't need $(document).ready() because jsfiddle loads code already. here's fixed one: http://jsfiddle.net/tz52u/6/ $("#show").click(function(){ $(".no-show").show(); });

android - How to handle exception and prevent crashing app -

i using amazon aws sdk download images s3. occasionally, when image not found exception "amazons3exception: status code: 404" thrown. however, seems exception should not crash app. how can handle exception not crash app? apologies, im noob java & android. to follow on type-a1pha's answer: if want handle exception gracefully, use try-catch statement. works this: try { // here put code may throw exception } catch (amazons3exception e) { // looks errored out, log exception , // tell user 404'd log.e(tag, "error fetching file amazon s3", e); toast.maketext(context, "error 404 while fetching file: file not found", toast.length_short).show(); // insert other code need here recover error } { // note part optional useful if want // after try-catch statement finished // example, if using inputstream: inputstream.close(); }

I want to create a file in a directory in computers with Java -

i'm making game, , game requires directory made in appdata folder of user's account. problem is, can't know put it, every user different. on windows way. want know if should write special or... file file = new file("c:\\users\\%user%\\appdata\\roaming\\[gamename]"); is there special name have give "%user%" (i used example), or there else gotta do? you can use appdata environment variable "c:\users\username\appdata\roaming" and can using system.getenv() function : string appdata = system.getenv().get("appdata"); edit : look @ example (create directory "mygame" , create file "mygamefile" directory). code awful it's give idea of how works. string gamefolderpath, gamefilepath; gamefolderpath = system.getenv().get("appdata") + "\\mygame"; gamefilepath = gamefolderpath + "\\mygamefile"; file gamefolder = new file(gamefolderpath); if (!gamefolder.exists()) {

php - Using $this when not in object context - MyBB -

so, i'm using mybb forums, , go moderate thread, , error. fatal error: using $this when not in object context in c:\zpanel\hostdata\sdcore\public_html\forums\inc\class_moderation.php on line 642 the code on line 642 is $this->delete_thread($mergetid); and surrounding code (just in case) $db->delete_query("threadsubscriptions", "tid = '{$mergetid}'"); update_first_post($tid); $arguments = array("mergetid" => $mergetid, "tid" => $tid, "subject" => $subject); $plugins->run_hooks("class_moderation_merge_threads", $arguments); $this->delete_thread($mergetid); and delete thread function function delete_thread($tid) { global $db, $cache, $plugins; $tid = intval($tid); $plugins->run_hooks("class_moderation_delete_thread_start", $tid); $thread = get_thread($tid); $userposts = array();