Posts

Showing posts from May, 2012

tsql - How to get DateTime formated -

in sql server how can current date time 12:00 am. getdate() current date , time.i need have datetime formated this: 2011-02-04 12:00 or 2011-02-04 00:01 thanks you first need know how time want. called "flooring" date time. see example: --floor datetime select '0 none', getdate() -- none 2008-09-17 12:56:53.430 union select '1 second',dateadd(second,datediff(second,'2000-01-01',getdate()),'2000-01-01') -- second: 2008-09-17 12:56:53.000 union select '2 minute',dateadd(minute,datediff(minute,0,getdate()),0) -- minute: 2008-09-17 12:56:00.000 union select '3 hour', dateadd(hour,datediff(hour,0,getdate()),0) -- hour: 2008-09-17 12:00:00.000 union select '4 day', dateadd(day,datediff(day,0,getdate()),0) -- day: 2008-09-17 00:00:00.000 union select ...

Will VS2010 work with Visual Source Safe 2005? -

until can convince others convert on team foundation server 2010 (tfs2010), i'm still going use visual source safe 2005 (vss2005). upgrade visual studio 2010 (vs2010) soon. need vs2010 work vss2005? understand there patch vss. here's the patch . i'm not sure if need make work or not.

php - where to store helper functions? -

i've got lot of functions create or copy web. i wonder if should store them in file include script or should store each function static method in class. eg. i've got getcurrentfolder() , isfilephp() function. should stored in file or each in class: folder::getcurrent() file::isphp(); how do? i know kinda "as u want" question great advices/best practices thanks. you're right, highly subjective matter use mix of 2 options. you have class (say helper) has __call() (and/or __callstatic() if you're using php 5.3+) magic methods , when non defined [static] method called it'll load respective helper file , execute helper function. keep in mind though including files decreases performance, believe benefit gain in terms of file organization far outweighs tiny performance hit. a simple example: class helper { function __callstatic($m, $args) { if (is_file('./helpers/' . $m . '.php')) { includ...

wpf - Why is button background defaulting to grey when IsPressed is true -

Image
i have simple problem. using ispressed trigger want able set background color of button other default grey. here button looks when not pressed and here looks when clicked here trigger button. know trigger firing correctly because of glow effect around edge of button when clicked. know brush correct because tried out background brush see looked like. <style.triggers> <trigger property="ismouseover" value="true"> <setter property="background" value="{dynamicresource buttonhoverbrush}"/> <setter property="bitmapeffect" value="{dynamicresource buttonhoverglow}"/> </trigger> <!-- trigger working background color wont change --> <trigger property="ispressed" value="true"> <setter property="bitmapeffect" value="{dynamicresource buttonhoverglow}"/> ...

listview - Custom filtering in Android using ArrayAdapter -

i'm trying filter listview populated arrayadapter: package me.alxandr.android.mymir.adapters; import java.util.arraylist; import java.util.collection; import java.util.collections; import java.util.hashmap; import java.util.iterator; import java.util.set; import me.alxandr.android.mymir.r; import me.alxandr.android.mymir.model.manga; import android.content.context; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.filter; import android.widget.sectionindexer; import android.widget.textview; public class mangalistadapter extends arrayadapter<manga> implements sectionindexer { public arraylist<manga> items; public arraylist<manga> filtered; private context context; private hashmap<string, integer> alphaindexer; private string[] sections = new string[0]; private filter filter; private boolean enablese...

java - Returning the value that for statement prints -

i return information output statement prints. for instance: public static int countnumbers(int x) { (int = 1; <= x; i++) { system.out.println(i); } return something; // should values statements prints. // example, countnumbers(5) returns 12345. } so when call method somewhere else, output. so: int output = countnumbers(3); //output = 123; how can done? use stringbuilder accumulate result. update: convert int using integer.parseint : public static int countnumbers(int i) { stringbuilder buf = new stringbuilder(); (int i=1; i<=5; i++) { buf.append(i); } return integer.parseint(buf.tostring()); } note works small values of i (up 9), otherwise integer overflow.

php - Problems in user - registration module in DRUPAL -

i have problem in drupal registration page. i want change whole user registration page. in registration module want add new field type. bcz want user can choose date date-time picker. have ready date-time picker have implement, don't know put code. i want add validation on new added text fields. means have added 1 text field phone no, want check if user had entered numbers.....in new user registration page. thanks in advance nitish if want alter way user registration works, can hook_form_alter on registration form. with date module, can insert form field has jquery popup date picker. the $form['#validate'] array of validation functions call, can add own list run own validation.

Database design and SQL query for the activity feed? -

i want build activity feed similar facebook. before ask question, want explain mysql database design. have users table, ie. user_id name other columns usera - - userb - - userc - - userd - - the users can follow each other, , here table called 'followers' id user_id follower_id 1 usera userb 2 userd userb 3 userb usera - - - as see, in above table, userb following usera , userd. now question is, when of user in user_id whom userb following, activity, should notified. should make table, lets say, 'activity', like: user_id activity_type activity_link activity_date usera note userb photo userc note userd photo question 1: need make additional table (shown above) store activities or can done without that? question 2: userb in following usera , userd, therefore userb con...

Find location of current m-file in MATLAB -

i'm working on matlab code in number of different locations, , if make code aware of location on computer. think there function gives me information, can't remember called or find on google. the idea have function myfunc needs file in own directory, can in different locations on different computers. in myfunc want this: dir = thefunctionimlookingfor; system(fullfile(dir, 'someapp.exe')); (it function i'm looking doesn't return directory, directory + m-file name, makes little difference me.) mfilename or better mfilename('fullpath')

listbox - WPF scrollview scrolled to the bottom default -

i have scrollviewer containing listbox . scrollviewer scroll way bottom default when view has been loaded! because recent element last element in listbox . is there easy way achieve behavior? thanks if have access scrollviewer , use scrollviewer.scrolltobottom() method.

oop - Inheritance in .NET is useless? -

i'm quite new .net programming. know .net programming 100% object oriented. intriguing paragraph read in book asp.net 4 states inheritance less useful might expect. in ordinary application, classes use containment , other relationships instead of inheritance, because inheritance can complicate life needlessly without delivering many benefits. dan appleman, renowned .net programmer, once described inheritance “the coolest feature you’ll never use.” i'm little bit confused here , need .net programmers tell me should take , should leave. edit please people understand question, first author didn't literally "inheritance in .net useless", way zip hole question in words fit title. second, book apress , title is: "beginning asp.net 4 in c# 2010" page 72. ouch. inheritance not useful, it's core concept, every class inherits system.object (not sure if there hacks/clr stuff doesn't). also in technologies asp.net mvc use in...

javascript - Jquery UI Autocomplete Custom HTML (item is undefined) -

i've been banging head off desk trying jquery ui autocomplete output custom html. here code. $(document).ready(function(){ $.widget( "custom.catcomplete", $.ui.autocomplete, { _rendermenu: function( ul, items ) { var self = this, currentcategory = ""; $.each( items, function( index, item ) { if ( item.category != currentcategory ) { ul.append( "<li class='ui-autocomplete-category'>" + item.category + "<ul class='autocomplete-category'></ul></li>" ); currentcategory = item.category; } self._renderitem( ul, item); }); } }); var data = [ { label: "anders", category: "antigen" }, { label: "andreas", category: "ant...

Convert YAML file to PHP File -

i have bunch of yaml configuration files want convert straight php files application not have process yaml files every time. i know there lot of libraries out there let convert yaml php array, there libraries let convert yaml file php file? the thing makes tricky converting yaml file php produce multidimensional array. thanks. update: i realized following code think need. notice second paramter in print_r. pretty cool... $test = print_r($yaml, true); file_put_contents('test.php', $test); there simple builtin export php variable/array , allows write small script task: $array = yaml_import(...); $array = var_export($array, 1); file_put_contens($fn, "<?php \$array = $array; ?>");

html - jQuery: best way to place dom element in the center of viewport -

i'm looking proper way of placing popup div-element in center of current view area. for example: have div element {display:none; position:absolute} , few buttons, 1 on top of document, second in center , last one, somewhere in bottom. clicking on of button, div should appear in center of current viewing area $(".btnclass").click(function(){ //some actions positioning here $(div_id).show() }) the following it. although there other ways (using css, margins, overflows, etc)...so may not answer question depending on consider "best" be. $(".btn_class").click(function(){ var win = $(window), winw = win.width(), winh = win.height(), scrolltop = win.scrolltop(), scrollleft = win.scrollleft(), container = $("#div_id").css({"display":"block","visibility":"hidden"}), contw = container.width(), conth = container.height(), ...

objective c - UIAlertView is not showing. What am I doing wrong? -

here code: -(ibaction)signupbtnpressed:(id)sender { uialertview *alert = [ [uialertview alloc] initwithtitle:@"k" message:@"thanks signing up!" delegate:nil cancelbuttontitle:@"continue..." otherbuttontitles:nil ]; [alert show]; [alert release]; } i have sign button attached action in view. i check connections made in ib, if you're using ib create ui. specifically, check whether uibutton in interface xib supposed call signupbtnpressed:(id)sender has touch inside event linked method, , 'file's owner' of xib set view controller method in.

db2 - Stored Procedure Wizards in IBM Data studio 2.2.1.0 -

i've downloaded db2 express c( version 9.7) , ibm data studio version 2.2.1.0. i'm quite new using data studio, , did have play year ago. i've got latest, trying create simple stored procedure, did shown in help, remember playing data studio year ago when stored procedure wizard launched, took me through 4 steps, step 1 - set name, , language, specific name step 2 - write code, or use built in give me basic structure using sql including setting sqlstate, , sqlerror codes... step 3 , step 4 let me confirm various choices. in current version (2.2.1.0) don't seem of these rather nice guides novice figure out how write basic sql statements. there way enable this? found extremely useful , struggling without helpful step step wizard. one way switch data perspective. click file -> new -> stored procedure. open wizard. another way open data project explorer view. right click , create new data development project. open/expand project see stored proce...

Rails on remote Apache server not displaying index.html.erb -

i played around rails on laptop (running linux + apache + mysql) , had no trouble getting getting started rails tutorial work locally. i'm trying same thing @ work on remote mac os x + apache server, , things aren't quite rosy. i typed rails blog -d mysql create directory called blog in /library/webserver/documents/mydirectory . trouble is, if go server.com/mydirectory/public , public/index.html in browser. but, don't file if go server.com/mydirectory/ . instead, 403 error. also, when i: script/generate controller home index to create: app/views/home/index.html.erb i unable view file, whether go server.com/mydirectory/home/index , or if add new line ( map.root :controller => "home" ) config/routes.rb , go server.com/mydirectory . am missing obvious apache , rails? apache not support rails out of box. have mod_rails aka passenger installed. or, use server comes rails, easier (but not suitable production). this, go directory , ...

java - Maven: Where be the code? -

greetings, can tell me how heck i'm meant use maven repository or whatever term project? i've downloaded oauth library google. run mvn compile, test, install, deploy i want know jar goes can put class path. appreciated! can tell me how heck i'm meant use maven repository or whatever term project? i've downloaded oauth library google (...) want know jar goes can put class path. appreciated! basically, need maven "put library on class path" declare library dependency of maven project. let's see how , how started here. first, need create maven project (i.e. directory containing pom.xml used describe project , following given structure). maven provides tool can create project you, have run following command (where artifactid name of project): mvn archetype:generate -dgroupid=com.stackoverflow -dartifactid=q2722892 -dversion=1.0-snapshot -dinteractivemode=false then cd in project directory , edit pom.xml declare oauth repo...

php - Implement a mark on the photo -

on site need implement mark on photograph. type in facebook. desirable not necessary selection of object not rectangle, , polygon. there ready-realization? not matter technology use php, flash, , other, exotic not necessary:) use php image masking class .

python: list manipulation -

i have list l of objects (for it's worth in scons). create 2 lists l1 , l2 l1 l item i1 appended, , l2 l item i2 appended. i use append modifies original list. how can in python? (sorry beginner question, don't use language much, scons) l1 = l + [i1] l2 = l + [i2] that simplest way. option copy list , append: l1 = l[:] #make copy of l l1.append(i1)

c# - Writing a HtmlHelper 'Table' method, which uses the model DisplayName's -

i have decided write generic table html helper generate tables models , other objects, have used reflection make more generic taking ienumerable argument table data , dictionary . i want use reflection or other method properties [displayname()] attribute models metadata not need specified in dictionary. methods have tried seem return null, have removed them code. public static mvchtmlstring table(this htmlhelper htmlhelper, dictionary<string, string> boundcolumns, ienumerable<object> objectdata, string tagid, string classname, string controllername, string idproperty) { bool hasaction = !string.isnullorempty(idproperty); bool hasdata = objectdata.count() > 0; urlhelper urlhelper = new urlhelper(htmlhelper.viewcontext.requestcontext); type objectdatatype = hasdata ? objectdata.first().gettype() : null; ienumerable<propertyinfo> objectdataproperties = hasdata ? propinfo in objectdatatype.get...

objective c - iPhone XML Parsing problem -

i trying extract title xml: <entry> ... <title type="html">some title</title> <published>2011-02-07t00:04:16z</published> <updated>2011-02-07t00:04:16z</updated> ... </entry> in nsxmlparsing's didstartelement code: if ([elementname isequaltostring:@"entry"]) { item = [[nsmutabledictionary alloc] init]; } if([elementname isequaltostring:@"title"]) { currentelement = [elementname copy]; currenttitle = [[nsmutablestring alloc] init]; } in foundcharacters : if ([currentelement isequaltostring:@"title"]) { [currenttitle appendstring:string]; } in didendelement : if ([elementname isequaltostring:@"entry"]) { [item setobject:currenttitle forkey:@"title"]; [currentelement release]; currentelement = nil; [item release]; item = nil; } the problem reason when gets didendelement currenttitle has got 3 node's conte...

sql - Start SSIS Asynchronously from a stored proc -

i need start ssis package via stored procedure. chose use 'exec dtexec' instead of starting job launch package, can have ability set variable in package. problem need package run asynchronously stored procedure return instead of hanging or timing out. what best practice achieving this? if want async operation variables, construct table hold variables wanted pass in, , agent job launched ssis them. use sp_start_job launch job asynchronously. package read variables needed table, or job read them construct appropriate launch command. package update table indicate results biztalk.

python - Deleting row with Flask-SQLAlchemy -

i'm trying make function delete record in database flask , extension sqlalchemy. problem is, instead of deleting 1 row, deletes of them. can tell me what's wrong code? @app.route('/admin/delete/<int:page_id>', methods=['get','post']) @requires_auth def delete_page(page_id): page = page.query.get(page_id) if not page: abort(404) if page.children: flash('you can not delete page child pages. delete them, or assign them different parent.', 'error') return redirect(url_for('admin_page')) if request.method == 'post': page.query.get(page_id).query.delete() db.session.commit() flash('page deleted successfully', 'success') return redirect(url_for('admin_page')) return render_template('admin_delete.html', page_title=page.title, page_id=page_id) thanks in advance! i suspect line not think. ...

COMPLETE list of HTML tag attributes which have a URL value? -

besides following, there html tag attributes have url value? href attribute on tags: <link> , <a> , <area> src attribute on tags: <img> , <iframe> , <frame> , <embed> , <script> , <input> action attribute on tags: <form> data attribute on tags: <object> looking tags in wide usage, including non-standard tags , old browsers html 4.01, html 5, , xhtml. check out w3c's list of html attributes , there's "type" column in there , uri types. and of course html 5 version of list useful too so html4 we've got: <a href=url> <applet codebase=url> <area href=url> <base href=url> <blockquote cite=url> <body background=url> <del cite=url> <form action=url> <frame longdesc=url> , <frame src=url> <head profile=url> <iframe longdesc=url> , <iframe src=url> <img longdesc=url> , <img s...

sharepoint - from a share point portal website, how can i tell what version of share point is running? -

that if browsing around on share point can details page tell me version of share point is? provided you're running 2007 , can select "site settings" (or "modify site settings"), it's right there on newly-opened page right of "version". there, pretty up-to-date mapping of version sp/cu install can found here . (edited reflect ryan's comment)

ASP.NET Repeater Causing JQuery Image Slider -

i have jquery image slider in content page worked fine. once converted asp repeater first image of repeater display twice, run normally. any idea on why repeater causing this? i think discovered first image link <itemtemplate> <a href='<%#eval("url")%>'> <img src='<%#eval("image")%>' alt="spring break 2011" rel='<h3><%#eval("title")%></h3><%#eval("caption")%>'/></a> </itemtemplate> i have place class="show" in first item only. know how implement during first time goes through. hmm something should work you: <itemtemplate> <a href='<%#eval("url")%>' <%# container.itemindex == 0 ? "class='show'" : "" %> > <img src='<%#eval("image")%>' alt="spring break 2011" rel='<h3><%#eval("title"...

oop - PHP classes source code -

i'm on stage of learning oop of php , david powers book ( php object oriented solutions ). i'm on chapter 3, talks using datetime class. i'll see implementation of datetime class in order underatnd how oop realy works. 1) where/how can find source code of datetime class? 2) beginner useful see code source of such classes, or better stay away messy things @ level? don't bother trying @ code built-in php classes; they're not written in php (they're in c), won't teach writing php. code available if want it, going useful if know c) however there lots of example classes available. pear repository contains loads of php classes can learning. might want download of examples in appropriately named phpclasses.org .

javascript - Help me diagnose this jQuery loop / Bookmark Hash problem? -

i'm having trouble getting jquery render correctly 100% of time - code using located below. purpose "simulate" feel of threaded forum hiding subject of replies - when subject clicked, 1st post replaced reply. you can see example of in action here: http://bulldogsworld.com/general-bulldog-chat/50-lbs-bulldog-one-shin-pic the problem script doesn't work when people land via bookmark # in url, such as: http://bulldogsworld.com/general-bulldog-chat/50-lbs-bulldog-one-shin-pic#comment-1627028 specifically, problem happens reason posts below bookmark entry point replicated twice. can't figure out why happening - thoughts? i'm pulling hair out on 1 - / guidance appreciated! function flip(comment) { $('#first-post').replacewith(comment.closest(".comment").clone().attr('id','first-post')); $('#first-post').children('.forumthreadtitle').children('.comment-info').empty(); $('#first-post').f...

delphi - How do I solve an unresolved external when using C++ Builder packages? -

i'm experimenting reconfiguring application make heaving use of packages. both , developer running similar experiment running bit of trouble when linking using several different packages. we're both doing wrong, goodness knows :) the situation this: the first package, packagea.bpl , contains c++ class fooa . class declared package directive. the second package, packageb.bpl , contains class inheriting fooa , called foob . includes foob.h , , package built using runtime packages, , links packagea adding reference packagea.bpi . when building packageb , compiles fine linking fails number of unresolved externals, first few of are: [ilink32 error] error: unresolved external '__tpdsc__ fooa' referenced c:\blah\foob.obj [ilink32 error] error: unresolved external 'fooa::' referenced c:\blah\foob.obj [ilink32 error] error: unresolved external '__fastcall fooa::~fooa()' referenced blah\foob.obj etc. running tdump on packagea.bpl shows...

php - Symfony Embedded form relation -

i'm using symfony 1.4.8 the problem in saving embedded form relation database. have child , parent; child embedded form, when i'm using embedded form parent connected same child , cannot change child select-box parent form. if comment embedding child works fine. i'm using ajax change child form values , after bind form child, got right values symfony don't use them. my guess, there protected values cannot see tells object connection between parent , child , save function restores connection security reason. maybe i'm wrong, can help?! here code snippet code ending , i'm passing right values symfony protected function processform(sfwebrequest $request, sfform $form) { $form->bind($request->getparameter($form->getname()), $request->getfiles($form->getname())); if ($form->isvalid()) { $values = $form->getvalues(); //test var_dump($values); //test $sf_guard_user = $form->save(); return...

web applications - What web-development platform should I use considering Time-To-Market? -

i have been looking @ few differend platforms coming web-development project. hear web-development platform recommended when considering time-to-maket. suppose know programming language well, not web-framework. os linux. my requirements , priorities: time-to-market restful maintainable code scales-up (not dog-slow) the 1 have looked @ never used are: java , play! framework or gwt python , django php , zend framework ruby , ruby on rails erlang , nitrogen , webmachine scala , lift c++ , wt c# , asp.net mono it's bonus if framework has support making sites mobile phones. if you're developer, sosh right. generally speaking, ruby on rails or grails best candidates they're productivity ( dry ) , getting product out door (although not mandatory, used in agile process). they might require compromises in terms of performance, stated 1 of priorities.

asp.net - like operator in linq -

i need use operator in linq query for this: timb = time.timbratures.include("anagrafica_dipendente") .where(p => p.anagrafica_dipendente.cognome + " " + p.anagrafica_dipendente.nome "%ci%"); how can do? timb = time.timbratures.include("anagrafica_dipendente") .where(p => (p.anagrafica_dipendente.cognome + " " + p.anagrafica_dipendente.nome).contains("ci"));

python - How to speed up read method call of object returned by urllib2.urlopen -

i have following code. req = urllib2.request(url,'',txheaders) f = urllib2.urlopen(req) data = f.read() f.close() in above code, read function takes 1-2 minutes when response of 58kb. how can make faster.

.net - ASP.NET membership using created UserId in query string -

hi learning .net , building first real website using .net. i wondering if people considered ok use generated membership userid in query string? , use foreign key in database link relevant information user? why need in querystring? provided by... if httpcontext.current.user.identity.isauthenticated dim user membershipuser = membership.getuser() dim guid guid= directcast(user.provideruserkey, guid) end if i wouldn't display such sensitive data users if wouldn't cause security issues, because application looks unsafe if can see more needs see. store temporarily in session pass page 1 page2. if want save userid foreignkey possible use uniqueid provided membershipprovider. if want use integer instead(readability, less disk space), have create table( aspnet_userid ) maps guid int-id in one-to-one relationship. create trigger inserts , deletes on aspnet_users -table, example: create trigger [dbo].[trgcreateuserid] on [dbo].[aspnet_users] insert insert...

Batch file string manipulation -

this specific question, however; say have batch file running from\located in directory c:\data\src\branch_1 how set environment variable %buildpath% c:\build\bin\branch_1 in batch file? (to clear, if same batch file located in c:\foo\bar\branch_2 want set %buildpath% c:\build\bin\branch_2 ) you should able use environment variable %~dp0 drive , path of batch file running. there, it's not-very-efficient method of stripping off end of string character character , building new string. for example, batch file: @setlocal enableextensions enabledelayedexpansion @echo off set olddir=%~dp0 echo current directory is: !olddir! if "!olddir:~-1!" == "\" ( set olddir=!olddir:~0,-1! ) set lastbit= :loop if not "!olddir:~-1!" == "\" ( set lastbit=!olddir:~-1!!lastbit! set olddir=!olddir:~0,-1! goto :loop ) set newdir=c:\build\bin\!lastbit! echo new directory is: !newdir! endlocal running c:\data\src\branch1\qq.c...

Visual Studio SDK: Where is the AssemblyFolderEx registry key for Windows Phone Game projects? -

i trying tell setup program add postsharp "add reference" dialog box of visual studio windows phone 7 projects. i figured out registry key windows phone applications hkey_local_machine\software\microsoft\microsoft sdks\silverlight phone\v4.0\assemblyfoldersex. what's corresponding key windows phone games? if assembly in gac can use " add gac reference " menu item it's simple , faster "add reference" dialog. additional details please review following article: muse vsreferences the add gac reference dialog box displays gac assemblies. s

.net - Windsor and delegating object creation/registration -

Image
i have been using spring.net 4-5 years, , have started looking @ windsor container. there lot windsor like, have support existing sites spring.net framework. is possible (and if how), have windsor controlling di container, incorporate delegating creation of types spring.net container. you can try custom activator aware that's asking trouble , cause more grief biting bullet , migrating completely. containers assume ownership of components manage , having 2 managers recipe disaster.

winapi - Running processes at different times stops events from working - C -

this question follows on answered question here at first assumed had problem way creating events due handles openevent returning null, have managed find real cause not sure how go it. basically use visual studio launch both process , b @ same time, in past openevent handle wouldn't work due process looking address of event fraction of second before process b had time make it. my solution allow process b run before process a, fixing error. the problem have process b reads events process , expect returns null handle when trying open events process a. i creating events in wm_create message of both processes, furthermore create thread @ same time open/read/act upon events. it seems if run them @ same time don't chance see each other, alternatively if run 1 before other 1 of them misses out , can't open handle. can suggest solution? thanks. just replace openevent createevent. createevent open event instead of creating new 1 finds existing event name ...

ASP.NET validation issue - DropDownList being populated dynamically on client -

i'm populating dropdownlist using js on client , validating requiredfieldvalidator. this works fine on client page.isvalid consistently comes false on server. is because selected value wasn't in dropdownlist when first served page? what's easiest way around this? (i need leave server validation turned on) is because selected value wasn't in dropdownlist when first served page? yes. you'll notice dropdownlist contain no items when postback, , yes, because you're adding items on client side. items add control on client totally unknown server. therefore, server validation fail, since field required. in fact, adding items dynamically client script trigger eventvalidation complain there possible security problem, , you'll have had set enableeventvalidation false in <%@ page %> directive able post. the best way around either generate items on server side, or not use server control (use regular non-asp.net select lis...

string - Detecting characters in C++ char stream -

Image
i working on piece of arduino code using blackwidow version wifi built in. using wiserver.h library, i'm using simpleclient.pde example mods send call webserver return integer - 0, 1, or 2. end goal turn on pin proper red, green, or yellow of stoplight. integers represent aggregate state of our hudson ci. i'm php lazy bastard, , pointers scare me. code working is // function prints data server void printdata(char* data, int len) { // print data returned server // note data not null-terminated, may broken smaller packets, , // includes http header. while (len-- > 0) { serial.print(*(data++)); } } printdata() callback of call webserver, , when run sends following serial monitor (this 3 loops, no newline before new output): http/1.1 200 ok date: thu, 10 feb 2011 17:37:37 gmt server: apache/2.2.13 (unix) mod_ssl/2.2.13 openssl/0.9.8k dav/2 php/5.2.11 x-powered-by: php/5.2.11 content-length: 1 connection: close content-type: text/html 0http/1.1 200 ...

vim - Search for a tag -

i know approximately tag i'm looking is. know maybe substring. there fuzzyfinder-like plugin lets me search through tags? whatever reason, fuzzyfinder's tag mode hangs on me whenever type :fuftag<cr> . no need plugin. can tell vim use regular expression find relevant tag. :tselect /pattern see :help tag-regexp .

wpf - Adding a menu item to a FlowDocumentReader ContextMenu -

the flowdocumentreader has 2 menu items in contextmenu, copy , select all. i'd add additional menuitem , have tried this: private void flowdocumentreader_contextmenuopening(object sender, contextmenueventargs e) { flowdocumentreader.contextmenu.items.clear(); menuitem menuitem = new menuitem(); menuitem.header = "test"; flowdocumentreader.contextmenu.items.add(menuitem); } additionally i've tried this: private void flowdocumentreader_contextmenuopening(object sender, contextmenueventargs e) { menuitem menuitem = new menuitem(); menuitem.header = "test"; flowdocumentreader.contextmenu.items.add(menuitem); } where don't clear items in context menu , attempt append it. neither of these work. i can create own menu so: private void flowdocumentreader_contextmenuopening(object sender, contextmenueventargs e) { menuitem menuitem = new menuitem(); ...

algorithm - How to find two most distant points? -

this question asked on job interview time ago. , still can't figure out sensible answer. question is: you given set of points (x,y). find 2 distant points. distant each other. for example, points: (0,0), (1,1), (-8, 5) - distant are: (1,1) , (-8,5) because distance between them larger both (0,0)-(1,1) , (0,0)-(-8,5). the obvious approach calculate distances between points, , find maximum. problem is o(n^2), makes prohibitively expensive large datasets. there approach first tracking points on boundary, , calculating distances them, on premise there less points on boundary "inside", it's still expensive, , fail in worst case scenario. tried search web, didn't find sensible answer - although might lack of search skills. edit: 1 way find convex hull http://en.wikipedia.org/wiki/convex_hull of set of points , 2 distant points vertices of this. possibly answered here: algorithm find 2 points furthest away each other also: htt...