Posts

Showing posts from March, 2013

c# - Restrict QueryOver by child collection using nHibernate -

i trying parent entity entities in child collection in list. for example: public class parent { public virtual int id {get;set;} public virtual list<child> children {get;set;} } public class child { public virtual int id {get;set;} public virtual string name {get;set;} } i've tried various combinations of joins , restrictions can't seem hit spot. so please suggestions. current example below: public ilist<lead> getallavailable(string[] names) { var result = session.createcriteria<parent>() .createcriteria("children") .add(expression.in("name", names)).list<parent>(); return result; } edit: this sql equivilent: select * dbo.parent join ( select p.id dbo.parent p join dbo.parenttochildren on p.id = dbo.parentstochildren.parent_id join dbo.child on dbo.parenttochildren.child_id = d

c# - Listen for MediaEnded event in another window -

i'm making simple c# wpf video player app. i have 2 windows: mainwindow (parent window) contains mediaelement display video. playlistwindow (child window) window contains listbox displays .avi files in approot path. currently, when double-click on listbox item, plays video in mainwindow. have auto-play feature next item in list automatically played when current video ends. i playlistwindow listen mediaended event triggered mediaelement in mainwindow can perform action on listbox in playlistwindow. how can subscribe mediaended event playlistwindow? edit add: ended using different approach shown below. don't think best way it, works me. public partial class mainwindow : window { playlistwindow plwindow = new playlistwindow(); public mainwindow() { initializecomponent(); } private void mainwindow_loaded(object sender, routedeventargs e) { plwindow.owner = this; plwindow.show(); } private void videowindow_

jasper reports - Fixed header in Excel using JasperReports -

how can create excel report fixed header using japserreports? mean need header fixed when scroll excel file. this possible adding couple properties in jrxml file each report. take @ advanced excel features freeze panes. if wanted freeze after first column header (down left side basically) this: <statictext> <reportelement style="sans_bold" mode="opaque" x="0" y="60" width="104" height="20" forecolor="#ffffff" backcolor="#666666"> <property name="net.sf.jasperreports.export.xls.auto.filter" value="start"/> <property name="net.sf.jasperreports.export.xls.column.width" value="110"/> <property name="net.sf.jasperreports.export.xls.freeze.column.edge" value="left"/> </reportelement> &

arrays - How to do typeof object[*] in C#? -

i'm new c# have searched web hour , no joy... i need ascertain whether object non-zero index array, i.e. object[*] i've tried: if(v != null && v.gettype() == typeof(object[*])) and if(v object[*]) as overloaded methods method(object v) , method(object[*] v) all result in compilation errors. as can't cast object[*] object[] , test getlowerbound(0) how hell can test type? (please don't tell me bad code/design, it's coming excel cannot change that). try type.isarray , type.getarrayrank , type.getelementtype if necessary. if need call getlowerbound can safely cast object system.array .

iphone - iOS RestKit what is the purpose of [mappingProvider setMapping:forKeyPath:] method? -

i'm working through restkit relationship mapping example , cannot understand purpose of these method calls , or if there's typo in calls. refer to? when object loader encounter content @ these key paths? [objectmanager.mappingprovider setmapping:usermapping forkeypath:@"user"]; [objectmanager.mappingprovider setmapping:taskmapping forkeypath:@"task"]; [objectmanager.mappingprovider setmapping:projectmapping forkeypath:@"project"]; the json file being loaded data has 3 objects: project, tasks , user. note tasks plural . there 3 entities defined in core data model : user, task , project. these start capital letters. finally, nsmanagedobject classes derived data model have relationships: task>assigneduser , user>tasks , project being regular nsobject should @"task" @"tasks"? @implementation rkrelationshipmappingexample - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { s

ISO 8601 Date Formatter in Objective for iPhone not setting offset correctly -

thank in advance help. i trying create iso 8601 date formatter iphone application , can not offset come out correctly. need result time zone in gmt , located in est , when tested @ 2:33 pm march 6th 2012 got 2012-03-06t14:33:35+0000 due zone difference need -05:00 show instead of +0000 the code using is: nsdateformatter* dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"yyyy-mm-dd't'hh:mm:ss zz"]; nstimezone *gmt = [nstimezone timezonewithabbreviation:@"gmt"]; [dateformatter settimezone:gmt]; nnsdate *gmtdate = [[nsdate alloc] init]; datestring = [dateformatter stringfromdate:gmtdate]; nslog(@"date string: %@", datestring); have tried setting time zone est? give -0500

osx - Alternatives to _blocksActionWhenModal Cocoa private method? -

our os x application shows modal forms @ times, , 1 of downsides of modal forms menu items don't work when have modal form visible. can click menu item normal, no selectors called on target. this bad because if there's modal form showing, want user able command-q quit app, normal apps on on os x. however, there undocumented method _blocksactionwhenmodal returns yes default. if override return no, menu items start working on modal forms, means can handled properly. i'd find alternative this, i'd prefer not use undocumented method (as apple change new os release). there way of achieving same result here? "not using modal forms" isn't option. for 10.6+, use [nswindow setpreventsapplicationterminationwhenmodal:] on modal window allow quit.

c# - App throws OutOfMemoryExceptions on a tablet computer but enough memory left -

i've written wpf application. runs on every pc , test tablet pc, too. only on 1 tablet computer customer throws outofmemoryexeptions after main form has loaded. icons visible on form, loaded later in startup procedure not visible. images not big or (just 200 kb each). task manager says there 800 mb used (it has 2 gb memory). there enough memory... interesting application runs if customer uninstalls intel graphic driver, not solution. specs of tablet: kupa x11 2 gb memory, intel gma 600 graphics , windows 7 professional. anyone idea can be? thank you, daniel .net applications limited amount of memory can use the .net runtime allow app use approx 3gb of address space. however, depending on how you're allocating, there may not contiguous block of memory large enough satisfy allocation. also, .net imposes 2gb object size limit, trying allocate array larger 2gb fail - msdn question

faceted search - SOLR multiple facet w query -

i need facet sorl based on multiple categories, 3 categorise exact. issue have need different facet seperate queries, i'm trying determine if can one. in essense i'd filter.query instead of count, i'd values of matches. the problem im matchign against multiple fields same value, lets field1=*bah* or field2=*bah* or field3=*bah* , facet on field1,field2, , field3 the query return docs who's field match, on facet, field1, doesnt include matchign field1 bah.. includes docs matched field2 , field3, who's field1 value not bah . id use fq={!tag} facet.field{!ex} produce facets of field1 field1 matching values, facet 2 withoutly field2 matchign value.. , on. is possible 1 query in solr? here basic setup <document> <field1>bah boo</field1> <field2>bah bing</field2> <field3>boo bar</field3> </document> <document> <field1>bar boo</field1> <field2>bah bong</field2> <f

sql server - Sql converted to Linq - Left Join, Group, Min and Sum -

i have simple piece of sql need... select min(pb.id) id, min(pb.quantity) requested, sum(pbi.quantity) total pickbatchitems pb left join pickbatchitemlocations pbi on pb.id = pbi.pickbatchitemid group pb.id results in... id, requested, total 1 100 null 2 200 165 3 200 null this want need in linq. so far have... var pick = (from pb in db.pickitems join pbi in db.pickitemlocations on pb.id equals pbi.pickbatchitemid tempjoin reslist in tempjoin.defaultifempty() pb.id == ipickitemid group reslist pb.id g select new { id = g.key, requestedquantity = g.min(???????????????????????), sentquantity = g.sum(a => a.quantity == null ? 0 : a.quantity), }).firstordefault(); how can requestedquantity ? update: thanks 'david b' have answer: var pick = (from pb in db.pickbatchitems join pbi in db.pickbatch

java - Email Internationalization using Velocity/FreeMarker Templates -

how can achieve i18n using templating engine such velocity or freemarker constructing email body? typically people tend create templates like: <h3>${message.hi} ${user.username}, ${message.welcome}</h3> <div> ${message.link}<a href="mailto:${user.emailaddress}">${user.emailaddress}</a>. </div> and have resource bundle created properties like: message.hi=hi message.welcome=welcome spring! message.link=click here send email. this creates 1 basic problem: if .vm files becomes large many lines of text, becomes tedious translate , manage each of them in separate resource bundle ( .properties ) files. what trying is, have separate .vm file created each language, mytemplate_en_gb.vm, mytemplate_fr_fr.vm, mytemplate_de_de.vm and somehow tell velocity/spring pick right 1 based on input locale. is possible in spring? or should looking @ perhaps more simple , obvious alternative approaches? note: have seen spring tutorial on

android - How do you populate an edittext field instead of a listview when using speech recognition? -

i using code google's sample voice recognition class. write top 5 results listview want top result posted in edittext field. possible? or possible populate listview automatically copy results edittext field? any appreciated. if want 1 result back, should specify in intent use start voice recognition activity: private void startvoicerecognitionactivity() { intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_calling_package, getclass().getpackage().getname()); intent.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form); //since want one, request 1 intent.putextra(recognizerintent.extra_max_results, 1); intent.putextra(recognizerintent.extra_language, "en-us"); startactivityforresult(intent, 1234); } and pull single result , set edittext: @override public void onactivityresult(int requestcode, int resultcode, intent data) {

java - Implement semaphores using the monitor concept -

i trying implement semaphores using monitor concept in java. i.e java class implements weak counting semaphore (using methods init, signal , wait) can tell me if class correct (if not problem): class mymonitor { int counter = 0; //init public mymonitor( int init ) { counter = init; } //signal public synchronized void s() { counter++; notify(); } //wait public synchronized void w() { if( counter == 0 ) { try { wait(); } catch(interruptedexception e) { } } counter--; } } if correct, give me idea of how can test class. it should (with while , not if ): class yourmonitor { int counter = 0; //init public mymonitor( int init ) { counter = init; } //signal public synchronized void s() { counter++; notifyall(); } //wait public syn

android - clearing background when replacing listfragments in the same area -

i have typical setup on left there listfragment displaying categories while on right listfragement displays details. for example: when category selected: left right a1 b a2 c when category b selected: left right b1 b c now when switching between , b on left right side updates correctly showing 2 lines a1,a2 , 1 line b1. (clearing a2) now give option @ different data of , b a1 (lower a) has a1 (not a1 , a2, a1, a2) i replacing right listfragment 1 displaying caps a1,a2, b2... second listfragment displaying lower a1, b2... the problem when replacing right listfragmentcaps listfragmentlower right area not cleared , on sees on screen: left right (with listfragmentcaps) a1 b a2 c switching listfragmentlower left right (with listfragmentlower) a1 b a2 <- left on of listfragmentcaps c the **a2** listfragmentcaps still visible though listfragmentlower has replaced it. other screen content of listfragmentcaps

Can't collect data from WCF -

my problem when downloading data webservice, 1250 records, works should (done in 30 seconds), when wants 1300 records , method works indefinitely (it's ends after 10 minutes timeout). tested sql query , query executes quickly(also tested in wcf service debugging), when there data transfer slows down. web config binding: <basichttpbinding> <binding name="soapuniglobshopservice" closetimeout="00:10:00" opentimeout="00:10:00" receivetimeout="00:10:00" sendtimeout="00:10:00" allowcookies="false" bypassproxyonlocal="false" hostnamecomparisonmode="strongwildcard" maxbuffersize="4000000" maxbufferpoolsize="524288" maxreceivedmessagesize="4000000" messageencoding="text" textencoding="utf-8" transfermode="buffered" usedefaultwebproxy="true"> <readerquotas maxdepth="32" maxstringcontentlength

SDL2 Event Loop on Android - cannot push any new events into the queue -

i trying use sdl2 in new android application, should work well: http://wilbefast.com/2011/11/11/recent-sdl-android-goodies/ it compiles without single problem , there sample project quite easy start using it. compiled library , started application, created event loop - in sdl 1.2 , tried push events function: int sdl_pushevent(sdl_event * event); however, fails error value -1. defined sdl_main function source file: http://hg.libsdl.org/sdl/file/6bb657898f55/src/main/android/sdl_android_main.cpp my sdl_main function contains simple event loop: sdl_event event; (;;) { sdl_waitevent(&event); switch (event.type) { case sdl_quit: return; case some_event: break; default: break; } } and that's all, no threads, no mutexes, no waits, simple main function. noticed event loop process events, event.type equals 2151293988, looks source sdlsurface instance, created in java code: http://hg.libsdl.org/sdl/file/6bb657898f55/andro

c++ - How to assign a subclass to an abstract class pointer in a function? -

void player::move(board &board, solver &solver){ position* best = solver.find_best_move(&board); cout<<"score: "<<best->get_score()<<endl; cout<<"board: "; best->get_board()->print_board(); board = *(best->get_board()); board * b(best->get_board()); cout<<"test: "; b->print_board(); board = *b; } i'm trying make actual board reference equal new board after calling function. board abstract class , get_board() returning pointer board subclass of board has attribute. however,after move function called, board same board before call move. possible assign subclass pointer abstract super class, while modifying actual value? issue of slicing seems occurring. i use board* pointer instead of board& reference, since subclass involved: void player::move(board **board, solver &solver) { position *best = solver.find_best_move(*board); cout <

git-mv showing file deleted -

when run git-mv file1 file2 , file moved file1 file2 i'd expect. sometimes, though, git status gives me 'odd' output. when run git-mv f1 f2 , git status : # changes committed: # (use "git reset head <file>..." unstage) # # renamed: f1 -> f2 that's i'd expect. other times, though, after i've committed f2 , get: # changes committed: # (use "git reset head <file>..." unstage) # # deleted: f1 this happens after i've committed new file. don't know why happens - seems occur @ random (because renamed: f1->f2 message, i'm expecting). i'd know why messages saying i've deleted file after run git mv , , steps i'd have gone through produce - i've tried reproduce, , got renamed:.. ; 10 minutes ago got deleted:... on file i'd git-mv ed 10 minutes before that . it's confusing me greatly. it sounds renamed f1 f2 , committed addition of f2 , not removal of f1

How to create a variable name from the value of a string in Ruby on Rails? -

i want create instance variable in controller used in view: foo = "bar" instance_variable_set("#{foo}", "cornholio") in view, use @bar that: @bar => "cornholio" this generates error: 'bar' not allowed instance variable name working in rails 3.1 this instance_variable_set("#{foo}", "cornholio") needs read instance_variable_set("@#{foo}", "cornholio") based on this post . tried in irb ruby 1.93; post 2009.

sql - extract valid IP from a field in oracle DB in C -

i facing problem in c language extract valid ip(v4 , v6) oracle db example. 1, if field having ip : 10.2.33.4.5-34 should able extract 10.2.33.4 only 2, if field have abc-100.2.33.4.545 extract 100.2.33.4 hope there solution in c . thanks , regards, mohib str1[]="10.2.33.4.5-34" substr(1,11,str1); str2[]="abc-100.2.33.4.545" substr(5,14,str2) the above code should used in c.

comet - Bayaux protocol implementation for Jquery -

we have application running on jquery. in this, there requirement of implementing bayaux protocol . afaik, dojo has implemented bayaux protocol in form of cometd . as dependent on jquery, can not import whole dojo toolkit release implementation. my question - there implementation of bayaux(cometd) jquery ? if not, there micro framework provides implementation? if not, can extract ony bayaux related stuff dojo toolkit , exclude else? seems question has been answered before: comet , jquery http://cometd.org/documentation/cometd-javascript (references jquery/jquery.cometd.js) http://cometd.org/documentation/howtos/primer the jquery plugin exists in tutorial above.

asp.net - Firefox cache in C# -

in asp site there's function upload images , display upload image in data grid view problem when upload image , replace later 1 it's doesn't appear change in data grid without reload page.but problem doesn't occured in google chrome . your image getting cached on browser. try either forcing have different url every time updated adding last modified header response image request, the write time of file.

facebook php api multiple users one computer force logout -

i working on application going operate in kiosk, point allow users while @ business able login facebook , after logging in posts message saying there, afterwords given coupon. the problem has arisen after have logged in , logged out, next person logs in account ends posting previous user, continues adnauseum. after getting coupon script automatically logs them out after 15 seconds , returns application home screen next user. when login, able returns them page asking permission post, pulling of previous users information. code being called in page after being sent logging in on facebook. <?php //include facebook php sdk include_once 'coupongenerator/facebook.php'; //start session if necessary if( session_id() ) { } else { session_start(); } //instantiate facebook library app id , app secret $facebook = new facebook(array( 'appid' => '00000000000', 'secret' => '000000000000000000000', 'cookie' => true, 'status

sql - How to prepend(?) number in text field with '0'? -

i have text field in microsoft access consists of digits. don't know if these digits preceded blank characters or not. what want if field has '1' want convert '0001', if has '89' want convert '0089', etc. meaning want make field consistent in length of 4 characters , pad number appropriate number of '0's. how do this? can use calculated field approach? can convert database sql if sql has easy way this. thanks. you can use format() function transform string of digits. format() doesn't care whether or not digits preceded spaces. ? format("89","0000") 0089 ? format(" 89","0000") 0089 if want display field values format in query: select format([yourtextfield],"0000") yourtable; if want change how they're stored: update yourtable set [yourtextfield] = format([yourtextfield],"0000"); edit : @onedaywhen suggested using check constaint or validat

arduino - Android ADK development in practice - what are best practices? -

i'm trying clear picture of what's involved practically when doing android/adk development. there scattered android/adk related questions on few relevant answers. i have questions related development , idea of answer - great if can confirm thoughs or provide additional information. can android/adk development done within avd? answer: no, because pc cannot function usb slave. adk usb host in accessory mode, (without extreme levels of hacking) adk cannot connected development pc running avd will ddms / debugger work on device that's hooked adk? answer: no, since device can connected either development pc or adk, not both. can connect adk using micro usb port pc , arduino-level serial debugging, that's quite different debugging java code android device running what workflow used when developping android / adk? answer: write arduino code in sketch, upload adk development board. connect physical android device yo development pc write code in eclipse, co

Issue in Push Notifications (APNS) -

i getting following message while sending push notifications php code: # warning: stream_socket_client() [function.stream-socket-client]: ssl operation failed code 1. openssl error messages: error:14094414:ssl routines:ssl3_read_bytes:sslv3 alert certificate revoked in /opt/lampp/htdocs/world-vision/admin/iphonepush/admin.php on line 225 warning: stream_socket_client() [function.stream-socket-client]: failed enable crypto in /opt/lampp/htdocs/world-vision/admin/iphonepush/admin.php on line 225 warning: stream_socket_client() [function.stream-socket-client]: unable connect ssl://gateway.sandbox.push.apple.com:2195 (unknown error) in /opt/lampp/htdocs/world-vision/admin/iphonepush/admin.php on line 225 warning: fwrite(): supplied argument not valid stream resource in /opt/lampp/htdocs/world-vision/admin/iphonepush/admin.php on line 243 warning: fclose(): supplied argument not valid stream resource in /opt/lampp/htdocs/world-vision/admin/iphonepush/admin.

c# - specifying a generic type parameter using a string -

suppose have method public void whatever<t>() { ... } suppose have type in form of string var mytype = "system.string"; normally, i'd call method like: whatever<string>(); but i'd able call using mytype somehow. possible? know doesn't work, conceptually: whatever<type.gettype(mytype)>(); you can use reflection , methodinfo.makegenericmethod this reflect method want call methodinfo , make generic , invoke it. something (notice top of head (no vs here), might not perfect yet should started): type type = myobject.gettype(); methodinfo method = type.getmethod("nameofmethod"); methodinfo genericmethod = method.makegenericmethod(typeof(string)); genericmethod.invoke(myobject, new object[] { "thestring" } );

How to use Powershell to get a websites HostHeader -

i trying use powershell pull hostheaders websites installed. once have down, want hostheaders websites using port 80 , port 443. so far able use get-webbinding cmdlet to pull information website, unsure how use query websites hostheader information. in output of get-webbinding command see host headers part of bindinginformation column, unsure how host header info. however when query website via get-webbinding -hostheader (hostheadername) i information back, believe there way use get-webbinding query hostheader information. if there way information, please let me know. have had no luck trying use get-website you have split bindinginformation on : , last part: get-webbinding | select -expand bindinginformation | %{$_.split(':')[-1]}

linux - gnu make foreach on empty list -

i have foreach in makefile seems execute when list empty - throws errors when shouldnt. how fix it? flagerror := $(foreach package, $(pkglist), $(if $(wildcard $(package)/lib),,$(error can't find package:$(package)))) it works fine when have list of packages in pkglist. when empty (i have no dependencies) should pass through. instead, exits error cant find package:

this - JQuery checkbox object reference -

i have following code (that works) toggle iphone style checkbox: $('.iphone-style').live('click', function() { checkboxid = '#' + $(this).attr('rel'); if($(checkboxid)[0].checked == false) { $(this).animate({backgroundposition: '0% 100%'}); $(checkboxid)[0].checked = true; $(this).removeclass('off').addclass('on'); } else { $(this).animate({backgroundposition: '100% 0%'}); $(checkboxid)[0].checked = false; $(this).removeclass('on').addclass('off'); } }); in different function, specific checkbox (aerialview) unchecked when checkbox (photostyles) unchecked. don't know how correctly replace 'this' reference more specific. have following (which doesn't work):

database - How to return column that matched the query in Solr..? -

i using apache solr searching database..!! suppose have indexed 4 columns 1 of table..!!..i want columns that contains query term returned in response..!!..is possible..?? for example : i have table cars columns : name, displayname, description, extra ..!! now make query , : localhost:8983/solr/select?q=maruti&wt=json now in rows name may contain word " maruti " so, in return, want name (along other fixed fields id ) .. similarly, if description contains word, description should returned..and not other columns..!! how can acheive this..?? you may able solr 4 , custom transformer - reading of documentation seem indicate much. quite bit of work, think. may have write front-end filter, difficult complex queries. update : here's how in solr without custom transformers, etc. enable highlighting 4 columns: hl=on&hl.fl=name,displayname,description,extra solr return "highlighting" structure containing key , field(s)

javascript - How to use the !! expression? -

possible duplicate: what !! (not not) operator in javascript? reference - symbol mean in javascript? i find js code write : !!undefined , !!false; the jquery source code (jquery 1.7.0.js: line 748): grep: function( elems, callback, inv ) { var ret = [], retval; inv = !!inv; // go through array, saving items // pass validator function ( var = 0, length = elems.length; < length; i++ ){ retval = !!callback( elems[ ], ); if ( inv !== retval ) { ret.push( elems[ ] ); } } return ret; } ! means opposite so !! means double opposite . it commonly used in case: var check = !!(window.something && window.runthis) //if exists , runthis exists, //check = true //if 1 of them not exist, //check = false commonly used in checking browser compatibly .

ruby on rails - Should I create an MVC Model in this scenario? -

i have rails3.2 application, , use formtastic , client-side-validations gems. i have user, tablereservation standard crud operations, validations work aforementioned gems. :user :has_many :table_reservations :table_reservation :belongs_to :user now need add 'search' form user details on table_reservation takes in user.first_name , user.last_name , table_reservation.secret_token . need add validations prevent normal user submitting invalid form. i wondering if should create tablereservationsearch model keep working formtastic, client_side_validations gems before. @ same time, feels creating model unnecessary since not stored in database. aain model need not inherit activerecord include activemodel::validations , etc. can write simple form , use jquery validations plugin or similar. so confused when create model such purposes , when not to! what best way of approaching subject? i think looking nested field validation . please issue . ma

cakephp - Date validation not working for the date format 'd-M-Y' -

in cakephp-1.2 application, using date format 01-jan-2012 which date validation rule should use test it? i tried array('date', 'dmy') . not working. by reading book, can see cannot use separators in date validation field algorithm have selected. need create custom validation rule. can using custom regular expression rule: '/^((31(?!\\ (feb(ruary)?|apr(il)?|june?|(sep(?=\\b|t)t?|nov)(ember)?)))|((30|29)(?!\\ feb(ruary)?))|(29(?=\\ feb(ruary)?\\ (((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\\d|2[0-8])\\-(jan(uary)?|feb(ruary)?|ma(r(ch)?|y)|apr(il)?|ju((ly?)|(ne?))|aug(ust)?|oct(ober)?|(sep(?=\\b|t)t?|nov|dec)(ember)?)\\-((1[6-9]|[2-9]\\d)\\d{2})$/'; note: rule modified version of canned ones cake shipped with. so, want do: var $validate = array( 'born' => array( 'rule' => '/^((31(?!\\ (feb(ruary)?|apr(il)?|june?|(sep(?=\\b|t)t?|nov)(ember)?)))|((30|2

blackberry - how to get the events from native calendar for a specific date -

i trying events native calendar date given user,i not able events date specific.how can ? private void getevents() { try { eventlist eventlist = (eventlist)pim.getinstance().openpimlist(pim.event_list, pim.read_only); enumeration events = eventlist.items(); while (events.hasmoreelements()) { event event = (event)events.nextelement(); if(eventlist.issupportedfield(event.location) && event.countvalues(event.location) > 0) { string location = event.getstring(event.location, 0); dialog.alert(location); } if(eventlist.issupportedfield(event.summary) && event.countvalues(event.summary) > 0) { string subject = event.getstring(event.summary, 0); dialog.alert(subject); } if(eventlist.issupportedfield(event.start) && event.countvalues(ev

What will be the correct java application type as per my need? -

i want create application upon java technology can of them: a standalone desktop application on swing, a webstart application, a web application deployed on apache tomcat or google app engine. coming type , nature of application, network based application such retail application based on 3 layers employee , manager , administrator . now things sure: administrator single whole application. managers appointed every branch (or every store). every branch/store have 4-5 employees . respective manager , employees connected via lan. every branch's manager connected administrator or vice versa. the administrator application web-based app, can accessed admin where. now confusion employee , manager consoles, want have one application can accessed both employee , manager per authentication, on same branch confused type of application. any type of application used in of roles. you need understand pros , cons of each approach, , make own choices

javascript - 'event' equivalent in firefox -

i using following code , works fine in chrome. function daybind(xyzvalue) { if(event.type == 'click') alert('mouse clicked') } note there no 'event' variable passed function still available me in case of chrome. when use firefox 'event' undefined. tried using following workarounds: var e=arguments[0] || event; also: var e=window.event || event; but none of them worked me. there 'event' equivalent in firefox? because ie , chrome put event in global object window , can it. in firefox, need let first parameter event. function daybind(event, xyzvalue) { var e=event || window.event; if(event.type == 'click') alert('mouse clicked') }

linear algebra - Calculating an inverse matrix in Matlab -

i'm running optimization algorithm requires calculation of inverse of matrix. goal of algorithm eliminate negative values matrix , obtain new matrix b. basically, start known square matrices b , c of same size. i start calculating matrix equal to: a = b^-1 * c or in matlab: a = b\c; i use because matlab told me b\c more accurate inv(b)*c . the negative values in divided 2 , normalised it's rows have length of 1. using new a, calculate new b with: (1/n) * * c' = b^-1 where n scaling factor (# of columns in a). new b used again in first step , these iterations continue until negatives in gone. my problem have calculate b second equation , normalise it. invb = (1/n)*a*c'; b = inv(invb); i've been calculating b using inv(b^-1) after few iterations start getting messages b^-1 "close singular or badly scaled." this algorithm works smaller matrices (around 70x70) when gets 500x500 start getting these messages. are ther

android - Move imageview from scrollview to relativelayout -

how move imageview scrollview relativelayout using drag n drop (or else)? android 2.2/2.3.3+ need ontouch take imageview , smooth move relativelayout... sorry english.. i not sure if want u go xml (no graphical layout drag n drop), cut imagaview code , place outside scrollview layout, just remember scrollview can father 1 object u can create linearlayout around image from this <scrollview android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignparenttop="true" android:layout_above="@id/adview1"> <relativelayout android:id="@+id/relativelayout2" android:layout_width="fill_parent" android:layout_height="352dp" > <imagebutton android:id="@+id/imagebutton1" android:layout_width="wrap_content" android:layout_height="wrap_content"

time series - reading monthly returns in R -

i have following monthly equity data in file "equity.dat": 2010-03,1e+06 2010-03,1.00611e+06 2010-04,998465 2010-05,1.00727e+06 2010-06,1.00965e+06 i trying compute monthly returns using following code: library(performanceanalytics) y = return.read(filename="equity.dat", frequency = "m", sep=",", header=false) y z = return.calculate(y) z z[1]=0 #added remove na in first return but following error: error in read.zoo(filename, sep = sep, format = format, fun = fun, header = header, : index has bad entries @ data rows: 1 2 3 4 5 i checked out formatting return.read when using as.mon , why using yyyy-mm. should using different format. according ?return.read default format.in= here "%f" not format of data have specified. index must unique (in case not) or else must aggregated per ?zoo , ?read.zoo latter of uses internally: return.read(filename = "equity.dat", frequency = "m", sep = &q

jQuery draggable and appendTo doesn't work -

i use jquery ui draggable option appendto doesn't work. other option containment or grid work properly. here code: html <div id="demo"> </div> <div id="sidebar"> <div class="item"> </div> <div class="item"> </div> <div class="item"> </div> <div class="item"> </div> </div> script jquery(".item").draggable({ appendto: "#demo", grid: [ 10, 10 ], containment: "#demo" }); css #demo { width: 500px; height: 500px; border: 1px solid black; float: left; } #draggable { background: red; width: 50px; height: 50px; } #sidebar { float: left; width: 300px; } .item { cursor: pointer; background: black; width: 100px; height: 100px; margin: 10px; } here live demo: http://jsfiddle.net/fzjev/ here's open bug on issue - dragg

pointers - Unexpected C code output -

this c code: #include <stdio.h> int main(){ int x[] = {6,1,2,3,4,5}; int *p=0; p =&x[0]; while(*p!='\0'){ printf("%d",*p); p++; } return 0; } when run output 612345-448304448336 what digits after minus sign , why code giving this? the condition *p != '\0' , same *p != 0 , never met because array doesn't contain element of value 0 , , overrun array bounds , step undefined behaviour . instead, should control array range directly: for (int const * p = x; p != x + sizeof(x)/sizeof(x[0]); ++p) // or "p != x + 6" { printf("%d", *p); }

ruby - Rails user params only allows some certain attributes -

in controller have: if params[:sort].nil? @sort = "created_at" else @sort = params[:sort] end @konkurrencer = konkurrencer.where("id not in(?)", @clicked).order("#{@sort} desc") i add if params[:sort] different "created_at" , "ratings" , or "rating" should sort after "created_at" . first, .order("#{@sort} desc") isn't idea when @sort taken straight params. better use .order('? desc', @sort) . http://guides.rubyonrails.org/security.html#sql-injection i'm not sure if read question correctly i'm assuming want created_at default order other valid options being ratings , rating . @order = case params[:sort] when 'ratings' 'ratings desc' when 'rating' 'rating desc' else # else 'created_at desc' end @konkurrencer = konkurrencer.where("id not in(?)", @clicked).order(@order)

Ruby on Rails - How to represent "has_many" with enums? -

what's best solution in rails 3.2 app represent this: appointment = appointment.first appointment.days_of_the_week = [monday, friday] you can have @ embedded association railscast ryan bates explains how use bitmasks avoid use of table, think idea in case.

add button in show.jspx in a spring roo mvc project -

i've created spring roo project using 'getting started spring roo' starting point. project created in sts using roo 1.1.5. i've added neo4j graph , able create nodes simple edges , create web-part issuing 'controller --package ~.web'. the project simple web-app person , race node , participant-edge start-time, end-time, total-time , race-id. since edge participant @relatedtovia becomes @relationshipentity , want add button save participant. i found web-inf/tags/form/field/table.tagx add-, modify-, delete-buttons , friends defined, ie.: <c:if test="${update}"> <td class="utilbox"> .. but set variable update? i've looked through code created sts, unable find it. pardon if obvious. regards claus edit: i found out web-inf/tags/form/show.tagx have knobs enable/disable instance update-button: <c:if test="${empty update}"> <c:set var="update" va

java - html in JTextPane - strange box appear for tags -

Image
i haven't used html in jtextpane before , playing today. come across strange output. here simple code, htmlstr contains contains tag <aa> : public class htmlinjtextpanetest extends jframe { private jtextpane jtp; private string htmlstr= "<html><body><b>what this</b> <aa > ?? </body></html>"; public htmlinjtextpanetest() { jtp = new jtextpane(); jtp.setcontenttype("text/html"); jtp.settext(htmlstr); //jtp.seteditable(false); //jframe setup add(jtp); setdefaultcloseoperation(jframe.exit_on_close); setsize(200, 100); setvisible(true); } public static void main(string[] args) { new htmlinjtextpanetest(); } } the output of : i don't know why box (seems input field) appeared tag name aa in it? it disappears when set editable false on jtextpane object jtp . jtp.seteditable(false); can p

Add a <?php text ?> in a code -

i have code if(!document.getelementbyid('slider_cmp')) { var tooltip = document.createelement("div"); tooltip.classname = "cmp_tips"; tooltip.id = "cmp_tips"; tooltip.style.position = "absolute"; tooltip.style.top = '145px'; tooltip.style.left = '50px'; tooltip.style.display = "none"; tooltip.style.zindex = 9999; tooltip.innerhtml = "i need text here"; document.body.appendchild(tooltip); var sliderdiv = document.createelement("div"); sliderdiv.classname = "slide-out-div"; sliderdiv.id = "slider_cmp"; sliderdiv.style.display = "none"; var handler = '<div id="clickme"></div><div id="slidecontent"></div>'; sliderdiv.innerhtml= handler; document.body.appendchild(sliderdiv); if(cmplastcat > 0) { i need put <?php e

deployment - Capistrano: "cap deploy" doesn't take effect when deploying a Rails application -

i deploying rails application using capistrano. once have made changes app "cap deploy" , seems working properly, changes don't take effect. have "cap deploy:stop" , "cap deploy:start" , fine. guess has "cap deploy:restart" run when deploying changes. here deploy.rb: deploy.rb gist hope can help. thank in advance if restart unicorn using usr2 signal doesn't automatically know correct environment bundler. check out gist (specially before_exec block) , adjust unicorn config accordingly. https://gist.github.com/534668 hope helps.

php - randomise SQL results -

on webpage grab data of datebase , show on result page. i'd sort results , in order (thats translation of google translate). mean is: i've got field called "type" , has value a, b or c. when select data returns results a a b b b c c c but see a b c b c b c my question, best solution (is possible sql query?) thanks help! the idea behind solution make rows numbered 1 , based on provider. if rows type 'a' numbered 1..4 , rows type 'b' numbered 1 ..3 , rows type 'c' numbered 1..3, can wanted using "order by" on these numbers. for example, suppose table name "my_table" , has 2 fields, type , data. in order make rownum in mysql, use described here: rownum in mysql now lets suppose want select rows type 'a' , give them ascending row number. can following: select type,data,@rownuma := @rownuma+1 order_num my_table,(select @rownuma:=0) ra type='a' we can same other types, union result

c++ - Input values into custom class with "<<" -

i new c++, , trying figure out how following: i have class holds qlist. trying populate qlist demonstrated below. wondering how achieve this? done in numberlist constructor? populate mylist using method takes list of objects, , extracts them fill qlist, not work example below. numberlist mylist; mylist << 1 << 2 << 3; easy. numberlist & operator<<(numberlist & lhs, number_t rhs) { lhs.append(rhs); return lhs; } or, member function, this: numberlist & numberlist::operator<<(number_t rhs) { append(rhs); return *this; }

What is the call flow for this window.onload scenario in javascript -

index.html <!doctype html> <html> <head> <title></title> <script src="script1.js"></script> <script src="script2.js"></script> </head> <body> </body> </html> script1.js var main; window.onload = main; script2.js function main() { alert("foo"); } if throw breakpoint @ var main; , step through code in webstorm, appears to: load script1.js. load script2.js. call main() . however doesn't execute statement alert("foo") in function. explain what's going on in more detail? note: realize should avoid using onload . note: realize re-order scripts , show alert. note: if omit statement var main; , step 3 above not occur. bonus: in webstorm, shows value of window.onload field null , value of main void . difference between value of null , void ? because main empty variable @ point in script 1. window.onload

linear regression - A simple perceptron in Python -

http://en.wikipedia.org/wiki/perceptron#example my question is, why there 3 input values in each vector when nand takes 2 parameters , returns 1: http://en.wikipedia.org/wiki/sheffer_stroke#definition pasted code convenience: th = 0.1 learning_rate = 0.1 weights = [0, 0, 0] training_set = [((1, 0, 0), 1), ((1, 0, 1), 1), ((1, 1, 0), 1), ((1, 1, 1), 0)] def sum_function(values): return sum(value * weights[index] index, value in enumerate(values)) while true: print '-' * 60 error_count = 0 input_vector, desired_output in training_set: print weights result = 1 if sum_function(input_vector) > th else 0 error = desired_output - result if error != 0: error_count += 1 index, value in enumerate(input_vector): weights[index] += learning_rate * error * value if error_count == 0: break it because need 1 value constant input. - known bias. if notice have 3 weights

c - Undeclared array of structs being populated -

i've been doing bit of testing on code wrote when noticed had huge mistake in code regarding array sizes, yet program still ran fine. here's simplified code give idea of what's going on. #include "stdafx.h" #include <stdio.h> #include <stdlib.h> typedef struct { int score; }player; void printscore(player *p, int num); int main(void) { printf ("\nenter number of players (1 - 4)\n"); scanf ("%d", &numplayers); player *p = (player*)malloc(sizeof(player) * 3); (i=0;i<numplayers;i++) { printscore(p, i); } } void printscore(player *p, int num) { p[num].score = 1; printf ("%d\n", p[num].score); } the 3 in malloc function should numplayers. if leave @ 3, , enter higher number in menu, program crash, work sometimes. how possible? if i've enough memory reserved p[0], p[1], p[2], how (for example) p[15].score exist populated? it's called "un