Posts

Showing posts from February, 2013

excel vba - VBA copy from a union of two ranges to a row of another range -

dear competent people. i'm having problem following code, sub completes correctly not copy correct data correct location. repeating pattern of lines of zeros not correlate iterators in place. i think problem copying values sub-set of range, episode&r. looked @ using union property shown wrong commenter below. currently 9 ranges named "episode"1-9 each row of contains data 1 respondent. columns 5 through 15 of these ranges contain data copied, therefore range copied each respondent is: row i, columns 5 through fifteen. step stuck with. if copy it, data end on sheet2 range has been named each respondent, called respondent&n. rows of response&n represent time slots during episode&r can occur. outside of slots episode&r occurs there can zeroes, isn't necessary. the logical structure appears work fine. have watched local values counters closely in debugging , work supposed to. i looking @ using range.item method select row 'n', c

php - Get the file extension -

i'm exploding on "." file format , name: list($txt, $ext) = explode(".", $name); the problem files have names dots. how explote on last "." $name=pic.n2 , $ext=jpg from: pic.n2.jpg ? use pathinfo : $pi = pathinfo($name); $txt = $pi['filename']; $ext = $pi['extension'];

iphone - Add a simple CGGradient to UINavigationBar -

possible duplicate: uinavigationbar gradient details i looked around web haven't found clear example. have no experience cggradient need simple thing: want add gradient navigationbar of navigationcontroller, gradient should linear, top bottom. want start color : (88.0, 38.0, 40.0) , end color (50.0 15.0 16.0). please give me example of how add gradient navigation bar? thank adjust color or supply image if want // #lighter r,g,b,a #darker r,g,b,a #define main_color_components { 0.153, 0.306, 0.553, 1.0, 0.122, 0.247, 0.482, 1.0 } #define light_color_components { 0.478, 0.573, 0.725, 1.0, 0.216, 0.357, 0.584, 1.0 } @implementation uinavigationbar (uinavigationbarcategory) - (void)drawrect:(cgrect)rect { if (imageready) { uiimage *img = [uiimage imagenamed: @"navigation_background.png"]; [img drawinrect:cgrectmake(0, 0, self.frame.size.width, self.frame.size.

objective c - iOS Development - Using rootViewController correctly -

i have been learning ios development few days now. @ moment, have questions on how rootviewcontroller used. searched web 3 hours yesterday looking answer turned quite few results never answered question. i trying learn program app using code (no storyboards/xib files). trying understand how switch between views without using uinavigationcontroller. in project have main delegate creates window, initializes main view controller (which loads separate view well) , adds rootviewcontroller. my first view has button calls function in controller switch next view. here question arises: switch main rootviewcontroller next view or load next view subview of rootviewcontroller? rootviewcontroller supposed encase views application? (i think how uinavigationcontroller works) i have gotten switching of rootviewcontroller work in app, want make sure there isn't other way suppose manage views. i not switch rootviewcontroller, think should remain stable. add subview, or can presen

xamarin.android - Join tables efficiency on Linq -

i'm beginner in linq , have observed inner join query slower , less efficient than, example, crossing tables in code. furthermore, these data charged in listview lighter. here code: public static ienumerable<alumno> getitems() { return (from gal in me.table<grupoalumno>() join alu in me.table<alumno>() on gal.idalumno equals alu.id select alu); } how possible? thank you. i disagree existing accepted answer! linq not operate on ienumerable<t> - can operate on iqueryable<t> , when linq statement executed in query language such sql. in case, linq similar in performance operating directly in sql, has other advantages compile time type checking , intellisense. i agree @anders whenever facing performance issues measuring happening first step - i'd disagree "linq not way go" - i'd opposite - "linq way go" please make sure measure , understand happen

php - Generated unique key in relational doctrine -

i trying create onetomany relation between answers , questions tables in doctrine. these basic yaml schemas answer schema type: entity table: fs_answer fields: id: id: true type: integer unsigned: false nullable: false generator: strategy: identity questionid: type: integer unsigned: false nullable: false column: question_id body: type: text nullable: false onetoone: question: targetentity: fsquestion cascade: { } mappedby: null inversedby: null joincolumns: question_id: referencedcolumnname: id orphanremoval: false lifecyclecallbacks: { } question schema: type: entity table: fs_question fields: id: id: true type: integer unsigned: false nullable: false generator: strategy: identity body: type: text nullable: false onetomany: answer: targetentity: fsansw

actionscript 3 - Adobe Air - Save window size and position -

i'm trying write xml file save position , size of app window in it. i'm running error: typeerror: error #1010: term undefined , has no properties. maintimeline/setupwindow() as: import flash.display.nativewindowinitoptions; import flash.display.nativewindowsystemchrome; import flash.display.nativewindowtype; import flash.display.nativewindow; function setupwindow(e:event = null):void { gotolastposition(); this.nativewindow.addeventlistener( event.closing, saveappposition ); } function saveappposition(e:event = null):void { var xml:xml = new xml('<position x="' + this.nativewindow.x + '" y="' + this.nativewindow.y + '" width="' + this.width + '" height="' + this.height + '"/>'); var f:file = file.applicationstoragedirectory.resolvepath("appposition.xml"); var s:filestream = new filestream(); try { s.open(f,flash.filesystem.filemode

java - struts controller and service layer? -

the existing application working on, action classes interact dao classes directly. would better action classes, invoke service layer classes(businessfacade) in turn invoke dao? is better develop layer between action classes , dao layer? it's better because in way can separate business logic (the logic not related naviagtion matters) possible reuse. if separate you'll able reuse business logic in non web application. the data access layer intended layer objects persisted to, , restored from, abstract storage , actually, specially in case of rdbms persistence, may implemented orms, can see business logic layer orm persist objects. prefer merge business logic orm, in case rather front end framework.

What type is the best to manage binary data in Java? -

i'm getting documents web , many of them binary files (executables, pdf, etc.). in java, correct type hold binary data until save in database? can use string this? use byte array (byte[]) or inputstream (e.g. bytearrayinputstream). java strings not container generic binary data. the apache library commons-io has nice utility classes dealing bytes , streams. e.g. ioutils.tobytearray(inputstream) bytebuffer introduced part of java nio , available in java 4 (1.4) , later. in specialized scenarios, can have performance benefits on using byte[]. has helpful convenience methods. still use byte[], though, since more known, more common in apis, , performs enough.

web services - is there a hosted web app I can use to test WS-I BP1 soap compliance? -

i have url has wsdl vendor , run hosted tool , forward him results. does such webtool exist can type in url of wsdl? (or have download soapui or other stuff this...yuck). looking quick way test out. one way if have .net run wsdl , associated xml schemas through svcutil.exe program. complains many compliance violations. older wsdl.exe tool complain many of them. there tools this. have used soapscope tool mindreef. have been purchased progress software, , appears tool may actional application development .

Graph connections in python -

i'm not familiar graph theory, i'll try explain problem. have dictionnary this: {67: [68, 332], 68: [67], 265: [266], 266: [265], 332: [67, 333], 333: [332, 334], 334: [333, 335], 335: [334, 336], 336: [335]} the keys of dict nodes, , values edges of graph. how can find connected groups in graph? [there 2 groups - 265->266 , 67->...->366] it looks graph undirected, meaning that, 2 nodes , b, if there edge b there edge b a. find connected components of graph, can use depth-first search . start @ node , follow edges until can't reach more nodes without hitting duplicates. first connected component. start @ node haven't touched yet , repeat. you're done when you've reached nodes in graph.

facebook - How can Link my App to my Page (fan page) -

i have new app linking smf forum, working ok. the thing want link app forum fan page, but when enter myapps-> advanced, see option create new one, , have x button option erase (no edit option), i'm in infinite loop here, can't link app fan page... what i'm doing wrong? try this: https://www.facebook.com/dialog/pagetab?app_id=your_app_id&display=popup&next=your_url your_url should contain same value page tab url: in app settings

c# - System.Net.Http: missing from namespace? (using .net 4.5) -

Image
tl; dr: i'm new language , have no idea i'm doing here class far: using system; using system.collections.generic; using system.net.http; using system.web; using system.net; using system.io; public class myclass { private const string url = "https://sub.domain.com/objects.json?api_key=123"; private const string data = @"{""object"":{""name"":""title""}}"; public static void createobject() { httpwebrequest request = (httpwebrequest)webrequest.create(url); request.method = "post"; request.contenttype = "application/json"; request.contentlength = data.length; streamwriter requestwriter = new streamwriter(request.getrequeststream(), system.text.encoding.ascii); requestwriter.write(data); requestwriter.close(); try {

iphone - how to declare UInt32 variable with global class access -

i trying declare uint32 variable can accessed method in class.. so global classes methods not other class... i trying in .h @interface enginerequests : nsobject { uint32 dataversion; } @property (copy) uint32 dataversion; but thats not working.. i'm getting error on line @property etc.. need or fine use uint32 @ top. you try @interface enginerequests : nsobject { @protected uint32 dataversion; } @property (assign) uint32 dataversion; @end @implementation enginerequests @synthesize dataversion; // methods can access self.dataversion @end but don't need property, unless want grant/control outside access. declare uint32 dataversion in class interface , reference dataversion in implementation without self. either way, @protected prevent outside classes accessing dataversion directly. have read on objective-c properties ? initialization your enginerequests subclass of nsobject . such, can (usually should) override nsobject 's -(

html - Add hover state for menu item with a little white bar -

Image
consider following structure: <ul> <li><a href="">home</a><img src="menu_hover_line.jpg" class="whitebarhover" /></li> <li><a href="">contacts</a><img src="menu_hover_line.jpg" class="whitebarhover" /></li> </ul> here "a" block element (display:block;) , menu element, height , paddings right , left: li { display:inline-block; float:left; position:relative; } { text-decoration:none; font-family:arial, helvetica, sans-serif; font-size:14px; color:#131313; display:block; line-height:51px; padding:0px 29px; } a:hover { background-color:#000; border:0 none; color:#fff; } .whitebarhover { width:40px; height:3px; position:absolute; top:2px; visibility:hidden; } div#menu li:hover img.whitebarhover { visibility:visible; } the point of "img" , related css code

xcode - Removed View, but sound is still playing -

i have view has sounds playing. when remove them using removefromsuperview, longer audio clips still play. why sound continue though view removed? gone; seems it's hidden? yes still play if don't stop it. need stop manually. before remove view write : [audioplayer stop];

python - import at module level or at function level? -

which style preferable? style a: def foo(): import some_module some_module.something style b: import some_module def foo(): some_module.something assume some_module not used elsewhere in code, inside function. indeed, noted, it's best follow pep 8 recommendation , imports @ top. there exceptions though. key understanding them lies in embedded question in second paragraph: "at stage import ... happen?" import executable statement. when import module, executable statements in module run. "def" executable statement; execution causes defined name associated (already-compiled) code. if have: def f(): import return none in module import, (compiled) import , return statements associated name "f" @ point. when run f(), import statement there runs. if defer importing "very big" or "heavy", , never run function (in case f), import never happens. saves time (and space well). of c

sorting - how to sort and arrange a text file in java to group lines -

really struggling work out... i have text file data (17000 lines of it) 45226 1 45226 1 45226 1 45226 3 45226 5 23470 1 45226 5 45226 5 29610 4 37417 2 37417 3 37948 1 what want sort text file (using java) left numbers grouped if right value 1. or left value group if right not equal 1 (so other number). example (but doesn't have this) 3 x 45226 1 4 x 45226 mixed 1 x 23470 1 1 x 29610 mixed 2 x 37417 mixed 1 x 37948 1 i know may need use array? or sort of sort? can't work out :'( any help, code or suggestions - appreciated! thank you! my code: public class sort { private static class counter { private int one; private int mixed; public void incrementone() { one++; } public void incrementmixed() { mixed++; } } public static void main(string[] args) throws ioexception { map<string, counter> map = new linkedhashmap<string, counter>(); string filena

extjs - How to query a component by component name that contain some part of string -

i want use ext.componentquery.query() query name of button contain path of name. assume have 4 button name declare 'edit_btn', 'add_btn', 'add2_btn' , 'edit2_btn' then use query. ext.componentquery.query("button[name='*edit*']"); i should ''edit_btn' ' , ''edit2_btn' ' button. ext.componentquery.query("button[name='*add*']"); i should ''add_btn' ' , 'add2_btn' button. or can use regex in ext.componentquery.query() command? if can, how use it? it's not implemented. looked @ source code, , there equality operator implemented. hovewer it's easy extend (see filterbyattribute in componentquery.html file), must copy code source, because it's implemented singleton. another way select buttons have name attribute , filter later, eg: ext.array.filter( ext.componentquery.query('button[name]'), function(c){ ret

c# - How to change WASAPI record bitrate with NAudio? -

i'm using naudio decode, play , record mp3 stream. recording use wasapiloopbackcapture save stream wav file: if (wavein == null) { wavein = new wasapiloopbackcapture(); writer = new wavefilewriter(outputfilename, wavein.waveformat); wavein.dataavailable += new eventhandler<waveineventargs>(wavein_dataavailable); wavein.recordingstopped += new eventhandler(wavein_recordingstopped); wavein.startrecording(); } i'm searching solution save wav file not 3072 kbit/s (what seems standard wasapi). mp3 stream provides 128 kbit/s, bitrate wav file. tried modify wavein.waveformat didn't find right properties. unfortunately wasapi not allow change sample rate loopback recording. have perform own sample rate conversion afterwards. dmoresampler or waveformatconversionstream classes in naudio can used this.

C# copy paste an image region into another image -

i trying write utility class permits automatic resizing of images tilebale. let's there srcbitmap copy region given rectangle srcregion. want paste (pixel information wise) region image called bitmap destbitmap, in destination region rectangle destregion. know how region source , put bitmap object, haven't yet been able find how paste bitmap object in region, inside another, bigger bitmap object. is there quick way this? (without gdi , without delving byte array of bitmaps). here snippet should clarify goal private static void copyregionintoimage(bitmap srcbitmap, rectangle srcregion, bitmap destbitmap, rectangle destregion) { // required region destination bitmap region = copy(srcbitmap, srcregion); } use : public static void copyregionintoimage(bitmap srcbitmap, rectangle srcregion,ref bitmap destbitmap, rectangle destregion) { using (graphics grd = graphics.fromimage(destbitmap)) {

vmware - Where is "Developer" folder? -

i want learn how develop ios devices, don't have mac, virtualise os x vmware. i'm beginning in objective-c, made simple view button. built first project simulator, , works fine, want use ipod developing. i know issue fixed in others topics, have problem. don't have folder named "developer" in root directory of hdd (and so, can't "cd /developer/"...) how possible? i'm sorry if question stupid, i'm beginner in mac environment. since version 4.3 xcode single app in application folder. before 4.3 xcode located in /developer . has changed, can find "developer folder" inside of app package. try cd /applications/xcode.app/contents/developer/ . you didn't why need in folder don't know if find looking for. possible files have been moved different locations.

asp.net mvc - Is there a way to get a PartialView HTML content in the controller? -

i have partial view controller outputcache on need cache element. then need render partialview in every page, first need string replacement. so question is, howdo partial view in controller can manipulate content , string replacement before returning view? thanks no, don't this. controller should not render view, that's job of templating engine. pass "replacement" values model partialview. public actionresult someaction() { somemodelmodel = new somemodel(); // model return partialview(model); // partial view model } and partial view: @model somemodel <div>replace values @model.value instead of string.replace().</div>

Trouble passing callback to my jquery plugin -

i'm trying develop plugin takes callback first argument on init. i've tried modify plugin code official tutorial . can't figure out why what's wrong here: the plugin: (function( $ ){ var methods = { init : function( callback, options ) { // create defaults, extending them options provided var settings = $.extend( { 'location' : 'top', 'background-color' : 'blue' }, options); return this.each(function() { $this.click(function(e) { e.stoppropagation(); var $target = $(e.target); if (callback) callback($target); }); }); }, }; $.fn.myplugin = function( method ) { // method calling logic if ( methods[method] ) { return methods[ method ].apply(

jquery - How to make Colorbox iframe to move with the scroll up/down? -

i have colorbox iframe links page. the problem is, if scroll up/down window colorbox remains @ it's initial position , can't see anymore. is there way make follow scroll up/down? guess can solved css positioning or couldn't figure out. thanks. please let me know if doesn't make sense provide screenshots. i'm not sure "colourbox" usual way describe is: #yourelement { position: fixed; left: 0px; top: 50%; } this keep element 0px left , half way down screen when scroll.

objective c - Multiple iOS devices + centralized sqlite database -

can share same sqlite database 2 different ios devices or update 1 another? not easily. can sync db on icloud there high chance data overwritten. i recommend writing sort of syncing tool can detect , merge changes originating on either device. a common method use timestamp column , rows modified since last sync, update other database.

c# - Compare XPath list to find the closest to another node? -

i have following node "/html[1]/body[1]/div[1]/div[1]/div[3]/div[1]/div[7]/p[1]/#text[1]" how can figure out last 1 of these closest one? "/html[1]/body[1]/div[1]/div[1]/div[3]/div[1]/div[4]/div[1]/img[1]" "/html[1]/body[1]/div[1]/div[1]/div[3]/div[1]/div[4]/div[3]/a[1]/img[1]" "/html[1]/body[1]/div[1]/div[1]/div[3]/div[1]/div[4]/div[3]/a[2]/img[1]" "/html[1]/body[1]/div[1]/div[1]/div[3]/div[1]/div[4]/div[5]/img[1]" "/html[1]/body[1]/div[1]/div[1]/div[3]/div[1]/div[5]/div[1]/img[1]" it won't last one. here's how got there: protected string guessthumbnail(htmldocument document) { htmlnode root = document.documentnode; ienumerable<string> result = new list<string>(); htmlnode description = root.selectsinglenode(descriptionpredictivexpath); if (description != null) // in case, predict relevant images ones closest description text node. { htmlnode node = description.

knockout.js - Sporadic un-evaluated values when using knockout-deferred-updates -

i using knockoutjs 2.0 & knockout-deferred-updates plugin. encountering sporadic null object reference errors in bindings, due, presumably, timing of evaluating various callbacks. looking guidance on how determine whether (or which) items set deferredupdates = false . as alternative, have put in test code in binding check if value obtained valueaccessor() call null; if so, not evaluate binding function. while might work update handlers, doesn't seem idea init ones. thoughts? thanks in advance, gene obviously problem happens sporadically difficult solve, if appear caused slower network response, can try simulating slow connection able reproduce problem more consistently. should let debug better (or @ least narrow down problem).

amazon cloud ec2 xampp username and password -

i connecting ec2 (amazon cloud) windows instance xampp, requires username , password. can find them? this documented in amazon elastic compute cloud microsoft windows guide , in step 3: connect windows instance within getting started section: to connect windows instance, must first retrieve initial administrator password, , use password remote desktop. you'll need contents of private key file created when launched instance (e.g., gsg_keypair.pem). the detailed actions required achieve documented , illustrated on aforementioned page. good luck!

Why am I leaking memory here (depth first search) c++? -

int solver::negamax(position* pos,int alpha,int beta, int color, int depth ) { if(depth==0 || is_final(pos)){ return evaluate(pos); } else{ vector < position* > moves = generate_moves(pos->get_board()); vector < position* >::iterator move; int min = 99999; for(move = moves.begin(); move < moves.end(); move++){ int val = negamax(*move,alpha, beta, -color, depth - 1 ); if(val <= min){ min = val; delete best; best = null; best = (*move)->get_board(); } else{ delete *move; //so isnt cleaning up? *move = null; } } min = -min; return min; } } vector < position* > takeawaysolver::generate_moves(board *brd){ takeawayboard *board = static_cast<takeawayboard*>(brd); vector < position* > moves; if(board->get_data() >= 3){ takeawayboard *b = new takeawayboard(board->get_data() - 3); position* p = new p

css - Is CSS3 fully enabled in every browser? -

i'm learning css , there prefix -moz , -webkit repeats same code accomodate mozilla, safari, etc. when comes things css3 transition or border-radius. all answers have found 2010 or 2011 nothing recent. still need use these prefixes or browsers css3 ready? the css3 specification incomplete , cannot possibly "fully enabled" in browser @ moment. won't reach widespread standardization few years, given granular modularization, suppose we're getting there. if need sources past month, here go: how find out when can safely drop vendor prefixes css3 property? do have use non-standard/browser specific css vendor prefixes anymore?

linux - set -e overwrites parameter variable($@) in bash script -

i have script test.sh #/!bin/bash set -e trap errorhandler err errorhandler(){ status=$? trap - err exit $status } echo "$@" exit 0 when call sh test.sh 'hey' print -e instead of hey . work around surround set -e backticks dont know if still works intended workaround store in variable in first line set -e in first line 1 obvious reason (handling error). there clever way this? "hey don't touch $@" command. got it! -e , –e notice dash. first 1 correct. lesson learned. not copy code directly html.

Assembly Theory -

we're working assembly. i'm kind of lost. practice question on study guide: using hypothetical machines (3-address, 2-address, 1-address , 0-address) , following commands: load= puts value in address add = + mult = * sub = - lda=load in accumulator sta = loads accumulator memory push=copies stack pop=copies stack show each machine instructions perform following task: f=e+(a-c) – (b*e) a. can explain how 4 different machine types differ in terms of code? b. can show me how 1 of 4 place start? 3-addr. (result , ops memory) mult b, b, e sub f, a, c sub f, f, b add f, e, f 2-addr (shared result , 1 op) mult b, e sub a, c load f, e add f, sub f, b 1-addr (accu only) lda b mult e sta b lda sub c sta lda e add sub b sta f 0-addr (stack only) push e push push c sub add push b push e mult sub pop f

xml - XSLT Only Let Through Duplicate Records -

is possible filter on speicif field , when 2 fields same, let 2 hierarchies through. mean: input data: <?xml version="1.0" encoding="utf-8"?> <payload> <set> <field1>compare</field1> <field2>info</field2> <field3>more infor</field3> </set> <set> <field4>compare</field4> <field5>put through</field5> <field6>this too</field6> </set> <set> <field1>compare1</field1> <field2>info</field2> <field3>more infor</field3> </set> <set> <field4>compare2</field4> <field5>put through</field5> <field6>this too</field6> </set> <set> <field1>compare2</field1> <field2>info</field2> <field3&g

android - Do you advise clients to use JSON or XML? And Why? -

many times client ask me whether deliver data via xml feed or json strings. say: xml if have feed , not have web developer create script generating json strings json if not have feed , need create scratch what say? think delivering data via xml feeds obsolete , xml over-complicated , heavy? should advise clients (for sake of future) move onto json way of delivering data? edit from discussion https://stackoverflow.com/questions/2636245/choosing-between-json-and-xml can see json advised web services, used case scenario in clients. seems advising them properly. what want pass news articles onto mobile device - shall advise xml of json? what post&get cases when need post data , response displayed on user's mobile device - xml or json? if consumers browsers or mobile devices, recommend json. faster lighter native parsing support if consumers other programs, recommend xml can validated easily code generators available make programming easy

php - user authentications via session or cookies? -

this moment if user enter's correct username , password creating session: $_session['userid'] = $user_data[0]->id; $_session['username'] = $user_data[0]->username); $_session['loggedin'] = true; after that, $_session['loggedin'] can check if user can view part of website or not. is method 'good/safe' ? any benefit's using cookies based , session based authentication ? which method common site's using ? what guys using sites ? have @ great answer joel coehoorn on page . of questions answered in post. web authentication state - session vs cookie vs? i hope help. cheers

How to get the JSON from the controller to display in the view of ASP.net MVC 2 -

i trying query data database, in order take create main menu in asp.net mvc 2 web site. this code in controller : public jsonresult getmenu(string id) { jsonresult jr = new jsonresult(); var ien_menu = ( d in this.datacontext.departments join c in this.datacontext.categories on d.id equals c.departmentid join in this.datacontext.items on c.id equals i.categoryid d.active == 1 && d.activeinweb >0 && c.active > 0 && c.activeinweb >0 && i.active > 0 select d ).distinct() .orderby(s=>s.name); jr.data = ien_menu.tolist(); jr.jsonrequestbehavior = jsonrequestbehavior.allowget; return jr; } but have no idea how take data , display in partial views. need do? how calling controller action? can use jquery json results if loading via ajax. @ s

html - Parse XML link with PHP -

Image
i have xml feed looks this: i can parse title enough using simplexml: $pictureboxxmlfeed = simplexml_load_file('https://www.picturebox.tv/xml/feeds/findanyfilm/findanyfilm.xml');; echo $pictureboxxmlfeed->entry[1]->title; foreach($pictureboxxmlfeed->entry $value){ echo $value->title; echo '<br/>'; } but need grab link element in feed looks this: <link href="http://www.picturebox.tv/watchnow?id=ukic30" rel="alternate"/> fyi, doesn't work: echo $value->link; thanks help... is mean? $string = ' <entry> <link href="http://www.picturebox.tv/watchnow?id=ukic30" rel="alternate"/> </entry>'; $simplexml = simplexml_load_string($string); foreach($simplexml->link->attributes() $name => $value) { echo $name.': '.$value.'<br />'; } gives: href: http://www.picturebox.tv/watchnow?id=ukic30 rel: alternate

javascript - how to delete the contents of a particular column of jqgrid table? -

how delete contents of particular column of rows of jqgrid table? or how can set particular column of rows of jqgrid table particular value in single shot. you can this: to delete contents: $('td[aria-describedby=<your table name>_<column name>]').html(''); to set value: $('td[aria-describedby=<your table name>_<column name>]').html('whatever');

java - GWT CellTable - Remove the sorting arrow from a header -

Image
i remove sorting arrow header of celltable. (the 1 in red circle below, gwt showcase : http://gwt.google.com/samples/showcase/showcase.html#!cwcelltable ) but still want sorting capabilities of celltable. is possible? idea? untested , bit of hack, try overriding default style return blank images. extend hilbrand's earlier solution override imageresources celltable uses: public interface tableresources extends celltable.resources { @source("blank.jpg") imageresource celltablesortascending(); @source("blank.jpg") imageresource celltablesortdescending(); } create 'blank.jpg' , put in same resources package interface.

php - Wordpress: change upload dir conditionally -

Image
for theme i'm creating need possibility upload images through theme-settings page. no problem far. images uploaded through specific settings page should stored in different dir standerd upload dir, or @ least have make them different 'other' media. i did find nice script change upload dir: function ml_media_upload_dir($upload) { global $user_id; if ((int)$user_id > 0) { $upload['subdir'] = "/" . $user_id.'test'.$id; $upload['path'] .= $upload['subdir']; $upload['url'] .= $upload['subdir']; } return $upload; } add_filter('upload_dir', 'ml_media_upload_dir'); by now, upload dir changed specific user_id. change dir when media uploader fired specific theme-options page. see screenshot below. would great comments on how handle this; after searching hours , hours still haven't found solution. i think 1 solution (temporarily) overwrite core function filter . add fil

android - Is it necessary to call Looper.prepare() from within the UI thread? -

if want implement handler object within activity's main thread, need call looper.prepare() beforehand, or activities have own internal loopers? same hold true if want instantiate handler instance within service? the main thread has own looper. see context.getmainlooper() . main thread encompasses activities , services in application.

javascript - Backbone.js: How to handle selection of a single view only? -

i stuck on following issue: i have model property defines if visibly selected or not, call selectmodel purpose of question. selectmodel = backbone.model.extend({ defaults:{ isselected: false } }) now first part not how should handle selection in general. if want use observer pattern, view should listen change of isselected property. view triggers in first place, have. selectview = backbone.view.extend({ initialize: function(){ this.model.bind("change:isselected", this.toggleselectionvisually) }, events: { "click" : toggleselection }, toggleselection: function(){ this.model.set({"isselected": !this.model.get("isselected"); }, toggleselectionvisually:(){ //some code shows view selected }, }) so in feels bit absurd guess understand wrong. but part fail implement without making code horrible handling selection multiple models 1 model selected @ time. selectlistview = backbone.view.extend({ initialize: function(){ this.collection

How to make a permanent change to an element after using jQuery's .keydown()? -

i have following jquery code: function showresult(str) { if (str.length == 0) { $('#mysearch').html(''); return; } else { $('#mysearch').load('search/'+str,function(){ $('#mysearch').css({ 'background-color': 'white', 'width': '250px', 'position': 'absolute', 'right': '0' }) }); } $(document).click(function(event) { if ( !$(event.target).hasclass('mysearch')) { $('#mysearch').html(''); $('#main_search').val(''); } }); $(document).keydown(function(e){ if (e.keycode == 40) { $('#mysearch tr.myrow:first').addclass("a_classy_class"); return false; } }); } when press down arrow key class 'a_classy_class' added tag id 'myrow'. however, stop pressing down arrow key class removed. how make change p

build - Missing tk.h and tcl.h files when building VRip -

i trying compile vrip in ubuntu 10.04, using site http://graphics.stanford.edu/software/vrip/guide/ guide. relies on installation of tcl , tk -- have acquired latest versions of these synaptic package manager. when write "make depend", error: in file included vripinit.cc:30: vripinit.h:22:17: error: tcl.h: no such file or directory vripmain.cc:22:16: error: tk.h: no such file or directory in file included vripmain.cc:28: vripinit.h:22:17: error: tcl.h: no such file or directory in file included vripmisccmds.cc:29: vripmisccmds.h:22:17: error: tcl.h: no such file or directory in file included vripfillcmds.cc:29: vripfillcmds.h:22:17: error: tcl.h: no such file or directory in file included vripfilecmds.cc:29: vripfilecmds.h:22:17: error: tcl.h: no such file or directory in file included vripgridcmds.cc:29: vripgridcmds.h:22:17: error: tcl.h: no such file or directory in file included vriprangecmds.cc:36: vriprangecmds.h:21:17: error: tcl.h: no

javascript - How to disable/enable input field on click with jQuery -

how enable/disable input field on click jquery? i experimenting with: $("#fullname").removeattr('disabled'); which removes disabled="disabled" input field: <input id="fullname" style="width: 299px" value="marko" disabled="disabled" /> but how add again click on button or how disable input field on click? for jquery version 1.6+ use prop : $('#elementid').click(function(){ $('#fullname').prop('disabled', true\false); }); for older versions of jquery use attr : $('#elementid').click(function(){ $('#fullname').attr('disabled', 'disabled'\''); });

sql server 2008 - Not getting Record Between two dates -

i want rows between 2 dates here query: select distinct convert(varchar(09), [datetime], 103) studentattendance_fk lecturerid = 5033 , courseid = 1004 , subjectid = 120 , [datetime] between '3/8/2012' , '3/11/2012' format (mm/dd/yyyy) sample values 3/8/2012 11:40:46 pm 3/8/2012 11:40:46 pm 3/9/2012 11:57:55 3/9/2012 10:48:02 pm 3/10/2012 11:57:20 pm the query isn't returning rows between these 2 dates. changes in query? thanks you ajay. if you're using 103 ( d/m/y ) why clause using m/d/y ? using british/canadian regional settings or not? stick standard, unambiguous formats such yyyymmdd , have more predictable results. select distinct convert(date, [datetime]) dbo.studentattendance_fk lecturerid = 5033 , courseid = 1004 , subjectid = 120 , [datetime] >= '20120308' , [datetime] < '20120312';

asp.net - How do I send API credentials and username / password with .Net / Parse.com? (PHP to C#) -

i trying create web page allow users login , view data. data hosted on parse.com exposes rest api. i using asp.net / c# access , can using api key , application key. however, need write version of php code documentation in c#... to this, send request /1/login endpoint username , password url-encoded parameters: curl -x \ -h "x-parse-application-id: ${application_id}" \ -h "x-parse-rest-api-key: ${rest_api_key}" \ -g \ --data-urlencode 'username=cooldude6' \ --data-urlencode 'password=p_n7!-e8' \ https://api.parse.com/1/login now stuck here...anything have tried returns http 400, such code... [webmethod] [scriptmethod(responseformat = responseformat.json)] public static string parseauthenticate(string strusername, string strpassword ) { var httpwebrequest = (httpwebrequest)webrequest.create("https://api.parse.com/1/login"); httpwebrequest.contenttype = "application/x-www-form-urlencoded"; httpwebreque

python - My matplotlib.pyplot legend is being cut off -

Image
i'm attempting create plot legend side of using matplotlib. can see plot being created, image bounds not allow entire legend displayed. lines = [] ax = plt.subplot(111) filename in args: lines.append(plt.plot(y_axis, x_axis, colors[colorcycle], linestyle='steps-pre', label=filename)) ax.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) this produces: as pointed adam, need make space on side of graph. if want fine tune needed space, may want @ add_axes method of matplotlib.pyplot.artist. below rapid example: import matplotlib.pyplot plt import numpy np # data x = np.arange(0, 10, 0.1) y1 = np.sin(x) y2 = np.cos(x) # plot of data fig = plt.figure() ax = fig.add_axes([0.1, 0.1, 0.6, 0.75]) ax.plot(x, y1,'-k', lw=2, label='black sin(x)') ax.plot(x, y2,'-r', lw=2, label='red cos(x)') ax.set_xlabel('x', size=22) ax.set_ylabel('y', size=22) ax.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0

python - Jquery AJAX calling is not returing success -

i novice , written code using jquery display output of python program on browser user: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>project</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <link type="text/css" href="jquery/css/ui-lightness/jquery-ui-1.8.18.custom.css" rel="stylesheet" /> <script type="text/javascript" src="jquery/js/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="jquery/js/jquery-ui-1.8.18.custom.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#runreport').click(function() { runreport($('#starttime').val(), $('#endtime').val()); });

unit testing - How to approach unittesting and TDD (using python + nose) -

i have been trying hang of tdd , unit testing (in python, using nose) , there few basic concepts i'm stuck on. i've read lot on subject nothing seems address issues - because they're basic they're assumed understood. the idea of tdd unit tests written before code test. unit test should test small portions of code (e.g. functions) which, purposes of test, self-contained , isolated. however, seems me highly dependent on implementation. during implementation, or during later bugfix may become necessary abstract of code new function. should go through tests , mock out function keep them isolated? surely in doing there danger of introducing new bugs tests, , tests no longer test same situation? from limited experience in writing unit tests, appears isolating function results in test longer , more complicated code testing. if test fails tells there either bug in code or in test, not obvious which. not isolating may mean shorter , easier read test, not unit tes

javascript - how to get the <script> code use regular expression from the page source? -

i want script code ,except outer reference script . example: want code of : <script type="text/javascript">alert("test");</script> from next s: var s ='<script type="text/javascript" src="image/plupload/plupload.js"></script><script type="text/javascript" src="image/plupload/plupload.flash.js"></script><script type="text/javascript" src="image/plupload/plupload.html4.js"></script><script type="text/javascript" src="image/plupload/plupload.html5.js"></script><script type="text/javascript">alert("test");</script>' p = /<(script)\s+((language=['"]?javascript['"]?)|(type=['"]?text\/javascript['"]?))?\s*\/?>.*(?:<\/\1>)?/gi; var arr = new array(); while(arr = p.exec(s)) alert(arr[1]+','+arr[1]+','+arr[2]); but regula

Rotation calling Garbage Collector Too Often Android MatrixMultiply -

good day, i writing open gl app on android. have 100 game objects execute fine when update position, velocity or acceleration. in game loop, want able call "yaw" (or pitch, or roll) method every iteration of update game object. problem causing the garbage collector go crazy gc_concurrent printout statements logcat. in yaw method, have following calls... realignvectors(); //no heap allocations in method wrote matrix.rotatem(rotationarray,0,angle,0,1,0); //rotationarray float[16] matrix.setidentitym(rotationalcomputearray,0); //another float[16] matrix.rotatem(rotationalcomputearray,0,angle,upvector.x, upvector.y, upvector.z); matrix.multiplymv(lookvector... matrix.multiplymv(rightvector.. i've commented out code call yaw method , have no calls garbage collector (gc), , 100 objects move through out world out noticable difference. when uncomment out yaw call, significant decrease in performance. objects move choppy , gc calls. does know if matrix.multiplymv or

java - How to load files/properties from WEB-INF directory? -

it seems in tapestry app, can't load ini files nor properties file web-inf directory or class path. i tried several different methods should load file non of them worked. ex realm.setresourcepath("/web-inf/auth.properties"); ex realm.setresourcepath("classpath:wip/pages/auth.properties"); i need load properties/ini file in order use tapestry-security module based on shiro. thanks ! the root of classpath way go. put file in src/main/resources/auth.properties set resourcepath using realm.setresourcepath("classpath:auth.properties"); check extendedpropertiesrealm , tapestry-security testapp example http://svn.codehaus.org/tynamo/trunk/tapestry-security/src/test/java/org/tynamo/security/testapp/services/appmodule.java http://svn.codehaus.org/tynamo/trunk/tapestry-security/src/test/resources/shiro-users.properties

iphone - Continue with previous downloaded session without using ASIHTTPRequest -

by using asihttprequest , asidownloadcache able continue previous downloaded session.now don't want use asidownloadcache.so,is there alternatives achieve it. in advance. if server supports it, can specify content-range field in header of http request , ask small portion of file @ once. when portions, can assemble file together. you can set http headers nsmutableurlrequest setvalue:@"0-1023/*" forhttpheaderfield:@"content-range"]; , example downloads 1024 byte of file. see content-range in http://www.w3.org/protocols/rfc2616/rfc2616-sec14.html this way can download file in parts , next time when want resume download can continue next part don't have yet.

Using rb_require with rb_protect to embed Ruby in C -

i want use rb_require rb_protect, in following example: int error; rb_protect( (value (*)(value))rb_require, (value) "./test", &error); but when compile it, error: passing argument 1 of ‘rb_protect’ incompatible pointer type [enabled default] /usr/include/ruby-1.9.1/ruby/intern.h:357:7: note: expected ‘value (*)(value)’ argument of type ‘value (*)(value, value)’ after searching on google see how use rb_require rb_protect, tried: int error; rb_protect( ruby_method_func(rb_require), (value) "./test", &error); or value require_wrap(value arg) { return rb_require("./test"); } /*in main:*/ rb_protect( require_wrap, 0, & error); but same error. error doesn't stop compilation binary segfault when launch whereas works without rb_protect. __ edit __ there error in source file. in fact solutions have tested works well: int error; rb_protect( (value (*)(value))rb_require, (value) "./test", &error); or int

php - Facebook access token for site feed -

i trying loading facebook feed webpage using: https://graph.facebook.com/177610425663218/feed for got access token graph explorer . problem token keeps running out: error validating access token: session has expired @ unix time ... i know create oauth login new token show feed on webpage. don't want oauth visitors of page. how constant access token site feed? you can access token. create app , login using app_id , app_secret : $response = file_get_contents('https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=some_app_id&client_secret=the_appsecret'); $token = str_replace('access_token=', '', $response); works me.

iphone - Method is not calling from another class -

i have "class-a" contains method -(void)methoda { //logic } i have "class-b" method -(void)methodb { //logic } now trying call methoda class b so in class b create object of "class-a" classa *a; @property(nonatomic,retain)classa *a; @synthesize a; -(void)methodb { [self.a methoda]; } but method not called. doing wrong or other approach doing ? //in class //classa.h @interface classa : nsobject -(void)methoda; @end //classa.m @implementation classa -(void)methoda { //logic } @end //in class b //classb.h #import classa.h @interface classb : nsobject @property(nonatomic,retain)classa *a; @end //classb.m @implementation classb @synthesize a; -(void)methodb { if(!self.a) self.a = [[classa alloc]init]; [self.a methoda]; //logic } @end

sql - Optimizing a MySQL Join Query? -

i have following query: select * products p left join files f on f.contentid = p.productid p.state = 'active' , p.price > 0 order p.created desc limit 2200 currently, query takes 1.7 seconds 2200 rows. don't understand is, why time not decrease when change limit 2200 10, , more importantly, can speed up? try : explain select * products p left join files f on f.contentid = p.productid p.state = 'active' , p.price > 0 order p.created desc limit 2200 to see indexes need

eclipse plugin - delete popup working fine over project explorer view but not working over navigator view -

i trying hide 'delete' popup-menu files. used following plugin.xml entry. <extension point="org.eclipse.ui.activities"> <activity id="hidedeletepopupmenuid" name="hidedeletepopupmenu"> <enabledwhen> <with variable="selection"> <iterate operator="and"> <adapt type="org.eclipse.core.resources.iresource" > <or> <test property="org.eclipse.core.resources.name" value="*.java"/> </or> </adapt> </iterate> </with> </enabledwhen> </activity> <activitypatternbinding activityid="hidedeletepopupmenuid" isequalitypattern="false" pattern="org.eclipse.ui.edit.delete"> </activitypatternbinding> </extension> this seems working fine on project explorer view, navigator view

java - synchronization on single statement? -

if have getter method has 1 statement this public class numberclass{ int number; public int getnumber() { return number; } ... } and multiple threads access method, have synchronize method or not necessary since has 1 statement?? it has nothing 1 or more statements. depends on whether or not value has been updated in thread , if want of threads see consistent value. if number field updated in thread1, thread2 may either original value or new value depending on how update sychronized . if set not synchronized or not value subject race conditions. you can use volatile keyword or atomicinteger share value between multiple threads reliably.

comparison operator objects in java -

are there object representation of these comparison operators (<, <=, ==, >=, >, !=) in java ? e.g. use case: void filterhotel( object operator, float rating ) { string query = "select hotel.name hotel hotel.rating " + operator.tostring() + rating; // execute query } no . easy write, consider using enum custom method: public enum operator { equal("=="), not_equal("<>"), greater_than(">"), greater_than_or_equal(">="), less_than("<"), less_than_or_equal("<="); private final string representation; private operator(string representation) { this.representation = representation; } public string getrepresentation() { return representation; } } pass e.g. operator.less_than , extract actual operator using operator.getrepresentation() . also make sure user cannot put arbitrary string in place of o

html - Div height equal to another div max-height -

Image
i have 3 divs: <div id="main"> <div id="one"></div> <div id="two"></div> </div> div "one" contains content height 300px example. div "two" contains more or less content height 400px example. both content changing, it's not static cannot calculate heights manually. style of div "two" contain "overflow-y: scroll;" how create div "two" same height div "one" can smaller or bigger? here quick sketch: using javascript, like: document.getelementbyid("two").style.height = document.getelementbyid("one").clientheight;

javascript - How to generate parent/child nest on client side? -

i've searched through myriad parent/child array/object/whatever questions here , elsewhere , haven't been able solve issue. know bit long, wanted ensure i'm providing enough info guys. here's want do: i have number of <div> -delineated items on page parent/child relationships, generated via php database i want use these items data source d3.js dendrogram (a node-link tree diagram http://mbostock.github.com/d3/ex/cluster.html ) i'm storing them left/right nested set values parentid values, can add id, parentid, rgt, lft , depth attributes <div> elements, should have available whatever's needed generate parent/child relationships on client side for various reasons, instead of creating json file on server side use data source, need create on client side based on attributes in #3 i've had difficulty getting various suggested javascript functions work , d3 examples i've found use either preexisting json file or generated math-based f