Posts

Showing posts from April, 2013

java - Using OGNL to get parameters -

in 1 jsp page, including jsp page , passing parameter: <jsp:include page="/web-inf/somepage.jsp" flush="true"> <jsp:param name="location" value="menu"/> </jsp:include> in included page, can access parameter using el. works: ${param.location} but cannot use ognl equivalent same parameter. none of these work: #parameters.location #parameters['location'] %{#parameters.location} %{#parameters['location']} i know there work-around using <s:set var="location">${param.location}</s:set> or <c:set var="location">${param.location}</c:set> , using ognl: #location want avoid that. don't want use scriptlets either. struts2 equivalent include tag <s:include that's should replace in code, apply <s:param parametrize it. <s:include value="/web-inf/somepage.jsp"> <s:param name="location" value="menu&q

How to handle Salesforce REST error response in JSON (Python) -

i wondering how correctly handle salesforce error responses portal i'm developing. or more generically, how handle json error response. instance, if queried database information didn't exist, if user provided incorrect login credentials, etc. i'm looking accepted, pythonic solution problem. thank you. check response, if there's error, raise exception. ideally, exception should match error message returned api, , include information returned api. if you're writing library, let end-user decide how want proceed. here's example of code wrote salesforce rest api wrapper: the exception: class soqlexception(sfdcexception): def __init__(self, errorcode, message): self.errorcode = errorcode self.message = message and in code making request, after loading json data . maybe changed, salesforce used return error dict inside array: if len(data) == 1 , u"errorcode" in data[0]: error = data[0]

Visual Studio 2010 cannot debug javascript after uninstalling IE10 -

my dev machine got automatic update ie9 ie10. latter broken on our development web site, uninstalled ie 10 "update" revert ie9. visual studio 2010 no longer attach debugger browser. can either debug in ie9 developer mode, or attempt launch new instance of vs'10 debug (but doesn't work either.) what can restore link between vs'10 , ie'09? edit: dialog titled "visual studio just-in-time debugger". "an unhandled exception ('script breakpoint') occurred in iexplore.exe [4824] possible debuggers: new instances of microsoft visual studio 2010 .... " cannot attach running instance of vs. try re-install .net library. .net library

sql server - Why can't I use database set defaults? -

why can't use database set defaults entity framework? when designed database, added appropriate default values (i.e. "default value or binding" field). seems have specify default in code anyway unless use storegeneratedpattern.computed not allowed change value later. if don't specify default value in code, exception. there logic here. in entity have public int exampleint { get; set; }. let set default value of example column 100. imagine situation entity object created. it's c# object default values being filled in runtime. exampleint initialized value 0. @ time, entity object knows nothing db. decide save entity. ef have create row , insert values specified. wait? should 0 or 100? ef have track if made change field, if create entity object, ef not aware of until attach it/save it. just idea: if run in constructor query check default value? work moment create object filled default value. if object created ef, value overwritten have in db. actu

asp.net mvc 4 - MVC 4 Update Menu On Every View Load -

i have shared view _layout.cshtml contain number of unread messages user. need check new messages every time user visits new view. @ time, don't see need on timed ajax-type call. i can day master pages on .net webforms i'm having hard time doing simple mvc. my question is: how can trigger database call on every view load check , see if there change in number of messages , update text in _layout.cshtml? create partial view contain unread messages etc create model pass view create "partial action" from _layout, call html.renderaction (or html.action() ) we prefix partials underscore. views\shared\_unreadmessagespartial.cshtml @model unreadmessagesviewmodel unread messages: @model.unreadmessagescount unreadmessagesviewmodel.cs public class unreadmessagesviewmodel { private dbcontext _db; public int unreadmessagescount; public unreadmessagesviewmodel() { _db = new dbcontext(); unreadmessages = _db.messages.co

c# - ListBox shows System.Collection.ArrayList -

i have listbox on 1 page carries items in listbox list box on page, when second listbox shows "system.collection.arraylist". page1: protected void btncheckout_click(object sender, eventargs e) { session["name"] = nametext.text; session["phonenumber"] = phonetextbox.text; session["address"] = addresstext.text; session["email"] = emailtext.text; session["city"] = citytextbox.text; arraylist al = new arraylist(); (int = 0; < itemlistbox.items.count; i++) { if (itemlistbox.items[i].selected == true) { al.add(itemlistbox.items[i].value); } } session["selectedvalues"] = al; response.redirect("invoice.aspx"); } page2: protected void page_load(object sender, eventargs e) { string phonenumber = (string)(session["phonenumber"]); string homeaddress = (string)(session["address"]); string name

ios - Youtube videos thumbnail not shown -

i'm posting users wall ios sdk 3.2.1. ok if post youtube video, it's thumbnail not shown. posting code this: postparams =[[nsmutabledictionary alloc] init]; [postparams setobject:link forkey:@"link"]; [postparams setobject:name forkey:@"name"]; [postparams setobject:desc forkey:@"description"]; [postparams setobject:url forkey:@"source"]; [postparams setobject:message forkey:@"message"]; appdelegate *appdel=[[uiapplication sharedapplication] delegate]; appdel.session=[[fbsession alloc] init]; [appdel.session openwithcompletionhandler:^(fbsession *session, fbsessionstate status, nserror *error) { }]; [fbsession setactivesession:appdel.session]; [fbrequestconnection startwithgraphpath:@"me/feed" parameters:postparams httpmethod:@"post" completionhand

autosuggest - Solr multi-word suggest gives zero results when full word is used -

field definition <field name="programdescriptionlookup" type="suggest_simple" indexed="true" stored="false" multivalued="true"/> field type & copy field <copyfield source="programdescription" dest="programdescriptionlookup"/> <fieldtype name="suggest_simple" class="solr.textfield" positionincrementgap="100"> <analyzer type="index"> <tokenizer class="solr.whitespacetokenizerfactory"/> <filter class="solr.lowercasefilterfactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.whitespacetokenizerfactory"/> <filter class="solr.lowercasefilterfactory"/> </analyzer> </fieldtype> 2 documents exist following values field <field name="programdescription

python - How to find the cumulative sum of numbers in a list? -

time_interval=[4,6,12] i want sum numbers [4+0, 4+6, 4+6+12] in order list t=[4,10,22] . tried: x=0 in (time_interval): t1=time_interval[0] t2=time_interval[1]+t1 t3=time_interval[2]+t2 print(t1,t2,t3) 4 10 22 4 10 22 4 10 22 if you're doing numerical work arrays this, i'd suggest numpy , comes cumulative sum function cumsum : import numpy np = [4,6,12] np.cumsum(a) #array([4, 10, 22]) numpy faster pure python kind of thing, see in comparison @ashwini's accumu : in [136]: timeit list(accumu(range(1000))) 10000 loops, best of 3: 161 per loop in [137]: timeit list(accumu(xrange(1000))) 10000 loops, best of 3: 147 per loop in [138]: timeit np.cumsum(np.arange(1000)) 100000 loops, best of 3: 10.1 per loop but of course if it's place you'll use numpy, might not worth having dependence on it.

python - How to parse F5 bigip.conf using pyparsing -

am trying figure out how use nifty lib parse bigip config files... grammar should,be this: stanza :: name { content } name :: several words, might contain alphas nums dot dash underscore or slash content:: stanza or zeroormore(printable characters) to make things more complicated, 1 exception: if name starts "rule ", content cannot "stanza" i started this: from pyparsing import * def parse(config): def bnf(): """ example: ... ltm virtual /common/vdi.uis.test.com_80_vs { destination /common/1.2.3.4:80 http-class { /common/http2https } ip-protocol tcp mask 255.255.255.255 profiles { /common/http { } /common/tcp { } } vlans-disabled } ... """ lcb, rcb, slash, dot, underscore, dash = [c c in '{}/._-'

Best practice for publishing an open source project with third party dependancies -

i publish project codeplex. question best approach 2 third party libraries project depends on. 1 system.data.sqlite , other dapper. should put specific binaries built against repository allow user code , run without getting other dependancies, or should mentioned in documentation requirements? i don't know how codeplex community handles typically. can speak in general. normally not publish binaries in open-source code repository. typically windows binaries published parts of releases, times installer package. in package include binaries executable depends on. note if publish binary (your own software) makes more sense provide dependencies. think worst case of user trying binary slightly, not compatible binary built third-party sources, , obtaining erratic behavior. one thing have note if publish third-party software, have adhere license . in example of gpl means need ship relevant documentation , offer provide source files used build these binaries on request. in

vb.net - DataAdapter update method progress status -

vb2010 using access2007 backend. creating dataset , adding several datatables , populating them. tables have small amount of records 1 can have million records. when issue .update command, there way status of it's @ can let user know x% done updating? it works great app hangs while doing update. rowsupdated = danewparts.update(dsinventory, "newparts") the oledbdataadapter has 2 events called rowupdated , rowupdating can use receive notification when row has been updated or before update event. addhandler danewparts.rowupdated, new oledbrowupdatedeventhandler(addressof onrowupdated) sub onrowupdated(byval sender object, byval args oledbrowupdatedeventargs) ..... end sub this first part of problem, need know how many rows updated when start operation. obtained calling getchanges on datatable updating dim count integer dim changeddata = dsinventory.tables("newparts").getchanges() if changeddata isnot nothing count = changeddata.rows.

oauth - Dropbox auth is not working on Python -

i'm trying build app using python ( flask ) , dropbox api. i'm trying authorize user, followed tutorial python. from flask import flask, render_template, url_for dropbox import client, rest, session # dropbox settings app_key = 'gb83a6gpdo4kba6' app_secret = 'w5q0yhj9ikiw39g' access_type = 'app_folder' # flask config debug = true app = flask(__name__) app.config.from_object(__name__) @app.route("/") def home(): dropboxaccount = dropboxaccesstoken = dropboxclient = none # dropbox auth dropboxsession = session.dropboxsession(app.config['app_key'], app.config['app_secret'], app.config['access_type']) requesttoken = dropboxsession.obtain_request_token() try: dropboxaccesstoken = dropboxsession.obtain_access_token(requesttoken) dropboxclient = dropboxclient.dropboxclient(dropboxsession) dropboxaccount = dropboxclient.account_info() except exception,

visual studio 2010 - Command-Line arguments not working (char, TCHAR) VS2010 -

i have following code: int _tmain(int argc, char** argv) { bool g_graphics = true; palphysics * pp = 0; #ifndef pal_static pf -> loadpalfromdll(); #endif char a[] = "bullet"; std::string aa; aa = std::string(argv[1]); //pf->selectengine("bullet"); debugbreak(); pf -> selectengine(argv[1]); //pf->selectengine(aa); //debug // assert(false); pp = pf -> createphysics(); } i trying read in command line argument no. 1 in line: pf->selectengine(argv[1]); however, first letter of argument. have tried changing int _tmain(int argc, char** argv) to int _tmain(int argc, tchar** argv), error: error c2664: 'palfactory::selectengine' : cannot convert parameter 1 'tchar *' 'const pal_string &' pal_string std::string. this might simple one, not sure how convert tchar std::string, since tchar else depending on compiler /environment settings. aware of easy way command-line argumen

sublimetext2 - .tmLanguage -- how to include / exclude a variable -

i looking examples include / exclude couple of variables defined within .tmlanguage file. example 1 -- highlight whole enchilada, including both variables: {\code_one*[variable_one]{variable_two}} example 2 -- highlight whole enchilada, less either or both variables: {\code_two*[variable_three]{variable_four}} include_variable_text -- e.g., \hspace*{3.45in} ; \begin{singlespace*} ; \end{document} . .tmlanguage <!-- begin include_variable_text --> <dict> <key>begin</key> <string>\\makebox\[|\\hspace\*\{|\\begin\{|\\end\{</string> <key>begincaptures</key> <dict> <key>0</key> <dict> <key>name</key> <string>lawlist.include_variable_text.begin.latex</string> </dict> </dict> <key>end</key> <string>\}|\]</string> <key>endcaptures</key> <

javascript - making two scripts work together for a dropdown menu -

i have html code <html> <head> <script type="text/javascript"> window.onload = function(){ document.getelementbyid("shipping-method").onchange = function(){ window.scrollto(0, 0); }; }; </script> <script> function calc() { var subtotal = parsefloat(document.getelementbyid("subtotal").innerhtml.substring(1)); var shipping = parseint(document.getelementbyid("shipping-method").value); if(shipping == 1) { var total = subtotal+6.95; document.getelementbyid("shipping").innerhtml = "$"+6.95; } else { var total = subtotal+17.95; document.getelementbyid("shipping").innerhtml = "$"+17.95; } document.getelementbyid("total").innerhtml = "$"+total; } </script> </head> <body> <select onchange="calc()" class="shipping-method" id="shipping-method"> <option value=""&

No WCF request is sent from Silverlight on client machine -

my sl application commercial , working fine on hundreds of machines. sl using wcf service , works expected, today observed behavior on client machine, literally no call made server. after click button sends call, error occures, , no record wcf call created in fiddler. error is: [httpwebrequest_webexception_remoteserver] arguments: notfound debugging resource strings unavailable... i read error people recommend use fiddler, there no call displayed in fiddler so problem worse thought initially. it comes , goes. have found working solution fixes problem after appears although doesn't make sense me. for example if error in chrome & mozilla & oob version, launching program in ie works, , after chrome,mozilla & oob start work too. thing same people had problem solved workaround experience again in days, week, no apparent reason, , combination of launches various locations helps (usually ie helps most). any appreciated, start bounty pretty sick

uitableview - Display a tableviewcell before it has data -

Image
sorry tittle i´m new , i´m trying understand things, far understand, tableview loads data wich distributed cells (dynamic) in way/design developer wants , keeping in mind model object. i know strange issue have been struggling trying inverse: 1 - tableview loads cells textfields on them. 2 - user fills textfields. 3 - user presses save, , saved in core data. 4 - tableview has editing mode, user possibility of inserting more cells, , process repeats itself. so want kind of form, tableview loads cells @ first (so there no data yet, , user see fill :) ) , textfields filled result in data. in view did load, have array initiating nothing...i´m saying because see lot of examples , start kind of data a, b, c etc...or colors...and understand it´s example don´t want initiate data. my question is, possible? missing? thank you, regards. not strange @ all, , can that. after all, isn't contacts app is? if have no contacts, can make one. see? bunch of empty field can

python - Multiple operators between operands -

can explain why python interpreter (2.7.3) gives following: >>> 5 -+-+-+ 2 3 is ever useful, , purpose? you can use dis here see how expression evaluated: in [29]: def func(): ....: return 5 -+-+-+ 2 ....: in [30]: import dis in [31]: dis.dis(func) 2 0 load_const 1 (5) 3 load_const 2 (2) 6 unary_positive 7 unary_negative 8 unary_positive 9 unary_negative 10 unary_positive 11 binary_subtract 12 return_value so expression equivalent this: in [32]: 5 - (+(-(+(-(+(2)))))) out[32]: 3

c++ - Out of bound address when directly reading from array -

i developing cuda application has routines allocation , deallocation of arrays in shared memory. in application (that, sorry, cannot make available), have class encapsulate chunk of memory array. class has count method counts number of elements matches value. so, imagine (which actual part of whole class) template <class type> struct array { // ... type &operator[](int i) { return data_[i]; } type operator[](int i) const { return data_[i]; } size_t count(const type &val) const { size_t c = 0; (size_t = 0; < len_; ++i) if (data_[i] == val) ++c; return c; } void print(const char *fmt, const char *sep, const char *end) const { (size_t = 0; < len_ - 1; ++i) { printf(fmt, data_[i]); printf(sep); } printf(fmt, _data[len_ - 1]); printf(end); } private: type *data_; size_t len_; }; assumed memory accessing correctly

jaxb - JAXBException, Unmarshalling an XML Document -

Image
i'm getting exception: default constructor cannot handle exception type jaxbexception thrown implicit super constructor. must define explicit constructor jaxbcontext.newinstance throws checked exception. won't able directly set on field. need move inside constructor , surround try/catch block.

ruby - Why the value of the assignment is always the value of the parameter? -

this question has answer here: why isn't `method=` treated same other method? 1 answer would care explain why in older versions of ruby, result of assignment value returned attribute-setting method, after ruby 1.8, value of assignment value of parameter; return value of method discarded. in code follows, older versions of ruby set result 99. result set 2. class test def val=(val) @val = val return 99 end end t = test.new result = (t.val = 2) result # => 2 what reasoning behind change? it's not uncommon chain assignments when want assign same value multiple variables. more common in other languages. @user_id = user.id = next_user_id but happens when aren't thinking that, , return value isn't same input value? class user def id=(name) @id = name @modified = true end def modified? @modified end end

performance - C Pointer Arithmetic Efficiency -

i've seen explanations pointer arithmetic (eg. pointer arithmetic ). wondering there real difference between: given: int* arr = (int*) malloc(sizeof(int) * 3); does: &(arr[1]) and: arr + 1 differ in way, beside syntax. either technically more efficient? there context use pointer addiction on first? saw 1 example printing 1 1000 without loop or conditionals . in advance. no, there's no difference, not in performance (unless we're talking compile times) because: arr[1] equivalent *(arr + 1) and in &(*(arr + 1)) neither dereference nor address operators (the c standard says explicitly, dereference doesn't occur in such cases), operators cancel each other out. so, after parsing , ast building phases compiler ends arr + 1 in both cases.

android - Include parent padding in selected state of TextView -

Image
i have relativelayout padding , textview child. when textview selected, want highlighted area extend include padding of parent, entire relativelayout highlighted. main.xml <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello world, myactivity" android:textsize="30dp" android:clickable="true" android:background="@drawable/myback" /> myback.xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@color/gray" /> <item android:state_focused="true" android:drawable="@color/gray" /> <item android:state_pressed="true" android:drawable="@color/gray" /> </selector> myactivity.java package com.example.textviewpadding;

ruby on rails - Unable to run localhost:3000 (Ubuntu 12.10) -

i've found related posts mine... none of existing answers worked... here new 1 newbee : i installed ubuntu 12.10 , tried install ruby on rails following various tutorials ( http://rubyonrails.org/download ), tried rvm... , when try launch server localhost:3000 not working. here terminal when launch server : laslo@ubuntu:~$ rails s /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv deprecated in future, use string#encode instead. /usr/lib/ruby/vendor_ruby/railties/lib/rails_generator/generators/applications/app/app_generator.rb:7: use rbconfig instead of obsolete , deprecated config. exists exists app/controllers exists app/helpers exists app/models exists app/views/layouts exists config/environments exists config/initializers exists config/locales exists db exists doc exists lib exists lib/tasks exists log exists public/images exists public/java

asp.net - Updating an item using LINQ -

i wish update item using linq. tried query. string option = "new value here"; (jt.summaryspecs.select(x => x.docspecs) .firstordefault() .where( y => y.delitemid == docspc.delitemid && y.itemcode == docspc.itemcode ) .firstordefault().finishingoptionsdesc[0] ) = option; i wish update value of "finishingoptiondesc," collection of string values wish update 1st one. but code above not working. the classes attributes: "summaryspecs.cs" public docspec[] docspecs { get; set; } "docspecs.cs" public string[] finishingoptionsdesc { get; set; } my concern update finishingoptiondesc 1st string. thanks the part of code prevents snippet working select(/*...*/) method. creates new reference , takes execution out of expression tree object context. you have write this: jt.summaryspecs .where(y => y.docspecs.first().delitemid = docspc.delitemid && y.docs

python - wxpython: issue with layout in example -

Image
i trying learn wxpython , problem when run example code wiki: the main frame isn't resizing properly. what's missing? i running under enthought python distribution 7.3-2 (python 2.7.3) # http://wiki.wxpython.org/getting%20started import wx class examplepanel(wx.panel): def __init__(self, parent): wx.panel.__init__(self, parent) # create sizers mainsizer = wx.boxsizer(wx.vertical) grid = wx.gridbagsizer(hgap=5, vgap=5) hsizer = wx.boxsizer(wx.horizontal) self.quote = wx.statictext(self, label="your quote: ") grid.add(self.quote, pos=(0,0)) # multiline textctrl - here show how events work in program, don't pay attention self.logger = wx.textctrl(self, size=(200,300), style=wx.te_multiline | wx.te_readonly) # button self.button =wx.button(self, label="save") self.bind(wx.evt_button, self.onclick,self.button) # edit control - 1 line ve

Weird tmux vim through ssh -

first ssh server called thor , set bash prompt, before start tmux looks following [1.9.3@lizhe] ~ → somecommand after start tmux, turns this [1.9.3@lizhe] ~ → somecommand more space before somecommand , after typing command hit enter, looks this [1.9.3@lizhe] ~ → somecommand [1.9.3@lizhe] ~ → somecommand another big problem vim, it's totally unusable, check following screen record, don't konw how describe it. wierd vim in tmux throug ssh i use j k move, current line not like, , lines not visiable. it seems term variable set wrong. according man page tmux found here the term environment variable must set 'screen' programs running inside tmux. new windows automatically have 'term=screen' added environment, care must taken not reset in shell start-up files. make sure term set screen or screen-256color (you can check typing echo $term ). if not check init files such

asp.net mvc - Messages from Gelf4Net are not stored in Graylog2 -

i have ubuntu server elasticsearch, mongodb, , graylog2 running in azure, , have asp.net mvc4 application trying send logs from. (i using gelf4net / log4net logging component). cut chase, nothing being logged. (skip update see wrong) the setup 1 xsmall ubuntu vm running needed software graylog2 everything running daemon 1 xsmall cloud service mvc4 app (2 instnaces) a virtual network setup can talk. so have tried? from linux box follow command cause message logged echo "<86>dec 24 17:05:01 foo-bar cron[10049]: pam_unix(cron:session):" | nc -w 1 -u 127.0.0.1 514 i can change ip address use public ip , works fine well. using this powershell script can log same message dev machine production web server windows firewall turned off , still doesn't work. i can log fileappender log4net, know log4net working. tailing graylog2.log shows nothing of interest. few warning plugin directory know working, can't gelf4net appender work. i'm loss her

regex - preg_replace HTML code in PHP -

i want remove string below html code <span style="font-size: 0.8px; letter-spacing: -0.8px; color: #ecf6f6">3</span> so came regex. $pattern = "/<span style=\"font-size: \\d(\\.\\d)?px; letter-spacing: -\\d(\\.\\d)?px; color: #\\w{6}\">\\w\\w?</span>/um"; however, regex doesn’t work. can point me did wrong. i'm new php. when tested simple regex, works problem remains regex. $str = $_post["txtarea"]; $pattern = $_post["regex"]; echo preg_replace($pattern, "", $str); as advocate domdocument job here, still need regular expression down line, ... the expression px numeric value can [\d.-]+ , since you're not trying validate anything. the contents of span can simplified [^<]* (i.e. opening bracket): $re = '/<span style="font-size: [\d.-]+px; letter-spacing: [\d.-]+px; color: #[0-9a-f]{3,6}">[^<]*<\/span>/'; echo preg_replace($

iphone - If/Then statements using UISwitch in xcode -

i trying app run 1 mathematical formula when uiswitch set "on" position, , when it's set "off" position. i'm trying lay out this: if switch = on, [first formula] if switch = off, [second formula] how code this? ============= edit: this how trying code it. -(ibaction)switchvaluechanged:(uiswitch *)sender { if(sender.on) { -(float)conver2inches: (nsstring *)mmeters { return [mmeters floatvalue]/25.4f; } -(ibaction)calculate:(id)sender{ float answer = [self conver2inches:entry.text]; output.text=[nsstring stringwithformat:@"%f",answer];}} else{ -(float)conver2mmeters:(nsstring *)inches { return [inches floatvalue]*25.4f; } -(ibaction)calculate:(id)sender{ float answer = [self conver2mmeters:entry.text]; output.text=[nsstring stringwithformat:@"%f",answer]; }} } you need hook function uiswitch's value changed uievent. -(ibaction) switchvaluechanged:(uiswitch *) sender { if(sender.on) {

I am stuck with breadcrumbs jQuery -

i create breadcrumbs in jquery in website. stuck. here coding below: <ul id="bc" class="bc"> <li><a href="www.test.com/index.php">home</a></li> <li><a href="www.test.com/about.php">about us</a> <ul> <li><a href="www.test.com/1.php">1</a></li> <li><a href="www.test.com/2.php">2</a></li> </ul> </li> $(document).ready(function(){ var str=location.href.tolowercase(); $(".bc li a").each(function() { if (str.indexof($(this).attr("href").tolowercase()) > -1) { $("li.highlight").removeclass("highlight"); $(this).parent().addclass("highlight"); var outernav = $(this).parent().parent().parent(); var outernav2 = $(this).parent().parent().parent().pare

python - django return foreign key object from queryset? -

so have 3 models class post(.... class project(.... # have many many relationship class projectpost(.... post = ..... # foreignkey project = .... # foreignkey the data set want select list of post objects given project object. this tried: posts_list = projectpost.objects.filter(project=project_object).select_related("post") but returns list of projectpost objects rather list of post objects. correct way of doing this? you may want use manytomanyfield() https://docs.djangoproject.com/en/dev/topics/db/examples/many_to_many/ you should this: class post(models.model): pass class project(models.model): posts = models.manytomanyfield(post) and then, if want access posts of project, can do project_obj.posts.all() you can use queryset methods if want access projects of posts can do post_obj.project_set.all() same before, can use queryset methods. if reason want way, do: post_list = projectpost.objects.filter(project=p

Google Maps API V 3 Referer Configuration -

hoping ok. if have following url: http://jeanpaulruizvallejo.com//pruebas/personales/plantillas/alpha-01/templatesviewer.php?cdplantilla=1 https://jeanpaulruizvallejo.com//pruebas/personales/plantillas/alpha-01/templatesviewer.php?cdplantilla=1 how should configure in google apis console? have tryied several configurations without success. any ideas welcome. thanks. ok, seems working: http://jeanpaulruizvallejo.com/pruebas/personales/plantillas/ * https://jeanpaulruizvallejo.com/pruebas/personales/plantillas/ * http://jeanpaulruizvallejo.com/pruebas/personales/plantillas/alpha-01/ * https://jeanpaulruizvallejo.com/pruebas/personales/plantillas/alpha-01/ * http://jeanpaulruizvallejo.com//pruebas/personales/plantillas/alpha-01/templatesviewer.php?cdplantilla= * https://jeanpaulruizvallejo.com//pruebas/personales/plantillas/alpha-01/templatesviewer.php?cdplantilla= * thanks anyway :)

C++ dictionary trie implementation -

i getting segfault in insert function on line: current->isword = true; everything compiles fine no warnings or errors ( g++ -wall -wextra ). main function calls insert function once , won't work. here code; hybrid between .h , .cpp file: const int alphabetsize = 26; struct node { bool isword; node* child[alphabetsize]; }; dictionary::dictionary() { initnode(head); //node* head; defined in .h file under private: } bool dictionary::isprefix(string s) { node* current = endofstring(s, false); if (current == null) { return false; } else { return true; } } bool dictionary::isword(string s) { node* current = endofstring(s, false); if (current == null) { return false; } else { return current->isword; } } void dictionary::insert(string s) { node* current = endofstring(s, true); current->isword = true; //segfault here } //initializes new node void dictio

verilog - How to execute a for loop over multiple clock cycles? -

the loop working , happening in single clock cycle. how make run single iteration per cycle? `timescale 1ns/10ps module multiplier (clock,multiplier,multiplicand,start,done,product); input [7:0] multiplier ,multiplicand; input start; input clock; output [15:0] product; output done; reg [15:0] multiplierf ,multiplicandf; reg [15:0] productf; reg donef; integer i; assign product = productf; assign done = donef; task rpa_16; input [15:0] multiplierf; inout [15:0] productf; assign productf = multiplierf + productf; endtask @ (posedge clock or posedge start) begin if(start) begin multiplierf = 0 ; multiplicandf = 0 ; productf = 0 ; donef = 0 ; end else begin multiplierf = {8'b0,multiplier}

popup menu in eclipse plugin development -

i want create plugin in if user right click on folder or file, popup menu open , there option read file. new plugin development have done code. plugin.xml following <?xml version="1.0" encoding="utf-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.ui.commands"> <category name="sample category" id="com_.samsung.plugin.second.commands.category"> </category> <command name="sample command" categoryid="com_.samsung.plugin.second.commands.category" id="com_.samsung.plugin.second.commands.samplecommand"> </command> <command defaulthandler="com .samsung.plugin.second.samplehandler" id="com .samsung.plugin.second.sample" name="name"> </command> &

google apps script - How to add button to GDrive UI on web? -

how add button gdrive ui on web? does gdrive api has apy extend ui? (like installing application can add button) i want extend gdrive ui button, best option me it's execute google apps script on button click. i want access select options on gdrive(to execute action on select folders/files). i think can solved chrome plugin using javascript add button , on action call google apps script, it's complex way , not sure how in right now. do have suggestions? thank in advance. like said, use chrome plugin. easy whenever google changes might break. wary of randomized dom properties since google js goes through closure / caja compilation etc.

xaml - WPF DVC Chart axis labeling -

i have created dvc:chart shown below in code, how add x-axis , y-axis labels chart? <dvc:chart name="calllogs" background="steelblue" grid.columnspan="2"> <dvc:chart.series> <dvc:columnseries title="calls per hour" independentvaluebinding="{binding path=key}" dependentvaluebinding="{binding path=value}"> </dvc:columnseries> </dvc:chart.series> </dvc:chart> thanks in advance i have managed figure out: <dvc:chart name="calllogs" background="steelblue" grid.columnspan="2"> <dvc:chart.axes> <dvc:linearaxis orientation="y" title="ammount of calls"/> <dvc:linearaxis orientation="x" title="time (hours)"/> </dvc:chart.axes> <dvc:cha

How to read row/col from CursorWindow ? - android -

this function compare it....... please find error if any.i have not logged in it public void onclick(view v) { // todo auto-generated method stub string unname=username1.gettext().tostring(); string storedpassword1=db.getdata(unname); db.open(); try { if(password.equals(storedpassword1)) { intent it=new intent("com.butterfly.bmw.adminlist"); startactivity(it); } else { toast.maketext(database.this, "user name or password not match", toast.length_long).show(); system.out.println("errorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"); } db.close(); } catch (exception e) { toast.maketext(database.this, "does not enter in try block", toast.length_long).show(); } } }); this db class please find error this.i have not login in this import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sq

unix - Executing a shell script with code accepted using I/O indirection -

i trying execute script this, accepting script using indirection sh <<eot str in `cat test` echo $str done eot the file "test" has contents a b c it gives below error. sh: line 2: syntax error near unexpected token `b' sh: line 2: `b' can clarify ?. aim execute script above instead of creating shell script file script.sh , executing (which works fine) your outer shell interpolating heredoc. prevent that, quote delimiter: sh << 'eot' to clarify, have equivalent to: sh <<eot str in b c echo done eot which makes syntax error obvious.

Exception Handling in Dynamic SQL in SQL Server -

in dynamic sql statement 1 @stu_id value failing insert data table. here need know @stu_id if failing when execution. create proc data_copy ( @src_table varchar(30), @dest_table varchar(30) ) declare @stu_id int begin declare student_cursor cursor select distinct stu_id student open student_cursor fetch next student_cursor @stu_id while @@fetch_status = 0 begin exec ('insert '+@dest_table+' select * '+@src_table+' stu_id='+@stu_id) fetch next student_cursor @stu_id end close student_cursor deallocate student_cursor end can me how ? thanks you can capture data during context of error try catch begin try exec ('insert '+@dest_table+' select * '+@src_table+' stu_id='+@stu_id) end try begin catch print 'error value @stu_id = ' + convert(varchar,@stu_id) end catch

Complex custom post type multiple loops in Wordpress -

i have custom post type staff members of organisation taxonomy named profession. i'm using easytabs display matrix of photos each member sorted different professions. when user clicks on photo (the tab navigation), appropriate information displayed in panel animates view. i can fit 4 members in each tab container div across page, more , 5th 1 breaks tab layout. i need loop pull 4 staff members per container, next 4 etc. this code have far ... <div class="team_content"> <?php $custom_terms = get_terms('profession'); foreach($custom_terms $custom_term) { wp_reset_query(); $args = array('post_type' => 'team_members', 'tax_query' => array( array( 'taxonomy' => 'profession', 'fi