Posts

Showing posts from March, 2015

delphi - Get the ascii value for a char, Ord equivalent in C++ -

in delphi exist function called ord returns ordinal value of ordinal-type expression. for example can retrieve ascii value char in way ord('a') return 65 ord('a') return 97 in c++ function must use ascii value char.? a simple int = c; c char should work.

immutability - enum vs immutable in D -

what's difference between enum = 2; enum s = "hello"; and immutable = 2; immutable s = "hello"; in d 2.0? an enum user-defined type, not variable. enum e = 2; short-hand enum : int { e = 2 } (i.e. anonymous enum 1 member e ), see the documentation . definition, members of anonymous enum placed current scope. so, e type member placed current scope, behaves literal . immutable = 2; on other hand creates variable i of type int. this difference has couple of consequences: enum e have no memory location , no address (is no lvalue), since neither type nor members have address. i.e. cannot auto ptr = &e; (just cannot auto ptr = &2; ). immutable i on other hand normal variable (just immutable). as discussed jonathan , immutable variables can initialized @ compile time or @ run-time, whereas type (with members defining type) must known @ compile time. the compiler can replace appearances of e 2 . i has create memory lo...

flex - Loading Swf with bytearray in AIR -

we have requirement air application loads flex generated swf inturn loads flash generated swf using swfloader. not working desired. gives following error: securityerror: error #3226: cannot import swf file when loadercontext.allowcodeimport false. this our air application. <?xml version="1.0" encoding="utf-8"?> <mx:windowedapplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="initapp()"> <mx:script> <![cdata[ import mx.controls.swfloader; [embed(source="flexloadingflash.swf")] public var flexmovie:class; private function initapp():void { // first convert swf movieclip var movieclip:movieclip = new flexmovie(); // bytearray movieclip var bytearray:bytearray = movieclip.movieclipdata; var swfloader:swfloader = new swfloader(); // load bytearray swfloader swfloader.source = bytearray; swfloader.maintainaspectratio = false; ...

cocoa - Adding a login window to a document based application -

i creating small document based application. in need start login page i.e., when application launches, login page should appear first(which should not document based). when running application right now, mydocument.xib loaded. there way can load login window first instead of mydocument.xib? tried change mydocument.xib make login page.but "untitled" @ first login page.. quite stuck @ point..pls help..i relatively new cocoa! make new class, add instance of mainmenu.xib, connect application object’s delegate outlet instance, implement applicationshouldopenuntitledfile: method. return no method , application open untitled document when user asks it. as login window, add new window mainmenu.xib , set visible on launch. place whatever logic need window in app delegate.

Developer documentation is empty after upgrading to lastest iOS sdk -

after upgrading latest ios sdk, developer documentation is empty. when doing search, contents list on left side bar appears main content empty. try right click , load in browser nothing happens too. please help. thanks. i had same problem, , solved downloading documentation in xcode via xcode --> preferences --> documentation. can check answer xcode documentation - offline reading gives general instructions install documentation api in xcode, , useful shortcut key combination check documentation directly source code.

browser automation - How can I ensure YSlow run automatically when firefox is started? -

it seems dumb question: have set extensions.yslow.autorun true , supposed work perfectly. it's not. when run bash script: urls=(http://www.google.com http://www.yahoo.com) link in "${urls[@]}"; firefox -p yslow -no-remote $link & echo $link pid=$! sleep 20 kill $pid done yslow doesn't run unless manually click yslow button. well, how can ensure yslow run everytime firefox started? have idea? why want this: want monitor several urls' performance. , report needs written every week, nice automate task. i did according post: http://tech.groups.yahoo.com/group/exceptional-performance/message/822 it's frustrating doesn't work out when it's supposed do. edit: someone having experience showslow might me out. thank you. tools -> add ons -> yslow -> options -> "automatically run yslow when page finishes loading"

mvvm - getting started with an asp.net webforms UI for c# application which uses nHibernate -

hi i've been building backend of application (using nhibernate data access). far i've had simple web-services manipulating data, i'm required develop web ui on application (using web forms). i've been looking @ different web frameworks ( webformsmvp , spring.net web ), , @ client-side js frameworks ( knockout , angular ), , can't decide best me, , how integrate all. hoping insight guys. i think general workflow this: view created, calls presenter. presenter contacts business layer retrieve information (which in turn contacts dao etc.) presenter returns view-model object, view displays. user manipulates data (maybe using ajax retrieve further needed information) view sends view-model of manipulated data presenter presenter translates view-model model entity , sends business layer here parts find tricky: a. how map between view-model , model entities think should use entitie's id retrieve unchanged entity dao (which stores in nhibernate's...

sql server - 12 hr time format in sql like.. 02:32:00 PM -

how can time 02:32:00 pm in sql server? i can 24 hr following code. convert(varchar(26), getdate(), 108) but want pure hh:mm:ss tt not milliseconds. i found 1 milliseconds. select convert(varchar, getdate(), 109) how achieve that? select right('0' + ltrim(stuff(right(convert(char(26), current_timestamp, 109), 14),9, 4, ' ')),11)

data binding - ASP.NET ComboBox fill and bind question -

i have long time catch asp.net, need create app has formview , several comboboxes in edit , insert templates. i use aspxcombobox wont make difference. i kina try understand if can have sqldatasource fill list of combobox , bind value sqldatasource. seems goal can never achieved. in windows easy normal task. now want ask efficient way this. any appreciated. [edit] i need achieve fill combobox database (datasource) , bind (datasource) similar in windows forms. have @ sqldatsource-class . find examples on how bind sqldatasource asp.net controls dropdownlist. <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:mynorthwind%>" selectcommand="select employeeid, lastname, address employees" updatecommand="update employees set address=@address employeeid=@employeeid"> <updateparameters> ...

windows - Folder Locker in c# -

please decipher on how folder locker works? create folder hide/lock functionality using c#? any suggestions welcome. you refer codeproject article on how protect\lock folder.

javascript - Is there a good JS ranged datepicker control out there? -

Image
i'm looking js control provides similar experience datepicker on google analytics you try jqueryui datepicker, it's effective , easy set up. http://jqueryui.com/demos/datepicker/

drupal - How to limit the results in a view? -

i have created 4 categories in feed aggregation. show results 100. want create view of aggregation item , in aggregation item use feed category select category have created in feed aggregation. here want category show latest 5 results not 100 results each category. how possible??? idea this? addressed in drupal view display - setting limit query results to sum: use items display field in view's basic settings.

php - organize the order of element and push the total of sub-array -

$base_arr = array ( 1 => array ( 0 => 1, 1 => 2, 2 => 5, 3 => 5 ), 3 => array ( 0 => 1, 1 => 2 ), 7 => array ( 0 => 1, 1 => 4 ) ); i want re organize order of element , push total of sub-array main array.the result want return this: $new_arr = array( 0 => 1, 1 => 2, 2 => 5, 3 => 5, 4 =>13, //this total 1+2+5+5 = 13 5 => 1, 6 => 2, 7 => 3,//this total 1+2 = 3 8 => 1, 9 => 4, 10 =>5 //this total 1+4 = 5 ); who can me please ,thanks. good chance try closures in php 5.3: $new = array(); array_walk($base_arr, function ($item) use (&$new) { $new = array_merge($new, $item); $new []= array_sum($item); } ); var_dump($new);...

c++ - how can we tell if the remote server is multi-threaded? -

my customer did not gave me details regarding nature of it's application. might multithreaded might not. server serves soap messages (http requests) is there special trick in order understand if peer single or multi threaded? i don't want ask customer , don't have access server/machine. want find myself. it's irrelevant. why feel matters you? a more useful question be: can server accept multiple simultaneous sessions? the answer ' yes, of course ' it's possible implement server that's incapable of supporting multiple sessions. just because server supports multiple sessions, doesn't mean it's multi-threaded. and, because it's multi-threaded doesn't mean have performance. when servers need support many hundreds or thousands of sessions, multi-threading may poor choice performance. are asking question because want 'overlap' soap messages on same connection - in other words, have 3 threads send request...

parameter passing - iphone pass values to the superclass from the subclass -

hi, want pass string value superclass subclass without using object. can please help. know has [self superview] . please help class c1 { string s1 -(void) m1 { } } class c2 { // here want call m1 , pass values s1 // without creating object of class c1 } they keyword communicate superclass super . can invoke methods on superclass this: [super mymethod:someparameter];

How to access the values of the custom fields filled in at facebook registration form? -

i wondering how access custom fields people filled in after registering on site facebook registration form. i understand usage of php sdk environment bit, , can access gender, name, etc. easily, have no idea how custom fields created. i prefer receive answer related php sdk, good. thanks in advance! once registration form submitted, signed_request holding all data need send server on url specify redirect_uri , how " extract " these data explained in documentation ( php example reading signed_request section): <?php define('facebook_app_id', 'your_app_id'); define('facebook_secret', 'your_app_secret'); function parse_signed_request($signed_request, $secret) { list($encoded_sig, $payload) = explode('.', $signed_request, 2); // decode data $sig = base64_url_decode($encoded_sig); $data = json_decode(base64_url_decode($payload), true); if (strtoupper($data['algorithm']) !== 'hmac-sha256...

vb.net - AuthSubUtil.getRequestUrl -

i try redirect user google calendar , authorization can combine events on google calendar , own calendar, can't token querystring somehow :( dim tokenurl string = authsubutil.getrequesturl("http://localhost:54522/scripts/wbmodules/test.aspx/retrievetoken", "http://www.google.com/calendar/hosted/mydomain.nl/", false, false) i see login , password page when enter information , try redirect own website, error message the page requested can not displayed. site requesting access mydomain account, format of request incorrect. the parameter 'scope' incorrect or missing. finally mistake found, using wrong 'scope' instead of "http://www.google.com/calendar/hosted/mydomain.nl/" i should have used more general term "http://www.google.com/calendar/feeds/" so correct version follows dim tokenurl string = authsubutil.getrequesturl("http://localhost:54522/scripts/wbmodules/test.aspx/retrievetoken", ...

Making classes public to other classes in C++ -

if have 2 classes example follows: class {...} class b {...} if want make class a public class b , make members of class a public or can use public class {...} ? is there way tell class b example class a public you? in other words, can make public classes a protected or private others? or, matter of deriving class (inheritance)? thanks. there's substantial difference between making class public , making contents public. if define class in include file (.h file) making class public. every other source file includes include file know class, , can e.g. have pointer it. the way make class private, put definition in source (.cpp) file. even when make class public, don't have make contents of class public. following example extreme one: class myclass { private: myclass(); ~myclass(); void setvalue(int i); int getvalue() const; }; if definition put in include file, every other source can refer (have pointer to) cl...

html - CSS JQuery Position Selector is null on IE -

i have problem jquery position() code. code works on chrome/firefox fails on ie. the js code is: function myfunc() { var x = $("#menu li.active"); if (x == null) alert('x null'); else alert(x.position().left + " " + x.position().top); } $(document).ready(function() { myfunc(); }); and html is: <ul id="menu"> <li class="active"><a href="test.php"><span>test 1</span></a></li> <li><a href="test2.php"><span>test 2</span></a></li> </ul> normal browsers returns left , top values, , ie says: message: 'position().left' null or not object thanks in advance. i found problem. html header was: <html dir="rtl"> and that's caused problem in case. when set page ltr works on ie. thanks.

c - How to iterate over long path names with any form of the Windows API -

i have files on server exceed max_path limit. i've repeatedly heard can list files pre-pending \\?\ path. however, doesn't solve problem findfirstfile[ex] , partners use data structure limits file name length max_path . is there other way iterate on directory structure find files have name long? i've seen utilities none of them available in source form. note have seen blog entries .net bcl folks , followed links provide. i'd prefer in c or c++ simplicity freely available language now. pointers code, docs or useful appreciated. i don't think there's problem here. referring win32_find_data indeed return filenames limited in length max_path . since filename part, , path omitted, there no limitation. within directory, object (file or folder) limited in length, typically 255 characters. can determine limit lpmaximumcomponentlength parameter of getvolumeinformation . i'd surprised if volume mounted in windows have maximum component len...

asp.net - PageLoad event is not fired when an aspx is opened through javascript of another aspx page -

i have aspx application 2 aspx pages. second aspx page opened on click of button in first aspx page using javascript. problem is, when second aspx page getting opened, page_load event not firing. when refresh second page, page_load event of second aspx page fired. please let me know might problem , done fire page_load event. thanks in advance in case (calling aspx page window.open()) have attach page_load event manually in page's oninit event: override protected void oninit(eventargs e) { this.load += new eventhandler(page_load); base.oninit(e); } protected void page_load(object sender, eventargs e) { // code here } reference: http://www.vbforums.com/showthread.php?t=249689

list - Java Collections containsAll Weired Behavior -

i have following code , using superlist , sublist , want check sublist sublist of superlist. my objects not implement hashcode or equals methods. have created similar situation in test. when run test result show big performance difference between results jdk collection , common collections.after running test getting following output. time lapsed java collection api 8953 milliseconds & result true time lapsed commons collection api 78 milliseconds & result true my question why java collection , slow in processing containsall operation. doing wrong there? have no control on collection types getting legacy code. know if use hashset superlist big performance gains using jdk containsall operation, unfortunately not possible me. package com.mycompany.tests; import java.util.arraylist; import java.util.collection; import java.util.hashset; import org.apache.commons.collections.collectionutils; import org.junit.before; import org.junit.test; public class collectioncompar...

attributes - xslt copy-of without children -

hi have sitemap xml document looks this <pagenode title="home" url="~/" fornavbar="true"> <pagenode title="admin" url="~/admin" fornavbar="false"> <pagenode title="users" url="~/admin/users" fornavbar="false"/> <pagenode title="events" url="~/admin/events" fornavbar="true"/> </pagenode> <pagenode title="catalog" url="~/catalog" fornavbar="true"/> <pagenode title="contact us" url="~/contactus" fornavbar="false"/> </pagenode> now want retrieve xml document navbar, includes pagenodes have fornavbar=true. how can done? the closest able far this: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match=...

javascript - No Textbox can take the focus by mouse clicking in IE8 -

i have problem in gwt 2.0.4 can reproduce ie8 (windows xp). use tabpanel iframes in tabs. when close tab has element focus no textbox in other tabs can take focus mouse clicking (but tab-key). if closed tab did not have focused element problem not occur. tried use tablayoutpanel did not help. can cause such behavior in web browser? thanks try blur() or ( setfocused(false) ) corresponding iframe when closing tab.

java - Asynchronous File Upload Servlet -

is recommended use asynchronous or nio servlet file upload? if so, sample code start great me. i'd know version of tomcat supports async / nio servlet too. no... ...use standard blocking io stuff. nio not automagically translate 'faster' old school blocking io. in fact, many people have reported degraded performance asynchronous nio implementations years, on top of code being considerably more complex code, understand, maintain , debug. if doesn't scare off, remember 2 important engineering concepts: keep simple, stupid! avoid premature optimization

c# - Table layout panel scroll bar -

given table layout panel 2 columns , many rows, how can attatch scroll bar grows greater size of form . thank you the tablelayoutpanel example of scrollablecontrol . can therefore set it's autoscroll property true , control automatically create scroll bars when it's preferred size exceeds current size. provide desired effect minimal hassle. procedure set maximumsize property preferred maximum size or can dock tablelayoutpanel in form. set autoscroll property of tablelayoutpanel true. fyi: panel, toolstrip, flowlayoutpanel, splitterpanel, tablelayoutpanel, tabpage , toolstripcontentpanel inherit scrollablecontrol class answer applies them well.

perl - netsnmp - How to get the size-constraints of a column in net-snmp? -

suppose have following code in mib2c.conf: @foreach $t table@ starting table $t @foreach $c column@ echo $t has column $c has syntax of $c.syntax ... @end@ @end@ eof how can size-related constraints column $c mib file (min/max value integers or list of accepted values enums). feed these values netsnmp_chech_vb_xxxx in order validate snmp set requests, not sure how them. from mib2c code you'll see comment below: # @foreach $range_start, $range_end range node@ # repeat iterate on code until @end@ setting $range_start , $range_end # legal accepted range set given mib node. you'll note need iterate on ranges. integers , sizes don't have single range of time. ie, it's legal have integer must 2-4 or 6-8 blank in middle. above code let loop through every range set.

Flex LinkBar similar to iGoogle links -

i wanted create flex linkbar looks similar igoogle links. links expandable (one level-deep) clicking on plus button. i've considered styling tree or accordion desired , feel. before spend time on 1 approach versus another, thought ask first. does know component use achieve this? or example of doing similar vertical navigation bar? should 1 level deep , parent nodes might not have children (doesn't expand). thanks in advance.... just wanted update implemented. ended using tree , styled , behave linkbar can have child links.

c# - Specifying rowfilter criteria to be evaluated in DataTable event handlers -

we have mini business application framework of our own meet our custom needs. using datatables in our business classes storing collections (e.g. detail data). our framework identifies datatable type properties declared in business object , attaches few event handlers provide services authorization control, change tracking etc. things running fine today small requirement got me little baffled. apart authorization requirements e.g. role based access edit datatable, edit columns of datatable etc., our devs require specify criteria datatable , matching rows (fulfilling criteria) prevented editing. for example if there datatable having values below - settingname | value | ispolicycontrolled setting1 | 10 | false setting2 | 20 | true the devs want specify criteria through our business framework below - somebusinessobject.makereadonly("settings", "ispolicycontrolled == true"); the first parameter being datatable name , second criteria readon...

profiling - MySQL Profiler - No entries in show profile -

i using mysql profiler diagnosis of mysql issues investigating. when issue show profiles command not results. this how using it: set profiling=1 --enable profiling -- run selects / inserts etc select count(*) mytable insert mytable (mydata) values ('wibble') show profiles i expecting show profiles command give me profile data selects etc performed after enabling profiling (per information from mysql dev page ), empty resultset. not see errors when enabling/disabling profiling nor see errors when attempting view profiles. the following may or may not relevant: the commands issued via phpmyadmin i running mysql 5.0.77 select * information_schema.profiling returns no results tested, works. you can phpmyadmin if can use transaction (depending on storage engines?) try this: start transaction; set profiling=1; --enable profiling -- run selects / inserts etc select count(*) mytable; insert mytable (mydata) values ('wibble'); show pro...

windows - ConvertStringSidToSid for S-1-5 (NT AUTHORITY group) -

i have csid object holding known sid system. calling domain() function can see domain "nt authority". in msdn found out group's sid "s-1-5", tried use convertstringsidtosid() in order psid group got error sid structure incorrect. is there way csid group? possible? thanks lot! :-) you need use allocateandinitializesid () function this. see this example in msdn. psid psid; sid_identifier_authority sidauth = security_nt_authority; if(! allocateandinitializesid( &sidauth, 2, security_builtin_domain_rid, domain_alias_rid_admins, 0, 0, 0, 0, 0, 0, &psid) ) { printf( "allocateandinitializesid error %u\n", getlasterror() ); return false; }

c# - .Net Session Scoped Variables? -

i'm new in .net , i'm using mvc2 + linq , c# i want know if possible use session scoped variables or clases , how that? need store in session object ? or declare global variable ? i need store data diferent sql tables associates logged in user thanks in advance yes, should able use session object within controller's action methods store , retrieve session data. session["mydata"] = mydata; mydatatype mydata = (mydatatype)session["mydata"]; obviously careful size of objects storing , how session data handled i.e. in process, sql server or application server. if not storing session data in memory need ensure serializable.

javascript - Custom checkbox (Use images in place of checkbox) -

i'm looking create custom checkbox. i display active/inactive image in place of checkbox. i'm limited using jsf/richfaces , javascript if necessary. i wanted avoid using javascript thing find openfaces 'o:selectbooleancheckbox' tag. is aware of way without resorting javascript? thanks easier , javascript. but anyways can using 2 different image tag rendering on boolean condition , changing value of variable bind. <a4j:outputpanel id="checkbox"> <h:graphicimage value="path/checkedimage" rendered="#{yourbean.value}"> <a4j:support event="onclick" action="#{yourbean.changevalue}" rerender="checkbox"/> </h:graphicimage> <h:graphicimage value="path/uncheckedimage" rendered="#{not yourbean.value}"> <a4j:support event="onclick" action="#{yourbean.changevalue}" rerender="checkbox"/> ...

android - How to define as a view for an AlertDialog a view described in a XML file -

here problem. have alertdialog have title , positive button. want describe content of alertdialog in xml file (except title/button). have created file called dlg_addpwd.xml in layout resources. here code i'm using: alertdialog alert = new alertdialog.builder(this); alert.settitle("password access"); alert.setview(findviewbyid(r.layout.dlg_addpwd)); alert.setpositivebutton("add", listenaddpwddlg); alert.show(); i guess line alert.setview(findviewbyid(r.layout.dlg_addpwd)); is wrong, isn't ? main idea of question is: how define view alertdialog view described in xml file? thanks vincent layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service); view layout = inflater.inflate(r.layout.paypaldialog, (viewgroup) findviewbyid(r.id.yourdialog)); alertdialog.builder builder = new alertdialog.builder(yourclass.this) .setview(layout); alertdialog = buil...

how to create a triangle in c++ without using opengl, directx, or other api -

i want know if possible me create line or triangle or shape c++ code. based on op comments elsewhere in thread, sounds wants direct manipulation of low-level instructions on various pieces of hardware used rendering images. this: understand hardware have performing this. means doing exensive research how hardware designed , used. understand how directly invoke manufacturer's device drivers. again, requires extensive research , made more complicated fact hardware manufacturers obfuscate device driver source code, if publish @ all, , don't release documentation device driver code. understand how can directly manipulate hardware using c++ write own api manage hardware functions. once that's done, can use api draw triangle or other polygon like. personally, seems bit me, , i'll use existing api. might worthwhile learning experience without spouse , children.

perl - http::proxy module engine -

i have question cpan module http://search.cpan.org/dist/http-proxy/ it seems module support engines could explain me difference between: use http::proxy; $proxy = http::proxy->new( engine => 'nofork' ); and : use http::proxy; $proxy = http::proxy->new; and: use http::proxy; $proxy = http::proxy->new( engine => scoreboard ); to quote http::proxy::engine pod the role of engine implement main fork+serve loop required bookkeeping. way test various implementation and/or try out new algorithms without difficulties. the descriptions of various engines are: http::proxy::engine::legacy - "older" http::proxy engine http::proxy::engine::nofork - basic, non forking http::proxy engine http::proxy::engine::scoreboard -a scoreboard-based http::proxy engine note: last 1 seems implementing "scoreboard" dynamic scheduling algorithm (which used cpu instruction sceduling). in case it's more simp...

Any open source Rails apps for managing employee's times? -

i've seen things in php timeclock . app manages vacations / hours / etc. anyone know of rails equivalent? what you're looking rails timesheet. can check these out

joomla - Create a Menu in a non-existent module in Everhest -

i'm using everhest joomla template 1 of websites. i can't figure how can build menu on top of scrolling images. objective have equal menu, sliding text when put mouse in "joomla overview". any ideas? ok, understand need now. template developers hard code menus in templates in order maintain of original template. there several ways this, common way have seen done using specific menu name - typically mainmenu. don't have put in module position, name menu want show there proper name. if want post code index.php template can tell sure.

objective c - iphone caching issue - UISearchbar -

i have app uses dynamic forward search using uisearchbar here does..i have 2 views; (list) & b (detail) on view a, have uisearchbar user can type , list below gets updated dynamically (uses copied arrays) i.e. external web service api say scenario, user has type "word" he'll start w list show "wa","wb","wc","wd", etc he'll type 2nd letter o (so search term "wo") list display "wo1","wo2","wo3", etc at point user has typed wo , clicks on 1 of options in list wo2, he'll taken details abt wo2 clicks there...so again shown wo1, wo2, wo3, ... now here question..if clicks on wo1, though list showing wo1, wo2, wo3, ...he taken details "wa" (i.e. first item in previous list (i.. @ time of typing 'w' only) so there seems caching abt previous index value, seems... please me issue. i using array of things. search result, pushing detail, etc please, ...

Tracking object allocation in python -

is there method can override allow me use print statements / pdb / etc. keep track of every time instance of class allocated? while unpickling objects seeming never have either __setstate__ or __init__ called on them. tried overriding __new__ , printing out id of every object make in __new__ , still encountering objects ids never printed. edit: here code use altering (instrumenting) __new__ of class , of super-classes except object itself: class allocator: def __init__(self, my_class): self.my_class = my_class self.old_new = my_class.__new__ def new(self, * args, ** kargs): rval = self.old_new(*args, ** kargs) #rval = super(self.my_class,cls).__new__(cls) print 'made '+str(self.my_class)+' id '+str(id(rval)) return rval def replace_allocator(cls): if cls == object: return setattr(cls,'__new__',allocator(cls).new) print cls.__base__ try: parent in cls.__base__: ...

Dealing with "mostly static" content in Rails -

my current project has dynamic stuff has quite few of these "mostly static" pages. these pages need updated cms style, "about" page or "welcome" page, rarely. my end goal have site owner able log in , edit text of these pages. there multiple translations of these various pages. what best way deal these "mostly static" pages? my current thinking need create model organization , store "about" blurb , other info properties of model. can translate using globalize2. seems goofy since there ever 1 of these models. does seem reasonable? anyone have better idea?

java - Does Play Framework support "snippets"? -

if want have common piece of ui across multiple pages, such menu, recommended way this? it contain both template code , back-end controller (similar "snippets" in liftweb framework). i aware there menu module play, i'm more interested in how achieved in general. there 2 ways include common view code play framework. you can use #{include} tag or #{extends} tag. the extends tag, name suggests, extends parent view. extends tag used default in skeleton code set play when create new application. extends main.html. add code here. the includes tag, allows inject common piece of view code templates @ specified point. works in same php include/require, or jsp includes work. the problem come when template code requires data or logic model (via controller). if case, need use @before or @with notation in controller ensure common piece of controller code executed each time. can add data renderargs list, available use within view. a simple example of using...

javascript - Delay before showing the tooltip -

i use simpletip jquery plugin , want make changes in it. want tooltip appear after time (milliseconds) when hovering link. unfortunately i'm not familiar jquery enough. can point out how can done? http://craigsworks.com/projects/simpletip/ thanks in advance simply use hoverintent plugin

javascript - Detect orientation change from within cross-domain iframe -

so have .jsp page has iframe in it. content of iframe hosted on separate domain. on mobile device, i'm looking iframe detect orientation change , alter dimensions of content accordingly. is there way add event listener content stored within iframe detect orientation change? if content not within iframe, , accessed directly instead, call like: window.addeventlistener('orientationchange', functiontobecalled, false); catches orientation change , calls appropriate function. however, can't seem work within iframe. i've tried parent.addeventlistener, parent.window.addeventlistener, top.addeventlistener, etc. no avail. from i've read sounds since cross-domain call have limited parent functionality available me, doomed fail? any appreciated. thanks! if own code of parent window can use cross document messsages solve this. send orientation parent window iframe. should work in cross domain scenario. tested on iphone 4.3 , android 2.2. in parent...

encoding in java -

i using java application , want set encoding utf-8 using : request.setcharacterencoding("utf-8"); the problem request not defined ?! this must set prior reading request parameters or reading input; therefore if doing after fact have no effect. in addition if using tomcat should set uriencoding utf-8 within connectors noted in so answer .

php - CakePHP why am I getting this error? -

here error message: warning (2): preg_match() [http://php.net/function.preg-match]: delimiter must not alphanumeric or backslash [core/cake/libs/model/model.php, line 2611] this happening when call following code controller: $this->account->save($this->data) the model looks this: class account extends appmodel { var $validate = array( 'first_name' => array( 'rule' => array('minlength', 1), 'required' => true ), 'last_name' => array( 'rule' => array('minlength', 1), 'required' => true ), 'password' => array( 'rule' => array('minlength', 8), 'required' => true ), 'email' => array( 'emailrule1' => array( 'rule' => ...

excel - E-Commerce, how to calculate price on 3 dimensional matrix? -

i have product wish have quote form for. form has: 1 - quantity 2 - size 3 - option 1 4 - option 2 etc.. the quantity , size determine cost of optional extras. e.g "paint" item optional need calculate based on quantity , size. whats best way build pricing matrix support structure? can excel table quantity & size, don't know how represent number of option elements depend on these 2 dimensions. any appreciated.. if takes twice paint paint 2 widgets one, just $(total) = $(each) * quantity for size, you'll need number scale cost. amount of paint needed proportional surface area paint, in case $(total) = $(per sq ft) * total sq ft but can roll first function second, right? treat 2 widgets 1 twice square footage. so you'll need estimate of cost per sq ft of surface area paint. calculate total square footage of of widgets you're selling, , multiply cost per square foot paint, , have price of extra.

jquery - Removing/Hiding a li href link within a DIV -

i need hide/remove link (team.aspx) within drop down menu added in later on. heres code: <div id="nav_menu"> <ul id="nav"> <li class="current"><a href="home.aspx">home</a> </li> <li><a href="iam.aspx">i a...</a> <ul> <li><a href="whoweare.aspx">who are</a> <ul> <li><a href="profile.aspx">our experience</a> </li> <li><a href="team.aspx">our team</a></li> <li><a href="mission.aspx">mission, values, vision</a></li> <li><a href="strength.aspx">strengthening communities</a></li> <li><a href="stories.aspx">where stories made</a></li> </ul> </div> first, tried remove <li> using pseudo worked re...

c++ - Is it possible to do real time network games in Actionscript 3.0 -

question: possible update 100+ objects in flash player on socket connections? more details , own try's below! details for internship got time create multiplayer physics game. worked steady 3 months on it. internship coming end , couldn't finish game. my problem hard send multiple packets each time-step server , back. packets send position updates of objects , mouse of other clients. i try explain network/game flow. client connects server using binary socket class in as3 server ask verification , client sends name , thumbnail. server waits until 4 clients connected (some matchmaking etc) server picks 4 clients , makes them run on separate thread(combined team) client sends performance score server range 1-100. server makes best client host machine physics , other 3 slaves host game sets level , makes around 1-100 shapes in level(primary shapes , complex shapes bridges, motors, springs) every time-step host gets updated property's of shapes , sends them ...

php - Accessing object properties of type array dynamically -

i building language class internationalization, , access properties dynamically (giving string name), don't know how when dealing arrays (this example): class language { public static $languages_cache = array(); public $index_header_title; public $index = array( "header" => array( "title" => null ) ); } now add languages this: language::$languages_cache["en"] = new language(); language::$languages_cache["en"]->index_header_title = "welcome!"; //setting variable language::$languages_cache["en"]->index["header"]["title"] = "welcome!"; //setting array function accessing members dynamically: function _($member, $lang) { if (!property_exists('language', $member)) return ""; return language::$languages_cache[$lang]->$member; } so, outputting members: echo _('index_header_title',...

Pass array (or TList) from C# code behind to external javascript? -

i need pass list (or array) of ip addresses , other information c# code behind javascript function, in external .js.. also, list may long (1000+ items) .. efficient way this? can provide small example? should use json serialization? var myobject = <%= justserializeasjson(...) %>; ... or pass function whatever. point json valid javascript literal can drop in number of places. don't worry "efficiency" here unless there profiled problem. both generation , javascript parsing should really fast . (bing maps loads 1mb file in js!) msdn json serializer

python - Is it possible to get the type of an XML node as it was defined in XSD? -

i'm parsing xml in python. i've xsd schema validate xml. can type of particular node of xml defined in xsd? for example, xml (small part) is <devicedescription> <wakeupnote> <lang xml:lang="ru">Русский</lang> <lang xml:lang="en">english</lang> </wakeupnote> </devicedescription> my xsd (once again small part of it): <xsd:element name="devicedescription" type="zwv:devicedescription" minoccurs="0"/> <xsd:complextype name="devicedescription"> <xsd:sequence> <xsd:element name="wakeupnote" type="zwv:description" minoccurs="0"> <xsd:unique name="langdescrunique"> <xsd:selector xpath="zwv:lang"/> <xsd:field xpath="@xml:lang"/> </xsd:unique> </xsd:element> </xsd:sequence> </xsd:complextype...

wpf - Is that possible to have a conditional setter, more than 0 value? -

how assign setter conditional value such more 0? need hide object if value not 0. best way it? ifeas highly appreciated. xaml example of datatrigger: <datatrigger binding="{binding role.count}" value="0"> <setter targetname="counts" property="visibility" value="hidden" /> </datatrigger> write value converter, isgreaterthanzero , write xaml as, <window.resources> <local:isgreaterthanzero x:key="isgreaterthanzero"/> </window.resources> <datatrigger binding="{binding role.count, converter={staticresource isgreaterthanzero}" value="true"> <setter targetname="counts" property="visibility" value="hidden" /> </datatrigger> and isgreaterthanzero can written as, public class isgreaterthanzero: ivalueconverter { #region ivalueconverter members public object convert(object value...

debugging - My static C# function is playing games with me... totaly weird! -

so, i've written small and, thought, easy method in c#. static method meant used simple password suggestion generator, , code looks this: public static string createrandompassword(int outputlength, string source = "") { var output = string.empty; (var = 0; < outputlength; i++) { var randomobj = new random(); output += source.substring(randomobj.next(source.length), 1); } return output; } i call function this: var randompassword = stringhelper.createrandompassword(5, "abcdefghijklmnopqrstuvwxyz1234567890"); now, method return random strings "aaaaaa", "bbbbbb", "888888" etc.. , thought should return strings "a8jk2a", "82mok7" etc. however, , here wierd part; if place breakpoint, , step through iteration line line, correct type of password in return. in 100% of other cases, when im not debugging, gives me crap "aaaaaa", "666666", etc.. how possible? sugg...

java - Spring RedirectView behaving differently in different tomcat installations -

i have 2 tomcat instances. both behind proxying apache httpds. code in spring controller looks this: @requestmapping(value = "/dosupersexystuff", method = requestmethod.get) public string viewsupersexystuff() { return "redirect:/mysupersexystuff"; } on first tomcat installation on windows have somedomain1.dev redirected http://localhost:8080/myapp , works flawlessly. redirect goes http://somedomain1.dev/mysupersexystuff on other tomcat installation (which on linux) redirect works relative context path , user end @ http://somedomain2.dev/myapp/mysupersexystuff wrong. what should spring ignore context path , redirect user "belongs"? all urls in application absolute(everything including links in jsps, redirect urls , places links used). guess that's not correct way stuff: if have implement https version of site i'll in trouble. if you think must change fundamentally in approach please point me in right direction. instead o...

c - Get Unicode string from Edit Control -

what unicode version text length instead of wm_gettextlength ? it same message. you'll need use createwindoww() or compile unicode defined unicode enabled edit control.

c# - How do you assign a transaction with EF4 CodeFirst CTP5 without using TransactionScopes? -

i attempting perform functional tests against live database, make sure linq queries translating sql correctly. want using transactions, 1 functional test not affect another. the problem is, cannot find way in api utilize transactions correctly. can retrieve new dbtransaction via mydbcontext.database.connection.begintransaction() , however, cannot find anyway use transaction. all documentation can find begintransaction() call, assign transaction object sqlcommand via cmd.transaction call command performing actions with. however, ef4 ctp5, there no way access sqlcommand used queries. thus, can't figure out how use transaction have begun begintransaction() . i not want use transactionscope objects, because sql ce 4 not support them, , prefer use local database , not go across network. sql ce 4 support transactions retrieved via begintransaction() , can't figure out how code first. does have idea how this? edit : after emails microsoft, seems transaction...

NHibernate 3. Alternatives to "ThenFetch" in QueryOver -

i'm using nhibernate 3.0 both linq provider , queryover. want eager load related data, , there comes method "fetch" rescue, both in linq , queryover. have special scenario want eager load property not directly on second level, like: foo f = ...; f.a.b.c with linq there's no problem, can "chain" fetches method "thenfetch", like: var result = session.query<foo>().fetch(a => a.a).thenfetch(b => b.b).thenfetch(c => c.c).tolist(); in queryover there's no such method, how can achieve same result? thanks in advance. i managed solve problem using 2 different approaches: approach one: session.queryover<foo>().fetch(x => x.a).fetch(x => x.a.b).fetch(x => x.a.b.c) approach two: a = null; b b = null; c c = null; session.queryover<foo>() .joinalias(x => x.a, () => a) .joinalias(() => a.b, () => b) .joinalias(() => b.c, () => c) both work (altough i'm not ...

vb.net - Only accept digits for textbox -

i found code making textbox accept numbers. private sub textbox1_keypress(byval sender system.object, byval e system.windows.forms.keypresseventargs) handles textbox1.keypress dim allowedchars string = "0123456789" if allowedchars.indexof(e.keychar) = -1 ' invalid character e.handled = true end if end sub but... user can't delete numbers using backspace button. how do then? you need handle pasted text (there may not keypress). best way maskedtextbox .

c++ - loading gdb source for a shared library -

i'm using gdb 7.2 on ubuntu 10.10 while stepping step point looks (literally) this: 0x00130a2c in boost::contexts::context::impl_t::impl_t(void (*)(void*), void*, unsigned int, boost::contexts::context::impl_t*, std::auto_ptr<boost::contexts::context::allocator_base>) () /home/lurscher/third_party/boost_1_45_0/stage/lib/libboost_context.so.1.45.0 so want associate appropiate source files; should on /home/lurscher/third_party/boost_1_45_0/boost/context , /home/lurscher/third_party/boost_1_45_0/libs/context . but truth i'm not sure how achieve this, been years since had debug in terminal mode you can compile third-party library debugging symbols, , debugging symbols chain [i.e. if app compiled debugging symbols, can step through , see source lines within library] boost jam takes debug argument instruct build debug version. in gcc, debug symbols -g

c# - Namespace issue -

Image
this driving me crazy! i'm trying namespace thrid party control called: hotdocs.server.session. my namespaces start cce.hotdocs.io , cce.hotdocs.test. when type "hotdocs." namespaces start cce.hotdocs ? wtf? should getting hotdocs.server missing? captured couple of screen snippets show mean... second screen snippet driving me crazy. try use global::hotdocs. or try: create alias 1 of them: using myalias = hotdocs.server;

networking - Mobile Adhoc NETwork -

how create mobile adhoc network using bluetooth transmission , j2me programming? should start? you can start first choosing api bluetooth bluecove etc. google available apis support java , can choose 1 find better you. have worked on bluecove. have never created adhoc network. think need create pan (personal area network) via bluetooth. please elaborate how want use ad-hoc network can tell more it.

spring mvc - Difference between Request MVC and Component MVC -

Image
i have heard jsf implementing component based mvc , spring mvc implementing request based mvc. know exact technical difference between these 2 types. in request (action) based mvc, single front controller servlet delegate action models based on request url/params. work directly raw httpservletrequest , httpservletresponse objects in action model. you've write code gather, convert , validate request parameters , if necessary update model values before can ever invoke business action. in component based mvc, single front controller gather, convert , validate request parameters , update model values need worry business action yourself. how controller needs gather/convert/validate/update values definied in single place, view. since that's not possible "plain" html, specific markup language required achieve goal. in case of jsf 2.0, that's xml (xhtml) based. use xml define ui components in turn contain information how controller should gather/convert/v...

c# - Bitmap.MakeTransparent in Silverlight? -

how can make of white pixels of bitmapimage transparent in sivlerlight? this using regular bitmap: //bitmap white background: var bmp = new bitmap(100, 100); using (var g = graphics.fromimage(bmp)){ g.clear(color.white); g.drawstring("string", new font(fontfamily.genericserif,10.0f), new solidbrush(color.red), 30, 30); } //i want make white transparent bitmap.maketransparent does: bmp.maketransparent(color.white); in silverlight, how do this?: var bmp = new bitmapimage(new uri("http://www.google.com/images/logos/ps_logo2.png")); bmp.maketransparent(color.white); i'm new silverlight, expect drawing canvas or later, can shader or if needs be. a shader perfect if need effect applied again , again there more options: preproces image in favorite paint program. (fastest, less flexible) preproces image using writeablebitmap. (slowest, more flexible) use shader. (fast, flexible) for shaders @ this wonderful tool shazzam

Overlaying two images with automatic resize using ImageMagick -

Image
is there way automatically resize overlay image according background size when overlaying images using imagemagick? using following code now: composite overlay.jpeg background.jpeg result.jpeg the problem overlay , background of different sizes, , i'd resize overlay accordingly (keeping aspect ratio) , place center. there way that? first of all, overlay , background not need same size composite work. example, given these 2 images: sydney.png (352x288): jet2.png (128x129): try following commands: convert -size 352x288 -composite sydney.png jet2.png -geometry 64x64+176+144 -depth 8 test.png convert -size 352x288 -composite sydney.png jet2.png -geometry 32x32+176+144 -depth 8 test.png -size specifies output image dimensions -geometry specifies dimensions , location of foreground this first command: edit here's bash script in 1 line: #!/bin/bash if [ -z "$3" ] echo "usage: $0 background.png foreground.png output...

scripting - Merge AVI files with partial sound tracks -

i need merge 2 avi files sound tracks substantially shorter video ones - i.e. can minutes of video without sound @ end. when merge either transcode or mencoder , sound , video merged "independently", resulting in avi file audio glued , silence glued , put @ end causing enormous loss of sync between audio , video. there way merge files file boundaries left intact , sound attached proper video frames? need linux command-line solution. edit: here code using: avimerge -i file.avi file2.avi -o result.avi mencoder -oac copy -ovc copy -o result.avi file1.avi file2.avi there tool in ubuntu repository called avidemux seems should need.

windows - Centralized development -

we developing asp.net applications in several windows xp (hyper-v on win 2008 r2) virtual machines, connect internet directly. we make centralized access point internet virtual machines. developers use browser (firefox/ie - http, https), outlook (smtp, pop, imap), ftp/sftp logs see users go on internet restrictions on websites (facebook, myspace, etc.) we setup 1 xp/vista machine used sort of gateway/proxy. any suggestions? only possible solution use wingate or squid proxy. took squid.

spring - How to repeat a cronExpression in a specific period of time? -

greetings have cronexpression want started on application startup , repeated every second, defining cronexpression via xml configuration follows: <bean id="mycrontrigger1" class="org.springframework.scheduling.quartz.crontriggerbean"> <property name="jobdetail" ref="myjob" /> <property name="cronexpression" > <value>${first.trigger.time}</value> </property> </bean> any please ? you can use simpletrigger more suited usage. from simpletrigger lesson : simpletrigger should meet scheduling needs if need have job execute once @ specific moment in time, or @ specific moment in time followed repeats @ specific interval. <bean id="simpletrigger" class="org.springframework.scheduling.quartz.simpletriggerbean"> <property name="jobdetail" ref="jobdetailbean" /> <property nam...

sql - adding a unique id and PK to existing tables -

i have few tables created in mssql 2005 server. due inexperience @ time, tables created without primary key or unqiquely identifying column. how can add column unique id (auto incrememnt?) table existing data (around 600k rows)? i need primary key can start using sql analysis services. many thanks, adam in t-sql: alter table table_name add id integer identity primary key not null but yaakov says, it's easy in ssms.

java - Access a class object from its inner class -

this method inside jframe object, how can pass jframe object argument method in inner class?? code is: comment explains interested do: public void runtime(){ actionlistener action = new actionlistener(){ public void actionperformed(actionevent e){ count++; text.settext(new integer(count).tostring()); while (count==2012){ //i want pass frame holds rather null, how possible? joptionpane.showmessagedialog(null, "helloend", "end of world", joptionpane.information_message, new imageicon("explode.jpg")); break; } } }; tr = new timer(1000,action); tr.start(); } hopefully, question wasn't answered before . anyway, try joptionpane.showmessagedialog(jframe.this, "helloend", "end of world", joptionpane.information_messa...