Posts

Showing posts from April, 2010

web applications - asp.net,web forms,about url task -

i have project name let take "xyz",it live project there on website,problem that when write "xyz" on browser url place , click enter not ctlr+enter has redirect "http://www.xyz.com".in programatic way using .net 2.0 , iis server project.so please tell me solution that 2nd problem in same url when write "xyz.com"then enter going page displaying "http://xyz.com" instead of http://www.xyz.com " so please tell me if u have answer problem in .net 2.0 , iis server for first part of question, not possible. cannot control browser send "xyz" there many factors including person's isp determine request "xyz" sent. for second part of question, suggest setting redirect in iis forward requests form xyz.com www.xyz.com see http://technet.microsoft.com/en-us/library/cc732969%28ws.10%29.aspx info on how that.

smtp - My server and php mail() function sends email to the spam folder -

is there way install smtp service on linux server , use php send emails through ? so emails doesn't show spam ? maybe through ssl ? my mail() function perfect , perfect headers , still sending spam :( thanks . there plenty of variables potentially involved here. your idea of perfect header seems subjective. recommend use phpmailer or swiftmailer handle mailing needs. some other variables might need take account processing of bounced emails, , making sure send mail in chunks opposed 1 big send off.

cocoa - Is there any detailed doc or sample codes about PBFSCopyFileSync from CoreService framework? -

i trying replace deprecated api pbhcopyfilesync pbfscopyfilesync recommend in files.h header. surprisingly, apple says several lines new api: pbfscopyfilesync duplicates file , optionally renames it. osstatus pbfscopyfilesync ( fsrefparamptr paramblock ); availability available in mac os x v10.5 , later. declared in files.h and couldn't find more how use function. specially, should filled parameter fsrefparamptr ? tried code below, keeps getting error of -50. paramerr -50 invalid value passed in parameter. application passed invalid parameter dialog options. here code: osstatus res = noerr; fsrefparam param; fsref srcfile, dstdir, newfile; const char *src = "$path_to_a_existing_file"; const char *dst = "/tmp"; res = fspathmakeref((const uint8 *)src, &srcfile, null); assert(res == noerr); res = fspathmakeref((const uint8 *)dst, &dstdir, null); assert(res == noerr); memset(&param, 0, sizeof(fsrefparam)); param.ioc

css selectors - CSS reach nested div -

is how write reach div phone in code nested divs? css #pagewrap #pagemain .content .colrow .container .col548 #contactinfoarea #phone { } html <!-- start: pagewrap --> <div id="pagewrap"> <div id="header"> <div class="headerwrapper"> <div id="headertopitems"> <a class="mainlink" href="../telge-energi/webbkarta/">webbkarta</a> <a href="#" class="login closed">min sida</a> <div id="loginboxwrapper"> <div id="loginboxbuttonwrapper"> <div class="rounded buttonwrapper"></div> <div id="toploginbutton"> <div class="rounded topleft"></div> <div class="rounded topright"></div> <a href=

How do I get access to an outer variable in a closure in ruby? -

i have following dynamically created class passed xpath function of nokogiri: country = nil ret = parent.xpath(".//text()[regex(.)]", class.new{ def regex(node_set, lead) result = node_set.find_all |node| node.text =~ post_code_expression || node.text =~ zip_code_expression end result end }.new) i somehow access or set country variable or access outer self within regex function. is there anyway can pass outer self class.new expression or can suggest better way? methods cannot closures in ruby, blocks can: country = nil ret = parent.xpath(".//text()[regex(.)]", class.new{ define_method(:regex) |node_set, lead| result = node_set.find_all |node| node.text =~ post_code_expression || node.text =~ zip_code_expression end result end }.new) by way: regex method more complicated needs be. it's equivalent to define_method(:regex) |node_set, lead| node_set.find_all |node| node.text =~ post_code_e

send arabic SMS on mobile in java -

in application there both arabic , english language suport facing problem when mobile receive arabic sms displaied ??? ???? (question marks) knowing monbile using testing supports arabic , arabic in application working fine problem when arabic sms received mobile. string ff = new string(smscontent.getbytes("utf-8"), "utf-8"); stringwriter stringbuffer = new stringwriter(); printwriter pout = new printwriter(stringbuffer); pout.print("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); pout.print("<!doctype message system \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >"); pout.print("<message ver=\"1.2\"><user username=\""+username+"\" password=\""+password+"\"/>"); pout.print("<sms udh=\"0\" coding=\"1\" text=\""+ff+"\" property=

jquery - How to resize background image? -

i followed tutorial resizing background images on link how to: resizeable background image i trying edit work on div width of 900px resize vertically , have no idea how make work. any 1 can tell me how want. thanks are using first, second or third approach? considering third approach, might work if change width height : #img.source-image { height: 100%; position: absolute; top: 0; left: 0; } in case doesn't work, have @ this question , this other question , experiment body height , doctype . might want ask same question on doctype.com .

php - How to create custom urls in cakephp -

i have created cakephp app. have urls looks like www.mysite.com/products/search/hardware it loads fine. want urls looks www.mysite.com/hardware can achieved setting route connect i appreciate help. thanks. yes, can use route. router::connect( '/hardware', array('controller' => 'products', 'action' => 'search', 'hardware') ); for more general solution (any category name routing products/search) see http://book.cakephp.org/view/948/defining-routes

vb.net - Creating a temporary file in VB on Windows 7 PC -

i have vb program creates temporay pdf file opens outlook , attaches file. create file in application path (the location program running - c:\program files\progamname). works fine in xp appears there no crazy permission issues. in windows 7, file not appear. there no errors, file not exist in location. i've changed path root of c:\, doesn't work either. suspect it's w7 virtualisation, question can create file can access again? i trying avoid creating on share on server, it's looking place put there doesn't seem many places user can write files in windows 7. surely there must location users can access (without being administrators) create files. don't me started on fun have had registry in w7!!! thanks patrick you need create file in system's temp directory, can find calling path.gettemppath() . in general, program should write files in user's application data (or temp) directories , write registry keys in hkey_current_user. (thi

nosql - aggregating profile feeds like facebook -

just wondering how guys feed aggregator simple facebook using nosql (like redis). basically have many profiles, , each profiles have own feed. everytime user requests aggregate, system fetch these profiles, process them (and group them) , displays users. problem approach when has 1000 friends, system have fetch 1000 feeds (regardless if there's update or not) , process them. how guys it? obviously if can't updates in real time, need have done update before user asked - have list of known feeds , check updates on regular schedule, possibly based on update frequency of each feed. when user requests aggregate need return data have. making sure data reasonably date bit trickier. if google can check entire internet every few minutes - not option people. however, can reasonably close real time combination of smart update scheduling , using real time apis available. similar working on basic architecture data store holding posts , number of processes can pull data pa

curl - How to disguise your PHP script as a browser? -

we've been using information site while (something site allows if mention source , do) , we've been copying information hand. imagine can become tedious pretty fast i've been trying automate process fetching information php script. the url i'm trying fetch is: http://mediaforest.ro/weeklycharts/viewchart.aspx?r=weeklychartradiolocal&y=2010&w=46 08-11-10 14-11-10 if enter in browser works, if try file_get_contents() bad request i figured checked see if client browser rolled curl based solution: $ch = curl_init(); $header=array( 'user-agent: mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.2.12) gecko/20101026 firefox/3.6.12', 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-language: en-us,en;q=0.5', 'accept-encoding: gzip,deflate', 'accept-charset: iso-8859-1,utf-8;q=0.7,*;q=0.7', 'keep-alive: 115', 'connection: keep-alive', ); curl_setop

Javascript: Download data to file from content within the page -

setting following: have homepage display diagram has been constructed using comma seperated values within page. i'd give users possibility download data cvs-file without contacting server again. (as data there) somehow possible? i'd prefer pure javascript solution. so far i've discovered: http://pixelgraphics.us/downloadify/test.html involves flash i'd avoid. i can't imagine question hasn't been asked before. i'm sorry double post, seems i've used wrong keywords or - haven't found solution in these forums. update : time changes things ;-) when first answered question ie8 latest ie browser available (nov 2010) , there no cross browser way accomplish without round trip server, or using tool requiring flash. @zectburno's answer need now, historical context aware of ie browsers support feature. btoa() undefined in ie8 , ie9 blob available in ie10+ be sure test in browsers need support. though blob example in other answe

c# - convert decimal? in primitive decimal -

i want convert nullable decimal primitive decimal. how this. have done googling , found system.componentmodel.nullableconverter 1 of solution. not able figure out how use it. decimal? offenceamount = 23; decimal primitive; primitive=offenceamount; // please help. you can do: if (offenceamount.hasvalue) { primitive = offenceamount.value; } or, if want result default 0 : primitive = offenceamount.getvalueordefault(); or shortcut above: primitive = offenseamount ?? 0;

c# - How can I update a UI progressbar or backgroundworker from code in a separate class? -

somewhat new c# have major problem getting these things work because if background worker running long process using method class, class has no access background worker in order update progress. for instance: private void bgworker_dowork(object sender doworkeventargs e) { bgargs args = e.argument bgargs; myclass objmyclass = new myclass(); myclass.mymethod(strvalue, args.option); //do based on return value of long process. } if try update bgworker class "myclass", cannot "see" bgworker, doesn't exist in context of class, it's in ui class because in visual studio, that's drag toolbox. the way i've gotten work pass whole ui form class, creates other problems when trying access class anywhere main form. there update progress bar manually via progressbar1.performstep() runs through loops. also, i've changed modifier on progress bar internal, it's not class doesn't see progress bar. i might able pass bgworker

c# - Create an user-control from another thread -

i wish create button ( made me user-control ) thread other 1 wish create on . thing know how modify user-control object thread ( using delegate , .invokerequired ) don't know how create 1 . suggestions ? try following: // other thread usercontrol11.begininvoke(new action(() => { var button = new button(); button.text = "my new button"; usercontrol11.controls.add(button); })); within delegate (the () => { } ), can user control , form.

How to send the contents of MFC CRichEditView class as an email in Visual C++ 2010 -

i'm have create project in mfc vc++ create wordpad equivalent word processor can send contents email . i've started inheriting view class cricheditview class. the thing can't figure out how mail contents of in mail body(instead attachment). i've searched net , did find way implement using mapi, opens ms outlook , attaches document email. is there way allow user login email account , allow him send contents of word processor via account ?

c++ - Does google protocol buffers support size calculation before serialization? -

my (dsp) application produces data @ constant rate. rate depends on configuration selected user. know how many bytes generated per second. data structure contains repeated (packed) floating point field. length of field constant, can changed user. is there protocol buffers function calculate message size before serialization? it's impossible know ahead of time, because protobuf packs structures given fewest bytes possible - won't use 4 bytes int x = 1; example - library have walk entire graph know output size. i believe find out doing serialize operation protobuf-compliant stream of own design counts bytes given. costly, no more costly library work.

Layout for tablets in Android -

i create different layouts tablets , handsets in android. should put layout resources in order make differentiation? i know old question, sake of it... according documentation , should create mutiple asset folders this res/layout/main_activity.xml # handsets (smaller 600dp available width) res/layout-sw600dp/main_activity.xml # 7” tablets (600dp wide , bigger) res/layout-sw720dp/main_activity.xml # 10” tablets (720dp wide , bigger)

drupal - Read/write data with blocks on Boost cached pages -

i have module supplies block. block set block_no_cache, , content pulled function. lets site admin create 'message' display on site, kind of cnn, breaking update displayed @ top, , user can close hitting x. when close it, action written , uuid written cookie don't see message again. i getting reports boost users when closes message, closes everyone. assume because boost caching page , serving cached page after closed message. how can make module work people using boost? i thought maybe hook_boot might work, but, again not sure if there better way address this. hook_boot not it. once page in cache no php run. need have block loaded via ajax because state of block dependent upon cookie. http://drupal.org/project/ajaxblocks , http://drupal.org/project/ajaxify_regions 2 projects this. also hard breaking updates out if page cached. have similar issues varnish users well.

java - Ant script gets killed but not with -verbose -

i running ant script using ant -f build.xml . script supposed compile project , generate jar file seconds after ant starts generate jar file, project gets killed , see message "killed" in console. if run same command "-verbose" option, build finishes successfully. any ideas? thanks. update : ant output get: buildfile: build.xml compile: jar: [jar] building jar: /var/lib/hudson/jobs/asproj/workspace/build/asproj.jar killed this dmesg output after process killed: out of memory: kill process 16398 (bash) score 13929 or child killed process 1499 (java) so it's memory related, it's not ant jvm.. has bash process. you can try increasing jvm size using ant_opts - set ant_opts=-xms500m this sets jvm size 500 mb.

java - Various ways of accessing an array -

today did learn 2 ways of accessing array, know various ways of accessing array element , best practice of it. student learning algorithm. int [] arr; long [] arr; advantages of long datatype declaration on int. class arrayapp{ public static void main(final string[] args){ long [] arr; arr= new long[2]; int i; arr[0]=112; arr[1]=111; **// way one** for(long l:arr) { system.out.println(l); } **// way two** for(i=0;i<arr.length;i++) { system.out.println(arr[i]); } } } we've 1 declaration of array: long[] values = new long[100]; this creates array 100 long type values. each value has index (position) inside array, first index (an int value!) 0, last 1 99. the traditional loop increments integer value generate index position numbers. int values used access long values of array: for (int index=0; index < values.length; index++) { // index int long value = values[index]; // value lo

VSTO Outlook ItemSend with C# -

i'm trying add string in end of outlook email's body vsto private void thisaddin_startup(object sender, system.eventargs e) { this.application.itemsend += new microsoft.office.interop.outlook.applicationevents_11_itemsendeventhandler(application_itemsend); } void application_itemsend(object item, ref bool cancel) { if (item outlook.mailitem) { outlook.mailitem mail = (outlook.mailitem)item; mail.bodyformat = microsoft.office.interop.outlook.olbodyformat.olformathtml; mail.body += "my sample text"; mail.save(); } } when run f5 code vstudio, the app isn't stopping in breakpoints , emails not contain added line what can it? note : i'm working vs2008 , outlook 2007 thanks in advance sorry... the problem i've close outlook , restarted f5. if have same issue, know

php - Can I modify the http headers sent via a SOAP request -

i'm having trouble getting soap compression working , after reading documentation service i've realised it's because they've decided ignore http standard , own thing. basically need able set content-encoding header to: content-encoding: accept-gzip,accept-deflate rather using accept-encoding, they've decided use content-encoding incredibly annoying , there's 0 chance of them changing it. if set compression option in soap client sends content-encoding: gzip which causes soap client throw exception saying "unknown content-encoding". so possible alter http request gets sent using default php soap client? maye somebody: $mode = array ( 'soap_version' => 'soap_1_1', // use soap 1.1 client 'keep_alive' => true, 'trace' => 1, 'encoding' =>'utf-8', 'compression' => soap_compression_accept | soap_compressi

tabcontrol - MS Access Tab Control: Wrong focus -

i have tab control different pages. when starting form tab control tabs lost , inner page gets screen focus. tab control used navigation user lost way. is there way let tabs visible on screen without resizing screen smaller? desired result: +--------------------+ | tab1 | tab2 | tab3 | +--------------------+ | name: ______ | actual screen: ^ +--------------------+ |_| | name: ______ | | | reducing size of tab control works (as discovered yourself), there alternative workaround: add command button , align top left corner of tab control set tab stop property no (in 'other' tab of command button property sheet) send put command button behind tab control in form's onopen or onload event, call .setfocus method on command button use sendkeys (i know, know...) tab tab control sample code: private sub form_open(cancel integer) me.hiddencommandbutton.setfocus sendkeys "{tab}" end sub expla

new to C , error C2371: 'error" : redefinition; diffrent basic types -

i've submit assigment in few hours , i'm nervous, it's sort of gas station managing programs, handeling input files, , printing results... it's 1 .c file , that's first code lines, defines structs #include <stdio.h> #include <string.h> #include <stdlib.h> struct gas_station *pgasstationhead = null; typedef struct gas_station { char *name; double octan95ss; double octan95fs; double octan98ss; double octan98fs; double gassoldtotal; double gassoldss; double gassoldfs; struct gas_station* pgasstationnext; struct client_list* pclienthead; } station; typedef struct client_list { char carid[10]; char gastype[3]; double gasamount; char servicetype[12]; struct client_list* pclientnext; } client; and problematic functions , main : void commandsswitch(char *orders) { file *input , *output; input = fopen(orders, "rt"); output = fopen("result.txt" , "wt"); if (input == null) { error("

c++ - Stable Fluids in 3D Example -

has run across or have example of jos stam's stable fluids in 3d? need pursue 3d version of in opengl have been having terrible time doing so. there example of preferably in opengl/c/c++? this best information found solving navier stokes equitation (searched 6 month ago): link text . explains every part of equitation solver in easy way have ever found. haven't looked intensively jos stam's paper, seems based on equitation. however link posted in 2d, code easy, should no problem add 1 (or more xd) additional dimension. edit:i realized talk have linked held jos stam :). small world. nevertheless talk better documented pdf, hope helps.

Django - Excluding some fields in Inline Admin Interface -

in django admin interface, possible exclude of fields in inline? https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.modeladmin.exclude update: broken link fixed....

c# - How manage a large interface for a WinForms application? -

when thinking of srp , find application i'm writing getting out of hand our main interface/form. i'd change before far project. what techniques making large interface has "drawing surface" toolbars, menus etc? i'd easy form testable. should there other classes know how control mainform such changedstatetracker (to monitor dirty state), documentcreator or along lines "file > new" new document? the problem i'm running there so many methods inside mainform.cs , it's starting ugly maintain. this can marked cw if necessary. other hints/tips appreciated. if option, create set of user controls produce entire form. these separate user controls can have own responsibility , can tested separately. for logic itself, create classes. you can create classes createdocumentcommand implement functionality. when e.g. new document button/menu item clicked, create instance of class , execute it. public interface icommand { boo

Odd PHP header() behavior from POST to php_self - inconsistent across environments -

i'm having problem sending header(location:) response html form post php_self. the essential parts of use case: i'm including inside main page, page contains of form ui echoed out. form posts ($_server['php_self']). this form contains "file" field , passes text (login, password, etc) ftp upload. if upload successful, output header() location main page (along parameters tells containing page print successful upload message). the main page (upon receiving header) should display include form echoed out again next upload. everything works expected in dev, in prod, never form - it's header isn't getting sent. the 3 things have made mysterious: i have 2 environments, dev windows/apache 1.3.37/php 5.2.11 fast cgi, prod linux/apache (2.2.16)/php 5.2.14 fast cgi, , i've configured of relevant looking php params same across both dev , prod. in dev, aforementioned use case works great. in prod, file upload, it's though header not g

How to copy files over Network to LocalDrive in Java -

i need sample code copies files on network local file system in java. how done in java? here code copies files in local file system file fromfile = new file("file"); file tofile = new file("../copiedfile"); tofile.createnewfile(); fileinputstream = new fileinputstream(fromfile); fileoutputstream = new fileoutputstream(tofile); byte [] buffer = new byte[4096]; int bytesread; while ((bytesread = from.read(buffer)) != -1) { to.write(buffer, 0, bytesread); } i think, if want copy files on network should send buffer using objectoutput , sockets

swing - creating a table interface in java -

Image
how can create interface similar following in java (tweetie)? i thinking of using jtable 1 columns , customized cell has image in it...not sure how though. the simplest way (i it) use vertical boxlayout on jpanel . each tweet own jpanel ( tweetpanel extends jpanel ) borderlayout image on west, , tweet text in center. the following how go laying out 1 of restaurant panels. public resturantpanel extends jpanel { public resturantpanel(string name, string address, list<string> reviews, icon icon){ setlayout(new borderlayout()); jlabel iconlabel = new jlabel(theicon); jlabel namelabel = new jlabel(name); jlabel addresslabel = new jlabel(address); jpanel southreviewpanel = new jpanel(); southreviewpanel.setlayout(new boxlayout(southreviewpanel, boxlayout.y_axis); (string review: reviews) { southreviewpanel.add(new jtextarea(review)); } add(southreviewpanel); add(ico

regex - Changing date strings with jQuery and Regexp -

what kind of code should use jquery looks every yyyy-mm-dd formatted (plain text) string on page , replaces dd-mm-yyyy? thanks lot! that might work: $(document.body).contents().each(function(i,e) { $(e).text(function(i,text) { return text.replace(/(\d+)-(\d+)-(\d+)/g, function($full, $year, $month, $day) { return [$day, $month, $year].join('-'); }); }); }); example: http://www.jsfiddle.net/jm2uq/

perl - How do I upload file using CGI APPLICATION -

hi trying upload image file using perl cgi-application. not sure doing wrong - empty image file (with right name) gets saved. my $picture = $self->query->param('picture') ; $buffer; $bytesread; open (outfile, ">>$user_dir/profile_picture/$picture"); while ($bytesread = read($picture, $buffer, 1024)) { print outfile $buffer; } read " creating file upload field" section of cgi.pm documentation. there see upload method return filehandle. $fh = $self->query->upload('picture'); $buffer; $bytesread; while ($bytesread = read($fh, $buffer, 1024)) { ... }

objective c - Position of a character NSString -

i have string contains either ,b, c, or d (example a123 or b235 or 2b35 not ab123) i want find index of a,b,c or d in c # write as string s = "123b"; index = s.indexofany(new char[] = {a,b,c,d}); how write in objective-c?? you can use -rangeofcharacterfromset: : nscharacterset *charset = [nscharacterset charactersetwithcharactersinstring:@"abcd"]; nsrange range = [string rangeofcharacterfromset:charset]; if (range.location == nsnotfound) { // ... oops } else { // range.location index }

javascript - Adjust font size of Android WebView -

how adjust font size of android webview ? following appears have no effect: private void fontsizeplus() { fontsize = (fontsize < font_size_max) ? fontsize + font_size_increment : fontsize; this.changefontsize(fontsize); } private void fontsizeminus() { fontsize = (fontsize > font_size_min) ? fontsize - font_size_increment : fontsize; this.changefontsize(fontsize); } private void changefontsize(int value) { string js = "document.getelementsbytagname('body')[0].style.webkittextsizeadjust= '" + value + "%';"; mwebview.loadurl("javascript:(function() { " + js + " })()"); } where webview , constants have been initialized follows: private final static int font_size_default = 100; private final static int font_size_min = 50; private final static int font_size_max = 150; private final static int font_size_increment = 5; private int fontsize = font_size_default; private webview mwebview; @ove

grails - Base64 encoding in Java / Groovy -

what proper way convert byte [] base64 string in java? better yet grails / groovy because tells me encodeasbase64() function deprecated. sun.misc.base64encoder package isn't recommended use , outputs different size string on windows platforms. apache commons has many utilities: binary package: http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/base64.html download: http://commons.apache.org/codec/download_codec.cgi

statistics - interactive R startup script -

i'm trying run interactive r (windows xp) input script runs few commands, , leaves me @ r command line prompt. however, when run it, exits. for example, here's input file: test.r: x = 1 x here's happens when run input file parameter: c:\>r --file test.t >x = 1 >x [1] 1 c:\> <--- exits , returns prompt is there way run without r exiting? i'd other way around. just write script starts normal r gui or terminal application (per choice), place file .rprofile in same directory contains code want executed each , every time. see help(startup) on details files r looks @ startup , may become clearer.

Perl: cmpthese text vs anonymous sub problems with parameters passed -

if read cmpthese in perl benchmark module's documentation, states cmpthese or timethese can used code in either text or subroutine references. documentation seems imply these forms interchangeable: # use perl code in strings... timethese($count, { 'name1' => '...code1...', 'name2' => '...code2...', }); # ... or use subroutine references. timethese($count, { 'name1' => sub { ...code1... }, 'name2' => sub { ...code2... }, }); i having difficulties passed parameters string form versus subroutine references form cmpthese . either values in @array not passed or have run-time error. i have following code: #!/usr/bin/perl use strict; use warnings; use benchmark qw(:all); @array = qw( first second third ); sub target { $str = $_[0]; print "str=$str\n"; } sub control { print "control: array[0]=$array[0]\n"; } $sub_ref=\&target; $control_ref=\&control; print "\n\n\n

c# - Cast between List<MyType> and List<IMyType> -

i'm trying work around lack of support return type covariance in c# described in this question , first 2 answers it. part i'm not having problems setting casts, 1 property i'm using list of objects/interfaces stymieing efforts. what need in order make casts ifoo.manybars work? public interface ibar { } public interface ifoo { ibar abar { get; set; } ienumerable<ibar> manybars { get; set; } } class cbar : ibar { } class cfoo : ifoo { public cbar abar { get; set; } //this cast works ibar ifoo.abar { { return abar; } set { abar = (cbar)value; } } public list<cbar> manybars { get; set; } //the compiler can't cast either of these list<ibar> ifoo.manybars { { return (list<ibar>)manybars; } set { manybars = (list<cbar>)value; } } } try this. have add using system.linq; top of source file, if it's not there already. list<ibar> i

php - Detecting the underlying solution of a social website -

just judging html source, can 1 tell underlying solution of website? example, techniques used http://foursquare.com/ ? php+mysql? it uses scala/lift

java - JPA 1.0 or hibernate? -

we planning migrate java ee 5 j2ee 1.4. of our orm needs fulfilled hibernate 2.1.0 s0 far. since moving java ee 5 has support jpa 1.0, wondering if worth move of orm stuff jpa. are there gotchas should concerned about? there places jap 1.0 wouldnt work? i don't want use jpa 2.0. the jpa 1.0 api has pretty glaring holes in (e.g. lack of custom value types, no collections-of-elements). porting application native hibernate api jpa 1.0 api can painful due lack of basic functionality. however, hibernate's annotations api extension of basic jpa api, use jpa far goes, , top off hibernate extensions. annotations style easiest way use hibernate now, nicest compromise. if have working hibernate application, though, have wonder if it's worth bother. i'd tempted leave is, should work fine in java ee 5 environment.

android - onTrackballEvent not firing on Samsung Moment -

i have list in app. when user touches list item finger, onlistitemclick handler fires , have opening new activity. however, when user uses trackball/pad click, want perform different functionality. i've overrode ontrackballevent , works fine in emulator's trackball mode. unfortunately, when testing on samsung moment, clicking trackpad fires onlistitemclick handler, not ontrackballevent handler. does know why? have way around this? in listview can setonkeylistener , code when keycode keyevent.keycode_dpad_center listview.setonkeylistener(new onkeylistener() { public boolean onkey(view v, int keycode, keyevent event) { switch(keycode){ case keyevent.keycode_dpad_center: if(event.getaction()==keyevent.action_up){ //to when key released // code while trackball/pad clicked } return true; default: re

Android problem with Image Rotate and Matrix -

hopefully easy 1 because i've been trying sorts of different ways rid of this. i making android app incorporates clock animation. i've got working except 1 annoying thing. i have second hand on clock , i'm using following code rotate around second hand center point. you'll notice i'm trying make analogue second hand sweeps instead of ticking. public float secdegrees, secondwidth, secondheight; secondmatrix = new matrix(); secondwidth = secondhand.getwidth(); secondheight = secondhand.getheight(); secdegrees = anglepersec * secnow; secdegrees += anglepluspermilli * millis; secondmatrix.setrotate(secdegrees, secondwidth/2, secondheight / 2); newsecond = bitmap.createbitmap(secondhand, 0, 0, (int) secondwidth, (int) secondheight, secondmatrix, true); c.drawbitmap(newsecond, (centrex - newsecond.getwidth()/2), ((face.getheight()/2) - newsecond.getheight()/2),

regex - C# regular expression '+' character -

how use c# regular expressions search special characters (like '+' in case)? i use + in perl / ruby, can't seem figure out how in c#. can provide. use backslash escape special characters

c++ - Mix C-string and fortran-string in one file -

i have 1 question mixing c-string , fortran-string in 1 file. supposed playing name string fixed length 9, define length macro #define name_len 9 in .c file. there existing fortran-function, let's name fortran_function(char* name) now have call fortran function in c function, let's name c_function(char name[]) { fortran_function(name) } now problem is, how should declare c_function signature? c_function(char name[]) c_function(char name[name_len +1]) or c_function(char name[name_len]) under situations, should use 9 name length or 10? my understanding that, long passed null-terminated string 9 characters c_function, declaration correct. right? any other concern should put here? potential bugs? there's 1 more gotcha here, if remember correctly. fortran not use null-terminated strings; instead, pads right end of buffer 0x20 (space). so, if have access fortran source, modify function signature take length of passed-in string argum

NServiceBus: How to get a reference to Bus if not using the generic host -

i trying create set of services send messages each other using nservicebus/msmq. doing no xml configuration whatsoever, , not planning on using nservicebus generic host (too "black magic" marker interfaces, profiles, containers , other crazy configuration options). all want have configuration straightforward, , contained in "main()" , able call bus.publish() in loop or something. have got working except don't know how reference bus. can tell me how that? thanks! :) try this: var bus = nservicebus.configure.with() .defaultbuilder() .xmlserializer() .msmqtransport() .unicastbus() .createbus() .start(); bus.send(new whatevermessage());

c# - JSON deserialization question -

i have written json serializer using javascriptserializer. wondering when server add property json object, serializer still work? take @ forward compatible data contracts on msdn: http://msdn.microsoft.com/en-us/library/ms731083.aspx if use datacontractserializer iextensibledataobject shown in article can implement forward compatible serialization , deserialization.

sql - How to only insert unique data into an access database -

i have access database need update if information unique. there simple sql statement accomplish this? 'insert ignore' work access? example: have info stored in array ('bob','34','hair'). if database contains record matches on 3 columns not want inserted. if found unique inserted. i writing in cold fusion cant seem sql right. before doing insert, select values. if don't record know safe insert. use 2 separate queries, 1 check, , if no record found, insert.

oracle - Regarding sql reporting -

i doing spool of sql select output. have below sql settings set feedback off set heading off set linesize 800 set pagesize 50000 set trimspool on set termout off set echo off the problem there blank line inserted spool file before select statement output. not sure sql settings need add. it's printing blank page heading - use: set pagesize 0

flex - How do I set the areaStroke and areaFill properties of an AreaSeries using ActionScript? -

in flex areaseries tag looks this: <mx:areaseries yfield="profit" displayname="profit" areastroke="{s1}" areafill="{sc1}" /> i creating areachart dynamically using actionscript , want set areastroke , areafill properties don't appear available in actionscript. so question is, how set these properties dynamically? areastroke , areafill styles, not properties of areaseries. in actionscript have this: myareaseries.setstyle("areastroke",new solidcolorstroke()); myareaseries.setstyle("areafill",new lineargradient()); check out docs mx.graphics.istroke see options , check constructors classes see can set.

c# - Func and lambda question -

i have declaration of void test (func<bool> f) i have method bool getitem(string id) i can call test ( ()=>getitem("123")) , why? i suppose can check need 1 string parameter. func<bool> expects function returns bool . func<t1> has 1 output argument, func<t1, t2> takes function input t1 , output t2. each successive version allows additional input argument, final generic type being type of output argument. ex.: func<string, string, bool> able invoke bool dostuff(string s1, string s2) quick edit clarify: test( () => getitem("123")) works because start of lambda declaration exposes no input arguments, , getitem returns boolean.

how to execute procedure with timer in oracle -

i need clear records in table if data exist 1 hour. know start time, have column "starttime" "date" data type. think need timer this, how can in oracle ? the requirements not quite clear. is job/program have run once , delete records existed more hour? if case, can use.. delete <table_name> starttime < (sysdate-1/24); commit; if need purge records constantly, you'll need schedule job . frequency depend on how want records deleted. what business case trying solve?

Azure connection string best practices -

i have application migrating azure. use web.config transformation manage changing database connecting string dev/staging/prod environments. how best manage these multiple connection strings in azure? in cases doesn't matter if developer can see production credentials, can use built-in visual studio 10 config transformations. if you're looking for, follow these steps: 1.navigate azure project folder in file explorer 2. make copy of serviceconfiguration.cscfg 3. rename copy serviceconfiguration.base.cscfg 4. each build configuration (e.g. dev, staging, production), create serviceconfiguration.<build config name>.cscfg file. in these files, can use normal config transformation syntax 5. open .ccproj file in text editor 6. find following node, <itemgroup> <servicedefinition include="servicedefinition.csdef" /> <serviceconfiguration include="serviceconfiguration.cscfg" /> </itemgroup> and replace (y

javascript - How to track my jQuery plugin's usage? -

i know if there way of tracking using jquery plugin using javascript code inside plugin itself. plugin being used on different sites, i'd know being used , how many times being accessed. you present registration form people fill out before download source code, asking them basic contact information , website they'll using on. don't think @slaks' idea of 1x1 pixel gif that bad of idea, cause additional load on both server , it's additional request visitors sites use plugin. because jquery plugins plain javascript code, many people might remove part adds tracking image, considering invasion of privacy or waste of resources, or whatever reasons. may feel trickery or "snuck in". asking people register clear demonstration of motives. it's not sneaky, you're wanting track usage , think developers understand that. even if registration form optional should give pretty feel who's downloading , using plugin.

c# - Fixed header column width in gridview? -

Image
i want set header column width grid view. tried headerstyle-width="30px" . depending on item columns. column width setting based on item value. want fixed width if has value or empty. you can give header style-width , itemstyle width.it possible add span , set width .so item width remains value whether empty or contains value.i think little changes gridview makes achieve solution problem <asp:templatefield headertext="category" headerstyle-horizontalalign="center" itemstyle-horizontalalign="center"> <headertemplate> <asp:linkbutton id="lnkcategory" runat="server" tooltip="click here sort category" commandname="sort" commandargument="category" text="category" /> </headertemplate>

iphone - coredata is best? -

coredata better fmdb?can maintain primary key in core data? or other method achive instead of using primarykey in core data?any tutorial please? i don't think these 2 things analagous. fmdb merely wrapper around native sqlite apis, coredata object persistence framework sqlite 1 possible persistent storage type. check out coredata programming guide apple: https://developer.apple.com/library/ios/#documentation/cocoa/conceptual/coredata/cdprogrammingguide.html as guide developing coredata on mac: https://developer.apple.com/macosx/coredata.html coredata not offer primary key uniquing though, typically uniquing handled application code. fmdb, or native sqlite api's might better depending on specific requirements.

Java algorithm to make a straight pyramid -

___________1 __________1 2 1 _________1 2 3 2 1 ________1 2 3 4 3 2 1 ______1 2 3 4 5 4 3 2 1 _____1 2 3 4 4 4 4 4 3 2 1 ___1 2 3 3 3 3 3 3 3 3 3 2 1 __1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 _1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 i create pyramid using java? suggestion? this surve purpose. can change number 5 number other 5. eg. 1,2,3,.. , 6,8 public static void main(string[] args) { list<string> list = new linkedlist<string>(); for(int = 5; > 0; i-- ){ wrapwithnumber(list, i); } (string string : editlisttobeintriangleshape(list)) { system.out.println(string); }; } /** * wrap number strings in llist perticular number. * @param list list of strings * @param ba number need wrapp list with. */ private void wrapwithnumber(list<string> list, final int ba) { list.add(0, string.format("%d",ba)); (int = 1; < list.size(); i++) { string newformat = "%1$d " + list.get(i) + " %

triggers - Insert a Row with values from multiple tables (SQL Server) -

i'm defining delete trigger, , need backup row deleted few arguments original , including 1 column other table: tablec: * column 1: value column in tablea * column 2 6: values colums 1,2,3,5,6 tableb all want this: insert tablec values ( (select column1a tablea tablea.column = 'somevalue'), (select column1, column2, column3, column5, column6 tableb)); the result on tablec must be: column1a , column1, column2, column3, column5, column6 but not working. in special case, tableb deleted table accessible in triggers. i'm using sql-server 2008 need logic of query, , try translate it. thank you. in case, find odd, might closer you're describing, might work: insert mytable select (select columna table1), table2.columna, table2.columnb, table2.columnc, table2.columnd table2 that way, you're selecting 1 column table1 , yet selecting many columns table2 , regardless of relationship between them.

c# - guassian smoothening formula application -

how apply guassian smoothening formula graph in array? these array mapped color , plotted on graph. want linear gradient of color after applying guassian smoothening.. i want know exact guassian smoothening formula too. i believe you're asking typically called "gaussian blur" in photo-editing applications. result of blurring image using gaussian function, resulting in reduction of visual noise , detail. can read more gaussian blur , gaussian functions in general on excellent wikipedia articles devoted subjects, including nature of formulae , how these functions commonly implemented. basic algorithm used same, there few different approaches implementing it, attempting speed task computationally. if you're looking code that's written apply gaussian blur, check out these links: image processing dummies c# , gdi+ fast gaussian blur v1.3 fast gaussian blur algorithm in c# image processing c# tutorial 4 – gaussian blur fast gaussian blur algo

textarea - newline in text area in html form doesn't remain once posted -

i'm having textarea in contact form php mail function. in php mail have set header html. but if user types this line1.... line2.... i'm getting in mail this. line1....line2.... what reason? update: text area simple this. <textarea id ="msg" name="message" cols="" rows="5" class="msg">message</textarea> its posted script jquery ajax function <?php $sub = "message posted"; $email = "some@somewhere.com"; $message = "<b>message :</b><br/>" . $_request["msg"]; $message = wordwrap($message, 70); $headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'from: ifthi@ifthi.com' . "\r\n" . 'reply-to: '. $_request["email"] . "\r\n" . 'x-mailer: php/' . phpversion(); // send mail($e

android - How to view AndroidManifest.xml from APK file? -

Image
is possible view androidmanifest.xml file? i changed extension of apk file zip . zip file contains androidmanifest.xml file. unable view contents of androidmanifest.xml . encrypted. how can view androidmanifest.xml file? yes can view xml files of android apk file. there tool this: android-apktool it tool reverse engineering 3rd party, closed, binary android apps how on windows system: download apktool-install-windows-* file download apktool-* file unpack both windows directory now copy apk file in directory , run following command in command prompt: apktool d helloworld.apk ./helloworld this create directory " helloworld " in current directory. inside can find androidmanifest.xml file in decrypted format, , can find other xml files inside "helloworld/res/layout" directory. here helloworld.apk android apk file. see below screen shot more information:

Android setContentView or Intents? -

i have simple 2 screen android app. is there downside switching out layouts via setcontentview or should using intents?don't want bugger app if wrong this. well stated on android dev http://developer.android.com/reference/android/content/intent.html an intent provides facility performing late runtime binding between code in different applications. significant use in launching of activities, can thought of glue between activities. passive data structure holding abstract description of action performed. therefore if 2 screens 2 different applications want use setcontentview. it simplify code when want pass info 1 other views

objective c - Can I have multiple Core data handlers for one iphone app? -

i'm wanting build app 2 core data handlers 1 iphone app. the app sports game pre-filled information. lets call prefilleddb reference. prefilleddb read-only, not want user add/edit/delete or change in this. the second db ("gamedb") have same core data relationships/models/entities , structure. when user selects "new game", blank/empty gamedb , fill prefilleddb contents, , "continue game" use prefilleddb, assuming not empty. however, i'm not sure if right way it. question therefore best way handle kind of processing. in-built migration system better dropping/recreating databases -- or perhaps using sqlite prefilleddb , filling gamedb contents? any on great. the prefilled persistent store have readonly if ships in app bundle in app bundle read only. make use of data in readwrite persistent store, need copy data persistent store outside app bundle e.g. in documents directory app. you have 2 ways of doing this: 1) simplest: