Posts

Showing posts from September, 2011

height - TabHost on Facebook for Android -

Image
anyone know how facebook did this: know cannot change height of tabhost. i'm guessing laid "frank cho" view on tabhost give appearance of being shorter may wrong. know what's going on? you can have custom looking tab widgets. need set tab indicator custom layout (with drawables) , should go. here's semi-example: final tabhost host = gettabhost(); final textview indicator = (textview) getlayoutinflater().inflate( r.layout.tab_indicator, gettabwidget(), false); indicator.settext("tab title"); host.addtab(host.newtabspec("the tab tag") .setindicator(indicator) .setcontent([put content here])); } where tab_indicator layout can this: <textview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tab_label" android:layout_width="0dip" android:layout_height="fill_parent...

web applications - Off-site web server talking to on-site database for small business: is it feasible? -

i going putting website talk directly microsoft sql database hosted in small office. debating between having web server in same office vs. hosting professional hosting company. trick database must remain in office because of internal software requirements. internet speeds @ office 1.2 mb / 5 mb down. feasible have off-site web server talk microsoft sql database in office? restrict access database based on ip address. website not high-traffic means. would feasible have off-site web server talk microsoft sql database in office? it's impossible tell without seeing site, not, @ least not on permanent basis. performance horrible, , tying web site shop server, making availability of web site depend on availability of shop's dsl connection. power outage in store take down web site, , store owner's son downloading pirated movie slow down app's order processing. :) you should either frequent data exports (instead of permanent connection) store database on...

java - Correct way to retrieve collection using XPath? -

i've got xml file of several recordings looks this: <audiolibrary> <prompt name="accountinfo"> <prompt-segment> <audio src="audio/default/accountinfo.wav" text="account information"/> </prompt-segment> </prompt> ... <prompt name="accountclosed"> <prompt-segment> <audio src="audio/default/accountclosed.wav" text="sorry, account closed."/> </prompt-segment> </prompt> </audiolibrary> following xpath tutorial, know can retrieve, example, attribute of first prompt following expressions: xpathobject.compile("/audioibrary/prompt[@name='accountinfo']/prompt-segment/audiofile/@src"); xpathobject.compile("/audioibrary/prompt[1]/prompt-segment/audiofile/@src"); now, if want retrieve of prompts, understanding correctl...

c# - Can you add extension methods that you call like static methods? -

according microsoft, "extension methods special kind of static method, called if instance methods on extended type". is there way add extension method called if static method? or else has same effect? edit: mean "called if static method on extended class". sorry ambiguity. according microsoft, "extension methods special kind of static method, called if instance methods on extended type". yes, extension methods static methods. can called in normal way static methods, extension instance methods on type "extend", , can called extension methods on null reference. for example: public static class extensions { public static bool isnullorempty(this string thestring) { return string.isnullorempty(thestring); } } // code elsewhere. string test = null; console.writeline(test.isnullorempty()); // valid code. console.writeline(extensions.isnullorempty(test)); // valid code. edit: is there way add extension m...

actionscript 3 - Organizing Long Scripts In Separate Files? -

in attempt organize code, i'm trying split (lengthy) main controller class separate files, but new files must still have access variables , functions of main controller class. i'm trying cut , paste code controller class new class/file, allowing controller class call new class, , allowing new class have access controller class's properties , function. assuming i'm not totally bludgeoning appropriate design patterns, below unsuccessful attempt @ accomplishing task: package { import flash.display.sprite; import flash.events.event; public class test extends sprite { public var mystring:string; public function test() { if (stage) init(null); else addeventlistener(event.added_to_stage, init); } private function init(evt:event):void { if (haseventlistener(event.added_to_stage)) removeeventlistener(event.added_to_stage, init); /////////////// move comment...

Create PDF from CSV on iPhone -

an iphone app creating generates reports core data database csv file, can emailed user may use data elsewhere outside of app. offer ability generate same reports pdf file (of course, nicer formatting) allowing user print report rather having jump through several hoops csv file - i.e. open in application (e.g. excel, numbers) reformat columns (so wide enough printing), bold headings, etc. essentially, want provide pdf file user given nicely formatted report, , need export csv file if wish data manipulation , need format editable. i thinking easiest method taking csv file , converting pdf file, same csv except incorporate nicer formatting (such tabular layout) rather simple comma-separated format of csv file. have been unable find ready-made classes purpose (to avoid reinventing wheel) , unsure how approach since have limited experience aspect of sdk. suggestions or pointers in right direction appreciated. you have 2 different problems: read csv data structure in memo...

jrubyonrails - JRuby on Rails app on and JBoss 4.2.0/Tomcat 5.5 -

my jruby on rails app works fine on tomcat 6.0, when deploy on company's webfarm jboss 4.2.0/tomcat 5.5 (servlet api 2.4) fails following stack trace: java.lang.arrayindexoutofboundsexception: 0 @ com.kenai.jaffl.provider.jffi.asmlibraryloader.generatebufferinvocation(asmlibraryloader.java:548) @ com.kenai.jaffl.provider.jffi.asmlibraryloader.generatemethod(asmlibraryloader.java:511) @ com.kenai.jaffl.provider.jffi.asmlibraryloader.generateinterfaceimpl(asmlibraryloader.java:223) @ com.kenai.jaffl.provider.jffi.asmlibraryloader.loadlibrary(asmlibraryloader.java:125) @ com.kenai.jaffl.provider.jffi.provider.loadlibrary(provider.java:31) @ com.kenai.jaffl.provider.jffi.provider.loadlibrary(provider.java:25) @ com.kenai.jaffl.library.loadlibrary(library.java:76) @ com.kenai.jaffl.library.loadlibrary(library.java:48) @ org.jruby.ext.socket.rubyunixsocket.tryunixdomainsocket(rubyunixsocket.java:167) @ org.jruby.ext.socket.rubysocket$service.load(rubysocket.java:103) @ org.jruby.ru...

linux - Adjust Time to Daylight Saving for localtime C++ -

i have piece of optimized function gmt time. convert local time. want call localtime , gmtime function once adjust time localtime calling localtime , gmtime multiple times defeat purpose of using optimized function. idea adding difference in time zone gmt time obtained. however, problem how adjust localtime when there daylight saving? ideas on checking that? thanks. you use tz database stored of time in /usr/share/lib/zoneinfo in linux distributions. database manages daylight saving not nees deal that.

How do you specify the channel .NET remoting will use to perform a callback -

i have client (and server) 2 channels set on different protocols, lets x:// , y://. if call service (over remoting) client (c) on server (s) needs perform callback client (so s->c) there way specify channel use? in use case want calls x:// callback on x:// , calls on y:// callback on y://. my current solution implement custom serialization surrogate (and selector) each channel marshalbyrefobjects removes uri of other channel serializationinfo when serializing them. similar to: remotingservices.getobjectdata(obj, info, context); ichannelinfo channelinfo = (ichannelinfo)info.getvalue("channelinfo", typeof(ichannelinfo)); channelinfo.channeldata = channelinfo.channeldata.where(x => { channeldatastore ds = x channeldatastore; if (ds != null) { if (!(ds.channeluris.length > 0 && ds.channeluris[0].startswith("y://"))) ...

c# - Message box pops up evertime -

i want messagebox show if number equal 0. part works part giving me bit of issue is, when nudtwobytwo_1_valuechanged @ 0 , increment nudtwobytwo_2_valuechanged 1 still gives me messagebox everytime increment nudtwobytwo_2_valuechanged. until increment nudtwobytwo_1_valuechanged 1. them work seperatly. if nudtwobytwo_1_valuechanged set 0 throw messagebox , same goes nudtwobytwo_2_valuechanged i creating lottery game. min , max value set 0-20. dont want default min 1. using system; using system.windows.forms; namespace lotterytickets { public partial class form1 : form { public form1() { initializecomponent(); } private void nudpickfive_1_valuechanged(object sender, eventargs e) { } private void nudtwobytwo_1_valuechanged(object sender, eventargs e) { if (cbtwobytwo.checked) errorcheck(); } private void nudtwobytwo_2_valuechanged(object sender, eventargs e) { if (cbtwobytwo.checked) er...

c# - Why keep code behind 'clean' and do everything in XAML? -

what benefit of keeping code behind 'clean'? many times come across posts here trying equivalent in xaml instead of code behind. reason being want keep code behind 'clean'. correct me if wrong, not case that: xaml compiled - baml - @ runtime has parsed code anyway. xaml can potentially have more runtime bugs not picked compiler @ compile time - incorrect spellings - these bugs harder debug. there code behind - or not initializecomponent(); has run , .g.i.cs file in contains bunch of code though may hidden. is purely psychological? suspect developers come web background , markup opposed code. edit: don't propose code behind instead of xaml - use both - prefer binding in xaml - against making every effort avoid writing code behind esp in wpf app - should fusion of both out of it. 1. designer perspective uis built designers using designer tools (expression blend , friends). if have kind of worklow, doesn't work if put significant amou...

html - Styling a table: how to add margin to one cell? -

consider this code : html: <table> <tr> <td>option 1</td> <td><input type='checkbox' id='option1' /></td> </tr> <tr> <td>option 2</td> <td><input type='checkbox' id='option2' /></td> </tr> <tr> <td>option 3</td> <td><input type='checkbox' id='option3' /></td> </tr> <tr> <td id='go' colspan=2>go</td> </tr> </table> css: td { border: 1px solid black; } #go { text-align: center; cursor: pointer; background: #aaa; } is possible set position of go cell 10px below current position ? i tried play margin-top , cellspacing didn't help. is possible ? i don't believe can set margin on td element. this nasty hack, insert row height="10px...

how to use youtube-g ruby gem? -

new rails , trying youtube-g work... having difficult time passing users search form_tag controller.. example: user lands on page, enters - tiger videos - in text_field_tag controller takes - tiger videos - , searches user lands on page displaying results... user lands on page, enters query index.html.erb <%= form_tag(youtube_path) %> <%= label_tag(:q, "search for:") %> <%= text_field_tag(:wth) %> <%= submit_tag("search") %> <% end %> -- controller takes query , searches youtubecontroller.rb class youtubecontroller < applicationcontroller def search require 'youtube_g' client = youtubeg::client.new client.videos_by(:query => params[:wth]) end end -- my routes file: actioncontroller::routing::routes.draw |map| map.search “search”, :controller => “youtube” i havn´t got step 3 yet.. what want page text box , submit button, , when user enters text , submits, brought ...

iphone - How to get the data from following XMl? -

i have application in getting xml below. how parse following xml such need maintain 2 separate arrays 'id' , 'last updated'. in idarray want maintain ids , in updatedarrays want maintain dates.how that? both id , lastupdate within single tag below. id="amitdixit007@gmail.com" lastupdate="08/27/2010 04:15:42pm" can u tell me link or response string can you; hold response after parse in array , in nsmutablearray *idarray = [[nsmutablearray alloc]init]; nsmutablearray *lastupdatearray = [[nsmutablearray alloc]init]; (for i=0;i<[array count];i++){ [idarray addobject:[[ array objectatindex:i]valueforkey:@"id"]]; [lastupdatearray addobject:[[ array objectatindex:i]valueforkey:@"lastupdate"]] }

asp.net - What are some good resources for learning about HttpContext, Request and Response? -

i'm trying learn httpcontext, request , response. resources? i'm interested in links tutorials (basic things). thanks saj if referring httpcontext in asp.net, key object exposes underlying request (incoming messages) , response (outgoing message) streams. @ low level, object populated iis , asp.net framework. this means httpcontext available business object running inside of .net web application (not aspx page, ascx, etc). httpcontext.current provides access request, response, session, cache, , more. http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx for http basics such request , response, see links younes provided.

Is VS 10.0 Runtime part of .Net framework 4? -

are vc runtimes part of .net framework? how can vc 10.0 runtime download? it has private copy, c:\windows\system32\msvcr100_clr0400.dll. not suitable use c or c++ program, needs msvcr100.dll , msvcp100.dll. local deployment option, might want take advantage of it. the merge modules you'd need if want use installer on machine. c:\program files\common files\merge modules. using setup project easiest way. add project + properties, prerequisites, tick "visual c++ 2010 runtime libraries". download links jon gave suitable if want customer prep machine.

What's wrong with this example of Java property inheritance? -

inheritance.java public class inheritanceexample { static public void main(string[] args){ cat c = new cat(); system.out.println(c.speak()); dog d = new dog(); system.out.println(d.speak()); } } animal.java public class animal { protected string sound; public string speak(){ return sound; } } cat.java public class cat extends animal { protected string sound = "meow"; } dog.java public class dog extends animal { protected string sound = "woof"; } output: null null my animals cannot speak. sad. fields aren't polymorphic. you've declared 3 entirely distinct fields... ones in cat , dog shadow or hide 1 in animal . the simplest (but not best) way of getting current code remove sound cat , dog , , set value of inherited sound field in constructor cat , dog . a better approach make animal abstract, , give protected constructor takes sound... constructors of cat , dog call super(...

java - what are non-unicode applications -

as know, in windows system, can set locale language non-unicode programs in "control panel\clock, language, , region". local language mean application? since understanding, application compiled binary executable file, contained machine code instructions , no data, how character encoding affect running? one guess if executable file contain literal strings in code segment, use internal charset encoding them. if charset not unicode, display garbage. not internal charset fixed one? in java, java spec defines internal encoding utf-16. hope can answer questions, thanks. windows has 2 methods programs can talk it, called "ansi api" , "unicode api", , "non-unicode application" 1 talks windows via "ansi api" rather "unicode api". what means string application passes windows sequence of bytes, not sequence of unicode characters. windows has decide characters sequence of bytes corresponds with, , control panel setti...

php - How to load externally hosted data in JSON format -

what syntax pull external data source, has data in json format variable worked with. understand using json_decode($variable) how load actual data variable decoding? if external mean it's hosted on 3rd-party domain name, open socket , data: $variable = file_get_contents('http://example.com/data.json'); $decoded = json_decode($variable);

how to from select parameterized query in asp.net -

i want write parametrized query select statement. gives exception "must declare variable '@'." how declare variable . my code given below: sqlconnection con = null; sqlcommand cmd = null; try { //int @[month_for], @[year_for]; con = new sqlconnection("data source=192.168.10.3;initial catalog=gpstrainees;user id=gp;password=gp"); con.open(); string select = @"select [component_name] ,[component_amount] [goalplanfortrainees].[gp].[team_funds_details] [month_for] = @[month_for] , [year_for] = @[year_for]"; cmd = new sqlcommand(select, con); cmd.parameters.add(new sqlparameter("@[month_for]", convert.toint32( textbox1.text.trim()))); cmd.parameters.add(new sqlparameter("@[year_for]",convert.toint32(textbox2.text.trim()))); dataset ds = new dataset();...

How do I consume JSON from a web service in ASP.NET? -

we have web application providing service using simple rest interface (get/post methods) , returning results in json format. a client wants use service asp application (i assume asp.net) , asks example code. is there standard/widely-acceptable procedure consuming json based web services asp.net application? i'm not familiar .net framework, can work way through c#. any pointers welcome. there's quite few json libraries available .net convert json poco objects: json.net jason king jsonfx.net the json.org website has references these libraries , more. there's support classic asp (which not same asp.net): json2.asp

Phone 7 Bing map control - Add a pushpin when tap -

i using latest phone 7 rtm tools ( downloaded today, october 7 2010). i trying simple thing here: when user taps once on map control, want put pushpin there. also, want keep regular built-in behavior of map control ( tap twice zoom). (if it's not possible keep both behaviors , maybe long press on map put pushpin). when trying figuring out, came across documentation of changes made control map phone7: http://msdn.microsoft.com/en-us/library/ff955762.aspx then saw new class mapinputeventargs , has viewportpoint member. when looking @ code examples on regular silverlight map control saw this: private void onmouseclick(object sender, mapmouseeventargs e) { point clicklocation = e.viewportpoint; location location = x_map.viewportpointtolocation(clicklocation); pushpin pushpin = new pushpin(); m_pushpinlayer.addchild(pushpin, new location(latitude, longitude)); } but in phone7 case, can't find appropriate event handler,...

delphi - which is fastest win32 or SQL query? -

i'm writing client-server win32 application in delphi 7 , in section need bring aprox. 100k (less or more) rows data oracle database. ok far, 1 of fields must calculated (a simple division large number). my question is, how less resources consuming , optimum, make division in sql query(maybe store procedure), or calculate value in code field(on server side)? don't want use tdataset calculated fields. oracle system(v 9.2) used others applications, not dedicated application. thanks in advance. the sql engines designed type of task, answer make operation in oracle system . always sql data manipulation tasks in database server, designed that.

generics - ClassCastException in Java foreach loop -

in circumstances can classcastexception occur in code below: import java.util.arrays; import java.util.list; public class generics { static list getobjects() { return arrays.aslist(1, 2, 3); } public static void main(string[] args) { list<string> list = getobjects(); (object o : list) { // classcastexception? system.out.println(o); } } } we had similar case in production environment (bad practice, know) , customer provided log classcastexception @ line comment can't seem reproduce it. thoughts? i know jvm creates iterator in background when using foreach, can create raw iterator in cases , parametrized 1 in other cases? update : i had @ bytecode generated , on windows, using jdk 1.6.0_21-b07 no checkcast made. interesting :) here main method: public static void main(java.lang.string[]); code: 0: invokestatic #34; //method getobjects:()ljava/util/list; 3: astore_1 4: aload_1 ...

sql server - Where can I find TableDiff.exe? -

i found out tablediff tool sql server on hidden features question , had full-blown nerdgasm . download tool, everywhere told in c:\program files\microsoft sql server\90\com\tablediff.exe . after looking everywhere on pc (i have sql server 2008 express , sql server 2008 installed), can't find it. where can download tablediff.exe tool stand-alone? the gui tool isn't droid i'm looking for. if cannot find tablediff.exe, re-run sql server install , choose replication support. tablediff officially "microsoft (r) sql server replication diff tool" , added when using replication.

How to import external module in python macro for OpenOffice? -

i'm writing macro openoffice in python, , have problem. want import external module (gdata) write import uno import gdata.calendar.service but when try execute macro (tools -> marcos -> run macro..) importerror :/ have gdata module in pythonpath , it's working when test in interpreter. what can import module not part of open office uno?

javascript - jquery .addClass to future js generated html -

i this: $(".field-validation-error").addclass('ui-state-error'); and @ moment happens $("body").prepend("<span class="field-validation-error">this field required.</span>") i new added element have class 'ui-state-error' you can either add yourself, changing .prepend() call, or use the .livequery() plugin , this: $(".field-validation-error").livequery(function() { $(this).addclass('ui-state-error'); }); this execute bounds .field-validation-error elements, , future ones. or, if changing stylesheet option, include both selectors: .field-validation-error, .ui-state-error { ....styles.... }

python - Require help in Django 'local variable 'form' referenced before assignment' -

i having problem in django. have created form in app can take details of client. want create form can allow me edit form. having problems when go /index/edit_client/1, error. local variable 'form' referenced before assignment i not know reason why have got error, have looked at, not matters unless of course there way how create edit form edit clients form. here output can helpful too. # urls.py urlpatterns = patterns('', (r'^index/$', login_required(direct_to_template), { 'template': 'index.html' }), (r'^index/clients/$', client_info), (r'^index/clients_details/(?p<id>\d+)/$', clients_details), (r'^index/edit_client/(?p<id>\d+)/$', edit_client), ) # views.py @login_required def edit_client(request, id=1): clients_list = client.objects.filter(pk=id) if request.method == 'post': form = clientform(request.post or none) if form.is_valid(): ...

c# - Inheritance related question -

i have class base. , b extend base. there class relationship contains 2 base objects (source, target). possible determine whether source/target or b instance? thanks. christian ps: here little add on. using automapper , map type of source/target string called 'type' - gettype did not work (actually works -s ee comments - , solutions too) : mapper.createmap<item, itemviewmodel>() .formember(dest => dest.name, opt => opt.mapfrom(src => src.itemname == null ? "" : src.itemname.name)) .formember(dest => dest.type, opt => opt.mapfrom(src => src.gettype().tostring())); how can use is/as in scenario? yup: if (source a) if (source b) etc or: a sourcea = source a; if (sourcea != null) { ... } etc see this question more guidance - , there plenty of other similar ones, too.

c++ - shared_ptr gets destroyed before I can use it properly -

i have following code, supposed add shared_ptr instance intrusive linked list thread a. other consumer thread use later on removing list. @ point shared_ptr seems destroyed , reference in linked list no longer valid resulting in assert. can enlighten me on doing wrong? suspect because create original shared_ptr in local scope , gets destroyed. although list should still have reference it??? (this not production code) edit: defintiions of variables used: basehookqueuelist* lst; typedef boost::intrusive::list<queuelist> basehookqueuelist; class queuelist : public boost::intrusive::list_base_hook<> // making basehookqueuelist take shared_ptr of pointing type queuelist conflicts // list_base_hook because not seem shared_ptr... //////////////////////////////////////////////////////////////////////////////////// if (dwwait == wait_object_0) //wait successfull { while(count != 100) ...

how can I display thumbnail image in spite of bubble in google map API -

i using google map api in application. how can show thumbnail image in place of red bubble perticular address on map. when create marker, set icon. i.e. var marker = new google.maps.marker({ map: null, position: new google.maps.latlng(jdata.locationlat, jdata.locationlon), visible: true, clickable: true, title: jquery.trim(jdata.locationname), icon: 'http://www.mysite.com/mythumb.png', shadow: 'http://www.mysite.com/markershadow.png' }); you can set after initialization well: marker.seticon('http://www.mysite.com/mythumb.png'); marker.setshadow('http://www.mysite.com/markershadow.png');

c++ - Expression template operator overloading problem with std::vector -

i'm working on numerical library uses expression templates. unfortunately encountered problem operator overloads. consider following stripped down example. #include <vector> namespace test { class test {}; template<class a, class b> class testexpr {}; template<class a, class b> testexpr<a, b> operator-(a a, b b) { return testexpr<a, b>(); } } test::test stuff(std::vector<test::test> &v) { return v.back(); } int main() { } which gives following error message when compiling gcc 4.4.3 or clang 2.8: in file included eir_test.cc:2: in file included /usr/include/c++/4.4/vector:64: /usr/include/c++/4.4/bits/stl_vector.h:696:16: error: indirection requires pointer operand ('testexpr<__gnu_cxx::__normal_iterator<test::test *, std::vector<test::test, std::allocator<test::test> > >, int>' invalid) { return *(end() - 1); } ^~~~~~~~~~~~ eir_te...

ruby - In Rails 2 yielding a block in a helper a method renders partial? -

rails 2.2.2 _competition.html.erb <p>this packed</p> <% pack %> // javascript <% end %> competitions_helper.rb def pack(&block) yield + 'packed' end however 'packed' not appended javascript string, if pack do has no effect. seems there oddness going off context of blocks , actual view rendering because if remove call yield in helper , return hard coded string no output pack. def pack(&block) concat(capture(&block) + 'packed') end

Can I find the most popular keyword for a particular page using the google analytics api? -

i hoping to use analytics api find out popular search terms (organic) lead particular page. is possible? i've trawled documentation , found looks if outlines possible data can retrieve api , can't see information here. http://code.google.com/apis/analytics/docs/gdata/gdatareferencedimensionsmetrics.html if case, there reason api isn't complete? assume if can access data using analytics interface should able query using api - assumption incorrect? yes, possible. example, if wanted see keywords led how many entrances index.html, set: dimensions : ga:keyword metrics : ga:entrances segment : gaid::-5 filters : ga:landingpagepath==/index.html sort : -ga:entrances (segment gaid::-5 segments data include visits referred organic search; sorting -ga:entrances order number of visits in descending order). try out here: http://code.google.com/apis/analytics/docs/gdata/gdataexplorer.html?dimensions=ga%253akeyword&metrics=ga%253aentrances&segm...

javascript - Unable to perform any PHP operations in an Ajax application -

my ajax application working fine, until implemented if statement in php script... contagious disease seems if data in php returns nothing javascript layer. all can echo data back... for instance query string i'm sending php reads... index.back3.php?form=login&json={"email":"mo@maurice-campobasso.com","password":"asdasdfas"} and know getting there because in simplest debugging php file (index.back3.php) created have simple echo statement... , never fails send data javascript file. when index.back3.php reads <?php echo $_get[json]; ?> the alert have triggering off in javascript reliably spits out json string. also when reads <?php echo $_get[form]; ?> when more complicated nothing comes javascript. simple concatenation... <?php echo ($_get[form] . $_get[json]); ?> ...returns nothing! a simple if...else statement returns nothing. <?php if(!isset($_get[form]) { echo "no!...

c# - Setting up an elapsed timer event -

i need measure time difference between when last packet received , new 1 has arrived. have tried using timer class in c# such: while (listening) { if (hb != null) { interval = hb.gethbinterval(); atimer = new system.timers.timer(interval+5); console.writeline("interval is: {0}", interval); byte[] bytes = listener.receive(ref groupep); decodeudpmessage(encoding.utf8.getstring(bytes, 0, bytes.length)); } else { byte[] bytes = listener.receive(ref groupep); decodeudpmessage(encoding.utf8.getstring(bytes, 0, bytes.length)); } } i had event called if timer elapsed after length of time of interval. realised timer wait length of interval , call event. need figure out is, can work out difference of when packet came l...

validation - Validating uniqueness with data annotations in asp.net mvc -

i have various questions validation using data annotations. using following setup asp.net mvc 2 entity framework 4 data annotations basically, i'm trying unique validation working , i'm little confused. models follows: public class buyer { public int id { get; set; } [required(errormessage = "the email required")] public string email { get; set; } [required(errormessage= "the name required")] public string name { get; set; } } public class seller { public int id { get; set; } [required(errormessage = "the email required")] public string email { get; set; } [required(errormessage= "the name required")] public string name { get; set; } } i have set unique field attribute follows public class uniquefieldattribute : validationattribute { public iuniquevalidator validator { get; set; } public int id { get; set; } public override bool isvalid(object value) { ...

firebird - Is there a way to have metadata name longer than 31 Characters? -

is there easy way have metadata names longer 31 characters in firebird 2.1 , above ? limitation annoying foreign keys , views name. thanks! even in firebird 2.5 realease now, can't. you can see firebird limit here you can check firebird tracker , vote request

svn - Extract TortoiseSVN saved password -

is there way extract credentials saved tortoisesvn? short answer: can use tortoisesvn password decrypter display cached credentials, including passwords. long answer: here's how tool works. the credentials saved in subdirectories of %appdata%\subversion\auth\ . listed this previous answer are: svn.simple contains credentials basic authentication (username/password) svn.ssl.server contains ssl server certificates svn.username contains credentials username-only authentication (no password needed) the first directory 1 of interest. appears contain files names guids; 1 each repository you've saved credentials. the passwords in these files encrypted windows data protection api . tool above uses sample code obviex interface api , perform decryption. in order work, must have access same windows user account running under when checkmarked "save authentication" checkbox. because windows data protection api uses encryption key tied windows ...

amazon web services - Query EC2 tags from within instance -

amazon added wonderful feature of tagging ec2 instances key-value pairs make management of large numbers of vms bit easier. is there way query these tags in same way of other user-set data? example: $ wget -q -o - http://169.254.169.254/latest/meta-data/placement/availability-zone us-east-1d is there similar way query tags? you can use combination of aws metadata tool (to retrieve instance id) , new tag api retrieve tags current instance.

css - html - controlling how many options show in a select element -

so have drop down (select) element. problem if there long list in it, "drops" upwards instead of downwards. is there way should scroll rather show of them @ once? i know there's "size" that's how many visible @ once (i want 1 visible, normal) or reason it's not having scrollbar automatically caused it's containing div? need know should end or something? the way works browser. nothing can it, other building own drop-down js.

asp.net - Error in formating of XML string with CDATA -

i error "start tag on line 1 not match end tag of 'document'". string rawxml = "<?xml version='1.0' ?>" + "<document>" + "<![cdata[" + "<topic>" + "my test" + "</topic>" + "]]>" + "</document>"; error occurres when try execute stored procedure send xml parameter. var xmldoc = new xmldocument(); xmldoc.loadxml(rawxml); dataresultxelement drx = ss.xelem_query(string.format("exec topic_update '{0}', '{1}'", sessionid, xmldoc.innerxml)); if remove works, need cdate store data in database. should format string differently? thanks! do not use string manipulation construct xml documents. do not use string manipulation construct sql queries. do instead: stringbuilder sb = new stringbuilder();...

Local Net Ip Address from a Remote Client in java -

does know how local net ip address remote client in java? thx is looking for? inetaddress addr = inetaddress.getlocalhost(); byte[] ipaddr = addr.getaddress(); // ip address string hostname = addr.gethostname(); // hostname that gets ip of machine code running on.

c# - How will you keep a specific country on top in a drop down list? -

in list of countries need displayed in alphabetical order, need place united states @ top of list. how this? i answered saying have table structure in such way @ id-0. rest of countries listed in alphabetical order. so when fetch table, " select countryname tableofcountries order id " i not sure if interviewer wanted hear this. suggested option of populating country array first element. rest of elements populated resultset of query. "select countryname tableofcountries countryname != 'us' order country_name". this ensure not selected twice. the interviewer wasn't satisfied option either. asked me if had other option in mind. said text file on webserver list of values. do have other options can think of? generally like: select countryname tableofcountries order (case when countryname = 'us' 0 else 1 end) asc, countryname asc

C#.net webform, avoid losing data from session timeout -

i have user complaining frequent timeouts in intranet web page. while looking solution found post: http://forums.asp.net/t/152925.aspx?pageindex=1 where poster recommends intercepting redirect login page, submit data database, either reauthorize user (without knowledge) or redirect login page. goal avoid situation user enters data in form, walks away, comes submit it, told have login again (which fine, if data remained , user sent right original webform). does know how can accomplish on specific pages in app (not of them)? it's not trivial, can add ajax component makes occasional calls page keep session alive. way lengthen session particular page need without affecting application whole. edit if want let session expire, keep form data, can implement protected void application_postauthenticaterequest (object sender, eventargs e) event handler in global.asax.cs file. called before forms authentication redirect happens, , form data available applicatio...

.net - Linq to XML...I never get any Descendent values with XML as-is -

here part of xml trying parse: <?xml version="1.0" encoding="utf-8"?> <workflow xmlns="http://soap.sforce.com/2006/04/metadata"> <alerts> <fullname>broker_not_in_sf_current_broker_account</fullname> <description>broker not in sf - current broker account</description> <protected>false</protected> <recipients> <recipient>geddylee@yyz.com</recipient> <type>user</type> </recipients> <sendertype>currentuser</sendertype> <template>broker_emails/current_broker_on_acct_not_in_sf</template> </alerts> <rules> <fullname>no service contact assigned</fullname> <active>true</active> <criteriaitems> <field>account.type</field> <operation>equals</operatio...

java - How to create object graph from an XML-file? -

i have xml file. like: <person> <name> <firstname>joni</firstname> <lastname>smith</lastname> </name> <born year="1983" day="31" month="01">finland</born> ... lots of elements ... </person> my goal create class person. how can "automatically"? think have used maven castor plugin create quite complicated object graph xml file without lot of effort. however, can not remember plugin was, , indeed can not remember how did used it. happy learn other (probably better) tools might know. i agree using jaxb. starting xml schema (generate classes xml schema) you can use jaxb generate java source code xml schema. below instructions doing eclipselink jaxb (moxy): http://wiki.eclipse.org/eclipselink/examples/moxy/jaxb/compiler java se 6 comes metro jaxb xjc compiler can found in bin directory of jdk installation: c:\program files\java\jdk1.6.0_20\bin>...

.net - Force IE to get a page -

i've tried numerous ways ie8 reload page failed. ie keeps using it's internal cache without asking webserver it. i'm sending following headers webserver: response.add(new stringheader("expires", datetime.utcnow.addyears(-1).tostring("r"))); response.add(new stringheader("cache-control", "no-store, no-cache, must-revalidate, max-age=0")); response.add(new stringheader("pragma", "no-cache")); response.add(new stringheader("last-modified", datetime.utcnow.tostring("r"))); it's 1 of many combinations i've tried. how make ie fetch page every time (without forcing users turn off caching inside ie)? the proper way send these http headers in response: pragma: no-cache expires: -1 cache-control: no-cache, no-store using them makes work in ie without other modifications.

Codeigniter, how to make a template -

im trying ding codeigniter mvc dont know how make template have 2 files (header , footer) , can make controllers , put information in "content" div, include top , header way this <?php include("header.php"); ?> <div id="content">my content here</div> <?php include("footer.php"); ?> hope understand mean , can me out :) the best way load views within views. within views/content.php: <? $this->view('header', array('title'=>'the page title', 'keywords'=>'some keywords', 'etc'=>'...')); ?> <div id="content">my content here</div> <? $this->view('footer'); ?> so in controller this: $this->load->view('content', $data); $data contain 'title' or 'keywords' , implemented such in controller: $data['title'] = 'title'; $data['keywords' = ...

Missing Visual Studio 2010 Sample Macros -

in visual studio 2010 macro explorer have "samples" folder empty. everything read seems indicate these should have been installed automatically. i ran setup again see if feature missed there no option. any ideas how can sample macros? thanks! here how resolved it. went computer had visual studio 2010 installed , copied file samples.vsmacros pc mine. have sample macros now. thanks.

permissions - RealBasic app crashes on writeline -

i have mac rb app crashes when write line textoutputstream on user's preferences. write operation works great when user admin, other user crashes. made me think it's permission issue, tried changing permission, without luck. the error is: "an exception of class nilobjectexception not handled. operation must shut down" any amazing people appreciated. thanks! here's code: dim tablestring string dim filestream textoutputstream dim file folderitem file = specialfolder.sharedpreferences.child("filename.txt") tablestring = translationtabletostring filestream=file.createtextfile // didn't help: //file.permissions= &o777 // line breaks: filestream.writeline tablestring you don't mention version of rb using, reasonably current version, syntax should using is: filestream = textoutputstream.create(file) which should wrap in try/catch this: try filestream = textoutputstream.create(file) filestream.writeline(tablestrin...

wcf - Custom MTOM binding and Max upload size -

i'm using binding configuration below upload service, <binding name="fileuploadstsbinding"> <security authenticationmode="usernameovertransport" requirederivedkeys="false" keyentropymode="serverentropy" requiresecuritycontextcancellation="false" requiresignatureconfirmation="false"> </security> <mtommessageencoding/> <httpstransport transfermode="streamed" maxreceivedmessagesize="2147483647"/> </binding> but setting, i'm not able upload big files more 1mb, server response bad request. any thoughts? you need set maxrequestlength attribute upload work. can here found in web.config file here: <configuration> <system.web> <httpruntime> check iis app pool identity ha...

resources - "@android:drawable/ic_" vs "@*android:drawable/ic_" -

does know can find documentation on asterisk? appears override protection of 'private' variables in subclass android.r.drawable. the @*android used access private resources. these resources can change or removed between 2 versions of android should never use them. framework use only.

How do i change my merge algorithm to accept different arguments in c++? -

the original code wrote uses these arguments: int m = size of sorted list 1 int n = size of sorted list 2 int a[] = sorted list 1 int b[] = sorted list 2 int c[] = merged list of 1 , 2 i asked add code existing file uses these different arguments: intvectorit start1 intvectorit end1 intvectorit start2 intvectorit end2 intvectorit start3 these variables defined here (n size of first sorted array, m size of second sorted array): typedef vector<int> intvector; typedef intvector::iterator intvectorit; intvector vector1(n); intvectorit start1,end1,it1; start1 = vector1.begin(); end1 = vector1.end(); intvector vector2(m); intvectorit start2,end2,it2; start2 = vector2.begin(); end2 = vector2.end(); intvector vector3(n+m); intvectorit start3,end3,it3; start3 = vector3.begin(); end3 = vector3.end(); //--the variables version of merge intvector myvector(n+m); intvectorit mystart,myend,myit; mystart = myvector.begin(); myend = myvector.end(); my merge co...

unicode - C# char/byte encoding equality -

i have code dump strings stdout check encoding, looks this: private void dumpstring(string s) { system.console.write("{0}: ", s); foreach (byte b in s) { system.console.write("{0}({1}) ", (char)b, b.tostring("x2")); } system.console.writeline(); } consider 2 strings, each of appear "ë", different encodings. dumpstring produce following output: ë: e(65)(08) ë: ë(eb) the code looks this: dumpstring(string1); dumpstring(string2); how can convert string2, using system.text.encoding, byte equivalent string1. they don't have different encodings. strings in c# utf-16 (thus, shouldn't use byte iterate on strings because you'll lose top 8 bits). have different normalization forms . your first string "\u0065\u0308": latin small letter e + combining diaeresis. decomposed form (nfd). the second "\u00eb": latin ...

java - visual vm analyze memory leak -

in visual vm, click on sample->memory, , keep see "windowprincipal" class, instances stay @ 25. right nobody using application. sign of memory leak? http://www.freeimagehosting.net/image.php?c069df48c2.gif trying requesting garbage collection multiple times , see graph again. if object instances still there can trace patch of these objects i.e., referencing these objects , can assess if memory leak or legitimate objects cached.

Facebook auth token and asp.net mvc -

we have asp.net mvc site needs authenticate facebook post photos user account. fine far. facebook redirect mvc site. again fine. the url facebook replies include access_token prefixed # char , mvc strips , token url controller , action nothing useful. this using user agent type of authentication. if use standard auth works fine doesnt give enough access rights. anyone got clues ?? thanks there's no way read hash part of url (everything follows # sign) on server side because part never sent server. way access on client side, might need read using javascript , send server again using example ajax or setting value of hidden field part of form submit server.

Joomla Form builder download! -

i searching joomla component generate form fields (form builder) database fields. know component installation. please provide me link download component. you can try richcontactpro . joomla form builder

jsp - java.lang.ClassNotFoundException: org.apache.struts.taglib.bean.CookieTei -

i finding java.lang.classnotfoundexception: org.apache.struts.taglib.bean.cookietei. i have struts2-core-2.1.8.1.jar, struts2-json-plugin-2.1.8.1.jar on classpath. it appears have dependencies on struts-1. jarfinder finds class in struts-1 libs . rid of struts-1 jars, , place struts-2 jars in classpath.

treeview - Javascript - Set source file and assigning value to a control -

i have tree view control build dynamically. want change color of selected node .one me write script given below. , work fine. <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("jquery", "1.4.2"); google.setonloadcallback(function() { //change cursor hand when user mouseover tree nodes $(".treeview1_0").mouseover(function() { $(this).css('cursor', 'pointer'); }); //unbold nodes bold selected node indicate it's selected $(".treeview1_0").click(function() { $(".treeview1_0").css('font-weight', 'normal'); $(".treeview1_0").css('color', 'black'); $(".treeview1_0").css('background-color', 'white'); $(this).css('color...