Posts

Showing posts from April, 2010

Any PHP Rest framework similar to Recess? -

i spend few days recess , impressed framework. disappointed see lack of support, community involvement , involvement developers. , need not mention documentation! i wondering if there other rad rest framework recess out there. know many 'big - fat' frameworks zend, cakephp etc support rest.. looking simple , rad. slim framework by far sophisticated , feature-rich restful framework i've found, , it's light , easy use

xaml - WPF GroupBox header Alignment issue -

how can align groupbox header center rather default left positioning. i read in many post 1 can use template have no idea such thing. please let me know how can header @ center. thanks !! yes, you'll have modify template. for center-alignment see this answer thomas levesque right-alignment see this answer mihir gokani uploaded sample project containing both center-alignment , right-alignment here: http://www.mediafire.com/?hd2vbwr97ep7yis center-alignment using same approach thomas usable this <groupbox header="centered header" style="{staticresource centeredheadergroupboxstyle}" .../> centeredheadergroupboxstyle <local:centerbordergapmaskconverter x:key="centerbordergapmaskconverter"/> <style x:key="centeredheadergroupboxstyle" targettype="{x:type groupbox}"> <setter property="borderbrush" value="#d5dfe5"/> <setter prop...

How can I remove relative path components but leave symlinks alone in Perl? -

i need perl remove relative path components linux path. i've found couple of functions want, but: file::spec->rel2abs little. not resolve ".." directory properly. cwd::realpath much. resolves symbolic links in path, not want. perhaps best way illustrate how want function behave post bash log fixpath hypothetical command gives desired output: '/tmp/test'$ mkdir -p a/b/c1 a/b/c2 '/tmp/test'$ cd '/tmp/test/a'$ ln -s b link '/tmp/test/a'$ ls b link '/tmp/test/a'$ cd b '/tmp/test/a/b'$ ls c1 c2 '/tmp/test/a/b'$ fixpath . # rel2abs works here ===> /tmp/test/a/b '/tmp/test/a/b'$ fixpath .. # realpath works here ===> /tmp/test/a '/tmp/test/a/b'$ fixpath c1 # rel2abs works here ===> /tmp/test/a/b/c1 '/tmp/test/a/b'$ fixpath ../b # realpath works here ===> /tmp/test/a/b '/tmp/test/a/b'$ fixpath ../link/c1 # neither 1 works here ===> /tmp/test/a/link/c1 '/...

html - Can the select option value be of different types? -

i want know practice select option values. example <select name="select"> <option value="0-9">sample</option> <option value="a-z">sample</option> <option value="this sample value">sample</option> <option value="this-is-sample-value">sample</option> <option value="this_is_sample_value">sample</option> <option value="this & | sample ** value">sample</option> </select> i'm little bit confused here. select value same input text , textarea there no limits real type of data can set in value attribute of option element. characters special meaning in html do, of course, need represented appropriate entities ( & &amp; example (although 1 in question meets "followed space character" exception rule)). the attribute defined containing cdata: <!element option - o (#pcdata) ...

C Segmentation fault when adding hash node -

i have structure of type: struct hashnode_s { struct hashnode_s *next; char *key; valuetype tag; union { int integervalue; char *stringvalue; } u; int isincycle; }; and when add item of type string, have can, code is int hashtbl_insertstring(hashtbl *hashtbl, const char *key, const char *value) { struct hashnode_s *node; hash_size hash; hash = searchforhashindex(hashtbl, key,value); if(hash == -1) { hash=hashtbl->hashfunc(key); } /* adding first node if not applicable (this based on value string)*/ if(hashtbl->nodes[hash]== null) { node = malloc(sizeof(struct hashnode_s)); node->key = key; node->tag = stringconst; node->u.stringvalue = value; node->next = null; hashtbl->nodes[hash] = node; } else { node = hashtbl->nodes[hash]; if(node->next ==null) { struct hashno...

java - merge sorting of 2 unsorted arrays -

is following implemetation correct merge sort? public int [] merge_srt(int [] ary){ if(ary.length==1) return ary; int mid = (int)ary.length/2; int a1[] = merge_srt(arrays.copyofrange(ary, 0, mid)); int a2[] = merge_srt(arrays.copyofrange(ary, mid+1, ary.length-1)); return mergea(a1,a2); } public int[] mergea(int[] a1,int [] a2){ // merge 2 array , reurn 1 sorted array } change if (ary.length == 1) return ary; to if (ary.length <= 1) return ary;

sharepoint - Problem with pageviewer webpart in sharepoint2010 -

i using pageviewer webpart display .htm page present in document library in sharepoint 2010. it asking me download page instead of diplaying in page but in moss 2007 working fine(i mean displaying in page) please suggest me solution thanks in advance. sp2010 has restrictions on displaying or opening files. that, need go central administration , check "browser file handling" "permissive" web application's general settings. i think you.

java me - Is there possible for communicate between piconet to another piconet -

in previous question posted in how communicate mobile devices using bluetooth in j2me have asked question based on bluetooth. got ideas implementing client server communication. here ask question based on communication between piconet piconet. possible? master device has communicate slave in piconet master , slave piconet slave of own piconet. can please give me guideline , articles problem. please me.. thankx in advance in bluetooth, master initiates communications slave. @ baseband level master polls slave. however, @ application (api) level, abstracted away allowing both master send slave , slave send master. the situation describe scatternet. bluetooth specification allows scatternet occur. bluetooth stack using may impose restrictions on whether scatternet allowed and, more generally, master/slave configurations allowed (e.g., number of concurrent slaves allowed). you'll find that, when interacting devices, role switch requested prevent scatternets. ex...

open source - Recycle a project name? -

i want start open source project, favourite project name used framework same goal. project never popular, there nothing download or executable, project had 2 active days commits @ google code , dead since 4 years. in other words: project irrelevant name in use @ google code , ohloh (the same dead project). .org domain available. would ok reuse project name? 4 years, 2 active days? , make better old dead 1 ;)

mysql - Need some tips on create table -

i plan create table store race result this: place racenumber gender   name  result 12 0112 male mike lee 1:32:40 16 0117 female rose mary 2:20:40 i confused @ items type definitions. i not sure result can set varchar(32) or other type? and racenumber , between int(11) , varchar(11) , 1 better? can i use  unique key way? do need split name firstname , lastname in db table? drop table if exists `race_result`; create table if not exists `race_result` ( `id` int(11) not null auto_increment, `place` int(11) not null, `racenumber` int(11) not null, `gender` enum('male','female') not null, `name` varchar(16) not null, `result` varchar(32) not null, primary key (`id`), unique key `racenumber` (`racenumber`,`id`) ) engine=myisam auto_increment=3 default charset=utf8 auto_increment=3; some advice/opinions regarding datatypes. res...

.net - Communication between two apps, is SSIS the way to go? -

working team of more traditional developers came across situation: we have growing number (two right now) of apps accessing common data inserted via ui of 1 of apps, called main administrative app. since other apps need of data or needed formatted different schema, 1 of solutions brought forward have database per app , sync job running frequency updates data 1 db another. being common soa scenario quick discard solution in favor of service oriented 1 data stored in 1 main repository , accessed via exposed services. so, i'd read thoughts think biased in favor of relative new technologies , might not appreciating value in more traditional solutions. my advice when choosing technology weigh pro's , con's. "new" vs "old" can in traps of time. there's going hot new buzzword or other out there @ given time , may or may not way go. let's analyze: pro's of ssis package vs. service: you can transform data destination databases...

msbuild - Getting a list of Nuget Package Updates from a Build script -

i looking @ adding line build script pump in text available package updates via nuget. available via package manager console issuing command such as: > get-package folderpath -updates surprisingly, while thought similar command have been surfaced via nuget console application, not! not sure why didn't surface of same functionality in powershell api console tool!? i'm no powershell guru, best approach running command build script? can call out powershell easily, or @ building utility references nuget.core.dll direct? you can't console application yet. we're looking @ building out nuget command line tool being full nuget client have same features in process powershell. you can build own client today if wanted referencing nuget.core , seeing cmdlets can figure out.

c# - DataGridView with images from XML file -

say store image paths in xml file. want display image in datagridview depending on status stored in sql server database table. therefore, if add new project, store 'in progress' in project table under status. display progress.png in datagridview. likewise, if change status in progress completed, want display complete.png. working 2 images, let me know best way go around doing be. sample code appreciated. thanks. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <images> <pic> <image>images/progress.png</image> <caption>in progress</caption> </pic> <pic> <image>images/complete.png</image> <caption>completed</caption> </pic> </images> use lambada expressions match conditions xml file , sql database. here sample walk through. var imagelist = imagelist.where(x => x.status ==status).firstordefault().tolist(); where imagel...

asp.net - CheckboxList to display aligned? -

i made checkboxlist , not line up. don't see way control generated html. right now, check boxes not align due widths of <td> of each checkbox label being automatic width. how can set width of , make labels , checkboxes appear in 2 vertical aligned columns? my code simple: <div style="text-align: center;"> <p> here tell.. </p> <asp:checkboxlist runat="server" id="cbl" width="300px"></asp:checkboxlist> <br /> <input type="button" id="next_3" value="next page" /> </div> and here screen shot alt text http://img718.imageshack.us/img718/6824/checkboxlist.png you can have contained within <div> left-aligning so: <div style="text-align: center;"> <p>here tell..</p> <div style="text-align: left; width: 50%; margin: auto;"> <asp:checkboxlist runat="...

Mysql Php Escaping single quotes with real_escape_string -

i having trouble figuring out how clean strings safe queries while maintaining meaning of string. given table of values have single quotes or other escapable characters. how use real_escape_string , still select values? my_table col1 col2 ----------------- 1 value's1 2 value's2 value's1 coming url have clean mysqli::real_escape_string means query looks this select col1,col2 my_table col2 = 'value\'s1' and of course because of getting no results returned. what various strategies dealing problem? note: did phpinfo() , magic_quotes_gpc 'off'. neccessary me clean value don't see how sql injection when php allows 1 query @ time? being on cautious? if(get_magic_quotes_gpc()) { $string = stripslashes($string); $string = mysqli_real_escape_string($string); } else { $string = mysqli_real_escape_string($string); } you might want make function out of this

c# - Domain Driven Design Question -

i have scenario in need advice on. have application there 2 kinds of users student , teacher. student , teacher share of common properties firstname, lastname, email, username, password etc. reason derive student , teacher classes user. now, problem there times don't know if user student or teacher. when implementing custom membership provider , in getuser function. getuser takes username lost should return. for student functions have created istudent , iteacher teachers. want return user , not care if student or teacher. returning base class not seems idea too. update: i think idea return user , not have student , teacher classes. student , teacher roles , can managed studentservices , teacherservices. a classic scenario , classic runaway problem. yes there pain work inheritance constrain. benefits occur when inject behavior class(es). seems have decided jut using user class , not having user base , child classes teacher , student. can idea if make teacher , ...

.net - How to redirect by throwing an exceptions from an Asp.NET controller? -

my controllers extend basic userawarecontroller class, exposes getcurrentuser() method. call method redirect login page if user not logged in. can accomplish throwing exception method? how can cause redirect happen when exception thrown? while think should change approach solution authorization, can stay , use code: public partial class baseuserawarecontroller : controller { protected override void onauthorization(authorizationcontext filtercontext) { if (getcurrentuser() == null) { filtercontext.result = new httpunauthorizedresult(); } } } if project not big, think changing use [authorize] . if used it, only: [authorize] public partial class userawarecontroller : controller { } you may think not big difference, [authorize] handles caching issues (returning cached response when not authorized anymore). install mvc 2 , create new mvc 2 web application. contains authorization logic can propably use in application....

javascript - Problem with jquery-droppable in Chrome -

i have simple application users jquery-ui's draggable , droppable. in firefox, works perfectly. in chrome, however, i'm having problems. this code: $(".cell").droppable({ drop: function(event, ui) { var originaltarget = event.originaltarget; ... } }); in chrome 'event' object of type 'object' (using chrome dev kit), , event.originaltarget 'undefined'. doing wrong? to draggable element, use ui.draggable (this jquery object). droppable, use $(this) . see documentation on drop event. var draggable = ui.draggable[0]; var droppable = $(this)[0];

json - Is it possible to retrieve the favicon of a url doing javascript client side scripting? -

i'm guessing have use jsonp don't know of service let me this. know of anyway of doing this? it's possible. first check if favicon declared in meta tag , extract url. if there isn't meta tag use url /favicon.ico. use new image(url) manipulate/test file.

parsing - Non PHP site generates PHP errors -

i have error appearing: parse error: syntax error, unexpected t_string in /home/ondesign/public_html/ywamleicester.org/index.html on line 1 which think php error. however, site in question out of box iweb design no php in it. i have no idea doing it. could server misconfigured treat .html files if can contain php code. might want check extensions server configured use php.

testing - Need a good website URL to test against -

i need url test basic http connectivity. needs consistent and: always up never change drastically due ip or user agent. (ie: 301 location redirect/ huge difference in content... minor tolerable) the url has consistent content-length. (ie: doesn't vary 2kb @ most, ever) a few examples, yet none match 3 criteria: one example of up: www.google.com (yet 301 redirects based on ip location). another 1 http://www.google.com/webhp?hl=en . problem there based on given holiday, content-length can vary. why not go http://www.google.com/ncr ? won't redirected

axis2 qname not fond for the package: org.hibernate.collection -

i trying test axis2 service creating client using wsdltocode , using adb databinding. while testing following error. qname not fond package: org.hibernate.collection. not sure means. also, possible step through service code using ide debugger the class had list. adding list attribute excludeproperties in services.xml fixed problem.

php dynamic class inheritance -

i know can generate class @ runtime executing $obj = (object)array('foo' => 'bar');+ this way can use echo $obj->foo; //bar what if want make $obj inherits existing class? what wanna achive: i'm forking paris project on github ( https://github.com/balanza/paris ). it's active record class. wonder need declare class every object, if it's empty: class user extends model{} i guess might use dynamic object avoid boring stuff. you eval('class user extends model{}') not idea. really, should create class in file, opcode caching work properly, can version tracked, etc etc. tl;dr: define model class, right thing do™.

wpf - Binding a resource to a custom control property -

i creating custom button shows faded text normally, , full-strength text on mouseover or mousedown . have defined 2 resources in generic.xaml of control represent brushes these text colors: <!-- text brushes --> <solidcolorbrush x:key="normaltextbrush" color="black" /> <solidcolorbrush x:key="fadedtextbrush" color="gray" /> the control compiles , works fine in configuration. but want let control user set text color, using custom control's foreground property. so, changed resource declarations this: <!-- text brushes --> <solidcolorbrush x:key="normaltextbrush" color="{binding path=foreground, relativesource={relativesource templatedparent}}" /> <solidcolorbrush x:key="fadedtextbrush" color="{binding path=foreground, relativesource={relativesource templatedparent}, converter={staticresource colorconverter}, converterparameter='1.2'}" /> the sec...

iphone - UITextView how to cut off text -

i have uitextview displaying facebook status loaded facebook connect. i'm trying make uitextview creating preview of text. want when there text uilabel. "there text..." dots uitextviews don't that. know how work? write separate method counts how many letters there in string , if there more preset value cut , append 3 dots end. also, consider using uilabels instead of uitextviews if don't need edit information inside since uitextviews take longer allocate , init , slower uilabels.

AutoComplete-ready ComboBox in Silverlight 3 -

has out there had situation needed implement "editable" combobox in silverlight? client wants combobox in ui allows user place focus on selection box , start typing automatically pull desired value available items, rather requiring use of drop-down list. this feature available, know, in several implementations third parties. example, can make happen telerik's radcontrols silverlight. however, client restricted using silverlight 3 toolkit, no third-party tools or plug-ins. any suggestions quick, down-and-dirty implementation? guidance or links appreciated! thanks, jeff okay, had same problem. we went ahead , used autocompletebox silverlight 3 tookit. implementation has lot of things missing wanted. because of these limitations, created our own inherited it. worked great , simple do. tutorial making own control inherits you. have fun. since toolkit open source, can @ code guidance. you can see samples toolkit here: https://www.silverlight....

qt4 - Qt 4.6 Adding objects and sub-objects to QWebView window object (C++ & Javascript) -

i working qt's qwebview, , have been finding lots of great uses adding webkit window object. one thing nested objects... instance: in javascript can... var api = new object; api.os = new object; api.os.foo = function(){} api.window = new object(); api.window.bar = function(){} obviously in cases done through more oo js-framework. this results in tidy structure of: >>>api ------------------------------------------------------- - api object {os=object, more... } - os object {} foo function() - win object {} bar function() ------------------------------------------------------- right i'm able extend window object of qtc++ methods , signals need, have 'seem' have in root child of "window". forcing me write js wrapper object hierarchy want in dom. >>>api ------------------------------------------------------- - api ...

iphone - Unable to update NSMutableDictionary initialized with the NSUserDefauts value -

i used nsuserdefaults save nsmutabledictionary. when retrieving value nsuserdefaults, unbale modify/update values of nsmutabledictionary saving values. need suggestion on how so? you non-mutable instances of nsdictionary nsuserdefaults . make them mutable, need this: dict = [[nsuserdefaults standarduserdefaults] objectforkey:@"mykey"]; mymutabledict = [dict mutablecopy]; // note retain count +1, need // release or autorelease mymutabledict later on.

Date object to Calendar [Java] -

i have class movie in have start date, duration , stop date. start , stop date date objects (private date startdate ...) (it's assignment cant change that) want automatically calculate stopdate adding duration (in min) startdate. by knowledge working time manipulating functions of date deprecated hence bad practice on other side see no way convert date object calendar object in order manipulate time , reconvert date object. there way? , if there best practice what creating instance of gregoriancalendar , set date start time: date date; calendar mycal = new gregoriancalendar(); mycal.settime(date); however, approach not use date @ all. use approach this: private calendar starttime; private long duration; private long startnanos; //nano-second precision, less precise ... this.starttime = calendar.getinstance(); this.duration = 0; this.startnanos = system.nanotime(); public void setendtime() { this.duration = system.nanotime() - this.startnanos; } p...

lua - Returning tables of objects from C++, adopt policy -

using luabind, create table of objects c++ luabind::object create_table(lua_state *l) { luabind::object result = luabind::newtable(l); int index = 1; ( ... ) { lua_object *o = new lua_object( ... ); result[ index ++ ] = o; } return result; } i register function as module(l) [ def("create_table", &create_table) ] and lua_object as class_<lua_object> reg("object"); reg .def(constructor<float,float>()) ; module(l) [ reg ]; how can tell luabind take ownership of objects stored in table ( new lua_object( ... ) )? work around? thanks - replace result[ index ++ ] = o with result[ index ++ ] = luabind::object(l, o, luabind::adopt(luabind::result)); on side note, don't have register create_table raw(_1) policy?

html - Table column with headers change column width -

html viewable @ jsfiddle.net (it's lot of code post here) the method change column width escapes me, i'd "produkt" column wider. add attribute header of cell, should force entire column @ least 100px: <th id="produkttext" style="width: 100px;">produkt</th>

javascript - Fancybox returning " The requested content cannot be loaded. Please try again later." -

using fancybox play youtube videos in modal box . my problem keep getting "the requested content cannot loaded. please try again later." the modal box popping know script running, might problem api call... here call: <script type="text/javascript"> $(document).ready(function() { /* basic - uses default settings */ $("a.fancybox").fancybox({ 'hideoncontentclick': true }); /* non-obtrustive method youtube videos*/ $("a[rel=fancyvideo]").fancybox({ overlayshow: true, framewidth:640, frameheight:360, }); }); </script> do have <a> s both class="fancybox" , rel="fancyvideo" ? if you'll binding fancybox elements twice , fancybox might not that. try taking out one: $("a.fancybox").fancybox({ 'hideoncontentclick': t...

How to add Facebook 'Like' button on each article on a Joomla website? -

i want add facebook's new 'like' button on articles on joomla website. when tried, add button website, not individual articles. how can achieve integration individual article? end result should http://mashable.com 'like' button appears on each article. see please. or facebook button

C - pellucid regex.h use tutorial -

i need use regular expressions in c , looking clear tutorial on use , how capture substrings. (i'm using regex.h library on linux) i have used regular expressions before in other languages know how construct actual expressions, looking tutorial on it's implementation in c. thanks. google found this: http://www.peope.net/old/regex.html

.svn folders and files -

my developer has emailed me compressed folder of project. since not available @ moment, want know if folder he's emailed me contains .svn files or folders. i want deploy folder(project) production server want without .svn mess. at first glance on uncompressing folder don't see .svn file or folder there. so mean doesn't contain svn related mess? and mean normal copy , not working copy developer's computer or else either has rid off svn through export or manually? if there no .svn folder then, yes there no subversion technical data ( i.e. : mess) in archive. on unix, linux or cygwin on windows can run following command root directory find , .svn dir: find . -name .svn -type d without cygwin on windows can right click on root directory, select search type .svn in search files or folders named: , check type in search options , select folder in drop-down menu. click search now , voilà . if nothing comes out of command there no subversion t...

How to find last day of week in iphone -

in application m using following codes retrieve current date , day :- nsdate *today1 = [nsdate date]; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"dd/mm/yyyy :eeee"]; nsstring *datestring11 = [dateformat stringfromdate:today1]; nslog(@"date: %@", datestring11); //[dateformat release]; nscalendar *gregorian11 = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar];   nsdatecomponents *components1 = [gregorian11 components:nsweekdaycalendarunit | nsyearcalendarunit | nsmonthcalendarunit | nsdaycalendarunit fromdate:today1]; [components1 setday:([components1 day]-([components1 weekday]-1))]; nsdate *beginningofweek1 = [gregorian11 datefromcomponents:components1]; nsdateformatter *dateformat_first = [[nsdateformatter alloc] init]; [dateformat_first setdateformat:@"dd/mm/yyyy :eeee"]; nsstring *datestring_first = [dateformat_first stringfromdate:beginningofweek1]; nslog(@"first_date: %@...

bash - Getting `make install` to source your bash_completion -

this install part of makefile: install: e in $(exec); \ sudo cp --remove-destination ${curdir}/$$e /usr/local/bin; done sudo cp ${curdir}/bin/stage2.d /etc/bash_completion.d/stage2 . /etc/bash_completion where "stage2" name of executable. the last line provides issue. after adding file bash_completion.d directory want source bash_completion . calling source or . yields: . /etc/bash_completion /etc/bash_completion: 32: [[: not found /etc/bash_completion: 38: [[: not found /etc/bash_completion: 50: bad substitution make: *** [install] error 2 make uses /bin/sh default. have force use bash since [[ not supported normal sh . gnu make lets set shell variable [in makefile] force use bash. need add line shell=/bin/bash at top of makefile

asp.net mvc - How do I add a css class to the TempData output? -

the tempdata output plain text , putting div around leave formatted empty div on screen if there no tempdata. is there way apply class shows when tempdata item set? other writing div code tempdata, seems horrible idea. i write helper: public static class htmlextensions { public static string message(this htmlhelper htmlhelper, string key) { var message = htmlhelper.viewcontext.tempdata[key] string; if (string.isnullorempty(message)) { return string.empty; } var builder = new tagbuilder("div"); builder.setinnertext(message); return builder.tostring(); } } which used so: <%= html.message("somekeytolookintempdata") %>

php - Undefined variable with $_GET? -

i have problem in php: notice: undefined variable: _get in /.../script/install.php on line 3 and code in line 3: if($_get['step']<1) so problem? variable names case sensitive in php. if($_get['step']<1) also, avoid notice level warnings, may want check existence of variable first: if ((array_key_exists($_get, "step")) , ($_get['step']<1))

winforms - Get child rows from UltraGrid -

i have master/details relation in ultragrid. , want show child rows in new ultragrid when user click on row. how can do? thanks you handle afterrowactivate or afterrowselected events of first grid , either populate second grid appropriate data. if have data of parent rows in second grid can set column filter apropriatly this: private void ugparent_afterrowactivate(object sender, eventargs e) { if (this.ugparent.activerow != null) { //either populate grid data specific current row: //this.ugchilds.datasource = this.getchilddata(this.ugparent.activerow); //or filter grid object key = this.ugparent.activerow.cells["idfield"].value; this.ugchilds.displaylayout.bands[0].columnfilters["relationfield"].filterconditions.add(filtercomparisionoperator.equals, key); } else { //clear child grid if required. if set datasource null loose layout , need relayout grid on next binding } } if use columnfilters remember reuse existi...

java - Duplicate static field (Array vs String) -

i have question following code: public class settings{ public static final string welcomemessage= "helloworld"; public static final string byemessage= "yo"; public static string[] widgets = {welcomemessage,byemessage}; } the compiler complains duplicat variables. can delete 2 separate variables , still acces welcomemessage settings.welcomemessage? don't need acces settings.widget[0]? , possible add variable welcomemessage variable (by instance using static hashtable)? edit: know code doesn't right it's example because wondered why compiler thinks welcomemessage (as separata variable) same variable in widgets array. i consider java-enums in case: public enum settings { welcomemessage ("helloworld"), byemessage ("yo"); public final string value; settings(string value) { this.value = value; } } you can access values via settings.welcomemessage.value . list of enums settings.value...

java - Is there a JSON library that can serialize Proxy objects? -

using activeobjects orm , gson json processor. ran problem going tojson persisted objects. problem persisted class interface , ao proxying object under hood. here's sample code: venue venue = manager.get(venue.class, id); gson.tojson(venue); comes exception: java.lang.unsupportedoperationexception: expecting parameterized type, got interface java.lang.reflect.invocationhandler. missing use of typetoken idiom? see http://sites.google.com/site/gson/gson-user-guide#toc-serializing-and... because venue.getclass().getname() gives: $proxy228 i've tried few solutions in various combinations: gsonbuilder.registertypeadapter(venue.class, newvenueserializer()); type listtype = new typetoken<venue>() {}.gettype(); nothing has worked far , i'm using wonky field-by-field workaround. suggestions? i'm not married gson, if there's alternative library can i'd happy use it. flex json should work - use bean property intr...

sql - Variable as top value -

original question: declare @num int set @num = 5 select top @num col1, col2 table1 the above not work. not @num being used way. needs done can have variable value next top command? it gives error: incorrect syntax near '@num' select top (@num) table sql server 2005 onwards, supported parameterize top.

How do you filter a view of a DataTable in .Net 3.5 sp1 using WPF c# and xaml? -

i found msdn example code getting default view of collection , adding filter view, of .net 4.0. i'm on team not switching 4.0, don't have option. none of examples found used datatable source, had adapt little. i'm using datatable because data comming db ans it's easy populate. after trying implement msdn examples, "notsupportedexception" when try set filter. c# code have: protected datatable _data = new datatable(); protected bindinglistcollectionview _filtereddataview; ... private void on_loaded(object sender, routedeventargs e) { _filtereddataview = (bindinglistcollectionview)collectionviewsource.getdefaultview(_data); _filtereddataview.filter = new predicate(matchescurrentselections); // throws notsupportedexception } ... public bool matchescurrentselections(object o){...} it seems either bindinglistcollectionview not support filtering in .net 3.5, or doesn't work datatable. looked @ setting in xaml instead of c# code, xam...

How do I display the record count of a related model with CakePHP? -

i have 2 models. lets "posts" , "comments". in admin view posts, want display how many comments on post. confused on put code. in controller or view? in controller. another option cache count . approach, you'd add field comment_count posts table, modify comment model's belongsto association this: class comment extends appmodel { var $belongsto = array( 'post' => array( 'countercache' => true ) ); } anytime new comment record created, comment_count of associated post record incremented, , decremented anytime associated comment deleted.

algorithm - Google search results: How to find the minimum window that contains all the search keywords? -

what complexity of algorithm is used find smallest snippet contains search key words? as stated, problem solved rather simple algorithm: just through input text sequentially beginning , check each word: whether in search key or not. if word in key, add end of structure call the current block . current block linear sequence of words, each word accompanied position @ found in text. current block must maintain following property : first word in current block must present in current block once , once. if add new word end of current block, , above property becomes violated, have remove first word block. process called normalization of current block. normalization potentially iterative process, since once remove first word block, new first word might violate property, you'll have remove well. , on. so, current block fifo sequence: new words arrive @ right end, , removed normalization process left end. all have solve problem through text, maintain current block, normal...

SQL Server query replace for MySQL Instruction -

i'm new sql server, , used mysql while now... select a.acol, if(a.acol<0,"neg","pos") column2 table i want on sql server, there doesn't exist if instruction. how replace if, in sql server 2008 query? select a.acol, case when a.acol < 0 'neg' else 'pos' end column2 table

mysql - Uploaded PHP files not running on Amazon cloud ,while files created there are running well -

i have deployed php web app on amazon ec2 cloud , files not running ,because my files's uploed using ec-user account while if create file there using root can run easily. have changed owner , group of uploaded files root , server response the website encountered error while retrieving mydns/index.php may down maintenance or configured incorrectly. while if run file create there using putty runs perfectly. please me if u think configuration required there have deployed website there inside /var/www/html/somefolder/ check permissions of .php file working , 1 isn't ls -l. believe permissions need 744.

Can I get SpecFlow to generate a list of missing step definitions without running the tests? -

i'm in process of refactoring our specflow-implemented bdd tests. part of work, i've commented out of step definitions. as run tests, i'm presented "no matching step definition found 1 or more steps." message. however, i'd prefer not wait until tests run. there way specflow check missing step definitions without running tests? you can use stepdefinitionreport parameter specflow.exe, follows: specflow.exe stepdefinitionreport mytests.csproj but aware: if assembly uses .net 4.0 runtime, you'll need add specflow.exe.config file <supportedruntime> element. it uses functionality that's 32-bit only. if you're on 64-bit windows, you'll need use corflags /32bit+ edit specflow.exe file. by default, looks in bin\debug folder.

objective c - How can I easily save the Window size and position state using Obj-C? -

what best way remember windows position between application loads using obj-c? using interface builder interface, possible bindings. what recommended method? thank you. put name unique window (e.g. "mainwindow" or "prefswindow") in autosave field under attributes in interface builder. have location saved in user defaults automatically. to set autosave name programmatically, use -setframeautosavename: . may want if have document-based app or other situation doesn't make sense set autosave name in ib. link documentation .

c++ - Question regarding inheritance in wxWidgets -

currently i'm attempting write own wxobject, , class based off of wxtextctrl class. currently have: class commandtextctrl : public wxtextctrl { public: void onkey(wxkeyevent& event); private: declare_event_table() }; then later on have line of code, doesn't like: commandtextctrl *ctrl = new commandtextctrl(panel, wxid_any, *placeholder, *origin, *size); ...and when attempt compile program receive error: error: no matching function call ‘commandtextctrl::commandtextctrl(wxpanel*&, <anonymous enum>, const wxstring&, const wxpoint&, const wxsize&)’ it seems doesn't inherit constructor method wxtextctrl. happen know why doesn't inherit constructor? thanks in advance help! c++ not inherit constructors (you may thinking of python, does ;-). class w/o explicitly declared ctors, commandtextctrl , in c++, has default , copy ctors supplied implicitly c++ rules. so, need explicitly define ctor desi...

c# - Is flags attribute necessary? -

i found or without flags attributes, can bit operation if defined following enum enum testtype { none = 0x0, type1 = 0x1, type2 = 0x2 } i wondering why need flags attribute? c# treat them same either way, c# isn't consumer: propertygrid render differently allow combinations xmlserializer accept / reject delimited combinations based on flag enum.parse likewise (from string), , enum's .tostring() behave differently lots of other code displays or processes value treat them differently more importantly, though, expression of intent other developers (and code); this meant treated combinations, not exclusive values .

.net - Are there SqlExceptions which throw but commit their data anyway? -

i've encountered error: system.data.sqlclient.sqlexception: transaction log database 'mydatabase' full. find out why space in log cannot reused, see log_reuse_wait_desc column in sys.databases on 1 of windows services. it's supposed retry after catching sql exception, didn't expect seemed data still going through (i'm using sqlbulkcopy btw) regardless of throwing exception. i've never encountered scenario before. i'd know if there other scenarios such thing might happen, , if thing entirely possible @ in first place? edit: system.data.updateexception: error occurred while updating entries. see innerexception details. ---> system.data.sqlclient.sqlexception: transaction log database 'my_db' full. find out why space in log cannot reused, see log_reuse_wait_desc column in sys.databases @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection) @ system.data.sqlclient....

.net - WCF - calling back to client (duplex ?) -

i have problem solution choose.. have server running having service running can receive orders website. server several client (remote computers) connected somehow. i use wcf comunication, not sure it's possible. i dont wanna configure client firewall settings in routers, clients have connect server. but when order recieved on server, should transferred specific client. one solution have client connect using duplex binding, have somehow keep connection alive in order able received data server... way ?? normally connection times out , reason... anyone have insight problem. thx alot advise :-) best regards søren müller this duplex bindings designed for. 2 best choices have nettcpbinding or pollingduplexbinding . the former uses tcp protocol may not suitable clients if aren't on network. however, allow two-way communication on client-initiated socket. client doesn't need able accept incoming connections. used on project , works well. it's res...

How can I tell whether two .NET DLLs are the same? -

i have source dll , have compiled version of lying around somewhere. if compile source have different date already-compiled version. how can tell whether in fact same , have merely been compiled @ different times? to compare 2 .dll files can use ildasm or other tool geting il code. have created sample embedded ildasm in dll file can use on every machine. when disassemble assembly check if ildasm.exe file exists in executing assembly folder , if not file extracted there our dll file. using ildasm file il code , save temporary file. need remove following 3 rows: mvid - wrote before unique guid generated every build image base (the image base tells program loaded in memory windows loader.) - different every build well time-date stamp - time , date when ildasm run so read temp file content, remove these rows using regexes, , save file content same file. here disassembler class: using system; using system.io; using system.linq; using system.reflection; using syst...

magento - Get customer object on an event -

i’m trying createan observer on following event.: ‘sales_order_payment_pay’. however according magento doc http://www.magentocommerce.com/wiki/5_-_modules_and_development/reference/magento_events i don’t have parameters avalaible on event.. do have idea how retrieve customer object (i need info such customer id , customer email)? thanks feedback , anyway wish nice day, anselme this event expose payment object, should able chain off of object want: public function yourobserverfunction($event) { $payment = $event['payment']; $customer = $payment->getorder()->getcustomer(); // ... useful } generally objects in magento can chained this, , code doesn't rely on event being triggered customer session (which not assumption anyway). hope helps! thanks, joe

osx - Separate build directory using xcodebuild -

the man page xcodebuild reads: run xcodebuild directory containing project (i.e. directory containing projectname.xcodeproj package). i keep source directory (which subversion external) clean , unmodified, , build object files , executables location outside of source directory. is there way build separate build directory terminal using xcodebuild can make tools or msbuild on windows? you can set build settings command line. configuration_build_dir set build directory. example: xcodebuild -project yourproject.xcodeproj -configuration debug -target archs=x86_64 only_active_arch=yes configuration_build_dir=../some/other/dir a reference found on apple's site: build setting reference

matrix - O'Reilly book clarification on 2D linear system -

the oreilly book "learning opencv" states @ page 356 : quote before totally lost, let’s consider particular realistic situation of taking measurements on car driving in parking lot. might imagine state of car summarized 2 position variables, x , y, , 2 velocities, vx , vy. these 4 variables elements of state vector xk. th suggests correct form f is: x = [ x; y; vx; vy; ]k f = [ 1, 0, dt, 0; 0, 1, 0, dt; 0, 0, 1, 0; 0, 0, 0, 1; ] it seems natural put 'dt' there in f matrix don't why. if have n states system, how spray "dt" in f matrix? the dt s coefficients of velocities corresponding positions. if write state update after time dt has elapsed: x(t+dt) = x(t) + dt * vx(t) y(t+dt) = y(t) + dt * vy(t) vx(t+dt) = vx(t) vy(t+dt) = vy(t) you can read f off of these equations pretty easily.