Posts

Showing posts from May, 2011

php - Laravel 4 - Eloquent. Infinite children into usable array? -

i've got categories table. each category can have optional parent (defaults 0 if no parent). what want build simple html list tree levels of categories. example date: foods -- fruit ---- apple ---- banana ---- orange -- veg ---- cucumber ---- lettuce drinks -- alcoholic ---- beer ---- vodka misc -- household objects ---- kitchen ------ electrical -------- cooking ---------- stove ---------- toaster ---------- microwave note needs work around 10 'levels'. i'd love infinite dont want going down route of using nested set model it'll cause huge delays on project. the docs on laravel terrible, no real reference start. i've been playing days trying work out , seem getting without huge messy block of each loops within each other 10 times. i've got tree of data using following in model: <?php class item extends eloquent { public function parent() { return $this->hasone('item', 'id', 'parent_id'); }

c++ - QT UIC does not automatically append the headers for custom widgets -

i made custom widget "duwagwidget" , custom widget plugin "duwagwidgetplugin" can dragged&dropped inside qt designer create duwag.ui file. however, when try compile program, ui_duwag.h generated qt user interface compiler, in auto generated file, uic not include "duwagwidget.h" necessary create custom widget class. the duwagwidgetplugin (derived interface in qt create customwidgets) factory class duwagwidget. here code duwagwidgetplugin :^ #include <duwagwidgetplugin.h> #include <qtplugin> #include <qwidget.h> #include <mtbfwidget.h> duwagwidgetplugin::duwagwidgetplugin( qobject *parent ) : qobject(parent) { initialized = false; } void duwagwidgetplugin::initialize(qdesignerformeditorinterface * /* core */) { if (initialized) return; initialized = true; } bool duwagwidgetplugin::isinitialized() const { return initialized; }

How to Access Application Config from View in Zend Framework 2 (zf2)? -

i wanted access application config view. how can achieve in zf 2? actually shouldn't need access application config inside view. in mvc, views responsible displaying/rendering data (output) , shouldn't contain business or application logic. if want can pass view in controller this: <?php namespace yourmodule\controller; use zend\view\model\viewmodel; // ... public function anyaction() { $config = $this->getservicelocator()->get('config'); $viewmodel = new viewmodel(); $viewmodel->setvariables(array('config' => $config )); return $viewmodel; } // ... ?> so in view.phtml file; <div class="foo"> ... <?php echo $this->config; ?> ... </div>

I can't figure out how to delete a row in my tasm assembly homework -

i have compiled assembly program , i'm asked modify removing last row seen in cmd prompt. i'm new @ assembly can't find solution. when run 5 rows appear, , i'm trying delete row below; press [q]uit [e]xecute [c]lear: ;serhad ali turhan 040060390 .8086 .model small .stack 256 .data ;~~~~~~ declarations ~~~~~~~~ cr equ 13d lf equ 10d cprompt db 'press [q]uit [e]xecute [c]lear: $' cname db 'serhad ali turhan',cr,lf,'$' cnum db 'electronical engineering',cr,lf,'$' csch db 'itu ayazaga kampusu 34469 maslak-istanbul',cr,lf,'$' vdw db 0 ;day of week vmon db 0 ;month vdm db 0 ;day of month cdw0 db 'sunday$ ' ;all days 10 bytes cdw1 db 'monday$ ' cdw2 db 'tuesday$ ' cdw3 db 'wednesday$' cdw4 db 'thursday$ ' cdw5 db 'friday$ ' cdw6 db 'saturday$ ' vi2s_i d

osx - Running a Shell Script on Shutdown via launchd -

since startup items , rc commands both deprecated (and in many cases not working @ all) on os x in favour of launchd , i'd find out correct way setup shell script runs on logout/shutdown. for startup item possible create shell script looked like: #!/bin/sh startservice() { echo "started." } stopservice() { echo "stopped." } runservice "$1" but runservice command isn't supported when running script launchd , , i'm not sure it's meant used anymore anyway. if possible, i'd create shell script provided launchd on-demand service started near shutdown , somehow informed system shutting down. alternatively, may need shell script opened on login/system start , remains running (or rather, asleep) until sigterm or other kill signal received, can run commands before closing. @gaige reply! in end went following: #!/bin/sh startservice() { echo "started" } stopservice() { echo "stopped&q

AJAX fetching data from Spring-MVC Controller -

Image
controller: @requestmapping(value = "jobs") public void removejobs(@requestparam("username") string username, model model) { string []jobs = jobsfetcher(username); model.addattribute("list", jobs); } my jsp: <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>insert title here</title> <link type="text/css" rel="stylesheet" href="<c:url value="public/files/styles/jobmanager.css" />" /> <script type="text/javascript"> function ajaxfunction(use

session - How to use exclusive locks in MySQL? -

i'm trying implement own version of session handler using mysql in php. version differs existing ones (like zend's) in mine namespaced , each namespace stored , locked separately. here's scenario should implemented in code: acquire exclusive lock sid+ns read sid+ns's data ... request takes course ... write sid+ns's data db release lock sid : session id - ns : namespace now question arises is: how use exclusive locks in mysql? there number of issues 1 needs keep in mind before answering question: there arbitrary number of namespaces in each session. one single request might need hold more 1 ex-locks (one request might need work on more 1 namespace @ time). locks need implemented using mysql's internal mechanism. implementing own application-level ex-locks pretty simple. have implement queues , semaphores mimic same behavior mysql giving makes hard. i'm saying want code work on of machines without going through heavy changes , i'm

What is a model and what is not a model php -

i'm quite confused on how build models, failed understand last 9 months. although reading , watching references , @teresko gave me. to further narrow down question, i'll give example of how did before. lets have student entity has student_number , first_name, last_name` i create called model , (my professor did same, know quite wrong). don't know if professor knows value objects, do. private $student_number; private $first_name; private $last_name; public function setstudentnumber($sn) {$this->student_number = $sn} public function getstudentnumber() {return $this->student_number} ... , on other properties if correct, setters , getters classified value object pattern, can used this: $s = new student(); $s->setstudentnumber(143); $s->setfirstname('fooname'); $s->setlastname('barname'); and pass in data access object (studentdao) this: $sdao = new studentdao($s); $sdao->add(); where dao extends database class, can crud

java - Using non-OSGi packages in Eclipse Plugins -

i'm developing eclipse plugin. building , deploying supported tycho , maven. add googles guava v. 14 project dependency. on tychos wiki page have found can resolve dependencies if osgi bundles. not able find version of guava osgi bundle. common workaround situation? check out interested revision guava repository, add manifest , bundle , add projects path, seams me dirty workaround — need maintain bundle myself, can't upgrade bundle, need commit binary in vcs ci. doing same storing bundle in maven repository — maintaining repository source code duplicates existing, upgrading not simple to. it seams me very-very hard import existing java code in osgi projects. don't try convert library osgi bundle yourself: either, simple turn library osgi bundle, e.g. if correct manifest can generated using 1 of bnd based tools. in case, provider of library should directly. maven build, they'd need add bundle goal of maven-bundle-plugin . or, hard turn librar

ruby on rails - Javascript within pop-up modal not running -

how bellow code run within load of javascript pop-up modal box? i'm using facebox. http://defunkt.io/facebox/ <% content_for :javascript %> <script type='text/javascript'> $(function () { function initializeevents() { /* new category */ $('#new_admin_category').on('ajax:success', function (event, data, status, xhr) { $("#dashboard_categories").html(data.html); initializeevents(); }); /* delete category */ $('a[data-remote]').on('ajax:success', function (event, data, status, xhr) { $("#dashboard_categories").html(data.html); initializeevents(); }); } initializeevents(); })(); </script> <% end %> if need more context code doing, please see previous question here: rerun javascript on successful ajax call solved! s

design patterns - When NOT to use MVP/MVC? -

okay question find few proper arguments for/against. i appreciate value these patterns provide testability , separation of concerns. in cases have sort of data store(s), presented user in different ways. but consider application each model bound 1 view. example maybe audio format converter, small gui sitting on (a) big api(s) back-end. ui needs basic validation (for paths , formats), , rest left back-end. would benefit of using 1 such pattern here justify code? personally, see unneeded overhead, may wrong, hence question. :-) edit: the example application wrote here seems have been distracting people main point of question. i'm asking when mvp/mvc not good. here's quote golden 4: no discussion of how use design patterns complete without few words on how not use them. design patterns should not applied indiscriminately. achieve flexibility , variability introducing additional levels of indirection, , can complicate design and/or cost performance. design patt

Need help on finding AVERAGE in python -

this question has answer here: finding average of list 19 answers finding average value of numbers in range 298-272? what average value of numbers in field [quant] in range (198) , (272) inclusive quant 95 189 176 200 177 340 205 203 284 88 109 83 360 67 250 56 111 439 354 143 this code tried. above [quant] field need find average. word_file = open('300000a.csv','r') firstline = true line in word_file: if firstline: firstline = false continue line = line.strip() line = line.split (",") field = int(line[0]) totalmetalcount +=1 if field >198 or field <272: metalcounts += 1 else: metalcounts = 1 countt +=1 if field >198 or field <272: count += 1 you can calculate average of list using sum , dividing length . float(sum(my_list))/

xml - UILoader does not act as MovieClip for Drag and drop; How can you make UILoader to behave like MovieClip -

i wrote code below counselors saw here main goal import images xml main stage , play them "drag , drop function" when turn on fine, when click on pictures "drag , drop function" message typeerror: error #1034: type coercion failed: cannot convert fl.containers::uiloader@1a52f1f1 flash.display.movieclip. @ forgallery_fla::maintimeline/item_onmousedown() typeerror: error #1034: type coercion failed: cannot convert fl.containers::uiloader@1a52f1f1 flash.display.movieclip. @ forgallery_fla::maintimeline/item_onmouseup() how fix problem , make uiloader uiloader import fl.containers.uiloader; import flash.net.urlloader; import flash.net.urlrequest; import flash.events.event; var count:number = 0; //requires: // uiloader control in library var xmlloader:urlloader= new urlloader(); var myxml:xml = new xml ; var uiloader:uiloader= new uiloader(); xmlloader.addeventlistener(event.complete, loadxml); xmlloader.load(new urlrequest("gallery.xml"

javascript - Same sidebar across webpages -

i'm pretty new web development. best practice in keeping same sidebar , other elements across web pages on one's site? store sidebar html , call that? if so, how 1 go doing that? here's one way it: use "include" files . no javascript required. server work, instead of requiring client add content. ssi, or server side includes, first developed allow web developers "include" html documents inside other pages. if web server supports ssi, it's easy create templates web site. save html common elements of site separate files. example, navigation section might saved navigation.html or navigation.ssi. use following ssi tag include html in each page. <!--#include virtual="path file/include-file.html" --> use same code on every page want include file. that page describes other approaches. if know called using include files, can search more easily. example, this article describes includes , how c

Is there an RoleInstanceId equivilent on Azure Websites? -

i'm looking equivalent of azure roleinstanceid, on azure website (as opposed azure web role). i've looked extensively such thing, no avail. deployed "test" website display of environment variables on azure website, there didn't appear useful variable in set. any in regard appreciated! btw, in case you're interested in why want such thing, i'm trying implement advanced version of steve marx's excellent scalable counters windows azure ... request.servervariables[ "instance_id" ] get iis site id website would give iis site id .. might work identify. other hard coding in configuration file. that should give unique id of inputting id each row of counter. worst case use guid , generate each time. this make sure counter good. hths, james

java - How to track mouse over SWT composite made from sub controls? -

Image
i have created own control: i want track mouse , added mousetracklistener . unfortunately mouseenter , mouseleave events generated, when mouse moves on parts of composite (that label , button). [mouse enter] - mouse enters empty space [mouse hover] - mouse on empty space [mouse exit] - mouse moved on label [mouse enter] - mouse leaves label , enters empty space [mouse hover] - mouse on empty space [mouse exit] - mouse leaves composite how can track composite 1 complete thing instead of sub parts? public class mycomposite extends composite { public mycomposite(final composite parent, final int style) { super(parent, style); final label lbl = new label(this, swt.none); lbl.setbounds(10, 10, 78, 15); lbl.settext("my composite"); final button btn = new button(this, swt.none); btn.setbounds(190, 29, 75, 25); btn.settext("ok"); pack(); } public static void main(final string

Android Touchevent - Pinch gesture -

i looking @ scalegesturedetector class. http://developer.android.com/reference/android/view/scalegesturedetector.html i have 2 method's zoom-in , zoomout . method should over-ride call these 2 methods. private class scalelistener extends scalegesturedetector.simpleonscalegesturelistener {@ override public boolean onscale(scalegesturedetector detector) { return true; } override public boolean onscalebegin(scalegesturedetector detector) { return true; } override public boolean onscaleend(scalegesturedetector detector) { } } let's take when pinch-up, want call zoom-in , pinch-down want call zoom-out . you need scale factor calling scalegesturedetecteor.getscalefactor() inside of onscale method. if less one, zooming out, otherwise - zooming in

backbone.js - Backbone - Render Text as HTML not a String -

Image
i have backbone app rendering underscore template json file. have body copy want render unordered list in html. text keeps rendered html 1 whole string. advice stop this? this getting cms have in json file <p>leading provider of tax credit services , financing productions wishing access state's <b>recently increased</b> 20%-25% production tax credit. &lt;ul&gt;&lt;li&gt;tax credit administration (including filing of forms, reports , tax returns).&lt;/li&gt;&lt;li&gt;tax credit advances (either during or upon completion of production)&lt;/li&gt;&lt;li&gt;deferral of 100% of equipment, camera , facilities costs &lt;/li&gt;&lt;/ul&gt;</p> here happens when rendered: i assume want have <li>code</li> rendered list item instead of raw text. this fiddle may help: http://jsfiddle.net/fzm4n/

asp.net - Accessing gridview from infile javascript aspx.net, paging issue -

so here's situation: i've got grid: <asp:gridview id="productgrid" runat="server" allowsorting="true" allowpaging="true" pagesize="20" onpageindexchanging="pageindexchanged" pagersettings-visible="false" autogeneratecolumns="false" onsorting="sort"> and i'm accessing this: var grid = document.getelementbyid("<%= productgrid.clientid %>"); which works, that's fine, problem is, when go grid.row.length , 21, grid bound several hundred elements, problem it's looking @ first page, how @ rest of data? i want iterate through whole table. yes i'm sure table has been loaded values before javascript executed, values on page load , script on button click. thanks help

does python stores similar objects at contiguous memory locations? -

does python stores similar objects @ memory locations nearer each other? because id of similar objects, lists , tuples , nearer each other object of type str . no, except of course coincidence. while highly implementation- , environment-specific, , there memory management schemes dedicate page-sized memory regions objects of same type, no python implementations i'm aware of exhibits behavior describe. possible exception of small numbers, cached under hood , located next each other. what you're seeing may because string literals created @ import time (part of constants in byte code) , interned, while lists , tuples (that don't contain literals) created while running code. if bunch of memory allocated in between ( especially if isn't freed), state of heap may sufficiently different quite different addresses handed out when you're checking.

sql server - Debugging Ambiguous outer join statement -

i new ms office access , having problems constructing sql view query . keep getting error : "the sql statement not executed because contains ambiguous outer join. force 1 of joins performed , create seperate query performs first join , include query in sql statement". 1) how create seperate query in ms sql view , include query main sql statement??? 2) cant understand why error occuring ?? select [table : purchasedetails].purchaseid [table: supplier] left join ([table : purchase] left join ([table : product] left join [table : purchasedetails] on [table : product].productid = [table : purchasedetails].productid) on [table : purchase].purchaseid = [table : purchasedetails].purchaseid) on [table: supplier].supplierid = [table : purchase].supplierid; i'm not sure access, in sql on command should follow join, so: select [table : purchasedetails].purchaseid [table: supplier] left join [table : purchase] on [table : purchase].purchaseid = [table

PHP and mySQL Dynamic Query -

im trying create dynamic query based upon or selections option values selected user. eg if select project id query return project id, size , lesson stored in second table, or if select size , department query execute. displaying projects of chosen size lessons against it. heres ive got far. help. <?php $pid = $_post['project_id'] ; $psize = $_post['projectsize'] ; $pdepts = $_post['depts'] ; $lstage = $_post['stage'] ; $ltype = $_post['type'] ; $impacted = $_post['impacted'] ; $sqlstring = null; echo "total number of captured post variables is:"; echo count($_post); echo '<br />'; $number = 0; foreach ($_post $param_name => $param_val ) { if ($param_val ==""){ }else{ $number++; } echo "param: $param_name = $param_val<br />\n"; } if($number ==1) { }else{ } ?> i hope can little , added array check , need check security , injection :) <

javascript - Using Dojo 1.9, all parsing fails in IE -

so have rather large web app running dojo 1.8. works fine in multiple versions of ie , firefox. decided give 1.9 go , changed dependency 1.8 1.9. firefox worked fine no noticable changes on first run. ie versions 8 , 9, however, both failed of @ all. static html content (and dynamic jsp content) fine, , of ajax calls required modules seemed work fine, parser acted wasn't ever being called. there no errors, warnings, or in console. i kept playing dojo config, nothing special: var dojoconfig = { baseurl: "js/", async: true, has: { "dojo-firebug": true, "dojo-debug-messages": true }, parseonload: false, isdebug: true, tlmsiblingofdojo: false, packages: [ { name: "dojo", location: "dojo-release-1.9.0/dojo" }, { name: "dijit", location: "dojo-release-1.9.0/dijit" }, { name: "dojox", location: "dojo-release-1.9.

java - GWT loading elements dynamically on page load -

i have page should have dynamic count of check boxes, , inputs depends on data received database now this: make rpc call on component load (getting data inputs) onsuccess add inputs dynamically on form result: form displayed without content(because makes call async), after resizing, displays content (probably can fire resize event or redraw self, don't know how.. ) question: new in gwt, best way task? (now using gwt-ext http://gwt-ext.com/ , think it's no matter ) update: refresh panel it's possible call dolayout() ; i'm not familiar gwt-ext in "vanilla" gwt have 2 options: refresh widget (that should show result) in onsuccess method proceed rest of code not until result returned. to bit more precise need more of code.

c - Strange wording in the standard, concerning comparison of pointers -

§6.5.8\6 (concerning >, <, <=, >=) if expression p points element of array object , expression q points last element of same array object, pointer expression q+1 compares greater p . in other cases, behavior undefined. several sections above, §6.5.8, explained basically, pointer arithmetic work expected on arrays. int a[3]; int *p = a; int *q = &a[2]; //q-p == 3 valid. however, read above q > p ub. what missing? firstly, have quoted part of paragraph, first part explains referencing, include paragraph here: when 2 pointers compared, result depends on relative locations in address space of objects pointed to. if 2 pointers object types both point same object, or both point 1 past last element of same array object, compare equal. if objects pointed members of same aggregate object, pointers structure members declared later compare greater pointers members declared earlier in structure, , pointers array elements larger su

perl - Print sysout lines at single go from open 3 -

i using open 3 , printing lines below 1 one after doing parsing. not want print line line want store , print @ once how can it? while(my $nextline=<handle_out>) { chomp($nextline); if ($nextline =~ m!<bea-!){ print "skipping line (bea): |$nextline|\n" if $debug; } print $nextline."\n"; } if don't want lines printed while you're looping on file handle, this: the data structure being hash of anonymous arrays( debug , output ). my %handle_output = ( debug => [], output => [], ); while(my $nextline=<handle_out>) { chomp($nextline); if ($nextline =~ m!<bea-!){ push( @{$handle_out{debug}}, $line ) if $debug; } else { push @{$handle_output{output}}, $line; } } $line ( @{$handle_output{output}} ) { print $line . "\n"; }

c# - IronPython - Error in URL request -

when using ironpython make url request xml (with python-requests), in visualstudio's console following error: failed parse cpython sys.version: '2.7.3 ()' what mean? how can fix it? this python code causes problem: def __xml_retrieve(self, query_string): """ handles mb speed limits """ attempt = 0 while attempt <= self.max_attempts: attempt += 1 # raises connectionerror; still not managed try: r = requests.get(query_string) except exception exc: print exc.message if r.status_code == 503: time.sleep(self.speed_limit_pause) elif r.status_code == 200: return r.content return the problem born when call request.get(query_string). requests library: http://docs.python-requests.org/en/latest/ .

C# updating information in an exe file -

im building application should consist of single .exe file in turn distributed others. in .exe file there 2 hardcoded fields, username , password. people going distribute want ability update fields , change information. i have absolutetly no clue how this. if there dll or config sure, read them information in plain text there no such files project. ones updating .exe should people distributing application going have update , reupload .exe suppose how? do write new application somehow decompiles, updates fields , recompiles it? or there "usual" way of doing im not aware of? or way go source code, change fields , compile new .exe , replacing old one? edit bad wording me, emailaddress , password using in smtp client, hardcoded because user dont choose account send mail from. rather hardcoding information executable, might make sense still have app.config file, encrypt it, provide utility write encrypted app.config specified information.

windows - How to fix RSS feeds in OSQA? -

when trying access rss link in windows installation of osqa, error log shows following error: c:\python27\lib\site-packages\django\core\handlers\base.py time: 2013-05-09 17:46:37,956 msg: base.py:handle_uncaught_exception:209 internal server error: /feeds/rss traceback (most recent call last): file "c:\python27\lib\site-packages\django\core\handlers\base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) file "c:\inetpub\wwwroot\osqa\[mysite.com]\forum\views\readers.py", line 73, in feed settings.app_description)(request) file "c:\python27\lib\site-packages\django\contrib\syndication\views.py", line 37, in __call__ feedgen = self.get_feed(obj, request) file "c:\python27\lib\site-packages\django\contrib\syndication\views.py", line 97, in get_feed current_site = get_current_site(request) file "c:\python27\lib\site-packages\django\contrib\sites\models.py", line 92,

Spring PropertyPlaceholderConfigurer with dynamic location path -

i have following spring xml-based config: <!-- these properties define db.type property. --> <bean class="org.springframework.context.support.propertysourcesplaceholderconfigurer"> <property name="order" value="1"/> <property name="ignoreunresolvableplaceholders" value="true" /> <property name="ignoreresourcenotfound" value="true" /> <property name="locations"> <list> <!-- contains default db.type --> <value>classpath:/default-cfg.properties</value> <!-- db.type can overridden optional properties in app work dir --> <value>file:${app.work.dir}/cfg.properties</value> </list> </property> </bean> <!-- db.type should used db specific config properties --> <bean class="org.springframework.context.support.propertysourcesplaceholderconfigurer"> &

sql - Insert common data from one database into another? -

i have database x , database y. x , y have tables , columns of same schema. there no data in database y. what sql/t-sql can write in order transfer data database x database y tables , column names same? thank you edit: both databases on same server. not know tables , columns of same name, cant insert each table manually (e.g. there may 100s of tables , columns same name) after receiving additional information question turned bit interesting tried come query should the task of comparing sys.tables , sys.columns between 2 databases , create insert/select script. test setup: use x create table t1 (co1 int, col2 varchar(10)) create table t2 (co1 int, col2 varchar(10)) create table t3 (co1 int, col2 varchar(10)) create table t4 (co1 int, col2 varchar(10)) create table t5 (co1 int, col2 varchar(10)) create table t6 (co1 int, col2 varchar(10)) create table t7 (co1 int, col2 varchar(10)) create table t8 (co1 int identity(1,1), col2 varchar(10)) use y create table t1 (

jquery - .editable table .animate css issue -

i have table jquery .editable, have set when make successful edit, field flashes green or red unsuccessful edit , return original field colour. the code follows: $('.editablepm').editable('<?php echo base_url();?>ratesheet/editrowpeakmin/<?=$editable['url'];?>/', { callback: function(value){ $(this).data('bgcolor', $(this).css('background-color')); if(value == this.revert) { $(this).animate({ backgroundcolor: "red", color: "white" }, 400); $(this).animate({ backgroundcolor: $(this).data('bgcolor'), color: "black" }, 400); } else { $(this).animate({ backgroundcolor: "green", color:

asp.net - How to sort variables in an xsl for-each list -

i have following code: <asp:radiobuttonlist id="priceselect_{$moduleid}" runat="server" repeatdirection="vertical" nowrap="true"> <xsl:for-each select="page/arrayofwebprice/webprice"> <xsl:variable name ="ratecode" select ="ratecode"></xsl:variable> <xsl:variable name ="ratestructure" select ="ratestructure"></xsl:variable> <xsl:variable name ="price" select="concat($currencysymbol, format-number(price, concat('#,###,##0.', substring($zeros, 1, $currencyprecision))), ' ', $currencycode)"></xsl:variable> <asp:listitem value="{$ratestructure}_{$ratecode}_price" enabled ="true" selected ="true" text="{$price}" > </asp:listitem> </xsl:for-each> <asp:listitem value="other" enabled ="true" selected ="f

Compare 2 excel columns, the result will be compared to another column -

i'm pretty new vba, , i'm having problem on comparison of 2 columns (all of data under 2 columns). the workflow is, column compare column b result put in column c. column (column d) used comparison (all of columns in 1 worksheet). the logic this: compare column column b if column b blank, put "no value here" if column b has value (sample value: product-id), compare b column d (sample value: pi, abbreviation of product-id) if matched put "matched". if no matches, put "no match" instead of vba, here solution using formulas in worksheet in column c want apply rule: if b="" "no value here" else if b=d "matched" else "not matched" end if you can below formula in column c (then filled down) =if(b:b="","no value here",if(b:b=d:d,"matched","not matched"))

Import Data in LDAP server -

i have create ldap server gets user information application (say app01) , send application (say app2). have created openldap server , installed jxplorer , created users(test data) using jxplorer. app02 has functionality connect openldap server , connection successful , getting test data in app02. my problem data (import data) app01 automatically. can ldap server import data? i m getting data app01 in form of csv file, need build >net application send openldap server or openldap server has functionality import data.. the ldap client can import data server - operation replaces existing database contents of file containing ldif the ldap client can add data server database file containing ldif change records using ldapmodify or ldapadd tool. operation not change existing database, rather adds data or changes existing data. a commercial synchronization device can deployed synchronize data data source destination, destination being openldap server.

java - How to create a zip file of multiple image files -

i trying create zip file of multiple image files. have succeeded in creating zip file of images somehow images have been hanged 950 bytes. don't know whats going wrong here , can't open images compressed zip file. here code. can let me know what's going here? string path="c:\\windows\\twain32"; file f=new file(path); f.mkdir(); file x=new file("e:\\test"); x.mkdir(); byte []b; string zipfile="e:\\test\\test.zip"; fileoutputstream fout=new fileoutputstream(zipfile); zipoutputstream zout=new zipoutputstream(new bufferedoutputstream(fout)); file []s=f.listfiles(); for(int i=0;i<s.length;i++) { b=new byte[(int)s[i].length()]; fileinputstream fin=new fileinputstream(s[i]); zout.putnextentry(new zipentry(s[i].getname())); int length; while((length=fin.read())>0) { zout.write(b,0,length); } zout.closeentry(); fin.close(); } zout.close(); change this: while((length=fin.read())>0

Wpf C# Datagrid row columns spanning multiple rows -

Image
is possible create datagrid looking wpf? i have column important information display, text long display horizontally. therfore need display in vertical fashion. cheers! daan

selenium webdriver - Not able to find get the text in browser -

<!doctype html> <html lang="en"> <head> <body class="layout-two-column unibet umyaccount"> <div class="tooltip-container"> <div id="tooltip" class="tooltip tooltip-error right-center" style="top: 466px; left: 709px; display: none;"> <div class="tooltip-content gutter-3 icon icon-small icon-error">danish site specific</div> <div class="tooltip-pointer"></div> <div class="tooltip-pointer-decoration"></div> </div> </div> <div id="window"> <div id="container" class="lobby-theme-3"> <header id="header"> <nav id="nav-main"> <div id="no-sub-nav"></div> <div id="main" role="main"> <div class="stack-wrap gutter-col-wrap-2"> tri

css - Aligning two divs? -

bit of css newb here. i'm using fluid grid layout in dreamweaver cs6. created headercontainer div, headerleft , headerright divs inside it. i've added image headerleft , typed text in headerright. want able have text remain in line center of image no regardless of resizing fluid layout. what's best way this? put 2 headers in container div hoping make easy me align 2 divs within container, i'm not sure how achieve it. here's code have section of page: edit: code says (but still doesn't work): .gridcontainer { margin-left: auto; margin-right: auto; width: 90.5666%; padding-left: 0.2166%; padding-right: 0.2166%; } #headercontainer { clear: both; float: left; margin-left: 0; width: 100%; display: block; font-family: arial, helvetica, sans-serif; color: #fff; text-align: left; } #headerleft { clear: both; float: left; margin-left: 0; width: 49.7607%; } #headerright { clear: none;

Creating a SQL Query with two tables -

Image
i need assistance creating query following result: i have 2 tables accounts, lists users , how initial owe , payments, holds records of payments users have made. know how merge tables join don't know how math needed owed amount , paid amounts. the columns in accounts consist of: id, name, account, borrowed columns in payments consist of: id, acctid, paymentamt i need query combine both of these tables , math show how user has paid , how user still owes initial borrowed amount. example table data: accounts table id = 3, name = joe, account = business, borrowed = 100.00 payments table id = 1, acctid = 3, paymentamt = 10.00 id = 2, acctid = 3, paymentamt = 10.00 i using ms sql in c#. you need join , use sum , group by. select a.name , a.account , a.borrowed - coalesce(sum(p.paymentamt),0) [still owes], coalesce(sum(p.paymentamt),0) paid, a.borrowed accounts left join payments p on a.id = p.acctid

regex java: how to replace a string in a generic between the start tag and end tag of a generic -

in java, have string so: "bla bla bla bla [back] bla bla bla [bla bla [go] bla bla bla bla [bla" and want find rule regex replace start tag "[" "(start)" , end tag "]" "(end)". a "start-tag or end tag alone" should ignored. the result following: bla bla bla bla (start)back(end) bla bla bla [ bla bla (start)go(end) bla bla bla bla [bla string resultstring = subjectstring.replaceall( "(?x) # turn on verbose mode \n" + "\\[ # match [ \n" + "( # match , capture in group 1: \n" + "[^\\[\\]]* # number of characters except brackets\n" + ") # end of capturing group \n" + "\\] # match ]", "(start)$1(end)"); will match/replace balanced [ / ] pairs no brackets in-between them.

c# - How can you programatically scroll a WrapGrid to a specific item within its ItemSource in a Windows Store App? -

i have following: <gridview.itemspanel> <itemspaneltemplate> <wrapgrid orientation="vertical" maximumrowsorcolumns="10" /> </itemspaneltemplate> </gridview.itemspanel> i scroll specific item, can't find out how. so far have: int itemindex = ...; var scrollbar = thegridview.getfirstdescendantoftype<scrollviewer>(); scrollbar.scrolltohorizontaloffset((double)itemindex / numberrows); ... feels oddly hacky, , means have programatically calculate number of rows. const int individualitemheight = /* nasty hard-coded thing */; numberofrows = (int)((thegridview.actualheight - thegridview.padding.top - thegridview.padding.bottom) / individualitemheight); ... more hacky. there must better way. appreciated! to scroll specific view gridview need access object bind grid view item , invoke listviewbase.scrollintoview(object)

python - Get Arguments To Program Remotely -

i have code: arguments = urllib.urlopen("http://website.com.info/file.php") command = location + "\file.exe " + arguments.read() i able control arguments remotely , code works, problem av block behavior because tries access website or something. alternative way able pass arguments program remotely? i use python2.6 , program run on windows (py2exe) p.s used on own computers i'm trying control arguments remotely when i'm not around.

arrays - Excel CSV help Python -

Image
i have following csv file: how import numbers array in python 1 row @ time? no date, no string. my code: import csv def test(): out = open("example.csv","rb") data = csv.reader(out) data = [row row in data] out.close() print data let me more clear. don't want huge 2d array. want import 2nd row , manipulate data 3rd row. need loop this, not sure on how csv works. try this: with open('the_csv_file.csv','r') f: box = f.readlines() result_box = [] line in box[1:]: items = line.split(';') # adjust separator character in csv needed result_box.append(items[1:]) print result_box

python - Adding two tuples elementwise -

i wondering if there pythonic way of adding 2 tuples elementwise? so far (a , b tuples), have map(sum, zip(a, b)) my expected output be: (a[0] + b[0], a[1] + b[1], ...) and possible weighing give 0.5 weight , b 0.5 weight, or on. (i'm trying take weighted average). which works fine, wanted add weighting, i'm not quite sure how that. thanks zip them, sum each tuple. [sum(x) x in zip(a,b)] edit : here's better, albeit more complex version allows weighting. from itertools import starmap, islice, izip = [1, 2, 3] b = [3, 4, 5] w = [0.5, 1.5] # weights => a*0.5 + b*1.5 products = [m m in starmap(lambda i,j:i*j, [y x in zip(a,b) y in zip(x,w)])] sums = [sum(x) x in izip(*[islice(products, i, none, 2) in range(2)])] print sums # should [5.0, 7.0, 9.0]

ruby - How do I return a value from inside a loop? -

i trying read xml file , store structure array of objects. here code: class bike attr_accessor :id, :color, :name def initialize(id, color, name) @id = id @color = color @name = name end end ---x---snip---x--- rules.root.each_element |node1| case node1.name when "bike" bike = bike.new(node1.attributes['id'], node1.attributes['color'], { |bike_elem| bike_elem.text.chomp if bike_elem.name == "name"}) bikes.push bike end end however, last element not fetching value alone. fetching whole tag. there better way it? your code block { |bike_elem| bike_elem.text.chomp if bike_elem.name == "name" } doesn't seem make sense inside new parameter list. where bike_elem come from? not valid ruby in context. it's hard give answer here without knowing xml looks like. recommend using xml library nokogiri, libxml, , parse out name before new . try using xpath .

sql server 2008 - How to return consecutive date ranges frm a set of dates in sql -

i have set of dates table in sql. want return date ranges , need help. so if had dates this pk - date 160 - 2013-04-16 12:09:00 160 - 2013-04-17 11:07:00 162 - 2013-04-16 12:10:00 160 - 2013-04-20 12:10:00 i want example pk - beg - end 160 - 2013-04-16 12:09:00 - 2013-04-17 11:07:00 160 - 2013-04-17 11:07:00 - 2013-04-20 12:10:00 162 - 2013-04-16 12:10:00 - 2013-04-16 12:10:00 can please me. thank you i using microsoft sql server management studio 10.0.1600.22 here's example using ms sql server 2008 (though should work 2005+): with cte ( select rownum = row_number() on (partition pk order date asc), * dates ) select a.pk, a.date [beg], coalesce(b.date, a.date) [end] cte left join cte b on b.pk = a.pk , b.rownum = a.rownum + 1 b.rownum not null or a.rownum = 1 this row numbers each pk, provide joins between table , itself, filtering out rows don't h

javascript - Php Rest API path hierarchy w/o id -

i reading book , searching on internet api path hirearchy , have not found solid yet, want know put id retrieve/update/delete hirearchical api methods. for instance know can do: authority/resource/[id]/catalog/category1/category2 also: authority/resource/catalog/category1/category2/[id] in previous example problem comes when next path category2 (id) can numeric field lets update value. i not know if there standard way of building state transfer api. can build own , wondering if there standards or aproach. the "standard" allows lot's of interpretations on how can design hierarchy. there not way it. however think presentation: https://blog.apigee.com/detail/restful_api_design read on topic. outlines design choices , shows how popular apis (such ones offered google or twitter) choose design urls.

vba - How to define variables based on value of another variable -

i new forum, please pardon me if not accustomed procedures. my question follows: suppose running loop in vba = 1 10 want define variables based on number of loops. that is, if there 10 loops there 10 variables created x1, x2,...., x10 if there 20 loops, there 20 variables created x1, x2, ....., x20. i pretty new vba , not have idea. any appreciated. thanks lot if aware of how many loops have, use info define array of variables. for example: dim numbers(1 10) long 'declare upper/lower bounds dim morenumbers(20) long 'default starts 0 lower bound now if want declare values through loop, easy. let's want array of 10 strings, foo1-foo10: dim arrayoffoo(1 10) string = 1 10 arrayoffoo(i) = "foo" & next hope helps.

php - JQuery script fails when URL has path after filename -

i trying incorporate javascript/jquery script php page. works fine when script called url script file, this: www.mysite.com/index.php however, use url path parameters program logic , seo. when use url: www.mysite.com/index.php/profile/edit the script fails with: syntaxerror: unexpected token '<' actually, error occurs if there trailing / @ end of url. the script far long include here, suggestions nature of should looking appreciated.

android - Dropdown Action Menu with Web Link -

Image
as tried show on image, in app 've address bar, dropdown action menu , webview. my question ; how can add described web links when clicked goes link in webview? menu not changeable or addable. thank you. please check source code , think you. here actionbar.onnavigationlistener click event public class mainactivity extends activity { /** array of strings populate dropdown list */ string[] actions = new string[] { "bookmark", "subscribe", "share" }; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); /** create array adapter populate dropdownlist */ arrayadapter<string> adapter = new arrayadapter<string>(getbasecontext(), android.r.layout.simple_spinner_dropdown_item, actions); /** enabling dropdown list navigation

paypal - Payment service that allows third-party commission -

i want make auction platform user can put product selling , user can buy him. want transaction process between seller , buyer only, want platform take commission fee. is there payment service provides kind three-actor transaction process in api? 1 transaction process, payment directly buyer seller , fee platform. you use adaptive payments perform kind of transaction.

jquery - How to get and set an attribute value for a HTML tag using AngularJS? -

i trying find best way & set value attribute in html tag using angularjs. example: <!doctype html> <html> <head> <meta charset="utf-8"> <title>my website</title> </head> <body> <h1>title</h1> <p>praragraph1</p> <p data-mycustomattr="1234567890">paragraph 2</p> <p>paragraph 3</p> <footer>footer</footer> </body> </html> then, when call url '/home', value data-mycustomattr (that use calculation), , replace "1", and if url '/category', value data-mycustomattr, , replace "2". with jquery simple: $("#mypselector").attr('data-mycustomattr'); or $("#mypselector").attr('data-mycustomattr','newvalue'); i used jquery code, putting inside controllers, , working fine. far read, might bad practice. however, solutions found, uses direc

Python: I'm misunderstanding stack logic, but I'm not sure where -

i have function evaluating infix expression via use of stacks. (bet you've never seen 1 before.) takes expression in list format, wherein each item in list single character (operand, operator, or parenthesis.) s = stack() tempvar = none ops = ['+','-','/','*'] in expression: if == '(' s.push(i) elif i.isdigit(): if tempvar none: tempvar = else: tempvar = tempvar + elif in ops: if tempvar not none: s.push(tempvar) tempvar = none popped = str(s.pop() + str(s.pop()) last = s.pop() if last not ')': popped += str(last) x in popped: print 'popping',x,'from stack.' print 'popping',last,'from stack.' math = eval(popped) s.push(math) print 'pushing',math,'back onto stack. my intention using "tempvar"