Posts

Showing posts from January, 2015

php - PDO_OCI vs OCI8 -

i'm working on new project , trying determine if should use pdo_oci or oci8 database connection. unfortunately don't think has compared two. the information have follows know why i'm concerned choice. oci8 developed oracle(afaik) seems solid choice. prefer pdo doesn't pdo_oci extension has been updated in time , still marked experimental on php docs page. if can give me thoughts on why / wouldn't use 1 or other can go little more of understanding of better great. i nervous using pdo_oci experimental note. however, saw major advantage standardizing our database connections on pdo across corporation because of data abstraction. implemented tests make sure data make database , stand anticipated load. @ point has processed 15,000 records successfully. the note on php.net says names , function may change in future release of php. plan test implementation before upgrade ensure functionality hasn't changed, way. i can works us.

debugging in mixed mode with native C++, managed c++ cli, and c# solution -

i have multithreaded project im working on , startup project set c# project runs ui. there whole series of underlying c++ native projects connected c# managed c++/cli projects. i've enabled in c# start project 'enable unmanaged debug' , when attempt debug native code, able hit break points set. however, hangs after try run again , try hit break point again. example, if have loop try hit inside in each iteration, after second iteration program hangs , have force quit. im working in visual studio 2010. debugging beginning prove not useful @ rate, there way preclude problem? when want debug native code c++/cli, following: in c# application, check allow unsafe code in build tab , enable unmanaged code debugging in debug tab of project properties. for c++/cli dll project, in debugging tab of properties, set debugger type mixed

User control in a page with a page level grid -

i have aspx page telerik radgrid right on page. there user control embedded in page seperate telerik grid. when row dragged page level grid user control grid having trouble finding usercontrol.grid when using intellisense, usercontrol.grid not show up. need able grab usercontrol.grid , work on durnig row drop event. ideas? the grid inside user control should accessible on client clientid despite resides inside user control (since user control not rendering additional html element). on server can reference user control grid invoking findcontrol(gridid) method user control instance.

wpf - How to make clipping geometry scale with the target? -

in following example whenever grid size changed, clipping region size remains expressed in absolute coordinates. <grid clip="m10,10 l10,150 l150,150 l150,10 z"> <rectangle fill="red"/> </grid> is possible somehow clip region such clipping geometry scaled along clipped object? code behind solutions not accepted, because used in control template. also, region in example simple shape clarity sake. actual used region complex , asymmetric shape. edit: it looks have more specific. snipped part of custom control template progressbar. when scaling outer grid, part_indicator rectangle not scale clipping region. correct composition when grid sized 200x200. <grid> <path name="part_track" data="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z" fill="aliceblue" stretch="fill"/> <rectangle clip="m100,0 a100,100 0 1 0 100,200 a100,100 0 1 0 100,0 z&qu

javascript - JS - iframe height with 100% and no scroll (Scroll-y in body) -

i have iframe problem. firstly search keyword iframe height in https://stackoverflow.com/search?tab=relevance&q=iframe%20height did not find need. how make iframe wicth height 100% , no scroll. scroll-y in body. <body style="scroll-x:hidden;scroll-y:auto;"> <iframe frameborder="0" id="iframe" scrolling="no" src="http://www.google.com" style="width:960px;height:100%" height="100%" width="960"></iframe> and if search via http://www.google.com in iframe, after turn google search result page. iframe calculate new height , still iframe height 100%, scroll bar in body part. (i wish work perfect not in ie , firefox, in safari , chrome ). lot. this should you're looking for: <!doctype html> <html> <head> <meta charset="utf-8"> <title>page title</title> <style type="text/css" media="screen

c# - Write in Java to work with .Net? -

i wondering if have experience writing codes in java while compiling .net assemblies? thoughts? library did use , disadvantages of codes in java become .net application? i see there couple of libraries out there out java <-> .net communication (eg. jnbridge http://www.jnbridge.com/ , ikvm.net http://www.ikvm.net/ ) . let me know if have suggestions on how go doing task, or may reason why not bother doing , better off starting out .net (c# may be) i suggest better off starting c#, unless doing straight port , ready deal lots of integration issues. c# pretty similar java syntactically , conceptually, , .net tooling work lot better.

c# - dropdownlist selectedvalue -

i've used webservice create dropdownlist of countries , i'm trying add dropdownlist selection sql database, when using ddlcountry.selectedvalue in insert statement, first value in dropdownlist showing in table. should use onselectedindexchanged somehow store value? code should using? try using ddlcountry.selecteditem.value instead.

php - How to mail to a static list segment with mailchimp API -

once i've identified identified email addresses of list segment (using get_emails() custom function, setting list segment follows: $batch = get_emails(); //now create list segment: $api->liststaticsegmentadd(wedding_list_id, 'new_wedding_guests'); $api->liststaticsegmentmembersadd(wedding_list_id, 'new_wedding_guests', $batch); //do build vars campaign? $options = array ( 'list_id' => wedding_list_id, //what value id's list segment? 'subject' => 'alpha testing.', 'from_email' => 'wedding@juicywatermelon.com', 'from_name' => 'pam & kellzo', 'to_name' => $account->name, ); from here can use basic campaign , send it? $content['text'] = "some text."; $content['html'] = get_link($account); $cid = $api->campaigncreate('regular', $options, $content); $res

php - is_numeric does not work when reading from txt file? -

in text file have file this: olivia 7 sophia 8 abigail 9 elizabeth 10 chloe 11 samantha 12 i want print out name , ignore numbers. for reason, dont work - wouldn't print anything? <?php $file_handle = fopen("names.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); if (!is_numeric((int)$line_of_text)) { echo $line_of_text; echo "<br />"; } } fclose($file_handle); ?> you casting every line (int) . lines strings become 0 (zero). you can change code to: !is_numeric($line_of_text) note: is_numeric() return true decimals , scientific notation also. if strictly determining if line contains digits , suggest ctype_digit() update you need trim($line_of_text) fgets() includes newline. code inside while() : $line_of_text = trim(fgets($file_handle)); if (!ctype_digit($line_of_text)) { echo $line_of_text; echo "<br />"; }

multithreading - How to persist Entity in separate thread with JPA on J2EE App server? -

i have chat application needs store messages db. connection db little bit slow, therefore delays response chat client. is possible persist message entity in separate thread? i'm need in: reduce delay before send-recieve message on client. i try it, doen't work. dao object: @stateless public class messagesdao { @persistencecontext(type= persistencecontexttype.extended) private entitymanager entitymanager; private persistencethread persistencethread = new persistencethread(); //another methods public void addmessage(message message) { thread thread = new thread(persistencethread); persistencethread.setmessage(message); thread.start(); } private class persistencethread implements runnable { private message message; public void setmessage(message message) { this.message = message; } public void run() { entitymanager.persist(message); } } } inte

c# - How to get the directory of database? -

Image
i using microsoft database inside c:\wpf1\wpfapplication1\wpfapplication1 folder. when update database updates 1 inside c:\wpf1\wpfapplication1\wpfapplication1\bin\debug don't want. how folder c:\wpf1\wpfapplication1\wpfapplication1 without typing full name? the directory c:\wpf1\wpfapplication1\wpfapplication1 project directory - 1 source code in, not directory application aware of or work (for example if application installed pc directory won't exist). the usual approach when working databases or dependent files either: put file in other common location (such in folder on c: drive) just have application work copy of file in output ( bin\debug\ ) directory, i.e. directory application installed - can change properties of item in solution have item copied output directory, either time or when item in solution directory newer: if really want use c:\wpf1\wpfapplication1\wpfapplication1 directory way assume directory 2 higher current working directo

sql - Adjust Date to match saved day of week -

i have table stores startdate , name of day of week start date falls on. don't know why, bad design didn't create , can't change it. of course, have dates don't match day of week. make worse, day of week correct , start date incorrect. need adjust dates each row's startdate falls on row's dayofweek. can assume startdate minimum value target date first [dayofweek] after set startdate. so example have rows (8/23/10 mon, 8/29/10 sun): startdate dayofweek ----------------------- 2010-08-23 monday 2010-08-23 tuesday 2010-08-29 thursday in row 2 can see date supposed tuesday it's monday. need end this: startdate dayofweek ----------------------- 2010-08-23 monday 2010-08-24 tuesday 2010-09-02 thursday i struggle when working dates, sql not strongest skill either. thanks. stealing geofftnz's setup, , hoping "clever" method thinking of: declare @baddata table(startdate datetime, [dayofweek] varchar(20)) insert

c# - wpf how to find a canvas inside a grid in a specific Row/column -

i have grid divided several rows/columns, how can canvas that's inside grid in (x,y) example how can canvas inside row 2 column 1 ? thanks lot there can multiple elements in "cell", there no nice way this, use query this: int x = 0; int y = 1; var target = (from uielement c in grid.children grid.getrow(c) == y && grid.getcolumn(c) == x select c).first();

c++ - Find 'new' items from two containers -

i have 2 containers (the actual container flexible, unsorted vs sorted doesn't matter me, whatever works best answering question i'll use) contain data. want compare these 2 containers, , either remove 'duplicates' second, or create new container 'new' values. by duplicate/newi mean following: container 1 contains: [1, 2, 4, 8, 16] container 2 contains: [1, 2, 4, 16, 32] after running algorithm, new container (or modified container 2) should contain: container 3 contains: [32] notice not want '8' in new container (or modified container) want find 'new' values. i implement naive , slow program myself, i'm looking elegant , efficient way achieve (boost fine if stl not provide necessary tools/algos without rolling own, otherwise rolling own fine too). so... 'best' (read: elegant , efficient) way this? thanks in advance. p.s. if @ relevant, i'm using write 'diffing' tool exported functions dll. have number of

Centering in CSS, when the object is larger than the viewport -

i'm trying jquery carousel centered on screen, when clipping area wider viewport. give element negative left margin -- how can specify this? clipping area fixed width of course viewport area variable. here's best solution i've been able find uses wrapping element around your-fixed-width content, -50% margin on content itself. off top of head, should enough started. here's code snippet: div.wrapper { position: absolute; left: 50%; } .content { position: relative; margin-left: -50%; } <div class="wrapper"> <div class="content">jquery biz-nass here</div> </div> of course, assumes div here direct descendant of body tag, , browser specifies body have width of 100% , no margin or padding.

java - Cancelling a thread safely due to timeout -

i have queue of tasks need performed, , pool of workers pick tasks , perform them. there's "manager" class keeps track of worker, allows user stop or restart them, reports on progress, etc. each worker this: public void dowork() { checkarguments(); performcalculation(); saveresultstodatabase(); performanothercalculation(); saveresultstodatabase(); performyetanothercalculation(); saveresultstodatabase(); } in case, "database" not refer oracle database. that's 1 of options, results saved on disk, in amazon simpledb, etc. so far, good. however, performcalculation() code locks intermittently, due variety of factors, due poor implementation of networking code in bunch of third-party libraries (f.ex. socket.read() never returns). bad, obviously, because task stuck forever, , worker dead. what i'd wrap entire dowork() method in sort of timeout, and, if timeout expires, give task else. how can that, though ? let's or

Exception in thread "main" java.lang.NoSuchMethodError -

possible duplicate: causes of 'java.lang.nosuchmethoderror: main exception in thread “main”' i got error after added method called setconstraints in generator.class.im free error when compiled. error: exception in thread "main" java.lang.nosuchmethoderror: rtg.generator.setconstra ints(ljava/util/arraylist;)v @ rtg.defaultprompt.main(defaultprompt.java:117) this method of setcostraints() in generator.java private arraylist<string> constraints_list = new arraylist<string>(); private boolean constr = false; public void setconstraints(arraylist<string> c) { constraints_list = c; constr = true; } this class using generator.class public class defaultprompt { public static void main() { generator gen = new generator(); gen.setconstraints(constraints_list); } { both classes r in same package.before added setconstraints, no error. anyone knows how/why happen? sounds cl

Emacs keyboard changed -

several times while programming in emacs keyboard has started write greek letters buffer. assumed i'd pressed key combination after searching i've yet figure out , solution right restart emacs. doing , how fix it? i'm going out on limb. you're working on windows computer has multiple input languages configured (including greek). has default keyboard shortcut switch between them enabled (left alt+shift default, , if have multiple inputs set up, on default). some emacs shortcuts require alt-shift combo, , depending on order press them, or don't windows intercepting ime switch. possible solutions include: remove greek ime disable windows shortcut switch imes change said shortcut i typically want multiple imes on systems, can switch imes quickly, , don't want mess default shortcuts, ended getting used pressing shift then alt when doing alt-shift combos in emacs.

c# - Why does Microsoft.Office.Interop.Excel corrupts my excel file? -

i found lib on net // library handle excel files in simple way. // copyright (c) 2009 gorka suárez garcía // // program free software: can redistribute and/or modify // under terms of gnu lesser general public license published // free software foundation, either version 3 of license, or // (at option) later version. // // program distributed in hope useful, // without warranty; without implied warranty of // merchantability or fitness particular purpose. see // gnu lesser general public license more details. // // should have received copy of gnu lesser general public license // along program. if not, see . using system; using system.collections.generic; using system.reflection; using microsoft.office.interop.excel; namespace excel { /// <summary> /// class used handle excel file write , read it. /// author: gorka suárez garcía /// </summary> public class excelhandler { /// <summary> /// excel application instance.

c - how to assign the address pointed by a pointer to another local pointer -

i'm doing video processing project, , got struck in assigning block address sending dct function. the following line not taking correct assignment address right hand variable pointing to. temp = (unsigned short *)((unsigned short *)(p_vqi->luma + j) + l); so temp not contain correct address pointed p_vqi->luma variable, j , i incremented 16 times on each step maximum of 144 , 176 respectively. the thing gets people pointer math doesn't add 1 byte @ time, adds 1 sizeof(thing pointed to) @ time, you're going skip on j lumas, big is, i unsigned shorts, big on architecture. usually, it's easier , more portable when working fixed formats work straight in bytes, like: uint8_t* temp = (uint8_t*)p_vqi->luma; temp += j*16 + i;

c# - Multiple nested canvases in Expression Design xaml output, why? -

just wondering why expression blend outputs path nested in 2 canvases (rather one), i've seen 3 or more still outputting 1 path: <?xml version="1.0" encoding="utf-8"?> <canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:name="cross" width="146.768" height="146.768" clip="f1 m 0,0l 146.768,0l 146.768,146.768l 0,146.768l 0,0" uselayoutrounding="false"> <canvas x:name="layer_1" width="146.768" height="146.768" canvas.left="0" canvas.top="0"> <path x:name="path" width="138.605" height="138.605" canvas.left="4.12044" canvas.top="4.04301" stretch="fill" fill="#fff80000" data="f1 m 4.28074,121.084l 4.15843,120.962c 4.40034,118.924 6.48998,117.557 7.9421,116.108c

syntax - How to do an IN query in Solr? -

i'm having documents multivalued field "sharedto" contains groups document shared to. want find documents shared @ least 1 of list of given groups. e.g. want find documents shared group "foo" or group "bar" or both. i'm building query this: sharedto:"foo" or sharedto:"bar" for each group add new or query part. works, wonder if there more efficient way of doing a sharedto in ('foo', 'bar') if default operator or, can give query sharedto:('foo' 'bar') if default operator and, you'll have this: sharedto:(foo or bar)

jsf 2 - Problem with f:ajax in JSF requiring double clicks to execute -

i'm having same issue on few places , i'm getting frustrated. whenever try trigger ajax event requires 2 clicks, first 1 nothing. i've tried firing first click , manually refresh site again, nothing happens. needs 2 clicks fire event. the below code shows simple loginform using composite. here login button requires 2 clicks fire. the main body <body> <h:outputscript library="js" name="topmenujs.js" /> <div class="topmenu"> <f:ajax execute="pagenavform" render=":currentmaincontent"> <h:form id="pagenavform"> <h:commandlink styleclass="selector" rendered="#{viewerrandsbean.userid.name != null}" action="#{renderhandler.showcreateissue()}" value="create errand" /> <h:commandlink styleclass="selector" rendered="#{viewerrandsbean.userid.name !=

javascript - Newbie: how to hide and show in my case using jQuery? -

i newbie in jquery. have index.html page, <body> <div id="content"> </body> i feature when page loaded, "content" area shows list: <div id="my-list"> <select id="carlist" size="10"> <option>bmw</option> <option>toyota</option> <option>skoda</option> </select> </div> when user select car list option, list " my-list " disappear( hide ), , image shown in " content " area. that's hide selection filed , show image in same " content " area. how in jquery?? i tried: var mylist=$('#my-list'); mylist.change(function(){ mylist.hide() someimage.show() } but, define " my-list " , image in same " content " area? how implement all? var mylist=$('#carlist'); mylist.change(function(){ mylist.hide(); var container = myl

java - ORA-08103: object no longer exists: This error is occuring for Oracle Procedure returning Refcursor from MyBatis -

when calling stored procedure in oracle returning refcursor getting error 2011-05-10 03:36:23 dirtiescontexttestexecutionlistener [debug] after test method: context [[testcontext@3a363a36 testclass = accountactivityservicetest, locations = array<string>['classpath:/com/bnymellon/pwb/pfdetails/service/test/test-application-context.xml'], testinstance = com.bnymellon.pwb.pfdetails.service.test.accountactivityservicetest@6d2c6d2c, testmethod = getdata@accountactivityservicetest, testexception = org.springframework.jdbc.uncategorizedsqlexception: ### error updating database. cause: java.sql.sqlexception: ora-08103: object no longer exists ### error may involve com.bnymellon.pwb.pfdetails.persistence.accountactivitymapper.getaccountactivitydata-inline ### error occurred while setting parameters ### cause: java.sql.sqlexception: ora-08103: object no longer exists ; uncategorized sqlexception sql []; sql state [72000]; error code [8103]; ora-08103: object no longer exi

css - jQuery Lightbox For Native Galleries wordpress plugin buttons not showing outside box -

hi using jquery lightbox native galleries wordpress uses colorbox plugin. i trying position prev, next , close buttons on edge of lightbox buttons keep on cropping. have tried playing around z-index of elements , nothing working. i pulling hair out feel have hit wall, hence if can me through fantastic. hope can help. here url http://satbulsara.com/luke-irwin/?page_id=14 try #cboxcontent { overflow: visible; } tried in firebug. #cboxcontent container of buttons. has property of overflow: hidden . that's why buttons cropped @ edges.

html - Will search engines try to follow a javascript type of address link? -

i have following on page: <a href="javascript:void(0)" onclick="docheck('test'); return false;" class="btn">test</a> it works great i'm wondering happen when seen search engine. search engine try click address , follow it? google ignore it. it's bad practice use onclick in way though, , using void statement pretty horrible too. have @ why using onclick() in html bad practice? explanation of why.

cocoa touch - how to import video from iphone with no time duration -

can 1 me please want pick video iphone recorded of uiimagepicker controller. want copy apps document directory. ---------------------------------- prashant i unsure of mean no time duration. can copying/moving in uiimagepickerdelegate method. - (void) imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { nsurl *movieurl = (nsurl*)[info objectforkey:uiimagepickercontrollermediaurl]; nsstring *documentsdirectory = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsurl *saveurl = [nsurl fileurlwithpath:[documentsdirectory stringbyappendingpathcomponent:@"movie.mov"]]; nserror *error; if (!([[nsfilemanager defaultmanager] moveitematurl:movieurl tourl:saveurl error:&error])) { nslog(@"error saving: %@", [error localizeddescription]); } [picker dismissmodalviewcontrolleranimated:yes]; }

vbscript - Defining a save path in VB -

the script creates txt file of info users pc saves shared directory folder f:\installedsoftware\ if writefile(s, sfilename) 'optional prompt display if msgbox("finished processing. results saved " & sfilename & _ vbcrlf & vbcrlf & "do want view results now?", _ 4 + 32, stitle) = 6 wscript.createobject("wscript.shell").run """" & sfilename & """", 9 end if end if a) sfilename = "f:\installedsoftware\" & scompname & "_" & getdtfilename() & "_software.txt" b) sfilename = scompname & "_" & getdtfilename() & "_software.txt" both result in file being created e.g “ johnpc_05112011_093842_software.txt” but b correctly creates in current active directory. two problems, have shared drive, if email link vb script, have use exhibit exhibit b uses current act

scala: override implicit parameter to constructor -

i have class takes implicit parameter used functions called inside class methods. want able either override implicit parameter, or alternatively, have implicit argument copied source. example: def somemethod()(implicit p: list[int]) { // uses p } class a()(implicit x: list[int]) { implicit val other = list(3) // doesn't compile def go() { // don't want put implicit inside here since subclasses override go() have duplicate somemethod() } } the behavior want somemethod() gets implicit parameter changed version of x, class's implicit parameter. want able either mutate x without changing whatever passed a's constructor, or otherwise override new value of choosing. both approaches don't seem work. is, doesn't copy list in former case, , compiler finds ambiguous implicit value latter case. there way this? i realize can redefine implicit value within go(), not choice in case because class subclassed numerous times, , i'd handle implicit cha

php - Complex reference maps in Zend_Db_Table to account for multi-column keys -

i going attempt keep simple possible, use case outside original intention of zend_db fear. concerns set of tables have tagging pages (or else eg. documents) in cms. i have 3 tables: pages ( pages ) tags ( tags ) taglink ( tags_link ) many-to-many linking table between pages , tags pages simple table (i have removed inconsequential columns code below): create table `pages` ( `id` int(10) unsigned not null auto_increment, `name` varchar(255) not null default '', primary key (`id`), fulltext key `search` (`name`) ) engine=myisam default charset=utf8 tags quite simple although there self-referential column ( parent_tag_id ): create table `tags` ( `id` int(11) not null auto_increment, `tag` varchar(255) not null, `parent_tag_id` int(11) not null default '0', `updated` timestamp not null default current_timestamp, primary key (`id`), key `getbyparenttagid` (`parent_tag_id`) ) engine=myisam default charset=utf8 taglink again simple:

android application delete only one sms in the inbox -

hi friends create delete sms delete sms want delete 1 sms. can possible if possible how can it. if code available please send me. please me. thanks in advance. simply use code. try { uri urisms = uri.parse("content://sms/inbox"); cursor c = context.getcontentresolver().query( urisms, new string[] { "_id", "thread_id", "address", "person", "date", "body" }, "read=0", null, null); if (c != null && c.movetofirst()) { { long id = c.getlong(0); long threadid = c.getlong(1); string address = c.getstring(2); string body = c.getstring(5); string date = c.getstring(3); if (message.equals(body) && address.equals(number)) { // mlogger.loginfo("deleting sms id: " + threa

.net - calling serverside method from javascript -

want call server side c# function javascript. i used way given in this article . this works fine when did same steps in new asp.net application. when repeat same steps in application on working give error: "pagemethods undefined". i working on .net 4.0. have enabled page methods on scriptmanager? <asp:scriptmanager id="scriptmanager1" enablepagemethods="true" runat="server" />

javascript - trouble updating multiple anchors aysc with jquery -

so have these links in html this <a href="#ajax" class="invlink" competition_id="532">gen invoice</a> <a href="#ajax" class="invlink" competition_id="534">gen invoice</a> <a href="#ajax" class="invlink" competition_id="535">gen invoice</a> then wrote javascript binds click event , want submit ajax request, , replace anchor returned text. if have clicked on multiple links several running asychronously, doesn't update anchors returned text, last anchor clicked on. i guessing anchor variable being overwritten each time run, how structure code each time click event triggered, updates correct anchor on completion? here javascript <script type="text/javascript"> $(document).ready(function() { // bind geninvoice function invlink's $('.invlink').bind('click', geninvoice); }); function g

How do WPF toolbars change their buttons' styles? -

in wpf, if put button inside toolbar, button automagically gets different style: no border default, different hover effects, etc. mechanism wpf use accomplish that? i know how restyle buttons in program, putting style targettype="button" resources in app.xaml. know how restyle buttons in single parent panel, putting same style targettype="button" panel's resources. don't know how make reusable, can apply multiple different panels (but not whole app) , have restyle buttons in panels. toolbar has magic make "apply children" style reusable. how that? it applies style in preparecontainerforitemoverride , looks like: protected override void preparecontainerforitemoverride(dependencyobject element, object item) { base.preparecontainerforitemoverride(element, item); frameworkelement element2 = element frameworkelement; if (element2 != null) { // ... resourcekey name = null; if (type == typeof(button

java - Help trying to understand modulo operation in circular array -

i have small issue trying figure out how modulo operation being calculated. building queue, have circular array. cannot figure out how modulo operation works. given q: array of character of 5 elements length, max constant gives max length of array "5" rare int represents first available spot in array q public void enqueue(character c)throws fullqueueexception{ if(size()== max -1){ //if 1 place left, full, throw exc throw new fullqueueexception("queue full"); } q[rare]=c; rare=(rare+1)%max; } now, supposing rare "first empty spot" three, rare value going after method has finished? dont get, rare=(rare+1)%max means rare=4%5 gives rare=0,8. same method size: public int size() { return (max - front + rear) % max; } given, front, int variable represents first element in array suppose front 1 , rare 4, there 3 elements in array, size (5-1+4)%5 8%5 gives 1.6, while actual size 3 suggestion? might more math j

ruby on rails relationship between tables, multiple fields in one table related to another table -

i have 2 tables: person , batch a batch has 3 fields relates person table: supervisor, creator , modifier. all 3 fields store person_id of person table. i created following relationship between person , batch models. class batch < activerecord::base belongs_to :person, :foreign_key => "supervisor_id" end class person < activerecord::base has_many :batches, :foreign_key => "supervisor_id" end so if 'batch.person.per_name', supervisor's name..but how go on creator , modifier details? many suggestion provided it sounds want 3 different relationships: class batch < activerecord::base belongs_to :supervisor belongs_to :creator belongs_to :modifier end then can reference each 1 independently as: batch.supervisor batch.creator batch.modifier alternatively, create join table between 2 , arbitrarily add , remove linkages: class batch < activerecord::base has_many :person_batches has

regex - Combining Regexes -

how can combine regexes? edit: if exam preparation. question write regex find strings have odd number of a's , number of b's? i.e. instead of | or, need mechanism emulate and i have 2 regexes: 1) find odd number of a's: ^[^a]*a([^a]*a[^a]*a)*[^a]*$ 2) find number of b's: ^([^b]*b[^b]*b)*[^b]*$ you can using lookahead expressions (here shown verbose regex since hard read, more on single line): ^ # start of string (?=(?:(?:[^a]*a){2})*[^a]*$) # assert number of (?=[^b]*b(?:(?:[^b]*b){2})*[^b]*$) # assert odd number of bs .* # match $ # end of string the last 2 lines can dropped if you're validating - match entire string.

geolocation - getting the location and speed via mobile platforms -

is there possibility of getting location of user, moving direction, , speed via mobile platforms(client side programming j2me) ? if there availability in platform please let me know platform , please give me study links study it? regards, rangana i'm not sure if there api this, because don't think information (velocity) available. you can still figure out though, , work on cell phones allow access "current location". ping phone it's current location every n seconds (10,20,30 seconds, etc...) log location of phone @ every ping (lat,long) determine distance traveled ping-to-ping. may need use vector resolution (http://www.physicsclassroom.com/class/vectors/u3l1e.cfm) for example, if phone moves 1000 meters on course of 30 second ping, means: 1000 meters / 30 seconds = 33.333 m/s doing this, can determine acceleration, etc... not give instantaneous velocity or acceleration, instead average velocity , average acceleration.

jquery - Is it possible to change the cursor on an element without refreshing the page? -

i have carousel scrolling through slides. carousel has overlay higher z-index content beneath it. slides contain links, don't. jquery gets href of slides link , makes overlay link href when clicked. [slide 1: <p>] [slide 2: <p> <a>] my problem is, want change cursor pointer when slide contains link , cursor auto when there no link. (the change won't matter when user hovering on carousel, because slides don't automatically move when case) i have click function stops overlay linking anywhere when there no link, cursor controlled css. tried using addclass , isn't working. is possible change cursor hover state on same div using jquery , css? this piece of function stops overlay doing if there no link: $('#carousel_overlay').click(function() { slidelinktarget = promoslides.eq(activeslideindex).find('a').attr('href'); if (!slidelinktarget == '') { window.open(slidelinktarget); (

NHibernate QueryOver distinct -

i have scenario: class user { id, username } class userrelationship { user groupuser, user memberuser } , query var query = queryover.of<userrelationship>() .joinqueryover(x=>x.memberuser) .where(x=>x.username == "testuser"); now want return list distinct user, cannot transformusing(transformers.distinctrootentity) because give me userrelationship. i need this: select distinct user.id userrelationship relationship inner join user user on user.id = relationship.memberuser_id please thanks given classes: public class user { public virtual int id {get; set;} public virtual string username {get; set;} } public class userrelationship { public virtual int id {get; set;} public virtual user groupuser {get; set;} public virtual user memberuser {get; set;} } and fluent mappings of: public class usermap : classmap<user> { public usermap() { id(x=>x.id).generatedby.native(); map(x=

excel vba - Passing objects to procedures in VBA -

i working on simple tool allow me parse multiple csv files , spit them out onto fresh worksheet "merged" together. here implementation (i've simplified it) , issue: class a private variables types property methods accessing variables class b private variables types property methods accessing variables class c private ca classa private cb collection 'collection of classb class d - part of problem private cc collection 'collection of classc 'other member variables , property get/lets public sub adda(a classa) if cc.item(a.foo) nothing dim tempc classc set tempc = new classc tempc.a = end if end sub main module - other half of problem dim cc new classc 'initialize class c, works fine dim tempa classa set tempa = new classa 'set tempa properties cc.adda tempa 'this error i've tried passing byval , byref each gives me different errors ("byref argument type mismatch", "in

ruby on rails - How to cache an entire page save for one element -

i'm running e-commerce website , many pages dynamic widget displaying number of items in visitor's cart. want cache page yet retain dynamism. i'm considering caching fragments before , after widget wondering if there simpler way done. edit: perhaps decided give cached page or not depending on whether cart empty or not start. kindest of regards, -- jack one way have cart items displayed using javascript that's inserted after page loaded. can see on places stackoverflow login status gets injected page if wasn't cached. jquery can make pretty straightforward. you can set number of items in cookie accessible javascript, not in session hash that's not exposed client, , handle in document.onload section.

c - Realloc Vs Linked List Scanning -

i have read file unknown number of rows , save them in structure (i avoid prepocessing count total number of elements). after reading phase have make computations on each of elements of these rows. i figured out 2 ways: use realloc each time read row. way allocation phase slow computation phase easier index access. use linked list each time read row. way allocation phase faster computation phase slower. what better complexity point of view? how traverse linked list? if it's once go linked-list. few things: vill there lot of small allocations? make few smaller buffers let's 10 lines , link togeteher. that's question of profiling. i'd simplest thing first , see if fits needs i'd think optimizing. sometimes 1 wastes time thinking optimum when second best solution fits needs perfectly.

java - Google MapMaker maximumSize Beta? -

mapmaker maximumsize in google guava library marked @beta . it's useful feature set maximum size when use cache , use in production code. experience other google products beta can pretty solid. know why it's @beta ? it used in production @ google , there no immediate plans on api changes. there consensus support weighted entries , we'll continue evolve algorithm closer concurrentlinkedhashmap's. in case @beta indicate method contract isn't officially set in stone.

Java: How to read available audio tracks in a video file? -

some video files contain multiple audio tracks. multiple languages example. there library gets information these audio tracks? names of audio tracks sufficient. it should support common formats (mkv, avi,...) i believe best monolithic media file library available vlc player. seem remember there java wrapper, it's not maintained (like java wrappers more few weeks old heheh).

Automatically Install Package-Based Perl Modules in Ubuntu -

i install perl modules required specific perl script, such listed perl-depends tool. however, in ubuntu using apt-get , meaning installing modules through package repository , not through cpan. most similar questions (such this one ) address ways of doing through cpan. debian-apt-pm

Matlab: Question regarding dataset() -

i have around 50 elements (1 column char array) in workspace. there way put these elements single dataset without addressing each 1 explicitly. have variable x, lists element names. i've tried lots of things nothing seems work. dataset() not helpful in case. can me final obstacle before may see results. if understand correctly, have 50 variables in workspace, names of stored in variable x (which presume 50-element cell array). following example (with 3 variables) illustrates how set of variables 1 dataset : >> var1 = ['a'; 'b'; 'c']; %# 3-by-1 character array >> var2 = ['d'; 'e'; 'f']; %# 3-by-1 character array >> var3 = ['g'; 'h'; 'i']; %# 3-by-1 character array >> x = {'var1'; 'var2'; 'var3'}; %# variable names in 3-by-1 cell array >> vardata = cellfun(@eval,x,'uniformoutput',false) %# collect variable data

cocoa touch - can't set tableview frame in landscape, parameters set but view is strange [screenshot attached] -

Image
i try set frame of uitableview (190,0,610,768) in landscape mode. frame parameters correctly set display not correct. to contrast result, added uilabel same frame bottom: cgrect frame = cgrectmake(190, 0, 610, 768); uilabel *lbtb = [[uilabel alloc] initwithframe:frame]; lbtb.backgroundcolor = [uicolor cyancolor]; lbtb.text = @""; [self.view addsubview:lbtb]; dishmenuvc = [[dishmenuviewcontroller alloc] init] ; dishmenuvc.view.frame = frame; dishmenuvc.view.backgroundcolor = [uicolor redcolor]; dishmenuvc.view.alpha = 0.5; [self.view addsubview:dishmenuvc.view]; i found workaround problem creating container uiview intended frame , add tableview subview.

iphone - UIWebView webViewDidStartLoad is called with request which properties are null -

i debugging uiwebview in order information improve performance (on server , iphone). noticed after calling loadrequest: callback - (void)webviewdidstartload:(uiwebview *)webview_ is called, each parameter of request null. i using following statement: - (void)webviewdidstartload:(uiwebview *)webview_{ nslog(@"%@ \t start request: %@ \n absolute: %@ \n method: %@ \n parameters: %@ \n port: %@ \n query: %@ \n header fields: %@ \n httpbody: %@ \n httpbodystream: %@", [nsdate date], [[webview_ request] maindocumenturl], [[[webview_ request] maindocumenturl] absolutestring], [[webview_ request] httpmethod], [[[webview_ request] maindocumenturl] parameterstring], [[[webview_ request] maindocumenturl] port], [[[webview_ request] maindocumenturl] query], [[webview_ request] allhttpheaderfields], [[webview_ request] httpbody], [[webview_ request] httpbodystream]); } the output is: 2011-05-11 17:15:34 +0200 start request: (null) absolute: (null) method:

Git merge mangles source files -

i've run strange behavior git , wondering if has experience it. have 2 branches, stable , master, have merged after resolving conflicts. unfortunately, master branch (which should reflect of changes in stable) not compile due insertion of markup git. looks this: >>>>>>> stable ======= duplicate code appear between markups, presumably differentiate between code in different branches. ideas? thoughts? doinitwrong? correct, mangling git's way of showing conflicts are. called 'conflict markers'. when resolving conflicts need remove characters go along , pick correct side keep (old vs new code). once have resolved conflicts , removed characters/lines add , commit changes finish merging of branches. here tutorial basic branching , merging , right git manual on resolving conflicts .

audio - create sounds for iphone game -

i'm searching possibility or wherewith can create sounds e.g. iphone game. there applications? thanks in advance you might interested in this: you check soundsnap gettings sounds. can use audacity making sounds on own http://www.soundsnap.com/ http://audacity.sourceforge.net/ so resource: how game sound or how create sound iphone

How to popup a dialog in another frame using jquery-ui -

i'm creating small web page using jquery-ui-1.8 having frameset , 3 frames. <frameset id="mainframe"cols="25%,*,25%"> <frame id="f1" src="test.php"></frame> <frame id="f2" src="test2.php"/> <frame /> </frameset> then have added button test.php file loaded @ first frame (f1) , div test2.php loaded @ second frame. <div id="testdiv"> test 2</div> then need pop jquery dialog "testdiv" on second frame (f2) when click on button in f1. i tried following solutions given @ these threads. [1] - display jquery dialog in parent window var $jparent = window.parent.jquery.noconflict(); var dlg1 = $jparent('#testdiv'); dlg1.dialog(); and [2] - jquery ui dialog display inside frame, bookmarklet? var frame = window.frames[1]; var div = $(frame.document.getelementbyid("testdiv")); div.html("my popup contents")

ruby - Savon raises error inside Rails app, but not inside irb -

i'm using savon library soap requests work. , i'm using same code within irb , rails application. when i'm running irb works should, rails generate error "no method 'to_hash' nil:nilclass" inside savon's do_request -> respond_with methods. here's code (the same when running within irb or rails): # setup savon client soap requests client = savon::client.new "http://www.webservicex.net/country.asmx?wsdl" # test if "webservicex.net" server , running actions = client.wsdl.soap_actions raise "soap server down" if actions.nil? or actions.length <= 0 # country list resp = client.request :get_countries raise "no response countries" if resp.nil? resp = resp[:get_countries_response][:get_countries_result] none of exceptions risen nor code far 'pinging server' executed. what's wrong , how fix that? it's problem httpi gem - https://github.com/rubiii/savo

iphone - Refresh a tab in xcode? -

is there way refresh tab's content in xcode? i'm setting tab follows: [[dappdelegate tabbarcontroller] setselectedindex:1]; however, when try , different screen, same tab screen still selected. there way have tab reload data? thanks, graeme. i use hack around seems work case: if(tabbarcontroller.selectedindex == 1) { [tabbarcontroller setselectedindex:-1]; [tabbarcontroller setselectedindex:1]; } else { [tabbarcontroller setselectedindex:1]; }

asp.net - How do I parse JSON dates with ActionScript? -

i have dates in json generated asp.net pages using json.net library. these dates this: "lastmodifieddate": "\/date(1301412877000-0400)\/" how parse these actionscript flex 3 professional? i'd have in native data format. note: i'm not asking here how parse json feed as3corelib. have json deserialized library dates not decoded. why need know how decode date format. you'll want use as3corelib 's json implementation decode string objects.

ajax - JQuery $.post() submitting multiple forms instead of just one -

i have page several forms on 1 page. have button (outside forms) want submit 1 form, form data getting submitted forms. $("#indiv_save").click( function() { alert($("#indiv_form").serialize()); // shows correct form $.post("/admin/update", $("#indiv_form").serialize(), function(data) { notify(data); // quick , easy feedback }); }); the alert() call shows want submit, firebug shows fields being submitted forms after .post(), though serialize() function identical. all forms have different names , element ids. what doing wrong? you making ajax post , returning. depending on button, it's going attempt submit page's forms. need prevent default action: $('#indiv_save').click(function(e) { e.preventdefault(); // code here });

How to create a jquery mobile ordered list with list symbols set to outside? -

<ol data-role="listview"> <li> <h3>heading</h3> <p>description</p> </li> </ol> the result is: 1. heading description i want: 1. heading description i have thought have stuck list-style-position:outside inline style li tag. no luck. if remove listview data-role, style applied correctly. some how listview date-role manipulating styles, can't figure out how though... i've searched list-style-position line in jquery mobile css , js files , no results returned, going on here? some please? ps. using jquery mobile 1.0a4.1 looks need add custom css live example: http://jsfiddle.net/7bn2z/43/ live example #2: http://jsfiddle.net/7bn2z/48/ (fixed layout little) html: <div data-role="page" data-theme="b" id="jqm-home"> <div data-role="content"> <ol data-role="listview"