Posts

Showing posts from April, 2010

python - How to add value from list into dictionary? -

dict={} i=["abc","def","ghi","jkl"] j=[["a","b","c","d"],["q","w","e","r"],["t","y","u","i"]] item in i: dict[item]=[str(j[item])] print dict output should dict={"abc":["a","b","c","d"], "def":["q","w","e","r"] ...} how can add list dictionary in python? use zip() function combine 2 lists: dict(zip(i, j)) demo: >>> i=["abc","def","ghi","jkl"] >>> j=[["a","b","c","d"],["q","w","e","r"],["t","y","u","i"]] >>> dict(zip(i, j)) {'abc': ['a', 'b', 'c', 'd'], 'ghi': ['t...

objective c - What is the assign-enum warning in clang? -

i going through afnetworking implementation , found this #pragma clang diagnostic push #pragma clang diagnostic ignored "-wassign-enum" [request sethttpbody:[nsjsonserialization datawithjsonobject:parameters options:0 error:&error]]; #pragma clang diagnostic pop ( afhttpclient:489-492 ) the assign-enum warning being turned off, wonder mean. what warning thrown clang in case? the warning emitted in absence of clang pragmas is: integer constant not in range of enumerated type 'nsjsonwritingoptions' (aka 'enum nsjsonwritingoptions') looking @ declaration of nsjsonwritingoptions , see there no defined value 0: enum { nsjsonwritingprettyprinted = (1ul << 0) }; typedef nsuinteger nsjsonwritingoptions; the docs suggest passing 0, there no option defined nsjsonwritingnooption = 0 , , assigning constant (0) enum type doesn't define 0 possible value.

mysql - How to Add month to a date while keeping the last month of a given month -

can me on how add month date while keeping last day of month? suppose have updated first data on 2013-01-29, when adding 1 month date, 2013-02-28. everytime add 1 month again on latest date, becomes 2013-03-28 must 2013-03-29. perfect command in mysql query can use. thanks in advance. unless preserving "first data" somewhere, impossible build logic achieve functionality expecting. please elaborate in detail data model , business use case

mobile - Please advise me on programming for different Android device screen sizes -

i've had apps developed apple never android love if me basic information don't know android , want e-book reader app developed. here questions: is actual program coding android devices same, whether android phones or various android tablet devices on market? what popular android devices know screen size optimise layout for, , screen size that? thanks help. kind regards,

r - regex remove seconds and miliseconds -

this linked previous question, regex add hypen in dates . i able remove seconds , milliseconds/change 0 using gsub again well i.e. somethine x <- c("20130603 00:00:03.102","20130703 00:01:03.103","20130804 00:03:03.104") y <- gsub([regex pattern match],[replacement pattern insert hyphen , remove seconds] ,x) > y [1] "2013-06-03 00:00:00" "2013-07-03 00:01:00" "2013-08-04 00:03:00" you can try regex, added bit: gsub("(\\d{4})(\\d{2})(\\d{2}) (\\d{2}:\\d{2}).*", "\\1-\\2-\\3 \\4:00", subject, perl=true); demo on regex101 .

how to define a multi line macro in verilog? -

i relatively new verilog (a vhdl user), , in order improve skills built test environment using verilog (my qc use own env). in env, emulate master force random stimuli on lines (i2c master). since didn't want use real master , wanted 'well behaved' master, created following macros provide me i2c communications: `define writechipid(addr)\ sda = 1\ #7500 sda = addr[3];\ #2500 sda = addr[2];\ #2500 sda = addr[1];\ #2500 sda = addr[0];\ #2500; `define writedata(data)\ sda = data[7]\ #2500 sda = data[6];\ #2500 sda = data[5];\ #2500 sda = data[4];\ #2500 sda = data[3];\ #2500 sda = data[2];\ #2500 sda = data[1];\ #2500 sda = data[0];\ #2500 sda = 1;\ #2500; // time slave answer `define readdata\ #sda = 1\ #20000 sda = 0;\ #2500; // master answer ack my problem that, when try use these macros compilation errors (using modelsim) saying have syntax error , have unexpected '[' should ';' using chipid macro , having unexpected '#' should ';...

html - css selector not working without its class -

html: <div id="header"> <div id="one"> <ul class="menu"> <li>one text</li> </ul> </div> <div id="two"> <ul class="menu"> <li>one text</li> </ul> </div> </div> this css won't work #header ul.menu{ background-color: red; text-align: left; } #two ul{ /*this line*/ background-color: blue; text-align: right; } this css work #header ul.menu{ background-color: red; text-align: left; } #two ul.menu{ /*this line*/ background-color: blue; text-align: right; } demo why so? update as per answers on css specificity #header ul.menu more specific #two ul . got ul.menu more specific ul. ul.menu{...} #two ul{...} /* works exactly, yes #two more specific ul.menu */ okay, change order order 1: #heade...

sharepoint 2010 - How to format person or group field values in c#? -

i retrieving sharepoint list data in c# , assigning spgridview. below code using fill spgridview. have column called "contact" in spgridview, mapped person or group field. after binding, when see "contact" column in spgridview, see results "kumar, ramesh;#55;#kumar, amit". want result "kumar, ramesh;kumar, amit". please me how achieve this. public void btnsearch_click(object sender, eventargs e) { splist mylist = spcontext.current.web.lists["mylist"]; spquery query = new spquery(); query.query = @"<where> <and> <eq> <fieldref name='year_x0020_start' /> <value type='text'>2010</value> </eq> <eq> <fieldref name='year_x0020_end' /> <value type='text'>2012</value> </eq> </and> </wh...

java - Good Junit testing for create a JTable? -

i'm new @ junit testing , trying create tests creating jtable. wonder if can guide me through basic tests create jtable? much appreciated :) i'm not sure you'd test creation of table rather data you're populating with. (not unless you're creating number of tables @ run-time) for example, have 2 rows of data want put table. // given jtable table = new jtable() //populate data etc. //when int rowcount = table.getrows() etc. //then assertequals(2, rowcount); keep in mind you're testing. careful not go off on tangents , start testing things don't need be/not meant tested.

Python regex slow when whitespace in string -

i match strings, using pythons regex module. in case want verify strings start, end , consist of upper case letters combined "_". example, following string valid: "my_hero2". following strings not valid: "_my_hreo2", "my hero2", "my_hero2_" to validate string use code: import re my_string = "my_hero" p = re.compile("^([a-z,0-9]+_??)+[a-z,0-9]$") if p.match(my_string): print "validated" so problem? validating long string containing whitespaces very, slow. how can avoid this? pattern wrong? reason behavior? here numbers: my_hero2 --> 53 ms my_super_great_unbelievable_hero --> 69 microseconds my_super_great_unbelievable hero --> 223576 microseconds my_super_great_unbelievable_strong_hero --> 15 microseconds my_super_great_unbelievable_strong hero --> 979429 microseconds thanks anwsers , responses in advance. :-) paul so problem? the problem catastrophic b...

android - How to suppress this warning in AndroidManifest -

Image
i have 1 line in androidmanifest.xml produces warning , can't fix : <activity android:name="com.paypal.android.mep.paypalactivity" /> i have following warning : use '$' instead of '.' inner classes (or use lowercase letters in package names) the problem if replace . $ , class won't work , i'll activitynotfoundexception . i've read lints in android couldn't find 1 need. could tell me how can fix ? in advance. the lint rule called innerclassseparator . in correctness category.

Parent & Child Node with different images & Clickable Event - Treeview Blackberry -

Image
i using tree view in app show client server data in blackberry. same thing achieved in android app using expandable listview items. here i'm facing 2 issues one is: i want add parent node icon folder icon & child node must have different icon. example if parent item images child nodes must have images icon, if parent item video child have video icons. second: when click on child node (like image child node), node opens in new screen & shows clickable item whether click on image or video. here code used desired result: class customtreefieldcallback implements treefieldcallback { public void drawtreeitem(treefield _tree, graphics g, int node, int y, int width, int indent) { // fontfamily fontfamily fontfamily[] = fontfamily.getfontfamilies(); font font = fontfamily[1].getfont(fontfamily.cbtf_font, 18); g.setfont(font); string text = (string) _tree.getcookie(node); bitmap b = bitmap.getbitmapreso...

drupal - Using different views for full nodes depending on contenttype -

Image
think of 2 contenttypes (film, project). have homepage showing few nodes of both. when clicking on node single node page (url of node e.g. node/14). i managed output single node page views (path: node/% , contextual filter). nodes regardless of contenttype node is. 'film' has different fields 'project' need different views showing single nodes each contenttype. is possible? thanks oliver just use - except nid contextual filter - filter criteria each content type. filter criteria > content: type

javascript - Pass data to CGI script and back with jQuery.ajax -

i'm working jquery.ajax() send html form data perl script on server , return data frontend. preferably, data should in text/string format. need save variable further use in jquery functions. i set html code, javascript code , cgi perl script, while javascript working, connection cgi perl script not , error message: "script call not successful" . maybe 1 can tell me mistake is? i'm not sure how return variable perl script server. since i'm still new both jquery , javascript , haven't worked asynchronous calls before, appreciated. this code: the html code: (where user fills form first name , name: <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="get_names.js"></script> </head> <body> <div id="logincontent" class="container"...

How to fill a fillable word 2010 document with c# -

how can create instance of existing ms word 2010 template (the template has 1 textbox), fillable field , insert string in there? all in c#, far couldn't open .docx document. it's not free, i've done syncfusion (on winrt once). can set bookmark , navigate bookmark in c# , replace content (strings, images, tables, etc.). http://www.syncfusion.com/ docu: http://help.syncfusion.com/winrt ( docio searching for) they have free trial, maybe can find similar (replacing bookmarks, if can't fillable) free (i didn't, searched winrt)

python - Irregular, non-contiguous Periods in Pandas -

i need represent sequence of events. these events little unusual in are: non-contiguous non-overlapping irregular duration for example: 1200 - 1203 1210 - 1225 1304 - 1502 i represent these events using pandas.periodindex can't figure out how create period objects irregular durations. i have 2 questions: is there way create period objects irregular durations using existing pandas functionality? if not, suggest how modify pandas in order provide irregular duration period objects? ( this comment suggests might possible " using custom dateoffset classes appropriately crafted onoffset, rollforward, rollback, , apply methods ") notes the docstring period suggests possible specify arbitrary durations 5t "5 minutes". believe docstring incorrect. running pd.period('2013-01-01', freq='5t') produces exception valueerror: mult == 1 supported . have reported this issue . the "time stamps vs time spans" se...

java - In Heritrix crawler tool how to extract the contents from crawled urls -

am new heritrix tool , able crawl web pages www , want extract contents of crawled urls. please me one.please.thanks in advance. 1.first download file wget http://python.org/ftp/python/3.3.0/python-3.3.0.tgz or higher version root user. 2. change directory installed python 3. example /opt/python3.3/; 4. configure files ./configure --prefix=/opt/python3.3 5.make 6. sudo make install 7. /opt/python3.3/bin/python3 8.opt/python3.3/bin/pyvenv ~/py33 9.source ~/py33/bin/activate 10. wget http://python-distribute.org/distribute_setup.py 11.python distribute_setup.py 12. easy_install pip 13. pip install bottle 14. pip install warcat 15. if installed warcat check whether warcat installed or not. 16. python3 -m warcat --help after enter can see commands like, list,concat,extract etc.. 17.python3 -m warcat list example/at.warc.gz worked me ..enjoy

drupal - How to publish node in a specific region -

i created several regions , added several blocks within these regions. created node , it's being displayed within "content" block. need know how display node in different block ("sidebar", "top bar" etc.). i watched several screencasts views, content-type etc. couldn't find way solve problem. know seems ridiculous, i've been working on other frameworks (yii, joomla, wordpress ...) , straightforward. any appreciated. best regards, wissam you have use block place content in specific region. content, sidebar, , top bar considered regions. blocks can managed admin/structure/block screen. can either create block right screen, or create block view in views , appear in list. can move whichever region you'd like.

spring mvc - Null-Pointer Exception while using AOP -

application context file <!-- aspect --> <!-- allow @component, @service, @controller, etc.. annotations --> <context:component-scan base-package="com.piyush.cns.*" /> <aop:aspectj-autoproxy/> <!-- allow use @autowire, @required , @qualifier annotations --> <context:annotation-config /> <!-- logger bean --> <bean id="logger" class="org.slf4j.loggerfactory" factory-method="getlogger"> <constructor-arg type="java.lang.string" value="com.piyush.cns" /> </bean> <!-- aspect --> <bean id="logaspect" class="com.piyush.cns.customer.resource.allaspects" /> </beans> above code application context file contain bean declaration. controller class customersresource . class receive request initially. basic requirement validate customer object server side. @controller @path(...

php - Accessing POST data -

i'm new php have understanding of c, when want access post data on api i'm creating in php use: $_post['date_set'] to fetch value being passed date - works perfectly, read should fetching this: $date_set = trim(urldecode($_post['date_set'])); this returns 00:00:00 value date after it's stored in db. when access directly using $_post['date_set'] whatever value posted, example: 2013-08-28 10:31:03 can tell me i'm messing up? you run urldecode on data url encoded. php have decoded before populating $_post , shouldn't using that. (you might have if dealing double-encoded data, right solution there should not double encode data). trim removes leading , trailing white-space. useful if have free form input in rogue spaces might typed. need further sanity checking afterwards.

windows phone 8 - Text and Image edit on Canvas with save as file -

i working on application, in there requirement 1 page user can add/edit text on canvas , save file print/edit again. for example: add text canvas, change fonts, color, size, etc. later want add option inserting image on canvas. it ms paint quite big software,here need simple canvas, under stack panel want add options edit text (color palette, size, & font). please me out suggestions & examples. not mandatory use canvas. objective text/image edit page, save file, , editable again. thank in advance. to save text file later use, use textbox , isolated storage. canvas work shapes, images, , other graphics controls. have textbox named box in xaml. xaml <textbox x:name="box" /> this code below in kind of save click method when button clicked. c# using (isolatedstoragefile isofile = isolatedstoragefile.getuserstoreforapplication()) { using (isolatedstoragefilestream isostream = new isolatedstoragefilestream("box.txt", file...

ember.js - Navigating to Record works, but deep link throws error? -

i have simple emberjs application 2 simple models (ember-model). accounts , items, while account hasmany items. so when navigate #/accounts/1/items links in application works fine. when directly reload #/accounts/1/items error: assertion failed: value #each loops on must array. passed <app.account:ember335> (wrapped in (generated items controller)) ember.js?body=1:382 uncaught typeerror: object [object object] has no method 'addarrayobserver' ember.js?body=1:19476 assertion failed: emptying view in inbuffer state not allowed , should not happen under normal circumstances. there bug in application. may due excessive property change notifications. ember.js?body=1:382 this how app looks like: app.router.map ()-> @resource 'accounts', -> @resource 'account', path: ':account_id', -> @resource 'items' app.accountroute = ember.route.extend model: (params) -> app.account.find(params.account_id) app.itemsr...

c++ - Template class to close HANDLES and other WINAPI's? -

i'm new c++ , need help. i want make template class / struct handles handle , other winapi s far code: template <typename type_to_open, typename returntype, returntype (winapi * globalfn)( type_to_open )> class handle_wrap { public: type_to_open data; handle_wrap (type_to_open in_data) { data = in_data; } ~handle_wrap() { returntype (winapi * globalfn)( type_to_open );} }; handle_wrap <handle, bool, ::findclose> hfind ( findfirstfilea (pattern.c_str(), &ffd) ); i don't think working , compiler gives me warning: warning c4101: 'globalfn' : unreferenced local variable i saw code web , did changes it, , don't know if right way it? the problem in destructor. repeat declaration of globalfn , rather call it. should be: ~handlewrap() { (*globalfn)( data ); } also, want make class copyable, movable or neither? if neither, should take steps prevent of relevant compiler generated defaults; otherwise, you'll n...

maven - including several jar projects into one WAR -

i have 4 maven projects should work 1 application, 1 parent project responsible building other, 1 war project jsf , beans, 1 jpa project entities , 1 ejb project dao , ejb layer. try run on tomee server .war, doesn't include other classes jpa , ajb project...here poms: eclipsejpa2-parent: .... <groupid>pka</groupid> <artifactid>eclipsejpa2-parent</artifactid> <version>0.0.1-snapshot</version> <packaging>pom</packaging> <profiles> <profile> <id>eclipsejpa2</id> <modules> <module>../eclipsejpa2-war</module> <module>../eclipsejpa2-jpa</module> <module>../eclipsejpa2-ejb</module> </modules> <activation> <activebydefault>true</activebydefault> </activation> </profile> </profiles> <dependencymanagement> <dependencies...

java - how to create an activity nested to an other activity -

i'm trying create mapdisplay activity mainactivity have error. androidmanifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.fin2" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="12" android:targetsdkversion="18" /> <permission android:name="com.example.fin2.permission.maps_receive" android:protectionlevel="signature" /> <uses-permission android:name="com.example.fin2.permission.maps_receive"/> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android...

vb.net - How to remove extensions from ListBox -

i have piece of code searches shortcuts , puts them listbox. how can modify in order display information without .lnk extension for each foundfile string in my.computer.filesystem.getfiles("z:\siteservices\maintenance\maintenance support folder\equipment specific information\des", microsoft.visualbasic.fileio.searchoption.searchtoplevelonly, "*" & txtsearch.text & "*" & ".lnk") listbox1.items.add(foundfile) next have @ usinng path.getfilenamewithoutextension method returns file name of specified path string without extension.

windows - creating a batch file -

i creat batch file recognise folders date moidified in network drive , copy them network drive while searching found way files, need folders didn't find way that sadly, didn't method you'd found. if method selects files using dir.../a-d... structure instance, omit - before d , directories matching selected pattern rather files processed.

android - How to copy element from one xml to another xml with python -

i have 2 xmls (they happen android text resources), first 1 is: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="txt_t1">aaaa</string> </resources> and second is <?xml version="1.0" encoding="utf-8"?> <resources> <string name="txt_t2">bbbb</string> </resources> i know attribute of element want copy, in example it's txt_t1. using python, how copy other xml , paste right behind txt_t2? lxml king of xml parsing. i'm not sure if looking for, try this from lxml import etree et # select parser , make remove whitespace # discard xml file formatting parser = et.xmlparser(remove_blank_text=true) # element tree of both of files src_tree = et.parse('src.xml', parser) dest_tree = et.parse('dest.xml', parser) # root element "resources" # want add new element dest_root = dest_tree.getroot() # anywhere ...

ios - Strange horizontal whitespace on iPhone 4 Safari -

while testing website's mobile version on several devices, noticed strange behaviour. i have scrollable content div overflow: auto , , works on tested devices, except iphone 4 on safari. other browsers , devices display correctly, iphone 5 safari. on iphone 4 safari, when scroll end of content, lot of whitespace appears @ bottom (looks 100-200% height) , text disappears when scrolling. doesn't happen on other devices in safari, nor happen in other browsers on iphone 4. has ever heard of such phenomenon before? have absolutely no clue causes behaviour or how fix it. since have access limited amount of devices testing, may overlooking other devices/browsers issue occurs. if have mobile device , want test well , live site here: live site . on mobile homepage, click 1 of logo's expand content, try scrolling down. please post results in comment. how looks on iphone 5 safari when scrolled down (no issue): image how looks on iphone 4 safari when scrolled down (issu...

compilation - Why does the Android SDK need a JDK? -

Image
i trying understand why android sdk needs jdk. the android sdk not supposed have jdk java classes needs (with potential implementation differences) ? does need tools included in jdk ? do use jdk when build .dex & .apk files ? what mean android java classes must written java 5 or 6 compiler compliance ? thanks the general process typical build outlined below: the android asset packaging tool (aapt) takes application resource files, such androidmanifest.xml file , xml files activities, , compiles them. r.java produced can reference resources java code. the aidl tool converts .aidl interfaces have java interfaces. all of java code, including r.java , .aidl files, compiled java compiler , .class files output. the dex tool converts .class files dalvik byte code. 3rd party libraries , .class files have included in project converted .dex files can packaged final .apk file. all non-compiled resources (such images), compiled resources, , .dex files sent apkbu...

angularjs - Issue with ngShow -

i have following problem ngshow. receive response json $http.get , construct several dom elements using ngrepeat. working properly. controller apply: $http.get(requesturl).success(function (data) { $scope.results = data.results; }); data.results object this: { "someprop": ["item1", "item2", "item3"], "someprop1": ["item1", "item2", "item3"] } from template try use ngshow this: <table ng-show="object.keys(results).length > 0"> and this: <table ng-show="object.keys($scope.results).length > 0"> with no luck. <table ng-show="true"> and <table ng-show="false"> working properly. so seems problem in expression. grateful help. it not evaluate object.keys function inside of expression not located on scope. 1 way can around assigning object scope. $scope.object = object; and insid...

How to format Events.StartDateTime in Salesforce EmailTemplate -

i'm trying format startdatetime in email template, can't do. i'm able same activitydate, problem don't time in activitydate. here's code: {!act.startdatetime} currently date looks fri aug 30 15:00:00 gmt 2013 want display 08/30/2013 11:00 (eastern time) any appreciated! please note i'm trying achieve within email template try {!act.startdatetime +0} or create formula field , display him instead of activitydate

asp.net mvc - How to get the JSON string from a Web API response -

i have asp.net mvc 4 application have controller whith action recieves xhr requests , returns json. in action want make call web api, recieve response json , use json string actions return value. (and i'm not allowed call web api directly javascript, need go via server) i manage make request web api can't figure out how read out json string. here method: public actionresult index() { string ret = ""; httpclient client = new httpclient(); client.baseaddress = new uri("http://localhost:8080/"); client.defaultrequestheaders.accept.add( new mediatypewithqualityheadervalue("application/json")); httpresponsemessage response = client.getasync("api/stuff").result; if (response.issuccessstatuscode) { // how json string out of response object? //ret = response.?? } else ...

c# - How can I upload file using watin for asp.net mvc upload control -

i'm writing watin test , have upload file mvc control watin don't recognize mvc upload control. here silverlight code: <object type="application/x-silverlight-2" data="data:application/x-silverlight-2," id="contentplaceholder1_aspxuploadcontrol1_textbox0_sluploadhelper" width="70px" height="22px" style="position: absolute; background-color: transparent; top: -5000px; opacity: 0.01; left: 75px;" class=" contentplaceholder1_aspxuploadcontrol1_dxfitextboxhover" title=""><param name="source" value="/dxr.axd?r=1_1-c5nv6"><param name="background" value="transparent"><param name="windowless" value="true"><param name="minruntimeversion" value="3.0.40818.0"><param name="initparams" value="controlname=contentplaceholder1_aspxuploadcontrol1, inputindex=0, multiselect=true, all...

Can use of $regex in MongoDB Aggregation Framework be optimized? -

i'm using aggregation framework calculate aggregate values on collection. typical query/operation might include close 1 million documents indexed (the f1/ts match reduces number of documents down 1 million 5 million, set can made smaller depending on query parameters, e.g. timeframe selected). the $match uses indexed attributes of documents, need include amounts full-text search. option i've used $regex match. unfortunately, can't anchor $regex match start of string since string(s) i'm looking anywhere. text i'm "searching" anywhere few characters in length few thousand. just running basic comparisons, inclusion of $regex match attribute doubles time calculation takes complete. what options optimizing operation? is possible achieve other way? will text-search available use in aggregation operations in v2.6? for reference: operation without $regex db.my_collection.aggregate( { $match:{ f1:objectid('417abd81...5770000...

add Equality Comparer class to base class for custom property classes in c# -

i'm using concurrentdictionary key made of class public properties. after playing around code ( hashcode on decimal iequalitycomparer in concurrentdictionary ) wanted find solution, don't have implement class interface iequalitycomparer every property class make. i made base class can check whether or not public properties set (or @ least not default value). so, thought, let give try , add iequalitycomparer class base class. so far, had , work. using system; using system.collections.concurrent; using system.collections.generic; private void somemethod() { concurrentdictionary<twouintsonestringskeyinfo,int> test = new concurrentdictionary<twouintsonestringskeyinfo, int>(new twouintsonestringskeyinfo.equalitycomparerelevenuintskeyinfo()); test.tryadd(new twouintsonestringskeyinfo { idone = 1, idtwo = 2, mystring = "hi" }, 1); test.tryadd(new twouintsonestringskeyinfo { idone = 2, idtwo = 3, mystring = "hello" }, 2);...

asp.net - Getting LINQ query result into a list? -

i'm converting old code use linq. old code looked this: // courses sqlquery = @"select comment.comment, status.statusid, comment.discussionboardid, discussionboard.courseid, comment.commentid status inner join comment on status.statusid = comment.statusid inner join discussionboard on comment.discussionboardid = discussionboard.discussionboardid (discussionboard.courseid = 'courseid')"; var comments = new list<comment>(datacontext.executequery<comment>(sqlquery)); i've converted above sql linq: var db = new cmsdatacontext(); var query = c in db.comments join s in db.status on c.statusid equals s.statusid join d in db.discussionboards on c.discussionboardid equals d.discussionboardid d.courseid == "courseid" select new { d.itemtype, c.comment1, ...

Best way to prepare hierarchical data for easy querying in MongoDB? -

i'm starting use mongodb new project , wanted insert customer data using scheme: { admin: {mail: "", realname: {first: "", last: ""}, address: {street: "", city: "", state: ""}, payment: {type: "", blz: "", account: ""}}, users: [ {mail: "", password: "", realname: {first: "", last: ""}}, ... ], categories: [ {name: "", assignedusers: [{id: "", readonly: true}, ...], entries: [ {name: "", tags: "", site: "", user: "", pass: "", notes: ""} ], ... ] } however, i've found out isn't possible to, example, 1 of users in "users" array it's mail address or categories 1 user assigned id. so seems i'd have split hierarchical data multiple collections, i'm not sure best way is...

xml - Adding color to results of PowerShell scripts Exception -

i new powershell world , having bit of difficulty figuring issue out. code below , pretty simple, compared others have done with, 1 not work , can't figure out have done wrong. have done exact same thing using longer , more complex "lists" start simple $vmtoolslist have below. when run code below following error both wsindex1 , 2. idea of missing? exception calling "indexof" "2" argument(s): "value cannot null. parameter name: array" @ c:\users\xxxxxxxxxxx\appdata\local\temp\f2dfef29-9e86-4193-9c37-98b35015e97f.ps1:9 char:2 + $wsindex1 = [array]::indexof( $vmtoolsxml.descendants("${namespace}th").value, ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [], methodinvocationexception + fullyqualifiederrorid : argumentnullexception add-type -assemblyname system.xml.linq new-viproperty -name toolsversion -objecttype virtualmachine -...

sublimetext2 - sublime text 2 phpcs plugin python error -

i using sublime text 2 plugins. can't seem work phpcs plugin, because after saving file, gives me ugly error: writing file /applications/xampp/xamppfiles/htdocs/myproject/application/libraries/authentication.php encoding utf-8 exception in thread thread-15: traceback (most recent call last): file "/system/library/frameworks/python.framework/versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner self.run() file "/system/library/frameworks/python.framework/versions/2.6/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) file "./phpcs.py", line 398, in run file "./phpcs.py", line 128, in get_errors file "./phpcs.py", line 194, in execute file "./phpcs.py", line 197, in parse_report file "./phpcs.py", line 149, in shell_out file "/system/library/frameworks/python.framework/versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__ errread,...

windows - Ping remote computer from another remote computer and get result back -

i'm trying batch script work whereby computer on script running computer b ping computer c , errorlevel can output. @ moment i'm trying using psexec access command line on computer b , getting ping c. issue of course errorlevel comes "0" since command executing on b. result c need. set /p altterm=please specify terminal test [0**]? echo. echo running internal ping test terminal %altterm%... psexec \\%hostname%-%altterm% ping %hostname%-%terminal% if errorlevel 0 set internalping=pass if errorlevel 1 set internalping=fail echo. echo internal ping test %internalping% the details hostname , terminal set earlier in script. it's important script not display workings show echo lines , result. have used /f >nul 2>&1 elsewhere in script suppress output according windows pro (referred in microsoft technet ): psexec displays process's exit code , returns exit code own exit code. so, batch should work. put echo errorlevel=...

How do I change the default password for an OpenMQ broker running as LOCAL in Glassfish 3.1.1? -

i'm trying change default password admin user in openmq broker instance running local in glassfish cluster. tried logging in server locally , using imqusermgr tool didn't work. i'm guessing have use asadmin set command don't know one. you can set custom password broker. go messagequeue5.0/etc/mq directory. here find passfile.sample file. read file. there lot of administration properties can set. admin password in 1 of it( imq.imqcmd.password ). after setting have set following properties in brokers config.properties file (a. imq.passfile.enabled=true b. imq.passfile.dirpath= directory of file , c. imq.passfile.name=name of passfile ) you find config.properties file in messagequeue5.0/var/mq/instances/imqbroker/props folder.

xml - How to make fo:table-cell wrap text to a new line? -

my generated .pdf file has few cells in 1 row , need text in each cell wrap new line once cell runs out of space. included fo:block wrap-option="wrap" .xsl file doesn't seem work. sample of have if can tell me doing wrong appreciate. <fo:table-row> <fo:table-cell> <fo:block wrap-option="wrap"> <xsl:value-of select="cust_num1"/> </fo:block> </fo:table-cell> <fo:table-cell> <fo:block wrap-option="wrap"> <xsl:value-of select="cust_num2"/> </fo:block> </fo:table-cell...

asp.net - my web servie returns a list<myStruct> but the values dissapear? -

i have web service function returns list 6 entries, uses custom struct. reference updates on client side project, list returned, while having correct number of entries, has data fields not listed , replaced 1 called "propertychanged" null. my guess i'm missing serialize properly, here's code: struct: public struct treedata { private readonly string text; private readonly string parent; private string val; public treedata(string text, string parent) { this.text = text; this.parent = parent; this.val = ""; } public treedata(string text, string parent, string value) { this.text = text; this.parent = parent; this.val = value; } [xmltext()] public string text { { return text; } } [xmltext()] public string parent { { return parent; } } [xmltext()] public string value { { return val; } } } the web method (simplified): [system.xml.serialization.xmlinc...

java - Handle all exceptions -

i used logback logging java application. how can handle exceptions in app logback my test config <appender name="exceptions" class="ch.qos.logback.core.fileappender"> <filter class="ch.qos.logback.core.filter.evaluatorfilter"> <evaluator> <expression>java.lang.exception.class.isinstance(throwable)</expression> </evaluator> <onmatch>accept</onmatch> </filter> <file>exceptions.log</file> <append>true</append> <encoder> <pattern>%d{hh:mm:ss.sss} %-5level %logger{36} - %msg%n</pattern> <immediateflush>false</immediateflush> </encoder> </appender> assuming mean catching exceptions, not caught: can define uncaught exceptions handler in code, possible: private static void setdefaultuncaughtexcep...

How to display a scrollable grid of images in matlab GUI -

Image
how can display scrollable grid of images in matlab gui? i want similar shown below this stackoverflow post describes way of displaying images in uitable setting 'string' property html code pointing image. requires me save images disk not option these displays fired dynamically. it nice, if add checkbox inside each image user can select subset of them. you can use this tool. in gui, should able scroll through. have title below every image might have edit tool. sample output: a grid of images http://www.mathworks.in/matlabcentral/fx_files/22387/12/imdisp.jpg

jdbc - RequestDispatcher to a jsp or servlet -

parameters[username, userpw] sent user through home.jsp. these parameters matched in login servlet against stored userinfo db using jdbc. in dopost method using if condition tfor authentication follows if (rs.next()) { string refname = rs.getstring("username"); string refpass = rs.getstring("userpw"); if (user.equals(refname) && pw.equals(refpass)) { out.println("<br>you in"); requestdispatcher dispatch= getrequestdispatcher("/searchfriend.jsp"); dispatch.forward(req, resp); system.out.println("sucess"); } when authentication successfull, how can direct user new jsp or servlet can input few textboxes , select-options select few records db table. not clear me how can direct page search.jsp page in above if condition. search.jsp in webcontent folder of juno. i using jdbc tomcat7. please help ...

python - Why does NamedTemporaryFile().write (without intermediate variable) result in "I/O operation on closed file"? -

i have following script, same thing twice, in different ways. first works, second not: #!/usr/bin/python import tempfile fhandle=tempfile.namedtemporaryfile(dir=".",delete=false) fhandle.write("hello") tempfile.namedtemporaryfile(dir=".",delete=false).write("hello") i follow error: traceback (most recent call last): file "./test.py", line 7, in <module> tempfile.namedtemporaryfile().write("hello") valueerror: i/o operation on closed file in example script, have put them show first 1 works. not affect results, points out there difference. is bug in python? weird machine? expected behaviour? correct behaviour? looks object being destroyed before write(). python 2.7.3 on ubuntu 12.04.3 lts i think comments @eric urban , @alecxe right, file closed - depending on platform - based on refcount, or similar. tried looking @ newly created tempfile object using similar process: >>> temp...

java - Struts 2 validation concept understanding -

i don't understand conception of struts2 validation in next case : my application consists of 2 actions: login.action drive.action i can run drive.action browser command line without filling user , password in login.action how can implement validation code prevents run of drive.action command line if user hasn't filled user , password in login.action ? the validation concept struts 2 validation configured via xml or annotations. manual validation in action possible, , may combined xml , annotation-driven validation. validation depends on both validation , workflow interceptors (both included in default interceptor stack). validation interceptor validation , creates list of field-specific errors. workflow interceptor checks presence of validation errors: if found, returns "input" result (by default), taking user form contained validation errors. if we're using default settings , our action doesn't h...