Posts

Showing posts from April, 2010

iphone - Need help opening callout of annotation on map automatically, when map first loads -

dear fellow iphone/objective-c developers: i have navigation based application iphone working allows user view selection table, on map. have annotation pinpoints user's selected location on map. per normal behaviour, if user clicks on annotation, callout appears details location. no problems here. question is, i'd callout appear automatically annotation, once user taken screen containing map, user not have click on annotation in order see details location, i'm not sure how this. have following method in "mapviewcontroller" class, bulk of map display work performed: - (void)viewdidload { [super viewdidload]; mkcoordinateregion region; mkcoordinatespan span; navbuttonappdelegate *delegate = [[uiapplication sharedapplication] delegate]; usercoord = delegate.userlocation.coordinate; region.center = usercoord; span.latitudedelta = 0.4; span.longitudedelta = 0.4; region.span = span; [mapview setmaptype:mkmaptypestandard]; [mapview setzoomenabled:yes

php - ffmpeg backgrounding? -

does know how background ffmpeg if executed php script? i've bee trying figure out while, absolutely nothing if nohupped/&/>dev/null/etc... can't seem run while not in focus when process video uploads php+ffmpeg, split tasks. script taking video upload queues job in beanstalkd , continues. second script runs indefinitely in background listens beanstalkd new videos process. this avoids issue of processing many videos @ once, encounter if forked ffmpeg background. if figure out way of forking ffmpeg background, you're better off using queuing system reason alone.

javascript - track mouse position to move images -

i have pretty simple page. <div id="index"> <img /> </div> the styling pretty simple too. #index {position:relative;} #index img {position:absolute; bottom:10%; right:10%; width:100%;} i use % image can resized proportionally if browser window resizes. never mind that. the problem is, i'm trying emulate effect on flash site : http://www.tatogomez.com/ image in bottom right of screen. when move mouse top left, image move bit more right bottom. when move mouse center, image revert original position. it's kinda i'm giving shadow/lighting effect mouse lighting , image object, except need moving animation. my code this $(document).ready(function($){ $('#index').mousemove( function(e){ $(this).children('img').each( function(){ var totalwidth = $(window).width(); var totalheight = $(window).height(); var centerx = $(

day of the week in Java -

this question has answer here: how determine day of week passing specific date? 13 answers php has built-in function takes data , returns day of week (monday, tuesday, etc.). java have similar function? import java.util.*; public class getday { public static void main(string[] args) { calendar calendar = new gregoriancalendar(); calendar.set(2011, 1, 9); // 1 = feb months 0 based remember system.out.println(calendar.get(calendar.day_of_week)); } }

64bit - Building 64 bit gcc on linux -

i wanted use "-m64" compiler option of gcc, , when tried on machine, got following error ... [root@-dell-1950-server]/root/abc/utilities>gcc -m64 porting1.c porting1.c:1: sorry, unimplemented: 64-bit mode not compiled in when checked processor info, following output. [root@-dell-1950-server]/root/abc/utilities/gcc-4.1.1-new/gcc-4.1.1>dmidecode -t 4 # dmidecode 2.7 smbios 2.4 present. handle 0x0400, dmi type 4, 40 bytes. processor information socket designation: cpu1 type: central processor family: xeon manufacturer: intel id: f6 06 00 00 ff fb eb bf signature: type 0, family 6, model 15, stepping 6 flags: fpu (floating-point unit on-chip) vme (virtual mode extension) de (debugging extension) pse (page size extension) tsc (time stamp counter) msr (model specific registers) pae (physical address

wcf - Is Fetching and updating in same web service operation symantically correct -

i know wcf or web service platform not prevent developers mixing fetch , update in same operation. mean mentioned below list updatedate( sometype datacontract) syntactically correct format supported in wcf. ok in service oriented world, industry wide standard support this. one problem see right away violate first law of soa atomicity there other issues associated? it's wider wcf: method appears get/fetch (i.e. name) should ideally not perform updates. the classic bad example property getter alters state of objects, introducing possibility of unwanted side effects.

c# - Need help with string manipulation please -

if string has values :- mystring = "good morning,good night"; and want reverse values in follows:- i want final values in mystring as:- mystring = "good night,good morning"; how achieve this? appreaciated. thanks. :) how about: string mystring = "good morning,good night"; string[] substrings = mystring.split(','); mystring = string.join(",", substrings.reverse()); or if write these 1 liners: mystring = string.join(",", mystring.split(',').reverse());

winapi - How to remove .zip file in c on windows? (error: Directory not empty) -

#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include "win32-dirent.h" #include <windows.h> #include <io.h> #include <direct.h> #define maxfilepath 1024 bool isdirectory(char* path) { win32_find_data w32fd; handle hfindfile; hfindfile = findfirstfile((ptchar)path, &w32fd); if(hfindfile == invalid_handle_value) { return false; } return w32fd.dwfileattributes & (file_attribute_directory); } int rd(const char* foldername) { dir *dir; struct dirent *ent; dir = opendir(foldername); if(dir != null) { while((ent = readdir(dir)) != null) { if(strcmp(ent->d_name , ".") == 0 || strcmp(ent->d_name, "..") == 0) { continue; } ch

extjs - How to "reset" Lovecombo combobox? -

i have form lovocombo of cities on it. @ start current value of lovecombo emptytext value = "select city". select options , submit form, , current values changed 'london' (for example). else there "reset" button on form, have handler: handler: function (){ lovecombo.setvalue(false); lovecombo.clearvalue(); } but lovecombo don`t takes on emptytext value = "select city", when "reset" button clicked. how reset or set emptytext value lovecombo? ps: sorry english. lovecombo homepage http://lovcombo.extjs.eu/ since lovcombo extends ext.form.combobox, inherits reset() method. try: handler: function() { lovecombo.reset(); }

android - i got a runtime error as "java.lang.RuntimeException: Unable to instantiate activity ComponentInfo" what would be the reason? -

i trying run listfragment prog during got below error in log cat , emulator shown force close in alert box. can 1 solve problem please.... error: 02-09 07:24:55.633: error/androidruntime(517): java.lang.runtimeexception: unable instantiate activity componentinfo{com.android.frags/com.android.frags.fragsactivity}: java.lang.classcastexception: com.android.frags.fragsactivity cannot cast android.app.activity you need make activity extend activity class. public class fragsactivity extends activity also shouldn't use com.android part of namespace.

arrays - Delphi TBytes - how to copy? -

point opimization here. now: type tsomeclass=class(tobject) private datawrite: tbytes; ... end; function tsomeclass.getpacket: tbytes; begin setlength(result, length(datawrite)); move(datawrite[0],result[0],length(datawrite)); end; what want achieve: function tsomeclass.getpacket: tbytes; begin result := datawrite; end; because arrays in delphi pointers first element, latter , writes 4 bytes faster. correct? that work note working on same byte array in client code calls getpacket . might bad idea. consider network library additional compression or encryption on byte array. creates lot of possibilites interact class without using exposed interface - bad. imho copying better option here. btw: how big arrays talking here?

php - Converting a multi-dimensional array into HTML form fields - how? -

i'm trying take multidimensional array , convert html form fields, this: <input type="hidden" name="c_record[contact][0][name]" value="first last"> <input type="hidden" name="c_record[contact][0][date_submitted][date]" value="2010-01-01"> <input type="hidden" name="c_record[contact][0][date_submitted][hour]" value="10"> <input type="hidden" name="c_record[contact][0][date_submitted][min]" value="08"> <input type="hidden" name="c_record[contact][0][date_submitted][sec]" value="16"> <input type="hidden" name="c_record[contact][0][ip_address]" value="192.168.1.1"> here have far: $fields = array( 'c_record' => array( 'contact' => array( 0 => array( 'name' => 'first last',

xcode - Search Bar in Native Meassage App in iPhone -

i need know type of view used in search bar of create message screen. bar searches , adds tabs per contacts selected , and gives option of selecting contacts form contact list througha button. i not able understand whether uitextview ot uiview variable size of uitextview. can please me out in regard. thsnks in advance!! since no 1 has yet answered problem, , have found solution answer own problem. yes, search bar used in native application uiscrollview variable sized uitextview converts selected name number. thanks

asp.net - Using a constant string in URL using url Rewriting or Routes -

i have asp.net website should have variable string in url. the content of website changes depending on year. idea have year in url in clean way. http://localhost/year/index.aspx i have done in mvc routing, have no idea how in asp.net. need 1 route guess. url's before (index.aspx, ...) basically in stead of having ?year=2011 behind every url in website i'd have value in route. how , should use that? rewriting or routes? have here http://urlrewriter.net/ download assembly, add reference in project. in web.config file in configsections element add this <section name="rewriter" requirepermission="false" type="intelligencia.urlrewriter.configuration.rewriterconfigurationsectionhandler, intelligencia.urlrewriter"/> create 1 more section <rewriter> <rewrite url="http://localhost/(.*).aspx" to="http://localhost/index.aspx?year=$1"/> </rewriter> try content need http://local

ruby: use module include in instance method of class -

have @ code below initshared.rb module initshared def init_shared @shared_obj = "foobar" end end myclass.rb class myclass def initialize() end def init file_name = dir.pwd+"/initshared.rb" if file.file?(file_name) require file_name include initshared if self.respond_to?'init_shared' init_shared puts @shared_obj end end end end the include initshared dosn't work since inside method . i want check file , include module , access variables in module. instead of using samnang's singleton_class.send(:include, initshared) you can use extend initshared it same, version independent. include module objects own singleton class.

c# - Throwing exceptions from .NET web service -

i have set of web services generated using [webmethod] attribute. considered "good practice" throw argumentexception such method if arguments aren't specified (and no sensible defaults used)? if so, should exception caught , re-thrown in order log both on server , client? no, throwing exceptions web services not practice, .net exceptions (like argumentexception ) aren't supported cross platform (think of how java client need respond). the standard mechanism indicating exceptions in web services soap fault . with .asmx , throwing soapexception generate fault you. if move wcf, can @ faultcontracts . for improved debugging of remote exceptions between .net client , .net server, cheat , send exception across wire using includeexceptiondetailinfaults in config. exception must serializable in order work. however, want turn off before system reaches production. as aside, find if caller's soap request call poorly formed (e.g. if arguments includ

I want git to give me a list of files within a folder unedited since a given revision -

i’ve been working on project needs touch every view (so within app/views folder), there’s lot of views. given combination of bash , git, how can list of files haven’t committed edit since given revision? there's neater way of doing this, think following works: if last revision before changes fa1afe1 , can find files changed under app/views with: git diff --name-only fa1afe1 -- app/views also, can see of files git tracking under app/views with: git ls-files app/views now can find lines appear in output of 1 of commands using comm -3 , bash's process substitution syntax: comm -3 <(git diff --name-only fa1afe1 -- app/views|sort) <(git ls-files app/views|sort) (you might find clearer send output of 2 commands temporary files , use comm rather use process substitution, since you'll have solution work /bin/sh , may easier understand.) this command show files deleted in changes since fa1afe1 , since files won't appear in output of git ls

printing - Trying to print colored source code from TextMate - "Could not locate your theme file!" -

i'm trying print java source code syntax coloring textmate, , recommended way seems to generate html source first. however, when choose bundles --> textmate --> create html document, message "could not locate theme file!" appears. not knowing "theme file" is, i'm pretty lost how can fix this. appreciated. thanks! ok, (think i) figured out. going preferences --> fonts & colors , selecting "mac classic" color theme (which selected, btw) seemingly recreated whatever was missing. html generation works fine.

blackberry - it displays only text,but not the image -

i developed code below.in used listfield ,one bitmapfield , 1 label field,when run ,it displays text on list field row,but not image don't know did mistake,so,plz,any 1 me know did mistake help class tasklistfield extends mainscreen implements listfieldcallback { private vector rows; private bitmap p1; listfield list; tablerowmanager row; public tasklistfield() { super(); list=new listfield() { protected void drawfocus(graphics graphics, boolean on) { } }; list.setrowheight(40); list.setemptystring("hooray, no tasks here!", drawstyle.hcenter); list.setcallback(this); p1 = bitmap.getbitmapresource("res/images/10.png"); rows = new vector(); (int x = 1; x < 13; x++) { row = new tablerowmanager(); labelfield task = new labelfield("" + string.valueof(x), drawstyle.ellipsis

sql - Returning unique results in a joined select -

i need query check msdb-database sql server agent job results. query follows: select convert(varchar(30), serverproperty('servername')), a.run_status, b.run_requested_date, c.name, case c.enabled when 1 'enabled' else 'disabled' end, convert(varchar(10), convert(datetime, rtrim(19000101))+(a.run_duration * 9 + a.run_duration % 10000 * 6 + a.run_duration % 100 * 10) / 216e4, 108), b.next_scheduled_run_date (msdb.dbo.sysjobhistory left join msdb.dbo.sysjobactivity b on b.job_history_id = a.instance_id) join msdb.dbo.sysjobs c on b.job_id = c.job_id order c.name so far good, running returns several results same jobs depending on how many times have ran until query. no good. want 1 result per job, , latest. if add the string: b.session_id=(select max(session_id) msdb.dbo.sysjobactivity) works better, lists latest jobs depending on sess

c# - LINQ to Dynamics CRM Query filtering records locally -

i have written linq crm query using crm 2011 rc (v5) linq-to-crm provider. have locally declared list<t> want join crm entity , want query executed on crm server. example might help: myobject myobject = new myobject(); list<myaccount> myaccountslist = new list<myaccount>(); myaccountslist.add(new myaccount() {accountnumber = "123"}; myaccountslist.add(new myaccount() {accountnumber = "456"}; myobject.listofaccounts = myaccountslist; var accountsquery = ax in myobject.listofaccounts join in orgcontext.createquery<customaccountentity>() on ax.accountnumber equals a.account_number select a; foreach(var item in accountsquery) { console.writeline("id of record retrieved: " + a.id.tostring()); } the code above compiles , executes, however, filtering of records being performed locally after retrieving entire crm entity recordset. when crm entity contains thousands of rows query perfor

Android Facebook SDK - Problem with authorizeCallback() -

i have android application which, among other things, publishes updates on facebook. i created code according this example , works fine. difference in code , 1 in link above extended onactivityresult mentioned on official facebook sdk android page. @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); facebookclient.authorizecallback(requestcode, resultcode, data); } sometimes however, null pointer exception on line call "facebook.authorizecallback()" within onactivityresult() method. this has never occurred on of mobile phones or emulators. however, keep getting user crash reports, droid , t-mobile mytouch 3g phones. tried lot unable reproduce problem. body have idea wrong ? by looking in facebook.java code seems dialoglistener , kept private parameter in class... when calling authorizecallback() assume dialoglistener exits , isn't null. if phone s

php - Disable APC Cache for cached files? -

i have quite large website, in there forum powered phpbb. have apc enabled 1gb of ram. phpbb generates lot of php files of cache (60 000-70 000 in case), , rapidly fill apc memory . thinking disable apc caching of such files through apc.filter option. in opinion, make sense? i haven't run phpbb in long time, answer conditional: if there's actual php code in cache files, there's worth had in caching in apc. might go step further , they're incredibly valuable cache, since phpbb feels these files used enough have been worth caching. if contain static html or other content that's not php, filter them out or convince phpbb give them alternate extension. how fast running through data in apc? if you're cycling through cache misses incredibly quickly, you've got problem. if number of misses stays constant , low on time wouldn't worry it. if you're storing lots of user data in apc might way shave down. apc.php great way more details on a

php - How to create a "dynamic" forms - and store data and form design in two fields -

i making system @ company has lot of field workers need fill out lot of certificates @ every job do. via tablet pc running mysql/php/apache system syncs main server. these certificates change lot - newer revisions time. , if make in traditional database/php/html setup - changing designs , databases forever, not talk handling revisions of certificate designs , data. (adding, removing fields) i looking way can design form , store design , data in 1 row (in 2 fields) - in mysql database. when reading specific row - have correct design matched data can merge together. can done via xforms - browser needs plugin this. xforms tedious. it easy text fields only, need checkboxes, lists , on.... any brainstorming appreciated. what using nosql mongodb storing certifacates? work you?

Emptying a file with php -

possible duplicate: php: there command can delete contents of file without opening it? how empty .txt file on server php command? here's way emptying if exists , doesn't have problem of using file_exists , the file may cease exist between file_exists call , fopen call. $f = @fopen("filename.txt", "r+"); if ($f !== false) { ftruncate($f, 0); fclose($f); }

c++ - Why is a default ctor needed for this inner (nested) struct? -

i trying compile code similar snippet below: class system { private: struct configuration { configuration(/*params*/); configuration(const configuration&); configuration& operator=(const configuration&); ~configuration(); /* member variables */ } m_config; explicit system(const configuration& cfg); // non copyable constructable, non assignable system(const system&); system& operator= (const system&); public: system(); ~system(); } //implementation system::system() { m_config = configuration(/*default params*/); // .... } compiler error: no matching function call ‘system::configuration::configuration()’ when provide (even merely declaration not definition of) default constructor nested struct, error dissapears - why?! misc details: gcc version 4.4.3 (ubuntu 4.4.3-4ubuntu5) m_config first default constructed , assigned. use member list set value directly. system::s

WPF MVVM ListView does not update! -

i'm using prism v4 , , mvvm. in viewmodel have: private tb_company tb; public tb_company tb { { return this.tb; } private set { if ( this.tb != value ) { this.tb = value; this.raisepropertychanged(() => this.tb); } } } in page, have datagrid (i tried listview too, don't work!): <datagrid itemssource="{binding tb.tb_address.rl_address_phone}" .../> rl_address_phone list of phones of company... so, in moment add phone list: private void mycommand() { ... tb.tb_address.rl_address_phone.add( new rl_address_phone { tb_phone = new tb_phone { nu_phone = _txttelefone, st_type = _txttipotelefone } }); ... } but nothing happens ui... in debug, list fullfiled.... should update ui? the rl

php - Regular Expression for Screen Solution -

i have following string 540x360 [par 1:1 dar 3:2] the result want 540x360 how can , please suggest in future able solve these kind of problem self. if want use regular expression can use: $string = "540x360 [par 1:1 dar 3:2]"; $matches = array(); preg_match('/^(\d+x\d+)/i', $string, &$matches); echo $matches[0];

image - Edit android ninepatch png programly (change color) -

is there way change color of ninepatch image(png) programly on android ? know how bitmap not ninepatch... thanks helping me. regards jim ninepatch images standard png files, 1-pixel border around outside mark repeated areas. can edit them in image editor, , long leave 1-pixel outer border alone, they'll continue work fine. see here how constructed .

fluent nhibernate - Extension methods on a poco class in subsonic? -

i'm considering switching fluent nhibernate subsonic nhib seems have massive memory footprint i'm not enjoying, want check how subsonic (the simple repository probably) cope with: adding fields database: @ moment can map dictionary value field in database cool, possible in subsonic? (or similar?) fwiw: dynamiccomponent(x => x.propertybag, getdynamiccomponentpart); propertybag dictionary. many many relationships cascading saves/deletes mapping complex object xml or varchar(max) column (seralize xml obviously) * adding fields database: @ moment can map dictionary value field in database cool, possible in subsonic? (or similar?) fwiw: dynamiccomponent(x => x.propertybag, getdynamiccomponentpart); propertybag dictionary. adding fields simple. add field table, re-generate classes t4 template. you won't mapping beyond basic primitive types, though. not dictionary in field. * many many relationships you have make cu

bdd - Behat over Cucumber in PHP -

don't me wrong. think both projects fantastic. but both php , ruby developer wonder if there there compelling reasons, besides possible language barrier, why 1 choose behat on cucumber (with cuke4php ) bdd when working php or php framework. i'm behat developer. why i've developed behat instead of cucumber customization: speed. there's no simple way bootstrap/run php ruby code. means need implement wires/proxies , other things, makes tests insanely slower. , slower tests not test, it's code eats customer's money. extensibility. there few php developers know ruby. it's hard use tool, many don't understand! examples written cucumber ruby code , can't @ cucumber sources, because, let's say, don't know ruby. it's buying submarine when need taxi. in terms of features, behat , cucumber same (i've worked hard achieve this). in terms of speed/extensibility/logic php developer's perspective - behat better, becaus

html - CSS image loading intermittently -

i can't provide info except (maybe 1 in every 25 runs) image call css not load properly. image there because if hover mouse on it shows in places. the html: <div class="body-top"> blah </div> the css: .body-top {background:url(../images/top.gif) no-repeat; height:55px; width: 970px; margin:0; padding:0;} it running on visual studio's development server. any ideas? edit : hovering on image doesn't make appear, it's when hover on link on image it's hard without seeing page, but. can verify none of elements inside have background colour? try adding test things: .body-top *{background:none !important;} don't use final code, because !important flag stop background working elements inside .body-top

how to use Dokuwiki for creating a common user manual -

i trying use dokuwiki creating software user manual, given have create 3 user manuals same product in different platform , changes less. there way in dokuwiki create common user manual can used different products? for specifics of dokuwiki i'd recommend site export plugin (primarily because made , use our documentation well). you can create chapters of book normal page in wiki. when comes combining them different books, create page called "toc" in different namespace. in there have following syntax (see github page details): * [[namespace:chapter1]] * [[namespace:chapter1.1]] * [[namespace:chapter1.2]] * [[namespace:chapter2]] * [[namespace:chapter2.1]] * [[namespace:chapter2.2]] now can export namespace roc option enabled - , merged 1 document. use pdf export custom book-like styles (this primarily).

jasper reports - Height issues in iReport -

i've got report needs print landscape letter size. report uses detailed header 1st page, , more concise header every other page. problem i'm running having both headers defined in ireport has made report large fit letter size constraints (in terms of height). when print report, correct headers display on correct pages, report large , contains massive amounts of whitespace. printer tries center report , ends clipping portions of header , footer midsection of report. is there way configure report have 2 versions of 1 report band (in case pageheader band) , provide expression determine when each version should print? or can group bands somehow ireport knows occupy same space? any appreciated. i couldn't ever find sort of fancy way of doing this, made 2 headers subreports , included both in same location on pageheader band. problem solved.

security - what info can you find out by knowing an IP, how and what tools/ sites are needed for this? -

i put site , saving ip addresses of users adding overhead. trying figure of benefit justified. i never used ip address other correlating user activity trending , site usage metrics. i know ip information can used audit , trace things user of ip. what info can gather useful based sole on ip address , how can info? if user criminal can report them fbi. trying block attacker based on ip address short sighted. proxy servers free, ip addresses pennies.

silverlight - Please suggest some resources from which explain silver-light business application in detail -

Image
http://msdn.microsoft.com/en-us/library/ee796239%28v=vs.91%29.aspx#y3078 but, hobbyist (small time :) ) dont understand every thing provided in these tutorials, please suggest online links explain each , used in great , simple detail. please provide references books same this book reference business applications developers silverlight

windows phone 7 - WP7 and unit testing -

is there unit test framework wp7? i have tried both mbunit , visual studio unittestframework, can't work. cannot reference wp7 project since has different version of system.dll stefano yes, there's wp7 version of silverlight unit test framework , written jeff wilcox.

javascript - Need regex to match unformatted phone number syntax -

i need regex javascript match phone number stripped of characters except numbers , 'x' (for extension). here example formats: 12223334444 2223334444 2223334444x5555 you guaranteed have minimum of 10 numerical digits, leading '1' , extension optional. there no limit on number of numerical digits may appear after 'x'. want numbers split following backreferences: (1)(222)(333)(4444)x(5555) the parenthesis above demonstrate how want number split backreferences. first set of parenthesis assigned backreference $1, example. so far, here i've come regex. keep in mind i'm not great regex, , regexlib.com hasn't helped me out in department. (\d{3})(\d{3})(\d{4}) the above regex handles 2nd case in list of example test cases in first code snippet above. however, regex needs modified handle both optional '1' , extension. on this? thanks! regex option seems fine me. var subject = '2223334444'; result = subject.replace(/

javascript - How to change an image link based on content in another page -

i want put image on page (page1) link page (page2), want image displayed 1 of 2 possible images, based on content of page2. page2 in case wiki page reports current status. if there no problems report, image on page1 green in color. if there problems listed, image red. my plan accomplishing use html comment tags embed either <!--statusred--> or <!--statusgreen--> on wiki page. figured use javascript, jquery or similar check presence of comment , alter image on page1 accordingly. not sure how this. i open other ideas. whatever solution come with, has simple wiki user change without requiring user change page1 (which not part of wiki). update: what ended doing: $(document).ready(function() { statuscheck(); setinterval(statuscheck,300000); } function statuscheck() { $.ajax({ type: "get", url: "path/to/wiki/mainpage.ashx", datatype: "html", cache: false, success: function(html) {

Android: Reading specific nodes from XML without parsing entire document -

i'm feeling kind of dumb here. storing sets of data organized @ top level chapter > scene > dialogue. dialogue has several attributes , has additional data stored in organized hierarchy (sets of conditions, or sets of choices, each attributes of own read). imagine choose-your-own-adventure book , of rules being stored in xml document. seemed best way store it, i'd welcome contradiction. i start on chapter 1, scene 1, dialogue 1. each dialogue, either through attributes or conditions, direct me single new node, example, chapter 3, scene 2, dialogue 8. never have parse entire document looking chapter, scene, or dialogue tags. however, want parse given dialogue node @ included sets of conditions or choices. i can not life of me find how specify, in android, equivalent of: xmlresourceparser parser = getresources().getxml((r.xml.script).getchild[chapter][scene][dialogue]); and while parse entire document every time , iterate off match indexes , know am, seems uncal

apache - linking C++ library so as it is callable as C -

i not expert @ c/c++ linking magic. g++ , cygwin neither, rather novice indeed. imagine have executable, (apache server in case), accepts c library modules. e.g. compiled file libmyserver.so if guts coding in c++, , export only vanilla functions , example static member functions of class i'd call cexporttoc... if linking magic make library libmyserver reachable program requesting c libraries ? you don't @ link time, declare compiler not mangle names when generating code (which of course disallows overloads). put declarations of things want expose c extern "c" { ... } block. see e.g. faq . classes pretty out of luck here, unless you're willing lot of work , live pita. , then, single compiler writer can break code (in ways show in runtime bugs, not in compile errors).

java - Where should I escape HTML strings, JSP page or Servlets? -

this question has answer here: xss prevention in jsp/servlet web application 8 answers i appreciate providing me set of clear guidelines or ruling handling escaping strings. use escaping strings apache commons-lang-x.x.jar library. stringescapeutils.escapehtml(string toescape) method. i need know: (1) better escape strings, on jsp page or in servlet? (2) recommend stringescapeutils.escapehtml(..) or <c:out> jstl (3) handling multiline strings, better, use <br> directly in string, or \n , nl2br() method: string strerror = "invalid username.\nplease try again."; or string strerror = "invalid username.<br>please try again."; (4) how go escaping strings receive wild cards, example: string strerror = "invalid user [%s].<br>please specify user." (5) since javascript escape characters different. sho

java - struts2 <s:select -

i trying populate <s:select options using struts action class. how initialiase class within jsp? instead of using myjsp.action - have myjsp.jsp , invoke myjsp.action within jsp itself. thanks based upon explanation in comment, feel how should doing this: user -> httprequest -> action (populate data required s:select in httprequest) | v user <- httpresponse <- onsuccess, show final.jsp (this jsp can include searchform.jsp) the s:select in searchform rendered correctly.

database - Free server side anti virus / security / trojan protection for file uploads? -

i allowing users upload photos photo albums, , attach files (documents now) mail attachments. assume need anti virus/security tool in place scan files first in case people upload infected stuff. 2 questions: 1) there 'free' or open source tools can use or integrate environment: codeignitor php? 2) how secure upload area rest of system? virus scanner fails catch virus , uploaded, how prevent infecting other files? can upload area sandboxed in or , use filepath users access content not spread other parts of system? there clamav free virus scanner. install , like: function virus_detected($filename) { $clamscan = "/usr/local/bin/clamscan"; $result = exec("$clamscan -i --no-summary $filename"); return strlen($result)?true:false; } as security, make sure temporary files uploaded directory outside of web root. should verify file type, rename file other it's original file name , append appropriate extension (gif,jpg,bmp,p

xslt - Detecting if a node exists? -

i have set of data called <testdata> many nodes inside. how detect if node exists or not? i've tried <xsl:if test="/testdata"> and <xsl:if test="../testdata"> neither 1 works. i'm sure possible i'm not sure how. :p for context xml file laid out this <overall> <body/> <state/> <data/>(the 1 want access </overall> i'm in <body> tag, though i'd access globally. shouldn't /overall/data work? edit 2: right have index data need use @ anytime when apply templates tags inside of body. how tell, while in body, data exists? does, doesn't. can't control that. :) try count(.//testdata) &gt; 0 . however if context node textdata , want test whether has somenode child or not write: <xsl:if test="somenode"> ... </xsl:if> but think that's not want. think should read on different techniques of writing xslt styles

jboss5.x - Unexpected token UNIQUE, requires COLLATION in statement [SET DATABASE UNIQUE]) -

whenever connect hsqldb application deployed on jboss 5.1, throws exception : caused by: org.jboss.resource.jbossresourceexception: not create connection; - nested throwable: (java.sql.sqlexception: error in script file line: 1 unexpected token unique, requires collation in statement [set database unique]) . my hsqldb script file reads below : `set database unique name hsqldb2e0bad63b3 set database gc 0 set database default result memory rows 0 set database event log level 0 .....` does have idea thos exception means or should change in hsqldb configuration? regards, satya your database files created version 2.x, version of database engine running on jboss 5.1 1.8.x. should able replace hsqldb.jar in jboss configuration new version.

jQuery core: display a floating image -

Image
i have a php-script listing 20 card game players per page: i have photo/avatar-urls of players , i'd display them - floating image when mouse hovers on corresponding link/name. not have dimensions of photos though. how means of jquery core (without plugins) please? i need create image holder , hide first? $('body').append('<div id="avatar"><img src="no_avatar.gif"</div>').hide(); and on mouse hover event replace img's src attribute , make #avatar visible? please me code should store url of each photo attribute of corresponding <a href="player_profile.php">player name</a> while generating them php-script? and how deal situations when mouse hovering near bottom of web page (i.e. how place image best, visible) thank you! alex i'm still learning jquery, let me take crack @ this. let's suppose there div each player info , want image appear when user moves mouse on it.

java - question about singleton classes and threads -

i'm trying learn singleton classes , how can used in application keep thread safe. let's suppose have singleton class called indexupdater reference obtained follows: public static synchronized indexupdater getindexupdater() { if (ref == null) // it's ok, can call constructor ref = new indexupdater(); return ref; } private static indexupdater ref; let's suppose there other methods in class actual work (update indicies, etc.). i'm trying understand how accessing , using singleton work 2 threads. let's suppose in time 1, thread 1 gets reference class, through call indexupdater iu = indexupdater.getindexupdater(); then, in time 2, using reference iu, method within class called iu.updateindex thread 1. happen in time 2, second thread tries reference class. , access methods within singleton or prevented long first thread has active reference class. i'm assuming latter (or else how work?) i'd make sure bef

javascript - How to save "add another" data in a form? -

i've got form. in form, user can fill out few fields, click "add". data gets turned html element, , form gets (partially) cleared can type more data. i'm trying figure out how store data when clicks "add" can submitted later. should serialize (json? or there more compact representation--doesn't need human readable) , store in hidden field? if so, happens when adds 2nd object? deserialize old data, , reserialize 2 objects together? seems inefficient. do somehow clone form, hide it, , update name attributes don't conflict, , kill myself trying parse these stupid things array later? what's best approach? create hidden field incremental numerical suffix somewhere in name. var fields = $('input[type=hidden][name^=foo_]', form).length; $('<input type="hidden" name="foo_' + (fields + 1) + '">').val(val).appendto(form); submit usual way, jquery.serialize() , on. finally intercep

javascript - How to add a PHP variable into my Jquery image slider? -

i'm using jquery image slider , , want add couple of things it. when load full-size image, want show 2 divs, 1 image title , other description of picture i'm new javascript , can't work out how it. i have tried adding document.write commands javascript code test it, outputs text on blank page, want appear when image loaded , can position divs want them. i appreciate help, in advance! jquery code: $("img.thumb").click(function(){ $("#fp_gallery").append("<div/>").text("description"); $("#fp_gallery").prepend("<div/>").text("title"); } try this. based on demo site.

ruby - How to do if X is equal to either one of these values (xxx,eeee,yyyy,dadadad) -

this question has answer here: test if variable matches of several strings w/o long if-elsif chain, or case-when 3 answers example if fileext "doc" if fileext equal either ("doc", "xls", "ppt") any ideas? use regular expression: do_x if file_ext =~ /\a(doc|xls|ppt)\z/ or, if have large enough list of things writing regex feels impractical, like file_extensions = %w(xls csv doc txt odf jpg png blah blah blah blah blah) do_x if file_extensions.include?(file_ext) of course there option of testing each value individually: do_x if file_ext == "doc" || file_ext == "xls" || ... || file_ext == "zzz"

java - How to calculate exact value of a trig function? -

i writing "triangle solver" app android, , wondering if possible implement exact values trig ratios , radian measures. example, 90 degrees output "pi / 2" instead of 1.57079632679... i know in order exact value radian measure, divide pi , convert fraction. don't know how convert decimal fraction. like this: int decimal = anglemeasure / math.pi; somemethodtoturnitintoafraction(decimal); i don't know begin trig ratios. you need take number , divide each of "special" numbers: pi,e, sqrt(2), sqrt(3), sqrt(5). after each division, determine if resulting number close exact fraction. last part, use continued fraction algorithm find approximations number. there criteria can use in continued fraction expansion determine if approximation exact. if nice fraction small numbers exact that's answer - fraction times special number divided @ beginning. oh , consider "1" divisor simple fractions come out too. been there, done t

regex - What would be the best (runtime performance) application or pattern or code or library for matching string patterns -

have been trying figure out decent way of matching string patterns. try best provide information can regarding trying do. the simplest thougt there specified patterns , want know of these patterns match or partially given request. specified patterns hardly change. amount of requests 10k per day results have pe provided asap , runtime performance highest priority. i have been thinking of using assembly compiled regular expression in c# this, not sure if headed in right direction. scenario: data file: let's assume data provided xml request in known schema format. has anywehere between 5-20 rows of data. each row has 10-30 columns. each of columns can have data in pre-defined pattern. example: a1- "3 digits" followed "." follwed "2 digits" - [0-9]{3}.[0-9]{2} a2- "1 character" follwoed "digits" - [a-z][0-9]{4} the sample like: <data> <r1> <a1>123.45</a1> <a2&

group by - Combining MySQL queries yields incorrect answer -

ok, have lot of sales data each of our clients. have been able find query total volume of sales each sales rep using simple query: select `merchantaddresses`.`rep number` `rep number`, sum(`residuals_2010_12`.`qual cr vol` + `residuals_2010_12`.`qual ch vol`) `vol_2010_12`, `reps`.`first` `first`, `reps`.`last` `last` `merchantaddresses`, `residuals_2010_12`, `reps` `residuals_2010_12`.`mid` = `merchantaddresses`.`mid` , `reps`.`id` = `merchantaddresses`.`rep number` group `merchantaddresses`.`rep number` order sum(`residuals_2010_12`.`qual cr vol` + `residuals_2010_12`.`qual ch vol`) desc this code works totally fine, returning table grouping total sales sales rep single month. @ moment, have been running 3 separate queries sales data 3 months. want combine these 3 queries one. so, did following: select `merchantaddresses`.`rep number` `rep number`, sum(`residuals_2010_12`.`qual cr vol` + `residuals_2010_12`.`qua

Cocoa - Custom appearance of NSStatusItem in menu bar -

it easy set title , length of nsstatusitem. is possible change appearance of nsstatusitem entirely, , replace custom view? for example, if want nsstatusitem whole row of icons surrounded border, rather single icon, , each icon can separately clicked. possible? got it. can use nsstatusitem's setview: method customize appearance of nsstatusitem. an example of here .

c - Linked list containing other linked lists & free -

i have generic linked list implementation node struct containing void* data , list struct holds reference head. here problem node in linked list may hold reference linked list via void*. causes memory leaks when free bigger list containing smaller lists. wondering there way check if void* pointing list follow , free or data. if add key beginning of struct magic number can check dereferencing void* , figure out list? edit: callers don't insert smaller lists inserted functions not want callers deal relasing multiple lists 1 hold pointer to. this question depends on responsibility clean entries in list. if struct responsible cleaning memory referenced void * fields, have bigger problem @ hand here, namely given void * referencing arbitrary block of memory can never know right way deallocate is. example, if have implementation of dynamic array along lines of c++ std::vector , void * might point @ struct contains pointer, , list need know has descend struct recursi

android - POPUP on Boot Completed -

trying create popup after every boot completed confirmation. able boot_completed message while opening alertdialog crashing, below code lines using. please suggest public class bootreceiver extends broadcastreceiver { private static final string tag = "bootreceiver"; @override public void onreceive(context context, intent intent) { string action = intent.getaction(); log.d(tag, "broadcastreceiver:" + action); if (action.equals(intent.action_boot_completed)) { log.d(tag, "action_boot_completeted receved" ); charsequence text = "boot completed!"; int duration = toast.length_short; toast.maketext(context,text,toast.length_short).show(); alertdialog.builder alertdialog = new alertdialog.builder(context); alertdialog.setmessage(&qu

javascript - Can't load multiple document.write scripts -

i'm trying load multiple document.write scripts single document. this: :docwrite.js document.write('<a href="#"><img src='myimage.gif'/></a>'); myhtml.html $('.myclass').each( function( index, element ){ var script = unescape('%3cscript src="'+docwrite.js+'" type="text/javascript"%3e%3c/script%3e'); $(element).html( script ); }); <div class="myclass">document.write loads image here</div> <div class="myclass">stops here , hangs</div> <div class="myclass">same</div> the first div loads script , image written inside stops after that. change docwrite.js don't have access it. ideas how can fix this? in advance. i think you're missing quotes around docwrite.js , try instead: $('.myclass').each( function( index, element ){ var script = unescape('%3cscript src="' + 'do

Javascript - Declare Domain persistent CSS or JS -

currently have local network(intranet) set 40,000 directional html files not following file layout ever. files contain no headers while others contain no bodies others contain custom scripts , on. my issue of these files have no styling ever. have default styles no trademarking or colors. apply basic styles these pages. the gotchas we can't use iframes because messes bookmarking system , i not intend edit files individual or batch script due amount of files. not want change headers output. conclusion so there way declare domain persistent styles/scripts domain sort of cookie. browser specific code fine considering can talk users(on intranet) using ie,firefox, or google chrome if want styles. if user needs visit initial page set styles domain ok. not want plugins installed because users not have admin access. hidden or outdated tecnologies ok vbscript in ie hidden features in firefox chris blogged http://css-tricks.com/using-css-without-html/ . edit: end

sml - firstElement::Middle::LastElement REGEX -

if want check input can last element right away, there form of regex do: fun somefunction (firstelement::middleoflist::lastelement) so can last element there appears last function lists in list structure; need?