Posts

Showing posts from April, 2014

c# - Interface / Abstract Class Coding Standard -

i spotted proposed c# coding-standard stated "try offer interface abstract classes". know rationale this? the .net framework design guidelines have interesting things interfaces , abstract classes. in particular, note interfaces have major drawback of being less flexible classes when comes evolution of api. once ship interface, members fixed forever, , additions break compatibility existing types implement interface. whereas, shipping class offers more flexibility. members can added @ time, after initial version has shipped, long not abstract. existing derived classes can continue work unchanged. system.io.stream abstract class provided in framework given example. shipped without support timing out pending i/o operations, version 2.0 able add members supported feature, existing subclasses. thus, having corresponding interface each abstract base class provides few additional benefits. interface cannot publically exposed, or you're left @ square 1 in ter...

c++ - error LNK2019: unresolved external symbol "public: -

i creating torrent application using libtorrent in vs 2008. tried example given in link http://www.rasterbar.com/products/libtorrent/examples.html showing me these error....how solve them? linking... main.obj : error lnk2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::~torrent_info(void)" (??1torrent_info@libtorrent@@qae@xz) referenced in function _main main.obj : error lnk2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::torrent_info(struct libtorrent::lazy_entry const &)" (??0torrent_info@libtorrent@@qae@abulazy_entry@1@@z) referenced in function _main main.obj : error lnk2019: unresolved external symbol "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,struct libtorrent::lazy_entry const &)" (??6libtorrent@@yaaav?$basic_ostream@du?$char_traits@d@std@@@std@@aav12@abulazy_entry@0@@z) referenced in function _main main.obj : ...

linq to sql - How to implement lookup table in mvc framework? -

asp.net mvc2: have many dropdownlists in mvc application. @ first, started creating table each 1 unique id , name , referring them in controllers , views. application got bigger, , suggested use lookup table, contains lookuptype , lookupvalue compound primary key , fill values dropdownlists in it. i've looked on internet, method used mvc 1 table each dropdownlist! can explain me how can implement it, , in detail please becoz i'm totally lost. link tutorial great. i'm using vb.net , linq sql. suppose tables have columns id , name , value . having 1 table table this: create table lookup ( lookupid int not null identity primary key, lookuptypeid int not null references lookuptype(lookuptypeid), name nvarchar(50) not null, value int not null, unique(enumtypeid, name) ) go this table make sure within same type names don't clash. anyway. of course have similar application (not data) model class public class enumvalue {...

android - Capture SeekBar values -

in android application have textview , seekbar . both values used calculating result on button click. the problem how capture seekbar value , convert string calculation. the code below: class clicker implements button.onclicklistener { public void onclick(view v) { string a,b; integer vis; = txtbox3.gettext().tostring(); b = slider1.getcontext().tostring(); vis = (integer.parseint(a)*integer.parseint(b))/100; tv.settext(vis.tostring()); } } please help. in advance. you looking method getprogress() of progressbar class seekbar subclass of progressbar . so that. int value = seekbar.getprogress(); also don't understand why want convert int string can convert string integer later. not make sense.

sql - Calling table-valued-function for each result in query -

say had query this: select x table y = 'z' how execute stored procedure using each x above query parameter? update i have changed sp table-valued function instead. each call function return table. need store these results in perhaps temp table , have sp return table. solution finally managed work @cyberkiwi. here final solution: declare @fields table ( field int) insert @fields (x) select * tvf_getfields(@someidentifier) select * @fields cross apply dbo.tvf_dosomethingwitheachfield([@fields].field) you can generate batch statement out of , exec it declare @sql nvarchar(max) select @sql = coalesce(@sql + ';', '') + 'exec sprocname ' + quotename(afield, '''') table afield2 = 'someidentifier' , afield not null exec (@sql) before edit (to tvf), have changed sp continue populate temp table. post-edit tvf, can use cross apply: select f.* tbl cross apply dbo.tvfname(tbl.afield) f...

svn - Xcode Subversion (SCM) Difference between Refresh and Update -

Image
i have configured xcode use subversion (hosted on remote webserver - beanstalk.com). in xcode menu under scm, want know difference between 2 options 1. "refresh entire project ..." , 2. "update entire project ..." please help. thanks dev. open scm results window scm menu item, click on little 'text' button on left-hand-side (might @ bottom of window start with?), expand can see little more, , run refresh , update see commands xcode passes svn. sorry, can't speak svn right now, cvs did me:

blackberry java backgroung image resize -

how automatically set size of image ?(for different screen size of different phone's) bitmap bitmaporig = bitmap.getbitmapresource("icon.png"); // create bitmap of arbitrary size int scaledx = 360; int scaledy = 415; bitmap bitmapscaled = new bitmap(scaledx, scaledy); bitmaporig.scaleinto(bitmapscaled , bitmap.filter_lanczos); bitmaporig.scaleinto(bitmapscaled , bitmap.filter_bilinear, bitmap.scale_to_fill); bitmapfield bitmapfieldscaled2 = new bitmapfield(bitmapscaled , field.focusable); check these links: http://supportforums.blackberry.com/t5/java-development/resizing-a-bitmap-using-scaleimage32-instead-of-setscale/m-p/255454 increase height widht of image per bb screen size

php - mysql create a table character sets -

in phpmyadmin, entered: create table ch ucs2 char(3) character set ucs2, gb2312 char(3) character set gb2312 test3 char(4) character set utf8; and gives me syntax error. doing wrong here? you forgotten parentheses: create table ch( ucs2 char(3) character set ucs2, gb2312 char(3) character set gb2312, test3 char(4) character set utf8 );

c# - Applying automatic and hidden filtering to a List<T> -

ok. i have class myclass , class based on list. let's call mycollection. now when types: mycollection coll = new mycollection(); ... coll.find(...) they acting on entire collection. want apply filtering - behind scenes - if write above code, actually executes like... coll.where(x=>x.canseethis).find(...) what need write in definition of mycollection class make work? can make work? you want write wrapper class implements ilist or icollection , using regular list internally. wrapper class proxy method calls internal list, applying filter required.

multithreading - Thread-safety in C? -

i want write high performance synchronized generator in c. want able feed events , have multiple threads able poll/read asynchronously, such threads never receive duplicates. i don't know how synchronization typically done. can give me high level explanation of 1 or more techniques might able use? thanks! the main concept in thread safety mutex (though there different kind of locks). used protect memory multiple accesses , race conditions. a example of use when using linked list . can't allow 2 different threads modify in same time. in example, possibly use linked-list create queue, , each thread consume data it. obviously there other synchronization mechanisms, 1 (by far ?) important. you have @ this page (and referenced pages @ bottom) more implementation details.

asp.net - Manipulating Word 2007 Document XML in C# -

i trying manipulate xml of word 2007 document in c#. have managed find , manipulate node want can't seem figure out how save back. here trying: // open document memorystream package pkgfile = package.open(memorystream, filemode.open, fileaccess.readwrite); packagerelationshipcollection pkgrcofficedocument = pkgfile.getrelationshipsbytype(strrelroot); foreach (packagerelationship pkgr in pkgrcofficedocument) { if (pkgr.sourceuri.originalstring == "/") { uri uridata = new uri("/word/document.xml", urikind.relative); packagepart pkgprtdata = pkgfile.getpart(uridata); xmldocument doc = new xmldocument(); doc.load(pkgprtdata.getstream()); nametable nt = new nametable(); xmlnamespacemanager nsmanager = new xmlnamespacemanager(nt); nsmanager.addnamespace("w", nsuri); xmlnodelist nodes = doc.selectnodes("//w:body/w:p/w:r/w:t", nsmanager); foreach (xmlnode nod...

c# - Create XNA sprite on the fly from an image -

i have image, let's says .png, uploaded user. image has fixed size, let's 100x100. i create 4 sprites image. one (0,0) (50,50) another (50, 0) (100, 50) the third (0, 50) (50, 100) the last (50, 50) (100, 100) how can prefered c# ? thanks in advance help to create texture png file, use texture2d.fromstream() method ( msdn ). to draw different sections of texture, use sourcerectangle parameter overload of spritebatch.draw accepts ( msdn ). here's example code: // presumably in update or loadcontent: using(filestream stream = file.openread("uploaded.png")) { mytexture = texture2d.fromstream(graphicsdevice, stream); } // in draw: spritebatch.begin(); spritebatch.draw(mytexture, new vector2(111), new rectangle( 0, 0, 50, 50), color.white); spritebatch.draw(mytexture, new vector2(222), new rectangle( 0, 50, 50, 50), color.white); spritebatch.draw(mytexture, new vector2(333), new rectangle(50, 0, 50, 50), color.white); spriteba...

c# - visual studio issue -

q: i have following problem : i don't know problem made, visual studio sound strange,, arrows in the side of .cs page , when type tab, dots appeared on page ..many keys type other letters. i reset visual studio through import , export , reset keyboard shortcuts in visual studio , restart visual studio b ut still same problem. try going to: edit > advanced > view white space if it's turned on it'll show tabs arrows , spaces dots.

.net - ASP NET MVC 3.0 GET USER INPUT -

whats best way user input view controller. mean specific input not "formcollection" someting "object person" or "int value" , how refresh page on interval say example if view typed "person" class: public class person { public string firstname { get; set; } public string lastname { get; set; } public int age { get; set; } } then inside view: @model mymvcapp.person @using(html.beginform()) { @html.editorformodel() // or html.textboxfor(m => m.firstname) .. , of properties. <input type="submit" value="submit" /> } then you'd have action handle form: [httppost] public actionresult edit(person model) { // stuff model here. } mvc uses called modelbinders take form collection , map model. to answer second question, can refresh page following javascript: <script type="text/javascript"> // reload after 1 minute. settimeout(function () { window.l...

c# - Converting Expression<T, bool> to String -

i need way recreate dynamically generated reports @ point in future. long story short, need store specific linq query (different each report) database , execute query dynamic linq later on. this good, can't find way convert expression string. as in: expression<func<product, bool>> exp = (x) => (x.id > 5 && x.warranty != false); should become: "product.id > 5 && product.warranty != false" is there way that? this may not best/most efficient method, does work. expression<func<product, bool>> exp = (x) => (x.id > 5 && x.warranty != false); string expbody = ((lambdaexpression)exp).body.tostring(); // gives: ((x.id > 5) andalso (x.warranty != false)) var paramname = exp.parameters[0].name; var paramtypename = exp.parameters[0].type.name; // add "orelse" , others... expbody = expbody.replace(paramname + ".", paramtypename + ".") .replac...

c# - Progress bar displaying execution of a method -

i don't know how display execution of method in compact .net framework. example have method (eg. upload() or print() ) takes time (in cases big interval) finish.i want user can see progression of time-consuming task (eg. upload() ) on progress bar. i tried doing thread , threadpool.queueuserworkitembut i'm stuck. problem don't know how sync thread of method , progressbar. please help. i hope help: progressbar pg = new progressbar(); pg.maximum = 100; pg.step = 1; this.controls.add(pg); new thread(new threadstart(() => { // replace code: (int = 0; < 100; i++) { if (pg.invokerequired) pg.invoke(new threadstart(() => { pg.performstep(); })); else pg.performstep(); } })).start(); this part important, or exception: if (pg.invokerequired) pg.invoke(new threadstart(() => ...

asp.net mvc - MVC render name of the view -

we have pages (lets call parent pages) calls other .aspx (lets call child pages) using renderaction. what use in these parent pages kind of helper prints name of these child pages if in querystring appears debug=1 using like: @html.autodiscoverwidgets() its possible this? avoid put in every child page like: @html.autodiscoverwidgets("nameofthechildview") what have moment following extension method: public static mvchtmlstring autodiscoverwidgets(this htmlhelper htmlhelper) { if (httpcontext.current.request.querystring["debug"].tostring() == "1") { return mvchtmlstring.create("hello"); } else { return mvchtmlstring.create(""); } } you use following helper: public static mvchtmlstring currentviewname(this htmlhelper htmlhelper) { var view = htmlhelper.viewcontext.view buildmanagercompiledview; if (view != null) { return mvc...

html - What's the best way to present an e-mail address on my website without being attacked by spammers? -

what's best way present e-mail address on website without being attacked spammers? the approach foo @ fooland dot com not i'm looking for. need present in way comprehensible normal people. edit the displaying e-mails dynamic there's recent answer on superuser.com addresses exact question comparing whole range of commonly used methods.

MySQL Workbench skip pulling schema list on opening a SQL editor -

is there way make workbench skip caching schema information on sql editor load? i've got tons of tables in database (not mention server half way across world) , takes ages fire sql editor. this akin --skip-auto-rehash (or -a switch) on command line life of me couldn't find on workbench or connection options this.

Approaches to building an efficient database -

i wondering if draw on experienced database designers. i;m not experienced building databases , have project complete within set time (couple of months). requirement build third normal form. i wondering best way start be? should go ahead , build works (trying efficient possible) go , refactor parts can improved or there methodology follow ensure degrees of normalisation start? do not build database intent go later , normalize it. databases not refactor application code 1 thing , another, have requirement follow third normal form, so start, far less work , in end far better product. there not shortcut correct database design in third normal form. understand before starting deisgn. if unfamiliar database dsign in third normal form, go spend couple of days doing reading on database design. spend day or reading performance tuning database - designing database start perform save lot of time. doesn't take longer designing poorly performing datbase, once know , avoid. fir...

NHibernate - QBE -

i have problem using qbe nhibernate. have one-to-one relationship between person class , employee. public class person { public virtual employee employee { get; set; } public virtual int age { get; set; } public virtual string forename { get; set; } public virtual string surname { get; set; } public virtual int personid { get; set; } } public class employee { public virtual int personid { get; set; } public virtual string payrollno { get; set; } public virtual int holidays { get; set; } public virtual person person { get; set; } } as example, want employees employee.forename="john" , employee.person.payrollno = "231a". wondering if use query example this? i have not been able find definitive "no" haven't been able work. i've found qbe promising unfortunately not useful due following limitations: cannot query related objects. requires public parameterless constructor. initialized properties ...

Access VBA throwing unlisted error code -

i'm seeing error code in access 2000 vba: -2147352567-record in '[sometable]' deleted user. so, 2 questions: 1) how handle/avoid error code this? 2) can explain why i'm getting error code doesn't seem exist in ms documentation? , there way decipher code? combination of several codes? guidance on topic appreciated. public sub form_open(cancel integer) ' check unposted record / regardless of date / shift ' if there unposeted record goto dim lcheck dim spress string on error goto form_open_err gotorecord: if bpressconsumptionopenran = true lcheck = dlookup("pressconsumptionid", "spi_getunpostedrecord") if not isnothing(lcheck) me.txtpressconsumptionid.setfocus docmd.findrecord lcheck else docmd.setwarnings false docmd.openquery ("spi_insertnewpressconsumption") me.requery docmd.setwarnings true end if end if form_open_exit: exit sub form_ope...

c# - Compression issue with large archive of files in DotNetZip -

greetings.... i writing backup program in c# 3.5, using hte latest dotnetzip. basics of program given location on server , max size of spanned zip file , go. there should traverse folder/files given location , add them archive, keeping exact structure. should compress down reasonable amount. given uncompressed collection of folders/files 10-25gb, created spanned files being limited 1gb each. i have working (using dotnetzip). challenge there little no compession happening. chose use "adddirectory" method simplicity of code , how seemed fit project. after reading around second guessing decision. given below code , large amount of files in archive, should compress each file added zip? or should adddirectory method provide same compression? i have tried every level of compression offered ionic.zlib.compressionlevel , none seem help. should think using outside compression algorithm , stream dotnetzip file? using (zipfile zip = new zipfile()) { zip.adddire...

c++ - Is there a better way to wordwrap text in QToolTip than just using RegExp? -

so question in title. qtooltip doesn't seem provide wordwraop feature. possible, however, replace nth space \n using regexps, wondering if has suggestion better sollution. specifically, problem approach doesn't take length of text account. example i'd longer texts form wider paragraphs. if text in tooltip rich text, automatically word-wrapped. here's trivial example, setting font black makes "rich text" , gets word wrapped. leaving out font declarations means tooltip plain text , extend whole length of screen. qstring tooltip = qstring("<font color=black>"); tooltip += ("i model of modern major general, i've information vegetable animal , mineral, know kinges of england , quote fights historical marathon waterloo in order categorical..."); tooltip += qstring("</font>"); widget->settooltip(stooltip); of course example, width of tooltip platform. there new suggestion in qt bug tracker proble...

php - $_POST from paypal response after payment is empty -

i created hosted button using business account , integrated code php application. i use 'website payments standard' , generated 'buy button' using tool provided in 'merchant services' page. i using http://sandbox.paypal.com/ test this. configurations in merchant profile: instant payment notification (ipn) 'enabled' , 'notification url' given. auto return on. return url specified (the same given above in notification url) payment data transfer on website payment off paypal account optional: off while creating button in third option gave same notify_url. transaction happens , gets redirected notify_url. issue is, $_post paypal response in notified page empty. i printed $_post in first line of notifier page itself. need add other configuration? making mistake? the data going ipn url. log $_post data file script @ ipn url , see getting. think if turn off ipn, may data on notify_url (been while though, not 100% sur...

Windows Phone 7 ListBox has bad performance with just a few items? -

i'm writing simple dictionary app gives suggestions words type. suggestions displayed in listbox , each time query changes, 10 suggestions should appear. unfortunately, performance low @ moment. takes second results appear , don't understand why. eqatec profiler shows methods running smoothly. i've confirmed putting stopwatch around code. i've experimented number of suggestions, , performance increase fewer items. this leads me conclude rendering listbox (which presume happens outside of methods) blame lack of performance. does rendering 10 items in listbox take more 250ms? how can put small number of words on screen? edit: way fill listbox straightforward. right way? resultslistbox.items.clear(); foreach (string s in suggestions.words) { resultslistbox.items.add(s); } resultslistbox.selectedindex = suggestions.matchindex; what see here it: default listbox, string items, no templates. violate 1 of these principals? ensure have item data templa...

I'm new to programming. My goal is to learn Objective-C but C has been easier to understand so far. Which direction should I go? -

would learning c before objective-c beneficial or slow me down? goal make useful applications osx. objective-c superset of c, c won't hurt you, , bit. furthermore, of os x's frameworks, corefoundation, expose c interface, , you'll have use them @ point anyway. but os x development uses objective-c, you'll have learn anyway.

php - Magento - How can I run code when my order is canceled or refunded -

my payment module required sent notifications payment service if order canceled or refunded. assume "cancel" button on order page (in administration backend) cancel order, , "credit memo" button (after invoice has been created) refund order. how run code on these events? tried using cancel() method in payment method model, code did not run. seems payment method not using transactions or not create authorization transaction id. common beginner mistake in payment gateways development. to enable payment gateway online actions need implement in payment method: class mybest_payment_model_method extends mage_payment_model_method_abstract { protected $_canauthorize = true; // set true, if have authorization step. protected $_cancapture = true; // set true, if payment method allows perform capture transaction (usally credit cards methods) protected $_canrefund = true; // set true, if online refunds availab...

c# - Dynamic Grid Measurements in WPF - Rendering Controls -

i working on drag , drop editor creating items , adding them dynamically wpf canvas. each item, creating dynamic grid , addign canvas. need layout state information each 1 of these grids added know coordinates on canvas. problem having when try access height/actualheight/renderedsize information of each of these grids add, turns out 0. assuming might need render items new state information registered, not quite sure how this. have seen support through invalidatexxxx() methods provided, not sure if/or 1 should using. there updatelayout() function, not sure if need. here code have running through loop , adding grids, represent lineitems in canvas. /*initialize grid layout*/ grid newgrid = new grid(); newgrid.minheight = 50; newgrid.width = previewwindow.actualwidth; newgrid.background = brushes.beige; newgrid.showgridlines = true; /*define column definitions*/ ...

java - Spring, beans and enum's valueOf -

when calling spring's "validate" eclipse, lot of errors when want enum using enum's implicit "valueof" method. for example: <bean id="docfamily" class="...docfamily" factory-method="valueof"> <constructor-arg> <value>logy</value> </constructor-arg> </bean> has eclipse telling me: non-static factory method 'valueof' 1 arguments not found in factory bean class ... however understand documentation: beanwrapperimpl supports jdk 1.5 enums , old-style enum classes: string values treated enum value names so above should work right? (btw 'constructor-arg' correct tag in case, shouldn't 'method-arg'?). why eclipse/spring's "validate" giving me error message? enum.valueof() has 2 arguments: public static <t extends enum<t>> t valueof(class<t> enumtype, string name) therefore des...

javascript - Filter n arrays by excluding values that don't exist in each -

i have n arrays need determine if x in of n arrays. (where n number, , x numeric value) have following in place, it's ending false. function filterarrays() { var x = $(this).attr('id'); // ex: 2 var arrays = [[1,2,3],[2,4,6]]; var result = false; each (var n in arrays) { result = result ^ (n.indexof(x) > -1); } } how make result equal true when x in both arrays, when x not in both arrays, make result equal false ? the function above used jquery's filter() method. example: $(arrayofelementswithnumericids).filter(arrayfilter); // arrayofelementswithnumericids prototype: [div#1,div#2,div#3,...] i'm thinking bitwise operation called for, wrong. please explain why solution right , why mine isn't working. (for bonus points) here issues example: comparing number string (id string). use x = parseint(...) using ^ operator. instead initialize result true , use && . get rid of each . correct syntax fo...

email - Mail sent "on behalf of" when using PHP Pear -

i using pear send mails our server. however, email clients (most importantly gmail) "mail received nobody@server on behalf of john doe". causes this? php or server config itself? with headers set: $headers["from"] = john doe<johndoe@example.com>; $headers["return-path"] = john doe<johndoe@example.com>; $headers["sender"] = john doe<johndoe@example.com>; however, when e-mail headers of actual mail arrived, see: return-path: <nobody@server> received: nobody server local (exim 4.69) (envelope-from <nobody@server>) id 1thn0y-0001yy; tue, 25 jan 2011 11:48:46 -0600 from: john doe<johndoe@example.com> sender: nobody <nobody@server> date: tue, 25 jan 2011 11:48:46 -0600 so except field, other header settings ignored...! do? what seeing envelope headers being generated exim. need change configuration, or send differently around this. normal sendmail, there few simple commandline s...

How does one query a SQL View with Linq to SQL? -

i this... var thedogs = d in db.dogs d.equals(5) select d; //letthemout(thedogs); where db datacontext , dogs table, view? is same? yes, same. can't insert/update/delete data in view. if you're using linq sql designer, drag view dbml designer. if you're using manual mapping, map object defining view, instead of table.

asp.net mvc - Validation on my domain objects or in the view model? Where should it go? -

i trying keep service layer free of asp.net mvc dependcies have ran problem. want use compare part of asp.net mvc library. should do? i have domain class(that later used fluent nhibernate) public class user() { [required(errormessage = "required")] [compare()] // can't because not user domain needs know mvc , rather not public virtual string email (get; set;} public virtual string confirmemail (get; set;} // not mapped fluent nhibernate } public class userviewmodel() { public user user {get; set;} } public actionmethod method() { if(!this.modelstate.isvalid) { } } i have domain object made find kinda pointless move properties usersviewamodel put validation on them later on through domain model used commit(nhibernate commit) you should use "buddy class" model class hold validation attributes: // note partial keyword below: full definition of mymodel // can put in file in model [metadatatype(typeof(mymodelmetadata...

ruby - Rails: money gem converts all amounts to zero -

i'm trying use money gem handle currency in app i'm running strange error. have in "record" model: composed_of :amount, :class_name => "money", :mapping => [%w(cents cents), %w(currency currency_as_string)], :constructor => proc.new { |cents, currency| money.new(cents || 0, currency || money.default_currency) }, :converter => proc.new { |value| value.respond_to?(:to_money) ? value.to_money : raise(argumenterror, "can't convert #{value.class} money") } amount integer. when create new record ignores whatever value put in amount field , defaults 0. there need add forms? i'm using rails 3.0.3 , money gem version 3.5.5 edit: added bonus @ end of answer well, question interesting me decided try myself. this works properly: 1) product migration: create_table :products |t| t.string :name t.integer :cents, :default => 0 t.string :currency t.timestamp...

SharePoint 2007 Publishing Site -

created new publishing site serve portal our division. contains several custom coded webparts fetch data db and/or rss feds , outside links. i found absolutely dumb owner i'm having approve own page. there turn off functionality? or modifying document library runs through approval process? in edit mode, there link "reminder: check unpublished items" , if click of web parts , links, pictures, , other contents within these web parts highlighted fat dotted red line. how rid of since sharepoint complaining embedded in these webpart? if try create doc library called "announcements" error: "the resource cannot found. description: http 404. resource looking (or 1 of dependencies) have been removed, had name changed, or temporarily unavailable. please review following url , make sure spelled correctly. requested url: /announcements/forms/allitems.aspx" for reason not word, can call buggsbunny , fine. "announcements" key word of kind...

c# - how would you remove the blank entry from array -

how remove blank item array? iterate , assign non-blank items new array? string test = "john, jane"; //without using test.replace(" ", ""); string[] tolist = test.split(',', ' ', ';'); use overload of string.split takes stringsplitoptions : string[] tolist = test.split(new []{',', ' ', ';'}, stringsplitoptions.removeemptyentries);

how do I copy a lot of images onto a canvas in PHP? -

i have witten function copies images onto canvas , saves file. code @ bottom of post. the code works fine when try copy 15 image onto canvas, when try copy 30 stops. no errors or exceptions... i hope 1 of can me out :) $img = imagecreatefromjpeg( $image ); $imgwidth = imagesx($img); $imgheight = imagesy($img); // create canvas , fill white $canvas = imagecreatetruecolor( $guidelines['canvasw'] * $dpi, $guidelines['canvash'] * $dpi ); $color = imagecolorallocate( $canvas, 255, 255, 255 ); imagefill( $canvas, 0, 0, $color ); // copy images onto canvas foreach( $guidelines['imageguide'] $guide ): $bestfit = bestfit( $imgwidth, $imgheight, $guide['w'] * $dpi, $guide['h'] * $dpi ); if( $bestfit['rotate'] ) { $output = imagerotate($img, 90, 0); } else { $output = imagerotate($img, 0, 0); } imagecopyresampled($ca...

magento - create a global function -

i want create function can accessed *.phtml files. should place function in magento framework? you should create module , helper class in module (usually mycompany_mymodule_helper_data default). then, add function helper class. can function in phtml this: mage::helper("mymodule")->somefunction(); hope helps! thanks, joe

How do I install a user-specific configuration file with the distribute python -

i'm creating python package, , using distribute package egg. i'd install user-editable configuration file each user of software. best way accomplish this? i'm using python 2.6 , targeting windows platform. since egg hard edit, doesn't go in egg. a user-editable configuration file goes in user's home directory or system-wide directory /etc/myapp . your app should search in number of easy-to-find places. follow linux guidelines tracking down .bashrc file hints on how best this. or follow windows guidelines on system , my documents directoryes. you write app in 1 of 2 ways. it can work no config. if -- after searching usual places -- there's no config, still works. it creates default config in current working directory if can't find 1 anywhere else.

windows mobile - Deploying an application into a smart device -

just wondering best way deploy application device using active sync / windows mobile device center? looked creating cab project works want know other options this.. and also, how icon displayed when application installed device , shortcut created device's desktop. a cab file option package can installed on device. can register cab activesync can automatically installed through wmdc interface (as opposed requiring user copy cab over). process outlined in this msdn article . getting icon matter of creating , copying shortcut appropriate directory, typically done in cab well. \windows\start menu location you're after.

java - filter not executing on static content request -

i'm trying implement making gwt apps crawlable , crawlfilter isn't being executed, ever. doing wrong? static content not subject filters? <web-app> <!-- crawling servlet filter --> <filter> <filter-name>ajaxcrawlfilter</filter-name> <filter-class>com.bitdual.server.crawlservlet</filter-class> </filter> <filter-mapping> <filter-name>ajaxcrawlfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- default page serve --> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> static content served entirely different infrastructure (like cdn) wouldn't surprised if filters not executed on content hosted statically.

android - Displaying downloaded image in an imageView -

hi :) i'm trying write android application downloads bunch of images , afterwads displays them in gallery. managed download images (i did download them data/data/project directory - not sure if that's right) can't access them (i tried using setimageuri method of imageview display image after i've created uri instance via uri.builder().appendpath("data/data/project/file.jpg").build() no avail). i'm new android developing appreciated. thanks! i started writing example, decided waste of time since net littered better examples create. at high level, you'll need this: get 1..n file objects load bitmaps these objects using bitmapfactory load these decoded bitmaps imageview the typical mechanism viewing set of resources adapter pattern. mentioned, there example here encompasses use of asynctask , other patterns typical of android programming should become familiar with. review , see if have further questions.

Start Google search query from activity - Android -

i wondering if there easier way (or way) start browser google search query. example user can select word or phrase , click button , activity start browser google search query. thank you. you can quite few lines of code (assuming want search google 'fish'): uri uri = uri.parse("http://www.google.com/#q=fish"); intent intent = new intent(intent.action_view, uri); startactivity(intent); otherwise, if rather start own activity handle browsing, should able webview: http://developer.android.com/reference/android/webkit/webview.html i think better answer here @zen_of_kermit's. nice though, if android allowed user provide search engine has though action_web_search , rather using google.

My android app stops recording GPS data when screen goes to home after being idle -

i have activity recording gps positions along route. not sure processes or methods need keep alive after screen shuts off , security trace thingy comes up. seems stop recording happens, right have 2 buttons handle boolean starts recording or not. not sure have or event have trap make sure state of program remains constant if call comes in, or else happens... (do have make service?!) really care gps recorder still recording after screen goes dark cause phones been idle. before put security patttern draw thingy work, on else going on code state getting kind of hosed. whats wake lock hear about? simple answer: yes, u need service complicated one: activity dies out of focus, if want continue recording data, need make service.

After successfully connecting to Google Contacts API via php, how/what do I store in database to reconnect later? -

so here's deal. i've connected google contact's api via php, stored in sessions, , retrieved list of contacts. what want store necessary tokens in database, , retrieve them @ later time re-use them on same user. can't figure out information store... i've attempted storing every little item session database , reloading when try reconnect api, 1 error or because tokens aren't correct. i imagine answer simple understands oauth - it's question of store. code below: <?php session_start(); include_once "../oauth-php/library/oauthstore.php"; include_once "../oauth-php/library/oauthrequester.php"; global $db; $userid=$_session['userid']; define("google_consumer_key", "website.com"); // define("google_consumer_secret", "----------------------"); // define("google_oauth_host", "https://www.google.com"); define("google_request_token_url", google_oau...

php - Trying to use yui treeview inside of a cakephp view -

i'd put yui treeview inside of add.ctp view in cakephp application. i've got treeview displaying fine i'm trying handle on how can incorporate treeview selected nodes post data gets submitted cakephp view. i solved same problem using json: create javascript function allow encoding of yui's selected nodes json string add json string hidden field dom properties

ruby on rails - Mongoid finders not working? -

i have set rails3+mongoid application , when open rails console, none of finders seem work - http://d.pr/fnzc user.all user.find(:all, :conditions => { first_name => "john" }) both return: #<mongoid::criteria selector: {}, options: {}> am doing wrong? okay, part of makes mongoid irritating newcomers. people expect methods user.all return array when returns criteria object. in order provide syntatic sugar of chainable methods , other fancy query mechanisms, mongoid seems use lazy loading type thing. you can do: #array index user.all[0] #first/last user.all.first #each on things, print out users user.all.each {|u| p u} #edit, forgot include this, want #this spits out array user.all.to_a it makes difficult verify things working newcomers activerecord user.all returns array.

redirect - Subdomain hosting on Apache -

i beginner in web server related stuff. i have server working domain www.example.com i want host test.example.com on server have same behavior www.example.com . is, requests test.example.com should mapped start.php file. also domain name should remain test.example.com , i.e. don't want redirect requests test.example.com www.example.com . how achieve this? your solution name-based virtual host . specifically, want set virtual host direct requests specific host (in case, identified subdomain) particular directory. thereafter, rewrite requests start.php . <virtualhost *> servername mysub.domain.tld documentroot /www/vhosts/http/mysub.domain.tld rewriteengine on rewriterule ^(.*)$ start.php [l] </virtualhost> place in apache configuration file or separate file in sites-available directory, enabling via a2ensite . make sure 1 loaded before 1 domain.tld , or else apache recognize path domain.tld , forget mysub.domain.tld . restart apache, ...

Java repaint image -

i have problem script; want repaint new image (another 1 shown) when button pressed, button doesn't anything... actionlistener 1 = new actionlistener() { public void actionperformed(actionevent e) { panel2.revalidate(); panel2.repaint(); } }; btn1.addactionlistener(one); jlabel test1 = new jlabel(mydeckofcards.givecardplayer1().getimage()); panel2.add(lab1); panel2.add(test1); panel2.add(pn5); panel2.add(pn1); panel2.add(btn1); inside actionperformed need hold of jlabel , call seticon() on it, passing in new image. there's few ways jlabel, 1 make sure have final variable declared contain somewhere in scope of actionperformed method, , find inside panel2 (not recommended). you pass in actionlistener through constructor if declare full-fledged class purpose. edit : final jlabel test1 = new jlabel(mydeckofcards.givecardplayer1()...

python - How come this Django plugin won't work? -

https://github.com/sunlightlabs/django-mediasync/ the media syncs s3, doesn't change {% media_url %} s3 url in template (when go production) i followed instructions. here's settings.py. mediasync = { 'aws_key': aws_accesskey, 'aws_secret': aws_secretkey, 'aws_bucket': "happy_media", 'backend': 'mediasync.backends.s3', 'serve_remote': true, 'aws_bucket_cname': true, 'doctype': 'html4', 'use_ssl': false, 'cache_buster': 1234, } i added urls.py from django.template import add_to_builtins add_to_builtins('mediasync.templatetags.media') i have: 'django.core.context_processors.media' context processors in settings.py try including 'django.core.context_processors.media' list of context processors in settings.py. think that's exposes media_url , makes visible in templates.

stream - Increase Internal Buffer Size Used by Java FileInputStream -

when calling read(byte[]) on fileinputstream , read size 8k, if byte[] exponentially large. how increase max read amount returned per call? please not suggest method merely masks limitation of fileinputstream . update: there doesn't seem real solution this. however, calculated method call overhead 226us on system, 1g file. it's safe not going impact performance in real way. wrap in bufferedinputstream allows specify buffer size.

vim - gVim crash when running autocomplete in ruby file on win7 -

i using gvim 7.3 , ruby 1.9.2 on windows7 64bit after set omni completion func rubycomplete#complete, build-in rubycomplete.vim whenever call omni complete, vim crash. the debug message :access violation reading location 0x00000020. does know might cause problem? or should downgrade ruby 1.8.7 might avoid bug? the problem because there's bug ruby plugin in vim version 7.3.46, http://www.mail-archive.com/vim_dev@googlegroups.com/msg12221.html i download latest build(7.3.107) wu yon's website ( http://wyw.dcweb.cn/ ) overwrite executable file in %vim%/vim73, , autocomplete works without crash.

Do iPhone's have a unique code that identifies them? -

do iphone's have unique code identifies them? can accessed via cocoa? serial number unique? every iphone has uid number. can calling: [[uidevice currentdevice] uniqueidentifier]

c++ - How to implicitly convert Qt objects to QString? -

what's best way of making all of commented code below work in standard c++/qt way? class { public: a() { } virtual ~a() { } virtual qstring tostring() { return "a"; } }; class b: { public: b() { } ~b() { } qstring tostring() { return "b"; } }; int main(int argc, char *argv[]) { qcoreapplication a(argc, argv); a_; b b_; // qdebug() << a_; // can make work overloading << yes? // qdebug() << b_; // qstring x = a_; // how make work? // qstring y = b_; qstring s = a_.tostring(); // i'm doing @ present qdebug() << b_.tostring(); // i'm doing @ present return a.exec(); } i have hierarchy of instances of own qt classes derive same base class. i'd turn them strings implicitly in standard way displayed in qt ui: i can explicitly myself above own standard method tostring above, it's not implicit , i'd rather follow qt or c++ convention believe t...

javascript - How to go to a specific element on page? -

this question has answer here: how can scroll specific location on page using jquery? 9 answers on html page, want able 'go to' / 'scroll to' / 'focus on' element on page. normally, i'd use anchor tag href="#something" , i'm using hashchange event along bbq plugin load page. so there other way, via javascript, have page go given element on page? here's basic outline of i'm trying do: function focusonelement(element_id) { $('#div_' + element_id).goto(); // need 'go to' element } <div id="div_element1"> yadda yadda </div> <div id="div_element2"> blah blah </div> <span onclick="focusonelement('element1');">click here go element 1</span> <span onclick="focusonelement('element2');">click ...

java - How to launch a daemon on RCP plugin load -

i'm developing rcp plugin , launch java based service when loads first time. please tell how should this. java file runs on first launch. regards, levon first add new startup org.eclipse.ui.startup extension rcp application create class implements org.eclipse.ui.istartup , run thread using eclipse jobs api .

ajax - ASP.net Gridview Paging doesin't work inside UpdatePanel -

although, questions somehow similar have been asked number of times, question still unsolved. here question: have gridview contained in tab container ajax control inside updatepanel . gridview works excellent , corresponding methods fired accurately, when enable paging (e.g.) after click on page 2, gridview hides itself. here pageindexchanging() method: protected void gridview1_pageindexchanging(object sender, gridviewpageeventargs e) { gridview1.pageindex = e.newpageindex; gridview1.databind(); updatepanel2.update(); } why paging causes gridview stop working correctly? can do? the solution should refill dataset used populate gridview, each time page index changed. way, ensure in each seperate postback has been triggered gridview page number, results populated.

python - Running an application in your localhost using php -

i have written php script enable me run few batch files , python script in cmd prompt. batch files , python script located in same machine php script. php script have hyperlink image if user click image load command prompt run batch files , python. in order need have .dll file called launchinie.dll , enable activex settings in internet explorer (you can refer link http://www.whirlywiryweb.com/q/%2flaunchinie.asp ) the problem php script can run in internet explorer not in firefox....... how this???? <script language="javascript"> function openpyt(strdoc) { var obj = new activexobject("launchinie.launch"); obj.shellexecute("open", strdoc); } </script> you're using activex, firefox does not support . sounds you're trying run python script via web browser? simplest way in way work browsers cgi. means code run on web server instead of in web browser, though, might not want. trying do?

java - Can you delete a field from a document in Solr index? -

i have big index, , during indexation process there error. avoid reindexing takes several days, want delete specific field , reindex. there suggestion? you cannot. solution document, store temporarily in memory, delete it, update required field (remove, add) , add document index.

Submitting a multi dimensional array with jQuery and YUI -

Image
hey guys, bugging me if me out amazing. i'm using jquery , yui , i'm trying send multidimensional array via json php reason can't grab text put in array span! go figure! no matter how try can't seem add it. if manually add test data weekdays 0 = , works reason wont grab text span! the alert on click works , outputs information out of span can't seem set array value function checkday(checkbox) { var checked = '0'; if ($('#' + checkbox).is(':checked')) { checked = '1'; } else { checked = '0'; } return checked; } var weekdays = new array(7); weekdays[0] = new array(); weekdays[0][0] = checkday('chxmonday'); weekdays[0][2] = $('#results22monday').text(); weekdays[1] = new array(); weekdays[1][0] = checkday('chxtuesday'); weekdays[1][3] = new array(); weekdays[1][4] = $('#results22tue').text(); weekdays[2] = new array(); weekdays[2][0] = checkday(...

How to define a password to wsdl in cxf-maven-plugin -

i want use cxf-maven-plugin generate java code wsdl per doc: http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html the service trying reach password protected. how specify password? doesn't seem documented. <plugin> <groupid>org.apache.cxf</groupid> <artifactid>cxf-codegen-plugin</artifactid> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <sourceroot>${project.build.directory}/generated/cxf</sourceroot> <wsdloptions> <wsdloption> <wsdl>http://host/theservice.wsdl</wsdl> </wsdloption> </wsdloptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin> you can use basic auth sc...