Posts

Showing posts from May, 2013

objective c - Cocoa NSIndexSet : Multiple Indexes. How to create the index set, multiple indexes? -

i trying figure out how create set of indexes of lets (1, 2, 3) use in - (void)selectrowindexes:(nsindexset *)indexes byextendingselection:(bool)extend it's (nsindexset *)indexes not know how use / create / populate indexes 1, 2, 3. should use class method or instance method? i tried whole bunch of ways have no idea i'm doing ... if indexes consecutive in example, can use this: nsindexset *indexset = [nsindexset indexsetwithindexesinrange:nsmakerange(1, 3)]; if not, create mutable index set , add indexes (or ranges) 1 one: nsmutableindexset *indexset = [nsmutableindexset indexset]; [indexset addindex:3]; [indexset addindex:5]; [indexset addindex:8];

sql - converting function to stored procedure -

i'm working in app has user functions throughout where clauses in data layer, , i'm sure it's causing problems performance. as example, let's there's report pulling entries , comments, , there's function where (dbo.countcomments(entries.id, '5/10/2011') = 0) ...showing us, let's say, entries no comments today. i'd convert stored proc, seems it's impossible same behavior stored proc. if had rewrite sp, how it? a couple of thoughts. first, using count=0 find out of there none of inefficient. you're better off using not exists (select...) that way sql can bail finds row return false instead of having visit of them return non-zero count. second, using function in queries? if want ot use output query criteria in example you're not going able stored procedures. what find myself doing writing functions or views commonly-used queries , wrap of them in stored procedures when want return rows return. if have

Perl change working directory of caller -

i want write perl script changes working directory somewhere else, something, , leaves me in directory after call shell. chdir first part. how change working directory of caller? what want not possible. closest thing write bash want , in calling shell, source instead of running it. software cannot affect shell calls it.

Why doesn't youtube have a Download button? -

youtube has buttons viz upload, browse, subscribe, etc. doesn't come inbuilt 'download' button. viewers have use third party software download videos youtube. wonder why. youtube doesn't want people download video's.. , may illegal anyway. want watch on there site.

javascript - How can I use jquery to save my form data then load it in fancybox to preview the changes -

i have form several fields has jquery autosave function saves form every 3 minutes, , button user can click save form. want preview feature loads in fancybox. currently, when click preview button, fancybox loads using iframe , pulls data php/mysql process. preview in fancybox loads, if form has changes since last save, , hasn't been saved since recent changes, fancybox displays data prior latest changes. $(function() { $('#preview-article').live('click', function() { savetheform(); $('#preview-article').fancybox({ 'width': '80%', 'height': '80%', 'autoscale': false, 'transitionin': 'none', 'transitionout': 'none', 'type': 'iframe' }); }); }); any appreciated!!! i found api option included fancybox called onstart able add savetheform function. onstart op

silverlight - Silvelright -set tabindex of UIElements in MVVM -

i trying set tab index of 2 uielement s within user control. user control contains text box , button. have focus being applied textbox via attached property have ability press tab key , navigate textblock button or detect key press (enter key) , trigger command on button(i know separate question) the main focus accomplishing tab index first. thanks pointers or suggestions. update i've since tried employ attached property handle tabbing order public static dependencyproperty tabindexproperty = dependencyproperty.registerattached("tabindex", typeof(int), typeof(attachedproperties), null); public static void settabindex(uielement element, int value) { control c = element control; if (c != null) { routedeventhandler loadedeventhandler = null; loadedeventhandler = new routedeventhandler(delegate { htmlpage.plugin.focus(); c.loaded -= loadedeve

spring - Recommendations required for communication between Eclipse RCP client and Server -

i want recommendation on best way communicate rcp thick client , set of business functionality implemented in spring on server side. please provide urls on net wherever possible. prefer pass domain objects directly between two. osgi option me? for restful web services use jersey client library . if exchange format xml easy exchange objects (see here tutorial). generally, can use client library depending on exchange protocol in eclipse rcp app (see here how convert jar osgi bundle).

Drupal: Content Type templates -

it possible choose different templates when creating new node? for example: when want create node of content type product, want choose between 4 different templates. i have 2 answers: 1) create cck field user choose template use, (e.g. field_template), , add snippet in template.php: function mytheme_preprocess_node(&$vars) { if (!empty($vars['field_template'][0]['value'])) { array_unshift($vars['template_files'], 'node-' . $vars['field_template'][0]['value']); } } that try use node-template.tpl.php template file, , fallback node.tpl.php if doesn't find it. 2) create taxonomy content type, , design taxonomy (something code above, little modified).

php - How to allow users to cancel their paypal subscription on the site, instead of going thru paypal CP? -

i have read thru api (https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_id=developer/e_howto_api_ecrecurringpayments), dont understand how use it. are there php examples on how utilize this? use ipn + express checkout create subscriptions. you can use managerecurringpaymentsprofilestatus api call cancel/suspend or re-activate recurring payments profile. have @ doc on https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_id=developer/e_howto_api_nvp_r_managerecurringpaymentsprofilestatus i don't have sample code @ hand, shouldn't hard adapt different example this. e.g. nvp sdk sample code @ https://www.x.com/

regex - How to redirect a URL by only changing the domain name, while keeping other URL parameters -

i'm migrating website new host , domain, , want know if can redirect enters url of old website new website, while keeping of url parameters. example: when types in url http://www.domaina.com/blog/?p=667 , want him redirected http://www.domainb.com/blog/?p=667 . is there way can adding .htaccess configurations? thanks! try in .htaccess file: options +followsymlinks -multiviews rewriteengine on # http rewritecond %{http_host} ^(www\.)?domaina\.com$ [nc] rewritecond %{server_port} =80 rewriterule ^(.*)$ http://www.domainb.com/$1 [r=301,l] # https rewritecond %{http_host} ^(www\.)?domaina\.com$ [nc] rewritecond %{server_port} =443 rewriterule ^(.*)$ https://www.domainb.com/$1 [r=301,l] this preserve uri while redirecting domaina domainb.

javascript - What's a good way to build a character separated string from a collection? -

every once in while, need build character separated string while looping through collection. believe or not, there first or last separator character gets in way! :) usually, end chopping off character, line of code. leave that, out of curiosity, have cool "smooooth" way of doing this? (in c# and/or javascript) example: {"joe", "jane", "jim"} after building comma separated string, get: "joe, jane, jim, " or ", joe, jane, jim" looking cool way build "joe, jane, jim" without string "chopping" after. in javascript it's easy: var input = ["joe", "jane", "jim"]; var str = input.join(','); // output: joe,jane,jim most languages have form of "join" either built-in or in library: javascript — it's a native function on array prototype php — implode java — apache commons lang c# — string.join by way, if writing s

iphone - How do you use custom UITableViewCell's effectively? -

Image
i making custom uitableview cell shown below. custom uitableviewcell in own nib file calling viewcontroller. (like so) // registrationviewcontroller.m //sets number of sections in table - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { return 2; } // sets number of rows in each section. - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return 1; } //loads both custom cells each section - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { //registration cell static nsstring *cellidentifier = @"customregcell"; static nsstring *cellnib = @"logincustomcell"; uitableviewcell *cell = (uitableviewcell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:cellnib owner:self options:nil]; cell = (uitableviewcell *)[nib objectatindex

How to save a html5 Canvas.toDataURl string as a png on a php backend -

after converting canvas image source using canvas.todataurl("image/png"); and passing php file, how save .png image on server? it's simple, if have allow-url-fopen enabled. php supports data: url scheme then, , automatically decodes base64 , urlencoding. preg_match('#^data:[\w/]+(;[\w=]+)*,[\w+/=%]+$#', $data=$_post["datau"]) , copy($data, "output.png"); but extract part after , , manually base64_decode() it.

Using GET request instead of POST one -

the issue there form want fill. it's submitted via post request. technically can use requests (pass url parameters). , don't have access server site (with form fill) located. i've tried use post params in request, didn't work. other thing came mind send request own server, perform desired post request. need request commited ip, not server's one... can give piece of advice concerning solving problem? is homework? seems odd wouldn't able use post. regardless, the best way override onclick event of submit button; js function poll fields looking submit. use encodeuricomponent() on values them sent webserver correctly. here able load new page get?element=value&.... request. http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp

flash - how do I put checkboxes or other content in a scrollpane? -

how put buttons or checkboxes in scroll pane scroll. tried adding them children seem attached scrollpane not inside. not scroll extend out of it? is there way put content in scrollpane besides text. problem i'm trying solve dealing large number of checkboxes in small area. checkboxes dynamically generated script. thanks, dan if talking standard scrollpane, should have .source property. if add name of checkbox, scrollpane. now, if want add complex content, suggest create empty movieclip , put scrollpane. want add scrollpane, add movieclip. //create container var mc:movieclip = new movieclip(); //you don't need add displaylist (addchild(mc)) //now set source of scrollpane your_scrollpane.source = mc; //any time add new item mc.addchild(your_checkbox); //you can set properties your_checkbox.x = 0; your_checkbox.y = 0; //and refresh scrollpane your_scrollpane.update(); you can setup mc before making source of scrollpane. hope helps.

network protocols - WCF Weird Service Behavior -

i'm using wshttpbinding service working since now. wpf application (client) connected , automatically receives information server every 15 seconds. i've been noticing (once in while, days there no problem) client receives following exception: system.servicemodel.protocolexception: content type text/html; charset=utf-8 of response message not match content type of binding (application/soap+xml; charset=utf-8). if using custom encoder, sure iscontenttypesupported method implemented properly. first 1024 bytes of response were: '<html> <head> <title> </title> <script type="text/javascript"> function bredir(d,u,r,v,c){var w,h,wd,hd,bi;var b=false;var p=false;var s=[[300,250,false],[250,250,false],[240,400,false],[336,280,false],[180,150,false],[468,60,false],[234,60,false],[88,31,false],[120,90,false],[120,60,false],[120,240,false],[125,125,false],[728,90,false],[160,600,false],[120,600,false],[300,600,

c# - Console application not doing anything -

basically write application perform in command prompt: sslist -h -r -h s234.ds.net /mobile > listofsnapshot.txt then code when create c# console application: using system; using system.collections.generic; using system.linq; using system.text; using system.io; namespace search { class program { static void main(string[] args) { system.diagnostics.process p = new system.diagnostics.process(); p.startinfo.filename = "sslist.exe"; p.startinfo.arguments = "-h -r -h s234.ds.net /mobile"; p.startinfo.useshellexecute = false; p.startinfo.redirectstandardoutput = true; p.startinfo.redirectstandarderror = true; p.start(); string procoutput = p.standardoutput.readtoend(); string procerror = p.standarderror.readtoend(); textwriter outputlog = new streamwriter("c:\\work\\listofsnapshot.txt"); output

regex - htaccess breaks indexs -

this works perfect: ^(.*)$ (lets site.com/login.php work site.com/login ) except breaks indexes. can't index file show up, index set same .htaccess file. shows blank page until remove ^(.*)$ . thoughts? rrelated question: htaccess regex 2 periods in file name ^(.*)$ matches anything, nothing. force require @ least 1 character instead. ^(.+)$

flex - ActionScript 3.0 integer overflow? -

i have old air file works fine. tried recompile resulting airfile buggy. after digging in code, found @ place strings parsed ints, , resulting int not correspond string. made simple actionscript file , executed code: var test:int = parseint("3710835714"); and variable have value -584131582 so looks overflow. i'm surprised air file have (which didn't compile myself) runs fine. wonder - internal representation of int somehow depend on version of flex or air sdk libraries 1 using compiling? //edit: seems boils down test: var obj:object = new object(); obj.val="3710835714"; var test1:boolean = (obj.val==-584131582); var test2:boolean = (int(obj.val)==-584131582); this evaluates me to test1=false; test2=true; however - old air file seems evaluate both cases true. how can be? it happening due give number exceeds actionsscript int limit the int data type stored internally 32-bit integer , comprise

android - Setting the width of EditText -

i setting width of edittext element fill_parent in xml file, when accessing code, returns 0. want, actual width of element @ run time. how it. use getmeasuredwidth(): http://developer.android.com/reference/android/view/view.html#getmeasuredwidth%28%29 read here: when view's measure() method returns, getmeasuredwidth() , getmeasuredheight() values must set, along of view's descendants. view's measured width , measured height values must respect constraints imposed view's parents. guarantees @ end of measure pass, parents accept of children's measurements. parent view may call measure() more once on children. example, parent may measure each child once unspecified dimensions find out how big want be, call measure() on them again actual numbers if sum of children's unconstrained sizes big or small (i.e., if children don't agree among how space each get, parent intervene , set rules on second pass). http://developer.android.com/guide/topi

php - Using simplexml_load_file to pull from tumblr - timing out every time -

my site taking ~45 seconds load. it's because i'm pulling in xml tumblr, can't figure out if server's fault, tumblr's fault, or other factor. can script time out in 5 seconds , echo 'tumblr down'; instead of timing out after minute? i'm getting error: warning: simplexml_load_file(http://blog.yaytalent.com/api/read?type=post&start=1&num=2) [function.simplexml-load-file]: failed open stream: connection timed out in /nfs/c08/h02/mnt/122191/domains/yaytalent.com/html/index.php on line 86 warning: simplexml_load_file() [function.simplexml-load-file]: i/o warning : failed load external entity "http://blog.yaytalent.com/api/read?type=post&start=1&num=2" in /nfs/c08/h02/mnt/122191/domains/yaytalent.com/html/index.php on line 86 with code: <?php $request_url = "http://blog.yaytalent.com/api/read?type=post&start=1&num=2"; $xml = simplexml_load_file($request_url); $title = $xml->posts->post-

c# - MVC3 dynamically update a div with a child action on control event -

currently have main view composed of several partial views this: ... some of partial views, rendered using html.renderaction , @sections. now 1 of page has tabular data view record list. want add dropbox has number of records displayed , on change of dropbox want trigger request re-render partial-view list. possible? regards, czetsuya include partial view in div. assign event dropbox using jquery make ajax call update div onsuccess see: http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html in example though use $(".city").html(html); i prefer name element name="city" , instead do: $("#city").html(html);

android - Programmatically set height on LayoutParams as density-independent pixels -

is there way set height/width of layoutparams density-independent pixels (dp)? looks height/width, when set programmatically, in pixels , not dp. you need convert dip value pixels: int height = (int) typedvalue.applydimension(typedvalue.complex_unit_dip, <height>, getresources().getdisplaymetrics()); for me trick.

c++ - Programatically fire a QMouseEvent and Keyboard Event given only global x,y coordinate -

on machinea mousemove events trapped screen machine b 's viewerwidget . , mouseclick events machineb 's widget carried machinea 's screen. keyboardevent of machineb carried machinea . dont know on widget events triggered. know global x, y coordinates. keyboardevents . questions are: how trap/fire mousemove or mouseclick events from/to desktopwidget ? how trap/fire keyboard events from/to desktopwidget ? something similar should trick. qmouseevent* event = new qmouseevent( qevent::mousebuttonpress, qpoint( x, y ), button, modifiers); qapplication::postevent( widget, event );

python - Get content from open window in Linux -

i want collect data , parse open window in linux. an example- suppose terminal window open. need retrieve data appears on window. after retrieval, parse specific commands entered. so possible that? if so, how? prefer use python code entire thing. i making guess first have sort of id open window , use kind of library content window id have got. please help. quite newbie. you can (ab)use assistive technologies support (for screen readers , such) exist in toolkit libraries. whether work toolkit specific—gtk , qt have support, others (like tk, fltk, etc.) may or may not. the linux desktop testing project python toolkit abusing these interfaces testing gui applications, can either use or how works , similar thing.

Google AppEngine entity groups and transactions -

i'm trying transaction work in appengine , i'm running problems entity groups. code bit this: parent_obj = classa.all().get() def txn(): key_name = 'hash of here' if not db.get(db.key.from_path('classb', key_name, parent=parent_obj)): obj = classb( parent = parent_obj ) obj.put() db.run_in_transaction(txn) ...but 'cannot operate on different entity groups in transaction' error. don't understand far can see transaction operates on entities in same group. namely, line 6 queries 'parent' same 'parent' set in line 8, both queries concerned same entity group. i'm left conclude understanding of entity groups wrong. how? i've read docs several times , still don't see how i'm doing wrong. any ideas? thanks! this happening because parent_obj none and not passing key_name when creating classb . in case, have multiple entity groups (each entity no ancestor separate group). this

Jquery Validation for HTML form -

i want validate text area , select box in html form before submitting html form jquery can me (form summiting without refresh). facing problem make script submit html form without refresh dont know how integrate validation want : 1. validate form 2. if validation true submit html without refresh jquery jquery : $(document).ready(function() { $("form#form").submit(function() { var bno = $("#bno").val(); var date = $("#date").val(); var hour = $("#hour").val(); var minute = $("#minute").val(); var datastring = 'bno=' + bno + '&date=' + date + '&hour=' + hour + '&minute=' + minute; $.ajax({ type: "post", url: "editb.php", data: datastring, success: function(){ $('.mform').hide(); $('.success').show();

iphone - Problem with Custom accessoryView in UITableView -

i have 2 table views following declarations. caboutus = [[uitableview alloc] initwithframe:cgrectmake(85, 272, 227, 30)]; ctableview = [[uitableview alloc] initwithframe:cgrectmake(85, 302, 227, 100)]; when try add custom accessory view using below code, both comes @ different locations in cell. (in caboutus more towards left(x) when compared ctableview cell accessory) uiimage *image = [uiimage imagenamed:@"bullet.png"]; uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; cgrect frame = cgrectmake(0.0, 0.0, image.size.width, image.size.height); button.frame = frame; [button setbackgroundimage:image forstate:uicontrolstatenormal]; cell.accessoryview = button; i tried same using cell.accessorytype = uitableviewcellaccessorydisclosureindicator it shows aligned. please me in solving bug. it solved increasing height of caboutus table cell 40. strange no reason why solved.

css - How to select elements with a style tag in IE6 with jQuery -

we have cms likes insert inline styles, have written code removes inline styles adds class , rewrites contents of style attribute style tag in head. example html <html> <head> <title>title</title> </head> <body> <div id="container"> <p style="width: 50%;">blah blah blah</p> <p style="font-weight: bold;">even more blah blah blah</p> <p>can blah blah blah</p> <p>ooo ahh blah blah blah</p> </div> </body> </html> jquery function $.each($('#container [style]'), function(index, el){ var csstext = el.style.csstext; var classname = "auto-class-" + index; $(el).removeattr("style"); $(el).addclass(classname); $("<style type='text/css'> ." + classname + "{" + csstext + "} </style>").appendto("head");

c# - how to work timer in background -

i can run timer hanging , when run background need timer run in background. can me how run timer in background. timer code is btnintraday.enabled = false; btnstartbackfill.enabled = false; btnstop.enabled = true; if (btnintraday.text == "intraday") { timerintraday.interval = 5000; timerintraday.enabled = true; btnintraday.text = "updating.."; } else if (btnintraday.text == "updating..") { timerintraday.enabled = false; btnintraday.text = "intraday"; } and background code btnintraday.enabled = false; btnstartbackfill.enabled = false; btnstop.enabled = true; txtinterval.text = ddtimeinterval.value.tostring(); int inter = (int.parse(txtinterval.text)) * multiplyingfactorbackfill; try { bgbackfilldcx.runworkerasync(); } catch

sql query in excel -

i have query parameters being fetched 2 cells in excell sheet, other 1 query is. so, problem opened data connection change query, since values it's returning wrong, , repplaced query. following: declare @year int declare @month int declare @date datetime set @year = ? set @month = ? set @date = dateadd( month, 1, convert( datetime, convert( varchar(4), ?) + '-' + right( '0' + convert( varchar(2), ?), 2 ) + '-01' ) ) set @date = dateadd( month, 1, convert( datetime, convert( varchar(4), ? ) + '-' + right( '0' + convert( varchar(2), ? ), 2 ) + '-01' ) ) and expect fo parameter button highlited me costumize them , nothing. problem declaration itself? later on, on query, things such date >= declare @year int declare @month int declare @date datetime set @year = ? set @month = ? set

javascript - Programmatically set IE8 in Private Browsing mode -

dear all, want set ie8 private browsing mode once user logs in javascript application. programmatically. possible? unfortunately best can offer simple directions opening webpage in inprivate browsing mode information section on login page. offer webpage's link ready copy because can't right-click link , open in inprivate ie8/9. while you're @ it, maybe offering similar directions browser visitor using more thorough solution problem.

c# - Entity Framework 4 vs Native Ado.net -

i wondering how entity framework 4 compared native ado.net , sps ? what missing if used normal ado.net ? does worth leaving ef4 ? in nutshell, ef object-relational mapper (orm), , ado.net raw power. orm allows trade runtime performance ease of maintenance. gain ability write code in more declarative manner, expressing what want out of database instead of how go getting it. result, changes database structure can accounted in mappings rather in every single part of application needed touch particular table changed. what missing if use ado.net developer productivity. describing each database operation in detail ado.net time consuming, error-prone, , not fun. i don't think ever want "leave" orm , go raw ado.net except in situations in extreme performance required, such importing large amounts of data, in case might better off writing ssis package anyway.

Rails find unused plugins -

you know it, rails project growing years, many developers comes, many developers go... now it's turn, newcommer in company , sitting "shiny" rails app source code. you task remove plugins clutters source , not used anymore. how find them ? look @ each plugin's source code (usually lives in /lib of plugin or gem folder). most of them define handful of methods supposed call in application code. search project directory of these method names see if called anywhere. for example: have acts_as_ferret plugin, search codebase words "acts_as_ferret". if have delayed_job, search "delay", "send_later", or "handle_asynchronously". sure take time, removing dependencies isn't want haphazardly.

restoring mysql backup -

i'm trying restore database backup. i've create new db: create database `my_db` character set utf8 after launch big sql, afrter time there written error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near ''oy7: commandwy24:broadcastcommandcontentsy15:changestructure:7y7:1080582i15ay7:1' @ line 1 does know what's here? i've tried on 2 backups, , don't think both invalid. thank in advance!

css - Guide lines for developing Android Web applicaiton -

are there guide lines developing android web application? developing web application , hosting on web, , want use webview incorporate link in android application. if want develop mobile website need follow set of standards? if yes, there tutorials or examples? w3c has list of mobile web app best practices. http://www.w3.org/tr/mwabp/ update: the android developer official site has reference; http://developer.android.com/guide/webapps/index.html

c++ - How can I cast or convert boost bind to C function pointer? -

suppose have this: void func(wchar* pythonstatement) { // pythonstatement } and need convert void function(void) this: bind(func, text("console.write('test')")) now have struct this: typedef void (__cdecl * pfuncplugincmd)(); struct funcitem { pfuncplugincmd pfunc; // ... }; how can set pfunc of struct bind(func, "something") ? bind returns lambda_functor not function pointer, how can cast functor function pointer? thanks. ended using the wrapping "solution" (github) i think can't, unless make resulting lamba_functor global variable. in case, declare function invokes it: void uglyworkaround() { globallambdafunctor(); } and set pfunc uglyworkaround() . edit sidenote: if binding static text function call, may omit bind() call , write just: void wrapper() { func(text("console.write('test')")); } and set pfunc wrapper() .

c# - Legacy VB6 app replacement -

i have posted on here before various stages of , here asking guidance once again. we have application depends on 3rd party. dependency managed via vb6 'wrapper' dll third party using com. what need able replace 3rd part dll our new 1 , not have recompile wrapper, or change references. i have written in c# .net of necessary emulates interface/s 3rd party app exposes, , when open wrapper app in code , change reference point app rather original 3rd party works well. no other code changes made or required - reference change. i need take step further. need able load our original vb6 wrapper app , have 'use' new c# .net dll exposing everything(almost everything) original did. have used progid, guid , namespace when registered dll viewing in regdllbview appear identical (with exception of threading being different). when open legacy vs new in dllexp exposed functions identical exception new 1 not expose( dllunregisterserver,dllregisterserver,dllgetclassobject,dl

layout - Unobtrusively add block in cart -

for module i'm working on, want add block in shopping cart screen, want unobtrusively , i'd place beneath cart content , before other blocks (coupon, shipping estimation, totals, ...). i've managed unobtrusive part: observer listens controller_action_layout_load_before , if fullnameaction checkout_cart_index adds handle of layout update xml file: observer: public function showuppergifts($observer) { $fullnameaction = $observer->getevent()->getaction()->getfullactionname(); if ($this->_isenabled && ($fullnameaction == 'checkout_cart_index')) { $layoutupdate = $observer->getevent()->getlayout()->getupdate() ->addhandle('my_special_handle'); } } and layout file: <my_special_handle> <reference name="content"> <block type="module/block" name="module_block" template="module/block.phtml"

before_destroy in rails, little help need! -

i have table called users , if want delete user (user can add questions , add respondents (who answer on questions )), need delete him , id people deleted person. example: sure. def destroy_and_transfer_to(user) transaction questions.each |q| q.update_attribute(:user_id => user) end respondents.each |r| r.update_attribute(:user_id => user) end destroy end end now use method instead of "destroy" method. or can stick callbacks this before_destroy :transfer_to attr_accessor :user_who_takes_over private def transfer_to if user_who_takes_over questions.each |q| q.update_attribute(:user_id => user_who_takes_over) end respondents.each |r| r.update_attribute(:user_id => user_who_takes_over) end end end then can : @user.user_who_takes_over = current_user @user.destroy just couple of ideas! luck! update: code provided above belongs in model. in controller need have destroy m

html - How do I make my website’s layout work gracefully with different browser window sizes, like Tumblr does? -

Image
i start study asp.net now, understand basic html (css not) need how create website fit web browser, like : when resize first and last i try create own skill , website in mess it's called adaptive layout technique more coined responsive web design (both great articles). gallery of websites employ technique can found @ mediaqueri.es . the guts of based around using css style website default "wide view" using @media css queries apply css rules specific screen dimensions. example: body { color:red; } @media screen , (max-width: 800px) { body { color:green; } } @media screen , (max-width: 650px) { body { color:blue; } } demo: jsfiddle.net/6lx9n (resize width of window see in action)

java - How to get the last three value of Arraylist -

hi how can last 3 values of list.i tried this stringary.get(stringary.size()-1); but displays last item of list. how can last 3 values of list. pls guide me. possible store 3 values in string array if (stringary.size() >= 3) // make sure have 3 elements { list<string> array = new arraylist<string>(); array.add(stringary.get(stringary.size()-1)); // last array.add(stringary.get(stringary.size()-2)); // 1 before last array.add(stringary.get(stringary.size()-3)); // 1 before 1 before last system.out.println(array); }

c# - Throwing an exception in a catch section -

i've got new project. every time dealing else code it's adventure. here found: try { ..... } catch (invalidoperationexception e) { throw e; } catch (exception e) { throw; } anybody has idea why? ps everybody. helps. here sources recommended: why catch , rethrow exception in c#? http://msdn.microsoft.com/en-us/library/0yd65esw.aspx http://msdn.microsoft.com/en-us/library/ms229005.aspx the real danger of (other being useless...) modifies call stack. others have briefly mentioned in comments, deserves called out specifically. when have throw ex; , previous call stack blown away , replaced call stack @ point throw ex; called. never want this. catch exception, log it, rethrow exception. when doing that, want use throw; . preserve original stack trace.

c# - how to access one name value pair from a JSON object -

let's have json object passed server via javascriptserializer oser = new javascriptserializer(); string sjson = oser.serialize(myobject); the json returned client via ajax call is "{\"isvalid\":false,\"employeeid\":null,\"fullname\":\"a\",\"emailaddress\":\"n/a\",\"phonenumber\":\"n/a\"}" so after $.parsejson(result); is possible retrieve isvalid value without looping through whole object name/value pairs? update: seems when json gets client : gets changed = between name value pairs. have figure out how replace = : can parse , access true object property notation. success: function (data) { data.replace("=", ":"); } doesn't work. also have ajax datatype property set 'json' you don't have loop through each field anyway - access direct property of result parsejson

c# - Variable scope at the same source file in partial classes -

is there anyway reuse method/variable name in partial classes? something internal defines variable scope @ assembly level time @ source file level. can use same name in code file , variable available other members @ same code (*.cs) file. is there anyway reuse method/variable name in partial classes? no, because partial classes mean actual class split amongst more 1 file. @ compile time combined single class, , same rules apply does. i don't know specifics of trying do, suspect have 2 different classes , have 1 inherit other. mark methods etc. internal instead of private , subclass can see them in same class. if absolutely need use same variable name in subclass, can use new key word: new string foo = "this new string."; ignore old foo string in base class , use 1 have redeclared. from c# 4.0 spec: with exception of partial methods (§10.2.7), set of members of type declared in multiple parts union of set of members declared

contextmenu - C# : getting folder name when right click on it -

i developing windows application, need folder name while right clicking on folder operations on . so far did following : made registry subkey in hkkey_class_root\folder\shell\(my program name) made registry subkey of program name\command [the path of program] now made registry key displayed in folder context menu. , in application did following : 1- in program.cs static void main(string[] args) { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); form1 p = new form1(); if (args.length > 0) { p.pathkey = args[0]; } application.run(p); } 2- in form1 : private string _pathkey; public string pathkey { { return _pathkey; } set { _pathkey = value; } } private void form1_load(object sender, eventargs e) { if (this.pathkey != null) { textbox1.text=pathkey; } } finally :

wpf - Multiple instances of views with Prism and MEF -

i need instanciate many instances of same view of prism module. using mef: codeplex version has exportfactory attribute allows multiple instance creation prism uses .net desktop version has not exportfactory attribute. tried make prism work codeplex version seems not possible.. i found composition.initialization.desktop thing did not succeed in using it. any other ideas ? you can use partcreationpolicy attribute , set nonshared. or, export , import factory class use build desired class.

excel - MaxIf with associated row info? -

im using array formulas determine maximum value of specific subset of row data: =max(($a2:$a100="somestring")*($c2:$c100)) this works fine & gets me maximum value in c = "somestring". now, want return other column values associated "max" row strings. intuitively think may need ditch boolean logic multiplication strategy since string values getting involved. what's best/cleanest way go this? try this: =index(b1:b100,match(max((a1:a100="somestring")*(c1:c100)),(a1:a100="somestring")*(c1:c100),0)) column want values set b in example.

javascript - How to get all the form elements values using name attribute -

i trying access form elements in jsp page using name attribute. form contains text,textarea , select fields. in javascript file have these values. $("input[name=first_name]").val() by using can values of input type fields (for ex:text) , not , fields. please me resolve this.i want use jquery code this. you don't need type of element in selector: $("[name=other_name]").val()

.htaccess - Apache rewrite all paths to index.php -

how rewrite paths like: /xyz/ijk?a=b&c=d to index.php: /index.php/xyz/ijk?a=b&c=d but variable path_info = /xyz/ijk it's when don't use rewrite (/index.php/xyz/ijk?a=b&c=d) try this: rewritecond %{request_filename} !-f rewriterule ^(.*)$ index.php/$1 [qsa ]

c# - How to RETWEET, REPLY or add a tweet to Favorite? -

i trying implement retweet , reply functionality in site in sharepoint 2010. creating web part , trying fetch tweets particular hash tags. i able hash tag data here have put retweet, reply , favorite buttons on every tweet. trying retweet right , javascript code looks this: $.getjson("http://search.twitter.com/search.json?q=%23" + hashtag + "&rpp="+ nooftweets +"&&callback=?", function (msg) { container.html(''); //remove loading gif (i = 0; < msg.results.length; i++) { //build divs containing tweets , add container div var str = '<div class=\'tweet\'><div class=\'avatar\'><img src="' + msg.results[i].profile_image_url + '" alt=\'twitter-img\'/></div>'; str += '<div class=\'status-body\'><a href="http://twitter.com/' + msg.results[i].from_user + '"target="

tutorial sql server 2008 reporting services R2 -

i need find tutorial or documentation how used tool beginner. check sql server video streams on channel9: http://channel9.msdn.com/niners/rdoherty/posts look reporting services.

iphone - flurry in IOS application -

i using flurry in ios application, have many question in : is file libflurry necessary add ( using flurry analytics) i have done in myappdelegate.m [flurryapi startsession:@"vmykey"]; [flurryapi logallpageviews:self.navcontroller]; what see instruction : [flurryapi logallpageviews:self.navcontroller]; i disable sending data when app down, have done in app delegate : [flurryapi setsessionreportsoncloseenabled:no]; write ? i wlould create events in app, have done : [flurryapi logevent:@"event_name"]; , put please ? put in each viewcontroller ( viewdidload) ?? what difference between : [flurryapi logallpageviews:self.navcontroller]; [flurryapi logevent:@"event_name"] thanks answer [flurryapi logevent:@"event_name"]; use logevent count number of times events happen during session of application. can useful measuring how users perform various actions [flurryapi logallpageviews:navigationcontroller]; to e

java (jdbc, ms sql server) how to get an indication that my query was executed? -

my application queries database (non-queries too). i show user indeterminate progressbar while transaction. the problem don't know when close progressbar, because have no indication or signal object of query completion. if queries taking long need progress bar, i'd recommend taking hard @ database see how can speed them up. since database operation blocks, know it's done when return. the progress bar suggests need kind of polling mechanism check metric indicates how have , how many have been done. since don't give details, can guess might be. but ajax call in jsp poll , update progress bar need.

php - How to print the array that contains the tags and the data in this xml parser? -

<?php class simple_parser { var $parser; var $error_code; var $error_string; var $current_line; var $current_column; var $data = array(); var $datas = array(); function parse($data) { $this->parser = xml_parser_create('utf-8'); xml_set_object($this->parser, $this); xml_parser_set_option($this->parser, xml_option_skip_white, 1); xml_set_element_handler($this->parser, 'tag_open', 'tag_close'); xml_set_character_data_handler($this->parser, 'cdata'); if (!xml_parse($this->parser, $data)) { $this->data = array(); $this->dat1 = array(); $this->error_code = xml_get_error_code($this->parser); $this->error_string = xml_error_string($this->error_code); $this->current_line = xml_get_current_line_number($this->parser); $this->current_column = xml_get_curre

javascript - Updating an image that is re-uploaded periodically -

i have webcam script sends jpg via ftp webserver every 10 seconds (overwriting original). how can jquery refresh image? tried: window.onload = function() { $('body').prepend('<img id="cam" src="ww.jpg" alt="" />'); setinterval(runagain, 12500); }; function runagain() { $.ajax({ url:'ww.jpg', cache:false, beforesend:function() { $('#cam').remove(); }, success:function() { $('body').prepend('<img id="cam" src="ww.jpg" alt="" />'); } }); } note: don't want refresh page if can it. a dirty way appending timestamp or random number @ end of image src, prevent caching, img src="image.jpg?random=[random]" [random] timestamp or random numb

python - Django; How can i serve templates/images/css/js from inside custom 'skin' directory? -

i'm trying make skinnable django project. what i'm having problems figuring out how can serve file(s) within skin directory, , not media dir, skin's images/css/js files can reside in skin's folder(s). a user should able choose skin name , preferably altering skin_name variable in 'settings' (and maybe later .ini file). , templates/css/images loaded directory. i imagine being able view raw templates bad, perhaps should 'media' directory inside skin folder, subfolders 'css', 'js' , 'images' inside, , served there. i'm pretty new django framework though have python experience, input on how is/can done appreciated. first thing, should rather keep static files in static folder , use media uploaded content. then within static folder have folder each of skin containing css, images , js needed. from skin template import files prefixed both {{ static_url }} , skin name. <link rel="stylesheet"

Scala Roadmap Post 2.9.0 -

with scala 2.9.0 rc3 available , the release page describing great features added in release, know can expect in 2.10 , future releases? here 3 things have been mentioned far: "interesting developments making use of massively parallel hardware in novel ways", example, embedded dsls generate optimized code gpu architectures http://www.scala-lang.org/node/7285 edit: tiark rompf gives more information (with links) exciting ongoing work of scala virtualization: http://groups.google.com/group/scala-user/msg/b51424a9855d9b5d better binary compatibility between scala versions via java bytecode rewriting http://permalink.gmane.org/gmane.comp.lang.scala.user/39290 a long term plan rethink equality http://permalink.gmane.org/gmane.comp.lang.scala.internals/4793

c# - 400 Bad Request when Sync via Sync Framework -

i try sync windows mobile device sqlserver via sync framework. it worked 400 bad request , don't know why. the service available , can open wsdl in internetexplorer on device. edit: use basichttpbinding. found out myself: the name of binding configuration in binding , in declaration of configuration diverent.

Complaring Mulitple Element's text with multiple Elements text in xslt -

input xml : <a> <b> <c>1</c> <c>2</c> </b> <d> <c>2</c> <c>3</c> </d> </a> from above xml want o/p <c>2</c> it not clear criteria outputting single element. want group , output groups more 1 item? in case <xsl:template match="/"> <xsl:for-each-group select="descendant::c" group-by="."> <xsl:if test="current-group()[2]"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each-group> </xsl:template> might suffice. if not explain in more detail why output should posted.

Sharepoint 2010 Masterpages -

i helping client correct masterpage issue. have close no experience sp2010 may missing simple. the site referring custom master page special.master. how can find file , edit it? use microsoft sharepoint designer 2010 , find in masterpage library see video how create master page in sharepoint 2010 designer

c# - Highlighting Menu Bar in ASP.NET Web Application -

i built web application using asp.net visual studio 2010 master pages. see project gives default menu bar item. have 5 pages (links) listed on menu bars. when user goes specific page want highlight menu bar link. dont know how :( i tried on master page code behind didnt work too: foreach (menuitem item in navigationmenu.items) { var navigateurlparams = item.navigateurl.split('/'); if (request.url.absoluteuri.indexof(navigateurlparams[navigateurlparams.length - 1]) != -1) { item.selected = true; } } and in mark view have this: <div class="clear hideskiplink"> <asp:menu id="navigationmenu" runat="server" cssclass="menu" enableviewstate="false" includestyleblock="false" orientation="horizontal" onmenuitemclick="navigationmenu_menuitemclick"> <items>

tdd - Testing A Function That Always Returns True -

how 1 write test following function? bool isaninterger(int ignore) { return true } i don't have enough time iterate on every integer (for actual code parameter isn't integer). this used part of specification pattern, can implement null object. ... testing can effective way show presence of bugs, hopelessly inadequate showing absence. -- edsger w. dijkstra i'd it's pointless try exhaustively black box test function. better test in context similar used.

objective c - Create frameworks for iOS bundled with unity data and its library -

this regarding creating framework in ios, have bundle of unity want create framework, data with-holding , linking library unity libiphone-lib.a. without adding library in bundle target, compilation works fine, if include libiphone-lib.a file, generates warning as: warning: implicit declaration of function 'unitysendmessage' the unitysendmessage function being called dedicated libiphone-lib.a framework. any suggestions regarding concern appreciated. thanks. the unity folks seem have neglected include header declaring function. can either declare yourself, or ignore warning.

javascript - JS output from data structure to table -

data structure var x = { a: [{name:"john", phone:777},{name:"john", phone:777},{name:"john", phone:777}], b: [{name:"john", phone:777},{name:"john", phone:777},{name:"john", phone:777}], c: [{name:"john", phone:777},{name:"john", phone:777},{name:"john", phone:777}], d: [{name:"john", phone:777},{name:"john", phone:777},{name:"john", phone:777}] } function function showtable(trnum,x,a) { var tablecode = "<table><tbody>"; (var i=0; i< x.a.length;i++) { (var j=0; j< trnum; j++) { tablecode += "<tr><td>"+x.a[i].name+"</td><td>"+x.a[i].phone+"</td></tr>"; } } tablecode += "</tbody></table>"; $("#elem").append(tablecode); } markup <body> <button onclick="showtable

windows - Classic ASP upload - free or commercial components? -

my asp uploading of files knowledge somewhere circa 2002. i've got classic site running in 32-bit mode on 64-but windows 2003 server. testing on 32-bit win 7 box. what couple of upload solutions might work in scenario? running classic asp 3.0 against sql server 2005 database. prefer store files outside of database. i have .net 3.5 on box, if there's hybrid solution might work better, can that. i'm concerned i'll use "old" , won't reliable. i'd run sort of antivirus against files when come in. you don't need components upload using vbscript: file upload using vbscript class - codeproject i've used on classic asp sites migrated 2008 rb 64-bit servers , found (nearly) slots right in code little modifications. additionally, few components 64-bit compatible and/or cause application pools crash after modest use. re virus scanning, long system has a/v solution real-time protection covered. otherwise need use shell.execute

jquery - $.widget is not a function -

i want make use of dragable elements.. load page this $.widget not function the code <script src="js/jquery/jquery-1.6.js" type="text/javascript"></script> <script src="js/jquery/jquery.ui.core.js" type="text/javascript"></script> <script src="js/jquery/jquery.ui.draggable.js" type="text/javascript"></script> <script src="js/jquery/jquery.ui.mouse.js" type="text/javascript"></script> <script src="js/jquery/jquery.ui.widget.js" type="text/javascript"></script> also take @ answer using a google hosted version . if can that, lot of benefits ( see here ).

php - Zend Framework - Redirecting to IndexController in different module -

all, i have following project setup in zend's mvc framework. upon accessing application, want user redirect "mobile" module instead of going indexcontroller in "default" module. how do that? -billingsystem -application -configs application.ini -layouts -scripts layout.phtml -modules -default -controllers indexcontroller.php -models -views bootstrap.php -mobile -controllers indexcontroller.php -models -views bootstrap.php bootstrap.php -documentation -include -library -logs -public -design -css -images -js index.php .htaccess my index.php has following code: require_once 'zend/application.php'; require_once 'zend/loader.php'; $application = new zend_application( application_env, application_path . '/configs/ap