Posts

Showing posts from August, 2010

java - select and highlight custom listview item -

i want position custom listview item listview.setselection(itemindex); selected item positioning on top of visible part of listview. not highlighted. how can set default highlight of listview item (then disable highlight , select one) without listview re-create thanks! p.s. know asked many times before did not understand how works update not work on android 2.2 (adt emulator , smartphone android 2.2 froyo) drawable/listselector.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/red" android:state_focused="true"/> <item android:drawable="@color/yellow" android:state_selected="true"/> <item android:drawable="@color/red" android:state_pressed="true"/> </selector> values/colors.xml <?xml version="1.0" encoding="utf-8"?> ...

How to download from Nexus a folder of artifacts (mass download)? -

i want move set of artifacts 1 nexus other (download , later upload). can download artifacts 1 one, ¿is there way download entire folder? ¿is there other kind of operation export/import? thanks! edit: i have access nexus repository (sonatype-work\nexus\storage) in user folder. have got there artifacts. didn't find way web client. nexus stores artifacts on disk in standard maven 2/3 repository layout, can directly copy artifacts 1 storage directory other using whatever means like. after you're finished, schedule repair index task against destination repository searching artifacts web ui work. note builds work after copy artifacts, indexes not used maven builds.

php - Yii dropDownList default value -

i have code: echo $form->dropdownlist($model, 'defaultprinterid', chtml::listdata(printer::model()->findall(), 'id', 'name'), array('prompt' => '-- none--')); which gives me dropdown list this: <select id="labeltype_defaultprinterid" name="labeltype[defaultprinterid]"> <option value="">-- none --</option> </select> however, when form posts, adds value table defaultprinterid 0. instead of that, how make null, since it's nullable field? in controller, after load attributes $_post $model->defaultprinterid = $model->defaultprinterid ? $model->defaultprinterid : null; this changes 0 null otherwise leaves unmodified.

neo4j - Neo4jClient Get All Referenced Nodes -

in application have classes/nodes like: -person -activity -company can create relationships between: - person , company - company , activity - activity , person - person , person - company , company so. possible, specific activity related person , company. company root. there no real hierarchy. it's more mesh structure. (i know how create relationships etc. saw tutorials. :) ) now. want directly related relationships nodes of specific node. don't want fetch related data relationship type. want (when possible) 1 query, reads relationships , according nodes. , second requirement: when have retrieved related relationships , nodes, want relationships (if exists) between these nodes! cool solve 2 queries! ideas? thanks! how like start company = node(2) match company-[?:employs]-> person return company, person see docs.neo4j.org/chunked/snapshot/cypher-query-lang.html details. otherwise, can companies, persons etc in index, e.g. start comp=n...

c# - MySQL insert if not exists/ignore -

so here's table layout: type_of agreement ipad heyo! i'm agreement! ipod touch i'm agreement! basically, i'm building admin interface administrator can add new types. i'd make he/she can't enter new type exists. basically, in above example, if enter 'ipad' in new type box , press submit, ignored or error thrown or something. here's existing mysql statement: insert ignore agreements (type_of, agreement) values (?, ?) com.parameters.addwithvalue("", request.form["pies"]); com.parameters.addwithvalue("", "wahey! sample license!"); ( upgrading answer ) you need define unique index on type_of . explained in the manual : a unique index creates constraint such values in index must distinct. error occurs if try add new row key value matches existing row. engines, unique index permits multiple null values columns can contain null . if specify prefix value column in unique in...

c++ - Why a C-style typecasting is mandatory while initializing a POD data in initializer list? -

struct pod { int i, j; }; class { pod m_pod; public: a() : m_pod({1,2}) {} // error a() : m_pod(static_cast<pod>({1,2})) {} // error a() : m_pod((pod) {1,2}) {} // ok! }; i see in old production code compiled g++34 , until din't know feature. g++ specific feature ? if not then, why typecasting needed , that's c-style cast allowed ? the syntax you're using isn't initializer lists, it's initialization of class types outside of declarations. example: pod p; p = (pod) {1, 2}; these called compound literals ; added c in c99. aren't supported in c++; gcc allows them in c++ (and c89) extension . c++11 adds syntax : p = pod({1, 2}); or in case: a() : m_pod(pod({1,2})) {}

Tomcat Web Application Manager - is it possible to limit what each user role can see? -

i couldn't find regarding on internet, expert here answer question. i have set tomcat web application manager on test server, created roles/users in tomcat-users.xml follows: <role rolename="manager"/> <user username="admin" password="admin" roles="manager"/> <user username="user1" password="password" roles="manager"/> admin supposed have full rights on webapp manager, while user1 (and perhaps subsequent users) users have been granted permission upload/deploy war files. right have same roles, see same ui upon logging in, want user1 see deploy/upload option - limited access webapp manager. is possible achieve this? if yes, how? if no, acceptable compromise? you didn't hard if couldn't find this. it's under "manager" section of tomcat users' guide: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#configuring_manager_application_acces...

winforms - Get list of C# Classes Names? -

i implementing syntax highlighter using c# windows forms, , list of names, know should done manually, adding keywords , names wondering if there function in c# me this. you have use reflection names of classes in dll. // using reflection information assembly: system.reflection.assembly o = system.reflection.assembly.load("mscorlib.dll"); var types = o.gettypes();

character encoding - java- how to obtain/store string variables which have different charsets -

i have data in variable of type list. different elements in list encoded in different charsets. know charset corresponding each element. i want know: how extract each string in respective charset? also, if have text being entered java application user (along charset), how can store each value in list variable? , how can store/retrieve such value in string variable? and after data stored/retrieved, changes of charset mean default charset (utf-8) no longer being used? if case, how can restore default charset? a string stored (internal) unicode. need handle charsets if convert bytearrays strings or strings bytearrays. see: http://docs.oracle.com/javase/tutorial/i18n/text/string.html example.

php - session_destroy in codeigniter don't work for IE -

session_destroy in codeigniter don't work ie when make logout destroy session, when enter page must logged, enter if logged, happens in ie, how can fixed? it has ie being funny. clear ie cache , restart browser. try visiting page private browsing on

xaml - how to get appbar in windows 8 metro applications using visual studio 2012? -

i developing metro application using visual studio 2012. trying appbar in metro application. how do that? there lot of samples in msdn dev center, http://code.msdn.microsoft.com/en-us/windowsapps . 1 of them appbar sample , , description reads: this sample demonstrates how use appbar control present navigation, commands, , tools users. the app bar hidden default , appears when users swipe finger top or bottom edge of screen. covers content of app , can dismissed user edge swipe, or interacting app. sample shows how add app bar, customize app bar, , control app bar. also, shows how use sticky app bars , global app bars. i think started.

actionscript 3 - sorting an associative array without losing your indexes -

i have following array: packages array (@24ff99c1) [99767] array (@24ff9809) forceupload false length 0 name "testdocument.indd" packageid "99767" progressstatus "allowed" singleitemsize 50582294 [0x303d316] singleitemuploadedsofar 17296352 [0x107ebe0] sortindex 1338984578952 [0x137c1b33f88] status "upload busy" totalsize 431203849 [0x19b3a609] uploadedatm "37015918" uploadedsofar "19719566" [94854] array (@24ff7fd9) forceupload false length 0 name "testdocument.indd" packageid "16842" ...

rest - How set a url(callback) to listen a answer by javascript -

currently, consuming rest service has signature http://service.ip/auth?clien=xx&redirect=urixx where urixxx shall http://localhost:8080/auth/callback i wonder if possible open "urixxx" in javascript in order received answer server? callback? if scripts employs jsonp yes, otherwise declare httprequest , parse stuff out of return , inject contents head of document in wrapper function opens window indicated , writes needful scripts / content newly created window... if mean trying tell request go location response suggest check out webserver class supports comet style interactions... https://net7ntcip.codeplex.com/sourcecontrol/changeset/view/89621#1752948 after submit request can receive in response location addition token... can take token , send page indicated in response , have achieved wanted do.. i suppose same technique employed same thing without web server...

c# - Visual Basic 2010 Login view asp.net -

i've created asp.net application membership login , registeration using generic template in visual studios 2010. below how template looks within visual studios: http://www.flickr.com/photos/79954191@n05/7345407648/ then once load application re-directs me login screen (as should) problem it's missing template / css elements. below picture when loaded: http://www.flickr.com/photos/79954191@n05/7160199089/ thank in advance!! check web.config permissions on css folder. you must use location give permissions no-authenticated users <location path="pathtocssfolder"> <system.web> <authorization> <allow users ="*" /> </authorization> </system.web> </location> check link : http://support.microsoft.com/kb/316871

performance - Iterative deepening or trial and error? -

i coding board game. have generated game tree using alpha-beta pruning , have 2 options: use iterative deepening optimize alpha-beta keeps generating 1 more ply until time over. by trial , error, know maximum depth reachable every board configuration in time limit without inspecting lower plies. which approach better , make search reach deeper depth? know, example, @ beginning can generate tree of depth x consuming time available... can iterative deepening add more depth? let me know if can more clear... if branching factor , evaluation function's required time stays same between different rounds might able use option 2. sounds might difficult. option 1 has ability dramatically increase alpha-beta's performance if don't have perfect move ordering already. save best move @ every node, found during previous search d-1, , tell alpha-beta search first. it's called transposition table, , if possible implement in case option 1 dominate option 2. the...

actionscript 3 - Deserializing objects received using Cirrus -

i'm using cirrus pass values other players in game, , of values objects, thing is, when receive objects, lost type, , become generic objects. i've read cirrus uses amf, don't know how regain original object type of data. edit.: //these classes involved registerclassalias("action", action); registerclassalias("entityvo", entityvo); registerclassalias("point", point); //action takes 3 parameters action(type:string = "", entity:entityvo = null, target:entityvo = null) // when entityvo doesnt require parameter in constructor or has string/int parameter works: var entity = new entityvo(); var bytearray:bytearray; bytearray = new bytearray(); bytearray.writeobject(action); bytearray.position = 0; var object:object = bytearray.readobject(); //<- works ok //when make entityvo take non standard parameter like, point, this: entityvo(point:point = null) //and this: var entity:entityvo = new entityvo(new point()); var action:...

linq - Get string version of lambda expression property -

similar question how can property name strings used in func of t . let's had lambda expression stored in variable called "getter" expression<func<customer, string>> productnameselector = customer => customer.product.name; how can extract string "product.name" that? i fixed haxy var expression = productnameselector.tostring(); var token = expression.substring(expression.indexof('.') + 1); but i'd find more solid way ;-) the expression tree expression looks this: . / \ . name / \ customer product as can see, there no node represent product.name . can use recursion , build string yourself: public static string getpropertypath(lambdaexpression expression) { return getpropertypathinternal(expression.body); } private static string getpropertypathinternal(expression expression) { // node represents parameter of expression; we're ignoring if (expressi...

c - Preventing local pointers -

maybe it's newbie question, there method in c/c++ prevent function accepting pointer local variable? consider code: int* fun(void) { int a; return &a; } the compiler generate warning pointer can not returned. consider this: int* g; void save(int* a) { g = a; } void bad(void) { int a; save(&a); } this pass through compiler without warning, bad. there attribute or prevent happening? i.e. like: void save(int __this_pointer_must_not_be_local__ * a) { g = a; } thanks in advance if knows answer. no, there no reliable , portable way tell pointer local pointer heap object. there no way declaratively prevent this, either. there hacks dependent on memory layout of particular system work @ runtime invoking unspecified behavior (see this answer example), on own if decide give them try.

synchronized - How to synchronize access to private members of a javascript object -

i have javascript object created follows: var ccstattracker = (function (){ ccmap:{ "1":["1","2","3","4"], "2":["4","5"]; } return { modifyccmap: function (){ // code takes following actions: // - adds/removes keys. // - modifies arrays stored values against keys in map. } } )(); i have dhtmlxgrid component displays grid in form of rows , columns. when edit cell in grid, "oneditcell" event called. now, want call ccstattracker.modifyccmap() event handler function attached "oneditcell" event. go on modifying cells, event called asynchronously in turn call function "modifyccmap" modify private member "ccmap" of javascript object. latest state of ccmap seen 2 calls might different right? best way handle this? there "synchronized" in javascript in java? please me determine approach want take implem...

java - Is there a bug with "set chained" in setAutoCommit() in net.sourceforge.jtds.jdbc.Driver? -

i having confusion set chained statement in setautocommit() method in net.sourceforge.jtds.jdbc.driver the source code says: 2161 if (servertype == driver.sybase) { 2162 if (autocommit) { 2163 sql.append("set chained off"); 2164 } else { 2165 sql.append("set chained on"); 2166 } however, shouldn't backwards, , chaining should off autocommit==false? the reason ran follows: i writing java app needs complicated sql , roll of if of fails: open sybase connection using net.sourceforge.jtds.jdbc.driver call setautocommit(false) do sql1 call stored proc 'mysp1' stored proc mysp1' not under control it has exec sp_procxmode 'dbo.mysp1','unchained' do sql2 if sql2 fails, roll (including sql1), otherwise commit. having done that, following error mysp1: stored procedure 'mysp1' may run in unchained transaction mode. 'set chained off...

php - reading external XML file -

i need use external xml file, i've tried different methods read file can't reach want. i used domdocument simplexml_load_file <? $xml = simplexml_load_file("http://www.isecur1ty.org/internetthreat/threatlevel.xml"); echo $xml->getname() . "<br />"; foreach($xml->children() $child) { echo $child->getname() . ": " . $child . "<br />"; } ?> but can't working me!! here xml file: <is-internetthreat> <level> <current>2</current> <previous>2</previous> <status>same</status> <date>09-06-2012</date> </level> <version>2.5</version> </is-internetthreat> as can see, there multi-levels. need values of each attribute (mainly under "level"), getting version ok. can tell me how this? thanks. access them this: <?php $xml = simplexml_load_file(...

java - Two JPanels in JFrame , One under other -

i've got 2 panels in frame, , set them 1 under other, , first should have size 9/10*screen frame, , second 1/10. i've tried gridlayout (2 rows , 1 column) can't set them specific size. how should that? ok maybe write code: i writing game - pacman, , in first panel there whole game, , in second display player info(like score, name etc.) first set on 80% screen, , second on 20%. what more frame should resizeable , in it, sa have change size of panels(keeping 80% 20%) when size of frame changing. wrote initcomponents(). package pacman; import java.awt.borderlayout; import java.awt.dimension; import java.awt.eventqueue; import java.awt.gridlayout; import java.awt.toolkit; import javax.imageio.imageio; import javax.swing.jframe; import java.awt.image; import java.awt.event.componentadapter; import java.awt.event.componentevent; public class pacman extends jframe implements items { image image; public pacman() { initcomponents(); try { ...

python - OpenCV - Reading a 16 bit grayscale image -

i'm trying read 16 bit grayscale image using opencv 2.4 in python, seems loading 8 bit. i'm doing: im = cv2.imread(path,0) print im [[25 25 28 ..., 0 0 0] [ 0 0 0 ..., 0 0 0] [ 0 0 0 ..., 0 0 0] ..., how 16 bit? figured out. in case else runs problem: im = cv2.imread(path,-1) setting flag 0, load grayscale seems default 8 bit. setting -1 loads image "as is".

jquery - Split() not showing when index param is used -

i have this: $('li').click(function() { var currentsrc = $('img', this).attr('src').tostring(); var grabalt = $('img', this).attr('alt').split('|'); //alert(grabalt[0]); $('.imgsample img').attr('src', currentsrc); $('.projectdescription').html('<p class="projectdescription">' + grabalt[0].join('</p>')); $('.projecttitle').html(grabalt[1]); }); when remove [0] , [1] can alert either , i'm thinking first value [0], replace project description, trying place each in respective place doesn't work @ all. snippet of relevant html: <section class="workarea"> <div class="imgsample"><img src="images/samples/testimage2.png" alt="this first part short description. | second part title."></div> <p class="projectdescription">this replaced when image c...

c++ - Controls blanked using XP themes -

Image
i have been learning win32 api, , have been stumped this: when run on windows 7 in both "classic look" , "windows 7 aero glass" look, ok, , has aero on controls, normal appearance. when run on xp machine, again, "classic look", looks ok, when run on xp "windows xp theme", above get. following microsoft's guidelines on visual styles @ http://msdn.microsoft.com/en-us/library/bb773175%28vs.85%29.aspx there 3 things needed do: 1 . link comctl32.lib , call initcommoncontrols. check, did this, added comctl32 linker settings. 2 . add file called yourapp.exe.manifest source tree has xml manifest format. check, did this. had version using, safe, tried version suggested on site, renamed started specified cover bases. (yes, know give name of application....) 3 . add manifest application's resource file follows: check, did this. added specified line suggest rc file. so, under conditions, works, except windo...

android selenium -

i using webdriver android automation of website testing. have done things installation of web driver , open google page.but dont take searching item entered.here "cheese".i mentioned code below .please suggest solution. thanks public class androidseleniumactivity extends testcase { /** called when activity first created. */ public void testgoogle() throws exception { androiddriver driver = new androiddriver(); // , use visit google driver.get("http://www.google.com"); // find text input element name webelement element = driver.findelement(by.xpath("html/body/div[2]/div[1]/div[1]/div[2]/div[2]/div/form/fieldset [2]/div/div/div/table/tbody/tr/td[2]/div/input[3]")); // enter search element.sendkeys("cheese!"); // submit form. webdriver find form element element.submit(); // check title of page // remember close webdriver connection free res...

html - Footer will not use 100% of width -

my footer, along wrapper , body, set 100% page width, yet reason footer has small (25px or so) gap on right side. i've tried moving out of wrapper, didn't work. body has margin , padding set 0. don't have issue header. here's code: http://jsfiddle.net/w63jk/ any thoughts how fix this? removing width #header works: #header { padding:5px; /* width: 100%; */ background-color:#272727; height:100px; margin-bottom:30px; -webkit-box-shadow: 0 8px 6px -6px black; -moz-box-shadow: 0 8px 6px -6px black; box-shadow: 0 8px 6px -6px black; } that's because paddings adding additional width element, if you've defined 1 in css: http://jsfiddle.net/w63jk/2/ works in ies, ffs , chrome. info: block elements such divs have full available width of parent default, if no other widths defined via css.

cuda - shared memory and constants -

is there benefit storing constant value in shared memory? example: a[tid] = constant * b[tid] , where , b arrays, constant constant value e.g. 4. , tid thread index (array element = single thread). every thread has read value constant , shared memory should useful, right? how think works: reading global memory consume lot of time, read constatnt value global memory once shared memory , threads can read fast. since there many threads (constant value has read many times) shared memory should speed up. some cpu instruction sets, such x86, support storing full sized constants operands interleaved opcodes themselves. in case, constants read in rest of stream of instructions cpu running , seems unlikely storing them anywhere else can faster. other architectures, such arm, support storing small constants , shift values within opcodes. constants typically needed in program can represented small constant plus shift value , can therefore stored directly within opcodes. i...

javascript - Match a condition RegEx -

i need able strip out condition in string, here is: (("${operation}" == "fixed") && ("-" == "-")) i'd able replace "${operation}" == "fixed" "" or between () has ${} in it. in other words if there ${} on left hand side of condition want rid of condition entirely. in general , regular expression not right approach here. there lots of cases valid javascript syntax, won't fit nicely regular expression. however, here's 1 way it: var code = '(("${operation}" == "fixed") && (thing1 == thing2))'; code = code.replace(/"[^"]*\$\{[^}]*\}[^"]*"\s*==\s*"[^"]*"/, 'true'); that handles double quotes. if need handle both types of quotes, expression more complicated. if need handle both types of quotes and strings might contain quotes, regular expression isn't going work. if can think of different way ...

c# - System.TypeLoadException while using CsharpRepl (mono shell) -

before ditch c# interpreter thought check if knows what's going wrong here. type complains is eloquera.client.dll. c:\program files\mono-2.10.8\bin>csharp mono c# shell, type "help;" enter statements below. csharp> loadassembly(@"c:\webapp1\webapp1\bin\webapp1.dll"); csharp> loadassembly(@"c:\webapp1\webapp1\bin\eloquera.client.dll"); csharp> using webapp1.models.data_access; csharp> using webapp1.models.persisted_classes; csharp> using eloquera.client; csharp> using system.linq.expressions; csharp> csharp> var repository = new eloquerarepository(); csharp> var result = repository.getall<custommembershipuser>(); system.typeloadexception: not load type 'eloquera.client.db' assembly 'eloquera.client, version=4.0.0.0, culture=neutral, publickeytoken=170cadcdba67 be6c'. @ class3.host (system.object& $retval) [0x00000] in <filename unknown>:0 @ mono.csharp.evaluator.evaluate (system.s...

html5 - Is this an ok use for the article element? -

Image
i re-writing code new re-design , wondering if best (pragmatically) semantic way write module? this has 3-4 more items , slide items left/right, paired down bit so. looks fine me. (as satisfies criteria independent item of content) from spec: the article element represents component of page consists of self-contained composition in document, page, application, or site , intended independently distributable or reusable, e.g. in syndication. forum post, magazine or newspaper article, blog entry, user-submitted comment, interactive widget or gadget, or other independent item of content

java - Not Reading Data from Bluetooth Health Device (for Android 2.2 and above) -

i trying capture (data)reading on android phone 'bluetooth health devices' such oximeter, thermometer, weighing scale machine etc. able connect device phone when goes read data stuck on there only. doing following steps..(android 2.2) first creating socket connection bluetoothsocket socket.connect();// socket connection-----done successfully bluetoothsocket tmp= device.createrfcommsockettoservicerecord(my_uuid); //here my_uuid="00001101-0000-1000-8000-00805f9b34fb"; in read thread byte[] buffer = new byte[37];// think here not getting exact bytes int bufferbytes = 0, bufferindex = 0; log.e(tag, "message_read...."); communications comms = null; bundle bundle = new bundle(); try { comms = new communications(); log.e(tag, "after communications...."); } catch (exception e) { log.e(tag, "error in communicaton...."); } // keep listening inputstream while connected...

sorting - Javascript object automatically sorts -

// mechanics mechanics_isolation : 1, mechanics_na : 2, mechanics_compound : 3, // mechanics exercise.mechanics = {}; exercise.mechanics[exercise.mechanics_compound] = 'compound'; exercise.mechanics[exercise.mechanics_isolation] = 'isolation'; exercise.mechanics[exercise.mechanics_na] = 'n/a'; when loop through exercise.mechanics , keys come out sorted. how can unsorted keys loop through? thanks! keys in hashmap not reliable. give keys order. example, put keys array , iterate keys. var keys = [mechanics_isolation, mechanics_na, mechanics_compound]; (var = 0; < keys.length; i++) { console.log(exercise.mechanics[keys[i]]); }

How to add cells within column in html table? -

Image
i have trouble finding right way add cells columns: here want do: a fiddle : http://jsfiddle.net/akrb3/ <!doctype html> <html> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <table style="margin-top: 40px" width="600" height="358" cellspacing="0" cellpadding="2" align="center" border="1"> <tr> <td align="center">fasfg1 </td> <td width="42"></td> <td align="center">fasfg2 </td> </tr> </table> </body> </html> thanx lot! try this,...

javascript - File Picker for Xpages -

for xpages application, need file picker (just select filename, no up- or download). i've looked around several hours , found no solution. maybe simple? why not use <input type="file" id="morituri" /> . can't set file name, can read it. add presubmit listener grabs name , removes input dom, won't submitted.

.net - How do I encrypt session data into a token to authorize subsequent web service calls? -

i have web service needs protected unauthorized users. need expose web service operation authorize user, based on username , password. response user validation request should contain security token. security token contains embedded user properties client applicatino can use, when encrypted, used authenticate subsequent web service operations. unencrypted token looks this: uid=444; dte=2012-06-01t14:01:54.9571247z; gid=1; wid=00:1c:b3:04:85:11; sid=lit3py55t21z5v55vlm25s55; i can use symmetric key algorithm key can shared secret between client , server (i control both). have implemented following rijndael example using sha1 , key size of 256. this code often quoted across internet , microsoft themselves, state in relation rijndael : the rijndael class predecessor of aes algorithm. should use aes algorithm instead of rijndael . more information, see entry the differences between rijndael , aes in .net security blog. are there security concerns should have? if...

r - Replacing values in column X with values from column Y, but only if the values of X match the values in column Z -

i have 2 data frames, 1 one column (x), , other 2 columns (y & z): column x contains numbers 1:99, has letters instead of numbers, ie: 1, 2, 3, a, 5, b, 7, 8, c, d, 11, 12 etc. column y contains these same letters, paired (as appearing in column z) numbers, ie: a 4 b 6 c 9 d 10 how can replace letters in column x values of column z, according whether letters in column x match letters in column y? result in column x being 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 etc. a straightforward merge won't work (i need retain values in x) , i'm not sure how can use sub conditionally. also, column y , z contain more rows needed column x, can't use cbind . i'm not skilled @ using regex , although best bet... any appreciated! i'd use loop. creating data: df1 <- data.frame(x = c("a", 5, "b", 7, 8, "c", "d", 11, 12)) df2 <- data.frame(y = c("a", "b", "c", "d...

ios - One IBAction for multiple custom prototype cells with buttons -

using storyboard, have table view controller containing multiple dynamic prototype cells. 1 of cells custom dynamic prototype cell (for created subclass) containing label , switch. have action switch wired action method (say switchchanged:) in view controller. in cellforrowatindexpath, configure , return cell appropriate specified index. far good. the problem: application has multiple instances of these custom cells, how differentiate switch has changed? 1 thought in view controller can create member switch each cell , link them specific cell switch when cellforrowatindexpath called first time. can use these member switches compare switch passed switchchanged:. i know can try , immediate answer, hoping discussion of how other developers trying do. best/worst/ok approach , practical alternatives? regards, --john i had situation once (not switches, believe applies same). i've managed around subclassing object class , adding required properties/methods ins...

java - Package name for classes that save and update -

i have various class perform save , update operations of gui elements, saves elements have been added/removed , new positions. what appropriate package name ? i considered com.myappname.contentsave does'nt 'feel' correct ? how about com.myappname.persist

inheritance - django orm - How to use select_related() on the Foreign Key of a Subclass from its Super Class -

i've found django orm's handling of subclassing models pretty spiffy. that's why run problems one. take 3 models: class a(models.model): field1 = models.charfield(max_length=255) class b(a): fk_field = models.foreignkey('c') class c(models.model): field2 = models.charfield(max_length=255) so can query a model , b models, available: the_as = a.objects.all() in the_as: print a.b.fk_field.field2 #note throws error if there no b record the problem looking @ huge number of database calls retrieve of data. now suppose wanted retrieve queryset of a models in database, of subclass records , subclass's foreign key records well, using select_related() limit app single database call. write query this: the_as = a.objects.select_related("b", "b__fk_field").all() one query returns of data needed! awesome. except not. because version of query doing own filtering, though select_related not supposed filter results ...

Ajax call to WCF Web Service returns 400 Bad Request -

possible duplicate: wcf web service returns “bad request” error when invoked through javascript i have simple wcf web service service1 1 method test() returns string. have deployed web service on test machine, when try invoke test method browser 400 bad request error. same happens when try invoke method through ajax request. surprisingly, method returns correct result when invoked through wcftestclient. here code: [servicecontract] public interface iservice1 { // method can called list of page sets per report. [operationcontract] [webget] string test(); } public class service1 : iservice1 { public string test() { return "test"; } } this ajax request: var serverurl1 = 'http://' + baseurl + ':86/service1.svc'; function getteststring() { var methodurl = serverurl1 + "/test"; $.ajax({ async: false, type: "get", contenttype: "app...

Manipulating C-strings with multiple null characters in memory -

i need search through chunk of memory string of characters, several of these strings have every character null separated, this: "i. .a.m. .a. .s.t.r.i.n.g" of '.'s being null characters. problem comes getting memory. i've tried several ways, instance: char* str2; str2 = (char*)malloc(sizeof(char)*40); memcpy((void*)str2, "123\0567\09abc", 12); will put following memory str2 points to: 123.7.9abc.. like str2 = "123456789\0abcde\054321"; have str2 pointing block of memory looks 123456789.abcde,321 , wherein '.' null character, , ',' actual comma. so inserting null characters cstrings doesn't work thought did, inserting newline character. encountered similar difficulties trying string library well. separate assignments, like: char* str; str = (char*)malloc(sizeof(char)*40); strcpy(str, "123"); strcpy(str+4, "abc"); strcpy(str+8, "abc"); but not...

java - Using a class with int in main() -

i want write class 3 int values in them , manipulate them in main(); there 2 ways can think of doing have seperate .class file , include class file containint main() function stuff.java: class stuff { ... } class app { public static void main(string[] arguments) { .. // manipulate instance variables } } 2 have class , class containint main function in same file app.java app.java: class stuff { ... } class app { public static void main(string[] arguments) { .. // manipulate instance variables } } are these main ways done in java ( didn't see on including java classes ). or can make stuff class contain main itself? i wondering, if want write class 3 int values in them , manipulate them in main() method it! why need staff class ?

c# - Calling function in WPF from silverlight inside web browser control -

i have wpf application web browser control inside silveriight application. earlier, have been able call functions wpf application sliverlight application using html bridge. now, have opposite i.e. have call function inside wpf application silverlight. how can done? you can using property shown below: c# part : webbrowsercontrolname.objectforscripting = new scriptinterface(); where scriptinterface follows [system.runtime.interopservices.comvisibleattribute(true)] public class scriptinterface { public void csharpmethod(string data) { messagebox.show(data); } } html part in page load in web browser control following : window.external.csharpmethod('from html page wpf');

android - RadioGroup checkedButton property -

i trying build radiogroup in android 1 radiobutton checked default. i'm wondering if possible through xml, rather programmatically. the following code snippet doesn't seem work i'm getting error: error: error: no resource found matches given name (at 'checkedbutton' value '@id/rdb_positive') the code is: <radiogroup style="@style/forminputfield" android:orientation="vertical" android:checkedbutton="@id/rdb_positive"> <!-- error on line --> <radiobutton android:id="@+id/rdb_positive" android:text="@string/answer_positive" /> <radiobutton android:id="@+id/rdb_negative" android:text="@string/answer_negative" /> </radiogroup> it make sense in way, id of radiobutton defined after attribute in radiogroup set, wonder why there such attribute available. use android:checkedbutton="@+id/rdb_...

xcode - UIView transitions with wrong orientation -

i have code (book1 uiviewcontroller class) book1 *book = [self.storyboard instantiateviewcontrollerwithidentifier:@"book1id"]; [uiview transitionfromview:self.view toview:book.view duration:1 options:uiviewanimationoptiontransitioncurldown completion:nil]; the viewcontroller loads orientation wrong. loads in portrait view want load in landscape. i have following code in book1 once view loaded autorotation seems fail. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation{ return interfaceorientation == uiinterfaceorientationlandscapeleft || interfaceorientation == uiinterfaceorientationlandscaperight;} how can load view in landscape? i haven't found problem previous methods found way it. this how: book = [self.storyboard instantiateviewcontrollerwithidentifier:@"book1id"]; book.modaltransitionstyle = uimodaltransitionstylecoververtical; [self presentviewcontroller:book animated:yes completion:^...

grails - how to displaydomain value in gsp -

i have 3 domain class class stock { product product } and class product { productname productname } and class productname { string name } in create.gsp of stock domain, default code generation:- <tr class="prop"> <td valign="top" class="name"> <label for="name"> <g:message code="stock.name.label" default="product name" /> </label> </td> <td valign="top" class="value ${haserrors(bean: stockinstance, field: 'name', 'errors')}"> <g:select name="product.id" from="${com.ten.hp.his.pharmacy.product.list()}" optionkey="id" optionvalue="productname" value="${stockinstance?.product?.id}" /> </td> </tr> my requirement display product name in drop down using optionvalue, showing produ...

c# - Ninject Func clarification -

could please me understand statement below please: kernel.bind<func<ikernel>>().tomethod(ctx => () => ctx.kernel) what above code do? what func? is trying bind , interface ikernel something...? part confuses me: <func<ikernel>>().tomethod(ctx => () => ctx.kernel ) i'm aware kernel.bind used bind interface concrete type not sure above there's no concrete type given. how fits in real world scenario. why , when use function thanks looks ninject . basically tells dicontainer of ninject return function returning kernel of current context whenever somethings asks dicontainer func<ikernel> . take here . so, func ? from the documentation @ msdn : encapsulates method has no parameters , returns value of type specified tresult parameter. you should have generics , lambda expressions .

http - PHP protected download manager -

i building small download module larger project working on, , have run bit of issue. although works small files, when browser (any browser) begins downloading larger file, loads page would, , in last few seconds "downloads" whole file (regardless of size) instantly. have gone through http 1.1 standard on , over, , seem following them letter. 1 thought instantly comes mind when php sending data client. answer should script runs - use principle in other long scripts debugging. here relevant piece of code (there more of course, headers , output sent: header("content-type: application/force-download"); header("content-length: $size"); header('content-disposition: attachment; filename="'.$filedata['name'].'"'); ($i=0; $i<$size; $i+=$step) { $content = fread($file, $step); if ($content === false) $content = ""; echo $content; } die(); any ideas? have feeling obvious issue can't...

long integer - SQL Query is too complex, yet seems very simple -

i developed model through sas/kxen , exported score code script in sql. however, i'm getting "this expression typed incorrectly, or complex evaluated. example, numeric expression may contain many complicated elements. try simplifying expression assigning parts of expression variables. (error 3071)" error code, yet script seems simple enough (just lot of case whens). ideas rectify problem? thank you: -- kxen analytic framework - ixi corp - equifax_us_amendment 1_2011_06_30 - itam media - - copyright kxen (c) 1999-2011 - model built in 5.1.4 - model name auto_digital_targets_model: auto trigger (month added) - model version 1 select $key, "rr_auto", cast( (case when "rr_auto" <= -1.077823785821e0 6.05306179145e-3 when "rr_auto" <= -7.882377294631e-2 6.05306179145e-3 when "rr_auto" <= -7.782378582091e-2 ( 1.353029818544e-3*"rr_auto"+6.159712720187e-3 ) when "rr_auto" <= -2.27776053868e-2 ...