Posts

Showing posts from March, 2011

php - Determine whether current script is running on development or production server -

i've got scripts call different urls depending on if they're processed online site (release), or offline localhost (development). i'd find quick way find which. i can come few clunky ways this, there definitive, fast, elegant method? if(is_offline()) { ... } a variable called $_server["computername"] available on iis servers, can use determine if script running on development server or production server ( mymachine vs. www37 ). you can use $_server["http_host"] variable ( localhost vs. www.domain.com ). you can create empty text file on development server (careful not upload it) , use is_file() check if presence (is_file(".foo") == true vs. false ). you can check php_os if operating systems on 2 servers different ( winnt vs. linux ). you can check presence of path inside __file__ constant ( c:/inetpub/wwwroot/website/ vs. /home/www37/ ). a variant of 3: @include("override_server_with_local_config.php");...

select() always returns 1; TCP connected socket troubles in c++ -

i'm doing c++ project requires server create new thread handle connections each time accept() returns new socket descriptor. using select decide when connection attempt has taken place when client has sent data on newly created client socket (the 1 accept creates). 2 functions , 2 selects - 1 polling socket dedicated listening connections, 1 polling socket created when new connection successful. the behavior of first case expect - fd_isset returns true id of listening socket when connection requested, , false until next connection attempt. second case not work, though code same different fd_set , socket objects. i'm wondering if stems tcp socket? these sockets return true when polled select due streamy nature? //working snippet struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 500000; fd_set readfds; fd_zero(&readfds); fd_set(sid,&readfds); //start server loop for(;;){ //check if listening socket has client requrests, timeout @ 500 ms int numsockets = se...

c# - Why doesn't Enumerable.Cast<> use my conversion operator? -

using type: class foo { public static implicit operator int(foo obj) { return 5; } } var test=new[] { new foo() }; the following works expected var ok=test.select(x => (int)x).tolist(); but using cast<> fails invalidcastexception - why? var fail=test.cast<int>().tolist(); read jon skeet's blog reimplementing linq (edulinq), part 33 , says this: it's worth noting (as of .net 3.5 sp1) cast , oftype perform reference , unboxing conversions. won't convert boxed int long, or execute user-defined conversions. follow same rules converting object generic type parameter. (that's convenient implementation!)

javascript - keyboard scrolling on focused div in webkit -

i've got little jquery plugin. there images in vertically scrollable div. can click on div , scroll using arrow keys. if take @ example , can see want observe if arrow key right/left pressed , if so, jump next image. in firefox , ie, keyup() event being called, , in safari , chrome it's not. i have encountered several strange scrolling , focus behaviours in webkit browsers, don't know why keyup() event not being fired. if have idea, please let me know. just add tabindex attribute div -element , work. kind of hack make otherwise not focusable element focusable, input or button . depending on value given tabindex , behave diffrently: 0 allow focus element keyboard arrows , tab key -1 disable tabbing, still focusable anything greater 0 allow prioratize tab focusing, 1 has highest priority i've updated jsfiddle demo accordingly.

What's the equivalent of TEMPDATA in Webmatrix? -

fill form data proceed fields' validation if validation pass, go different. in aspnet nvc, can put data in tempdata["mykey"] , recover somewhere else. how can obtain same result in webmatrix? thanks helping there isn't direct equivalent. can use session instead.

DataBinding between DataSet and DataGridView in C# -

i have datagridview on form want use datatable in dataset, populated sqlite database (using system.data.sqlite). so, have dataadapter between database , dataset , can set datagridview data source directly datatable. displays fine. my question this: why want use binding source here? many tutorials have said can use or not. there use it, other adding step? also, if want database updated when datagridview changed, how can done? dataset automatically updated - need tell dataadapter update? or there binding source useful? thanks! afaik, have call getchanges on dataset , , insert/update/delete records.

css - Data-URI's and caching -

i read this on wikipedia: data uris not separately cached containing documents (e.g. css or html files) data downloaded every time containing documents redownloaded. does mean code downloaded every single time page refreshed or whenever user clicks on navigation link? can cache data-uri's? ps - i'm talking 20 or small png files (mostly silk icons 2 * 16kb files well) data uris nothing more text in form of base64-encoded binary data, that's embedded within html , css files. yes, downloaded part of html , css files every time they're requested, unless files cached. if keep data uris stylesheets , send proper cache headers, caching data: images css shouldn't pose issues.

data binding - WPF DataGrid RowHeader databinding -

i have datagrid, bound datatable. want display text in rowheader, achieve this: col0 col1 col2 col3 table | 1 | 3 | 5 | 6 | chair | 3 | 2 | 1 | 8 | is possible , if so, how can this? i tried both answers, , neither worked me. had mix them together. this works me: <datagrid name="ui_datagrid> <datagrid.rowheadertemplate> <datatemplate> <textblock text="{binding relativesource={relativesource mode=findancestor, ancestortype={x:type datagridrow}}, path=item.header}"/> </datatemplate> </datagrid.rowheadertemplate> </datagrid> the trick find ancestor datagridrow , bind textblock.text attribute item's property care about, in case header (easier said in xaml english maybe). then in .xaml.cs: ui_datagrid.itemssource = data...

javascript - Calling s.tl throws a TypeError -

i'm having problem omniture happens if set s.products akin s.products = ";101;;;;evar33=mystatus"; unfortunately when script later calls s.tl , crashes. error has following description in firefox: typeerror: tl not function when put in product usual, product s.tl works: s.products = ";101"; anyone knows why script may crash this? missing something? well you're going have provide more context. more code, link issue is, something. tried following test code: <a href='#' onclick="s_dlt(this);">click</a> <script language="javascript" type="text/javascript" src="omniture.js"></script> <script language="javascript" type="text/javascript"><!-- function s_dlt(that) { var s=s_gi(s_account); s.linktrackvars='products'; s.products = ";101;;;;evar33=mystatus"; s.tl(that,'d','some name'); } /...

href attribute in Jquery not being pulled correctly -

i using following code fade in clicked tab keeps fading in same tab regardless of list item click on: $('#productinfowrap .tab:first').show(); $('#subselect li').click(function() { var thistop = $(this).position().top; $('#subselect li').removeclass('current'); var li = (this); $('.pointer').animate( {'top': thistop}, function() { $(li).addclass('current'); }); var id = $("#subselect li a").attr('href'); $("#productinfowrap > div").fadeout(500).hide(); $(id).fadein(); return false; }); and html <ul id="subselect"> <li class=""><a href="#overview">overview</a><span class="pointer" style="top: 225px;"></span></li> <li class=""><a href="#applications...

Radio button in android -

Image
i have array of radio button creating radio buttons dynamically in layout. here want, when check 1 radio button other radio buttons should unchecked. how manipulate using radio button array? please body help! here image. radio buttons not unchecked automatically. put of radiobuttons inside radiogroup

performance - How Fast is Windows File System for Database Operations? -

i came across crazy thought , wanted share , ask feasibility, performance wise: the idea manage object database operations by: creating folder each class named after class name creating sub-folder each sub-class named after sub-class name creating file each object named after unique id creating sub-folder each index named after names of indexed fields creating shortcut file each index entry referring original object file reading/writing binary objects fast serializer/deserializer inserting/updating/deleting objects , index entries renaming object , shortcut files caching/paging using memory-mapped files querying utilize binary search on sorted file names update: thank replies. thinking can improved using compression/encryption library such 7z, instead of dealing os file system. otherwise, of stated concerns far valid. i'm wondering kind of underlying file system does, example, oracle uses cons: on filesystems, 1 byte file takes full block of 4kb. ca...

java - Mapping Composition in MyBatis -

i'm having trouble mapping in mybatis java , appreciate help. class structure below: //getters/setters omitted clarity class foo { int id; bar bar; } class bar { string x; int y; } my table looks - i.e. de-normalized class structure. create table foo_bar ( id int, x varchar, y int ); my working insert statement able de-normalize using (bar.x, bar.y) parameters. <insert id="insert" parametertype="foo"> <![cdata[ insert foo_bar (id, x, y) values (#{x}, #{bar.x}, #{bar.y}) ]]> </insert> so, problem: when execute select, resultant object instance of foo has reference bar. i don't think can use type handler since works on single column, , and association doesn't seem make sense since 'bar' not entity explicitly represented in database via foreign key relationship. can show me recommended way of doing please? thanks! have tried using resultmap definition in ibatis sqlm...

displaying hierarchical xml in asp.net - vb -

i've tried converting code c# vb it's not working , i'm not sure why. it's supposed render hierarchical xml. here's code... private sub page_load(sender object, e eventargs) dim doc new xmldocument() doc.load(server.mappath("~/myxml/getbooking.xml")) _rep1.datasource = doc.firstchild _rep1.databind() end sub and <asp:repeater id="_rep1" runat="server" enableviewstate="false"> <itemtemplate> publisher: <%# ctype(container.dataitem, xmlnode).attributes("name").value %><br/> <asp:repeater runat="server" enableviewstate="false" datasource='<%# container.dataitem %>' > <itemtemplate> author: <%# ctype(container.dataitem, xmlnode).attributes("name").value %><br/> <asp:repeater runat="server" enableviewstate="false" datasource='<%#...

Old jquery click handlers still being active after ID change -

i know subject not clear couldn't find better sentence. i building ajax form. can save form fields db via clicking save button , getting values db edit button . change #id of save button when edit button clicked. button still act save button change it's #id. here button: <a class="btn" id="save_post">save post</a> when click on edit button change form values , change #id of save post button; $('#save_post').attr('id','edit_save_post'); after all, firebug shows ok, #id changed. <a class="btn" id="edit_save_post">save post</a> but when click on button doesn't run update db, runs again save. how can have browser forgot old #id? thanks, you bound handlers using $('...').click(yourfunction); binds them matching elements @ moment. if adding/changing elements dynamically, use live events: $('...').live('click', yourfunction); upda...

Can my iPhone app register its own launch URL with a http schema, rather than a custom one? -

ive implemented feature in few apps without issue, have yet test whether handle custom web urls, youtube , googlemaps apps do. as im not @ mac thought id pose question useful other people. this question suggests possible, doesnt how without using 3rd party service: add custom url schema using http:// it may seem stupid question 1 of devs needs know , im not there help/test @ moment yes! here's nice tutorial on it: http://www.idev101.com/code/objective-c/custom_url_schemes.html

unit testing - Java: how to make sense out of cryptic stack traces? -

while trying run unit test, following stack trace. don't know start looking (read comment below). where should start , solve this? (note following stack trace how eclipse, without formatting or anything: countless lines of 120 chars each) [i pasted 5 lines apparently problem happens] caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'acceptancechain' defined in class path resource [.../chain/connector/...xml]: cannot resolve reference bean 'xxxcommand' while setting constructor argument key [0]; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'xxxcommand' defined in class path resource [.../bl/chain/connector/....xml]: cannot create inner bean 'yyydto#1d95da7' of type [yyylistdto] while setting bean property 'yyylistdto'; nested exception org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name ...

reflection - How to create a class dynamically in java -

i don't know if possible. anyway, here problem: want create class having database table schema, example suppose have table id - unsigned int username - varchar(128) password - varchar(128) and let's assume can query data db. want dynamically create (and, of course, instantiate) java class should this: public class user{ private unsigned int id; private string username; private string password; } (actually activerecord table) can me starting this? tnks what do dynamically created , instantiated class none of other code knows about? for stically typed language java, makes little sense have such classes. on other hand, or mappers hibernate come tools allow statically generate classes database schema.

iphone - Objective-C Novice. Change property in Controller from another Controller? -

so, first of i'm new posting in here. have been browsing stackoverflow ages , first time i'm asking question. the context: have 3 views. 1 introductory view, upload view , main view. classes (with respective headers) have rootviewcontroller (switchviewcontroller), introviewcontroller , uploadviewcontroller. first view shown introview. user presses button (declared in switchviewcontroller) takes them uploadview, in uploadview choose image , press button again go introview. the thing while user gets pick image uiimagepickercontroller button switch views won't hide nor uiimageview have logo on top of view(screen). uiimageview , uibutton both declared in switchviewcontroller's header. the code used: uploadviewcontroller.h #import [...] //imports @class switchviewcontroller; @interface uploadviewcontroller : uiviewcontroller <uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate,uiactionsheetdelegate> { uitextfield *imagetextfield; uii...

svn - TortoiseProc launch failed Error:The requested operation requires elevation -

i have installed tortoisesvn-1.6.12.20536-win32-svn-1.6.15 on windows 7 proffesional. tortoiseproc launch failed :the requested operation requires elevation. any option in context menu gives same error. already troubleshoot- - uninstall , install repair install checked exe's (including tortoiseproc) have "run administrator" option checked. start>run>cmd (enter)>[dos prompt]>c:>"ipconfig /flushdns" any ideas? checked exe's (including tortoiseproc) have "run administrator" option checked. that's problem: make sure option not checked! if allow tortoiseproc run normal user won't prompt.

Importing stored connections from Mysql Gui tools to Mysql Workbench -

i've been working mysql gui tools (for 5.0) @ work 2 years , have accumulated 100 stored connections. we're upgrading use mysql workbench 5.3 community edition , i'm looking way import, convert or other way make stored connections available in workbench. i've looked around ways found little, no topics or threads on how go this. only thing i've found stating xml used store connections both apps different , non-trivial convert hand. does know of tool, plugin or method stored connections gui tools workbench? by gui tools mean seperate programs query browser, administrator , system tray monitor.

information retrieval - Question Answering with Lucene -

for toy project, want implement automated question answering system lucene , i'm trying figure out reasonable way implement it. basic operation follows: 1) user enter question. 2) system identify keywords in question. 3) keywords searched in large knowledgebase , matching sentences shown answers. my knowledgebase (i.e., corpus) not structured. large, continuous text (say, user manual without chapters). mean structure sentences , paragraphs identified. i plan treat each sentence or paragraph separate document. present answer in context, may consider keeping 1 sentence/paragraph before/after indexed 1 payload. know if makes sense. also, i'm wondering if there other tried , well-known approaches kind of systems. example, approach comes mind index large chunks of corpus documents token positions, process vicinity of found keywords construct answers. i appreciate direct recommendations based on experience or intuition, tutorials or introductory materials question-ans...

asp.net mvc 2 - telerik grid and ajax -

i'm trying create page using asp.net mvc 2 shows 2 things: 1. upper half of page should show form 2. lower half should show results based on information form what tried using ajax.beginform , update lower half of page using updatetargetid. basically, worked. however, results contain telerik grid pageable. trouble starts. the grid shows fine, starts going wrong when try navigate through grids pages. plain (non-ajax) grid, uses links. if use variant of grid, trouble because links request new page, not contain information form , stack of errors. if turn on ajax, doesn't work either because won't work on partial view retrieved via ajax (script tags won't work in case). in case, json result object rendered plain text. if put on single page, can work well. reason, grid won't use ajax. on index-view use following code render grid: html.telerik().grid<foobarlistitem>() .name("foobar") .databinding(databinding => da...

ruby on rails - Can't get plain old many-to-one nested form to save -

i'm on rails 3. have model client has address_id . in client form, have nested address fields. here's address part of form: <%= f.fields_for @client.address |address_form| %> <div class="field"> <%= address_form.label :line1 %><br /> <%= address_form.text_field :line1 %> </div> <div class="field"> <%= address_form.label :line2 %><br /> <%= address_form.text_field :line2 %> </div> <div class="field"> <%= address_form.label :city %><br /> <%= address_form.text_field :city %> </div> <div class="field"> <%= address_form.label :state_id %><br /> <%= select("client[address]", "state_id", state.all.collect {|s| [ s.name, s.id ] }) %> </div> <div class="field"> <%= address_form.label ...

javascript - Check if element exists -

possible duplicates: is there “exists” function jquery jquery determining if element exists on page if(tr) returning true when tr not element, how check whether it's element exists? var tr = $('#parts-table .no-data').parent(); $('.delete', row).bind('click', function (e) { that.delete(e.currenttarget); }); console.log(tr); if (tr) //returns true when shouldn't check length property: if(tr.length) { // exists } if(tr) evaluates true because jquery object, or any javascript object matter, truthy.

asp.net - Asp .Net LINQ to SQL Databinding, do a "lookup" without a lookup table? -

say have employee table. each employee has unique id. 1 of columns in table managerid, corresponds employee. when binding employee's data gridview, want display manager's name, not id. if had lookup table mangers <%# eval("lu_managers.managername") %> , don't have such table, nor want make one/keep track of it/update everytime new manager added or removed. currently in onrowdatabound call e.row.cells[1].text = getfullnamefromemployeeid(convert.toint32(e.row.cells[1].text)); seems messy me. is there way without using codebehind? or less efficient have now? you need join employee table again manager select employee.*, manager.firstname managername tblemployee employee join tblemployee manager on employee.managerid = manager.pkemployeeid edit: can translated linq: var q = employee in db.tblemployee join manager in db.tblemployee on employee.managerid equals manager.pkemployeeid select new { employee = employee...

c++ - How to determine if an existing class can be unit-tested? -

recently, took ownership of c++ code. going maintain code, , add new features later on. know many people not worth adding unit-tests existing code, still add tests @ least partially cover code. in particular, add tests reproduce bugs fixed. some of classes constructed pretty complex state, can make more difficult unit-test. i willing refactor code make easier test. is there article recommend on guidelines identify classes easier unit-test? have advice of own? while martin fowler's book on refactoring treasure trove of information, why not take @ " working legacy code ." also, if you're going dealing classes there's ton of global variables or huge amounts of state transitions i'd put in lot of integration checks. separate out of code interacts code you're refactoring make sure expected inputs in order recieved continue produce same outputs. critical it's easy "fix" subtle bug might have been addressed somewhere else. t...

Determine if a XmlNode is empty or null in C#? -

the following code takes xmlnode data type , populates dataset object xmlnode content. write dataset's content file. public void populatedataset(xmlnode node) { xmlnodereader reader = new xmlnodereader(node); dataset ds = new dataset(); ds.readxml(reader); system.guid guid = system.guid.newguid(); string name = string.format("{0}{1}_{2}.xml", utility.xmloutputpath, utility.xmloutputfilename, guid.tostring()); //need write "node empty" file if xmlnode object empty of null ds.writexml(name, xmlwritemode.ignoreschema); } the problem encountered 1 scenario not write content file. how determine if xmlnode object null or empty? you can check if node parameter null or has innertext or innerxml properties null or empty, when enter method before creating xmlnodereader .

Android ImageView ScaleType *FIT_TOP* -

i trying implement imageview holds both landscape or portrait images. images should fit width of imageview (if landscape) or height (if portrait) in case must aligned top of view no margin or padding. what achieve android:scaletype="fitstart" centered in case of portrait images or aligned top in case of landscape images. added: now using such ugly code, seems work, not sure best solution: <com.custom.layout.myimageview android:id="@+id/detail_view_image" android:src="@drawable/logo" android:background="#fff" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerhorizontal="true" android:croptopadding="false" android:adjustviewbounds="false" /> and in class, extends imageview do: @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { ...

asp.net - Get the virtual url when using routing with webforms -

how virtual url , not webforms page name url mapped when using system.web.routing webforms. i want url "/confirm/5" , not "confirm.aspx". to routed url for page visiting , use request.url , pavel notes. if need routed url different page (such when creating hyperlink page), use page.getrouteurl method. here's code snippet showing use of page.getrouteurl . it's article, url routing in asp.net 4 : lnkcategory.navigateurl = page.getrouteurl("view category", new { categoryname = "beverages" }); in above snippet, "view category" name of routing rule want use. categoryname 1 of routing parameters , want use value "beverages". above call page.getrouteurl returns string "/categories/beverages". (of course, exact string returns depends on routing rule "view category" , parameter values, idea.)

Are there any profilers that run on the .NET Micro Framework? -

i have project runs on .net micro framework (or netmf) , looking profiler. far none of ones i've tried run on netmf. know of profiler will? a week no answers. you have tough problem, getting measurement data in small footprint world. my company, semantic designs provides profilers variety of languages including c# in number of variations. our (c#) timing profilers can handle multiple threads of execution require additional space per function call track data. unclear if need capability, , unclear have room capture it. our counting profilers require enough space track counts each basic block (stored in array) additional code space instrumentation. typically need counter slot every 4-5 lines of code have. best bet. you'll have build custom support machinery; in particular, in small embedded environments, our customers have build small bit of code exports count array content disk file. if can achieve that, can profiling data.

java - joda-time 1.6.2 jar not downloading from maven central repository -

i issue i'm trying bring in joda-time jar eclipse can't find it, reason. message get: 1/25/11 11:53:22 cst: missing artifact joda-time:joda-time:jar:1.6.2:compile here dependency: <dependency> <groupid>joda-time</groupid> <artifactid>joda-time</artifactid> <version>1.6.2</version> </dependency> however, can go http://repo1.maven.org/maven2/joda-time/joda-time/1.6.2/ , it's there. any ideas on why seems i'm unable retrieve it? if there's other information might seem pertinent, let me know , i'll include it. i've run other artifacts when .m2 repo gets munged. delete .m2/joda-time folder , try again. if doesn't work show repository list. think if generate effective pom, show complete list. if doesn't, show repositories section settings.xml, parent pom, , poms. also version of maven using? finally, if run tricky maven issues try solve @ command line using maven (pref...

c# - Right click, text capture -

i have c# application runs in bottom right corner of page, wondering how go making application appear when user selects text anywhere (say pdf, browser etc) , right clicks, goes custome selection bit , pastes text in running application. if made sense of advise me in need researching done. thanks i've got dictionary similar. here's mode of operation (or @ least think does) when there double click, sends key command (probably ctrl + c ) copy selected text. reads text clipboard. for purpose, implement mouse listening , sending keystrokes article found on codeproject: inputmanager library . you retrieve copied text clipboard , whatever want it.

Facebook Open Graph Search Filter -

i searching facebook users' posts keyword, fine, want filter posts according location, can filter out according gender how can apply location filter on it? have idea? https://graph.facebook.com/search?q=watermelon&type=post&access_token= ........... the location filter user search , "...&loc=12345678...." based on tests, not possible.

java - getting JSON response from webpage -

i don't know lot area please excuse me if question vague or stupid. i have webpage uses javascript , ajax display live data. every few seconds, request made , json response returned , data on webpage updated. what want create program in java capture every response , interpret data. have found libraries handle json format already. however, don't know how response using java. so example, live news feed. log data appears. thanks basically need make http get request page hosts json. can using java http client . 1 in link apache commons believe there 1 built java relatively straight-forward use. when make request, return result object can use access response data , information such response headers, etc.

java - How do i use a MaskFormatter on a JFormattedTextField without knowing the length of the string? -

so have jformattedtextfield , need restrict user entering letters , hyphens. i'm not quite sure how use maskformatter without explicitly knowing length of string entered. my code looks this: maskformatter formatter = new maskformatter(); formatter.setvalidcharacters("abcdefghijklmnopqrstuvwxyzabscedfghijklmnopqrstuvwxyz-"); jformattedtextfield firstnametextfield = new jformattedtextfield(formatter); when call firstnametextfield.settext(getname()) , text not set, leaving me unusable, empty text field. any appreciated. thanks. since want no commitment in terms of string length, have impression, lot easier achieve effect of jformattedtextfield , maskformatter, if use regular jtextfield , keylistener keyadapter. can check each keystroke against allowed character string , either accept character or beep.

Can we play audio and video files using Applet? -

i need develop webpage plays both audio , video files. , need change controls using arrows up, down, left , right buttons manage audio or video. regards, serenity. if these audio , video files of formats strictly controlled you, there ways achieve in java. otherwise java not choice of language loading , using wide variety of media types. for example, javax.sound.sampled package covers things au, wav & snd. uses service provider interface supporting other formats can provide decoder/encoder. e.g. support mp3s (decoding only) can added using mp3plugin.jar of java media framework (jmf). and having mentioned jmf brings video. jmf can load , play types of mov, avi , mpeg files, but not types. e.g. have 2 kodak cameras can record movs, older 1 produces mov files compatible jmf, newer movs aren't. jmf 'abandon-ware' quite api in it's day - lags today because of lack of support more modern codecs (encoding/file types) - , web-cam resolutions. ...

forms - Rails How to easy show hide user fields? -

i want easy implement show hide funktion on sertant fields. birthday or email user. example if user has chosen hide email wont display in profile. how create this? best regards, a rails (3) beginner one option creating model store user preferences in keep track of user wants show/hide. option use 1 of gems out there accomplish task. looking on github, came across https://github.com/pluginaweek/preferences .

python - avoid having to scroll in GTK popup menu -

i working on gnome panel applet displays pop-up menu on clicking it's icon. problem is, lots of entries, menu not pop first items visible, somewhere in middle. makes necessary scroll see top item (a sub-menu) , first ones under it. these data, not "menu" choices in usual sense. can suggest fix, other showing fewer items? on linux. thanks! would work...? menu.set_active(0)

php - Submit form Store Response -

i have form lies on server not have control of. lets call form1. know post requirements of form1. creating own form submit data form1. lets call 1 form2. form1 returns ticket number, need store ticket number department database, along other information (that part ok with). need form2(my form) submit data form1(its form) , store response form1 our department database. what easiest way this? have searched online hours, , have come empty. went javascript iframe ajax jquery. , lost now. my server php server, theirs asp server. thanks in advance. this not client-side operation, server side operation. there no need "form2". want use curl this. this: // set connection target of form1 (this "action" attribute of form1) $curl_connection = curl_init('http://hostname.com/form1.asp'); // set options -- connection timout, store string, follow redirects curl_setopt($curl_connection, curlopt_connecttimeout, 30); curl_setopt($curl_connection, ...

syntax - Why can you omit the surrounding parentheses for generators in Python when passing it into a function? -

i experimenting in python different syntax passing in generator argument function, , realized although i've been doing this, >>> sum((j j in xrange(5))) 10 this works well: >>> sum(j j in xrange(5)) 10 this tested on python 2.6.6 on linux. what's going on under hood? syntactic sugar? after all, unwrapped generator indecipherable interpreter: >>> j j in xrange(5) file "<stdin>", line 1 j j in xrange(5) ^ syntaxerror: invalid syntax i'm sure reading python grammar answer question. if prefer plain english on grammars: pep-289 explains it.

api - Should changing the documented performance of a method be considered a breaking change? -

it seems common rule in software development once have deployed public api, especially if you've documented api (which—yeah, should have), must think long , hard before making changes break backwards compatibility api such changes breaking changes . in fact i'm sure many developers argue flat-out should not @ all, regardless of how long , hard may think it. occasionally developer document performance of method. lot of msdn docs this, example, using big o notation . changing also constitute "breaking" change? maybe that's not clear question; put way: should avoided? it seems me in cases where, e.g., might have developed superior algorithm solve problem, if had documented algorithm o(n 2 ) might forgiven improving api replacing superior algorithm is, say, o(log n). users of api might notice , would, imagine, feel glad improvement. on other hand wonder whether ever considered "excusable" worsen performance of component of api other reasons—e....

mysql query problem WHERE date < -

Image
i have following query select *, count(jx_commissions.commission_amount) summe jx_members inner join jx_commissions on jx_commissions.mid = jx_members.mid jx_commissions.date > '2011-01-01' group jx_commissions.mid order summe desc limit 1, 20 field date have date format , dates have right format y-m-d but if use query not results... if change date nother one, wrong results... think compare string... how can search date?? if jx_commissions.date date field can conditional jx_commissions.date > date('2011-01-01')

flex - Enable Icons ADL -

i can't seem work out how enable icons in air debug launcher. seems work on linux, when run on windows or mac adobe air icon shows. have specified location of icon in <icon></icon> in application descriptor file. those icons created file references in application descriptor file when application installs won't able see them during development. there solution available on christian cantrell's adobe blog works around though instructions february 2008. may or may not work latest flex sdk or flex/flash builder ide. fortunately, i’ve found easy way make work. here’s do: make copy of application icon , name different. 1 version should referenced application descriptor file, , other compiled application. (you don’t technically have make copy of icon, when generating release build of application, flex builder doesn’t copy on embedded resources means application icon missing. trust me when tell it’s easier create copy , avoid whole issue.) ...

How can I monitor my iPhone's charging status while plugged into my PC? -

i'm working on program monitors iphone's charging statues while plugged pc. how can in either vb, bat or c++? you can set following on timer (in objc): -(nsstring *)getbatterypercent { cftyperef blob = iopscopypowersourcesinfo(); cfarrayref sources = iopscopypowersourceslist(blob); cfdictionaryref psource = null; const void *psvalue; int i; int curcapacity = 0; int maxcapacity = 0; int percent = 0; int numofsources = cfarraygetcount(sources); //if (numofsources == 0) return 1; (i = 0 ; < numofsources ; i++) { psource = iopsgetpowersourcedescription(blob, cfarraygetvalueatindex(sources, i)); psvalue = (cfstringref)cfdictionarygetvalue(psource, cfstr(kiopsnamekey)); psvalue = cfdictionarygetvalue(psource, cfstr(kiopscurrentcapacitykey)); cfnumbergetvalue((cfnumberref)psvalue, kcfnumbersint32type, &curcapacity); psvalue = cfdictionarygetvalue(psource, cfstr(kiopsmax...

iphone - Retrieve values from UITextFields inside custom UITableViewCell -

i swear i've searched entire google database possible solution i'm still stuck on issue :) basically, have 12 rows in database table generate custom uitableviewcell 4 uitextfields inside. table columns (sqlite) entryfieldid number description text fieldtype text now want each uitableviewcell tag entryfieldid above can refer later storing in table. table looks this. orderid number entryfieldid number value1 text value2 text value3 text value4 text the 4 value* fields 4 uitextfields inside each uiviewcell . hopefully makes sense far :) now inside tableviewsource have code: protected list<infocapturetableviewgroup> _tableitems; protected string _customcellidentifier = "infocapturefield"; protected dictionary<int, infocapturetableviewcell> _cellcontrollers = new dictionary<int, infocapturetableviewcell>(); public infocapturetablesource (list<infocapturetableviewgroup> items) { this._tabl...

delphi - Detect what window was active just before my app activates -

in delphi xe, i'm trying use getforegroundwindow detect window active before application activated. "activated" means app may have been restored iconic state, or switched via alt+tab, or brought activaton hotkey, etc. the problem available application events (onactivate, onrestore) come late, getforegroundwindow returns own form's handle. main form's events less useful. processing wm_activateapp in main form happens late, too. one way keep checking active window on timer while application not active, seems rather wasteful. better solution subclass tapplication.wndproc , thing before wm_activateapp processed, don't think tapplication can subclassed. is there better way? when application activates, becomes topmost window. iow, jumps top z-order position. with this, previous topmost window demoted "just below new topmost window" position. iow, becomes second in z-order position. calling getnextwindow , passing handle of form , gw...

winapi - ULIB.dll -- Any API documentation? How do you use it? -

a little peeking @ disassembly of tree.com (the command shows directory tree given folder) shows functionality lies in ulib.dll , same file system library used chkdsk.exe . which pretty funny, considering enumerating directory tree should pretty straightforward findfirstfile , findnextfile ... so here come 2 questions: why tree.com use ulib.dll (seemingly) trivial? why not use standard traversal methods? is there any documentation whatsoever (official or unofficial) on api of library? thing i've found this api listing, there more? because has version of findfirstfile declared as: void* __stdcall findfirstfilew(class path const *, struct _win32_find_dataw *) why use c api when you've got nice c++ implementation lying around. internal microsoft library, not documented.

objective c - Help with setTitle on iOS -

i rookie programming. have entered in following code , app runs without bugs crashes when button pressed. goal identify if button pressed once or twice. if pressed third time, should reset never being pressed. buttontestviewcontroller.h #import <uikit/uikit.h> @interface buttontestviewcontroller : uiviewcontroller { } -(ibaction)pressbutton:(id)sender; @end buttontestviewcontroller.m @implementation buttontestviewcontroller -(ibaction)pressbutton:(id)sender{ static int counter; if (counter == 0) { [sender settitle:@"not answered"]; }else if (counter == 1) { [sender settitle:@"pressed once"]; }else if (counter == 2) { [sender settitle:@"pressed twice"]; } counter += 1; if (counter > 2) { counter = 0; } } - (void)dealloc { [super dealloc]; } @end i change background color of button when pressed , continue errors if use setbackgroundcolor. thank in advance time , consideration. you need initialize co...

respond to hyperlinks in Three20 TTStyledTextLabel iphone -

im using of three20 source code show hyperlinks text twitter, far i've managed map "*" urls class ttwebviewcontroller using. [map from:@"*" toviewcontroller:[ttwebcontroller class]]; but want able return previous view (where twitter feed being shown), done in tttwitter sample project don't understand how done, seems obscure me , haven't find in documentation. i don't understand why map every class url, , how navigator knows how initiate , manage different classes, example in case never have control on ttwebcontroller, because have wrapper class intantiates webcontroller , place inside uinavigationcontroller wouldn't know twitter url need load; any pointers appreciated, if knows three20 tutorial great. when using ttnavigator should create our view controllers using ttnavigator.and should map our view controller url schemes. when ttnavigator called first time in app (in case through ttstyledlabel) creates base navigation cont...

facebook javascript api get user email -

i trying fetch facebook user email app. when query email address returned null. forums suggest user should grant email permission app. how make user grant permission or ask him fields give access application. able name not email code below. fb.api( { method: 'fql.query', query: 'select name, email user uid='+fb.getsession().uid }, function(response) { alert(response[0].name); } ); its prettry simple dear take permission @ time of login. <fb:login-button perms="email" autologoutlink="true"></fb:login-button> and take other permissions in perms comma seperated values. hope help

Most efficient way to parse delimited into html table c# -

i've got following delimited string pairs: 1,5|2,5|3,5 i want create table follows: < table> < tr>< td>1< /td>< td>5< /td>< /tr> < tr>< td>2< /td>< td>5< /td>< /tr> < tr>< td>3< /td>< td>5< /td>< /tr> < /table> what's efficient way in c#? version 1: straight-forward string html = "<table>"; array.foreach<string>("1,5|2,5|3,5".split('|'),r => { html += "<tr>"; array.foreach(r.split(','),c => { html += string.format("<td>{0}</td>", c); }); html += "</tr>"; }); html += "</table>"; untested, of sort? take back, battle tested , working. version two, less delegate: string html = "<table>"; foreach (string r in "1,5|2,5|3,5".split('|'))...

java - Dozer: map single field to Set -

how map single field set in dozer? i have class like: class foodto { private iddto bar; private iddto baz; } class foodomainobject { private list<id> ids; } i'd map bar , baz ids list, can't this. i found on dozer support list: http://sourceforge.net/projects/dozer/forums/forum/452530/topic/1557144 basically, use syntax: <field> <a>bar</a> <b>ids[0]</b> <b-hint>org.foo.id</b-hint> </field> <field> <a>baz</a> <b>ids[1]</b> <b-hint>org.foo.id</b-hint> </field>

java - Servlet : What exactly the use of context.getRealPath(" "); -

as know returns application path? use of it. in many environments application user not allowed read files outside of deployment directory. done security purposes - example if hacks application won't able read passwords file. and in professionally managed environments developers don't have in directory application placed. so if need read file properties, images, certificates, etc. can place in application directory (or .war file) , use getrealpath("") path need load. as alternative can place external files on classpath there issues this. large files app servers try load entire file memory , cache if on classpath.

Reading Configuration xml files in C++ -

how can following configuration file read in c++. there support in stl. can't afford use other 3rd party libraries. <?xml version="1.0" encoding="utf-8"?> <appsettings> <add key="filetype" value="doc"/> <add key="filelength" value="102234"/> </appsettings> i not using managed c++. stl has no support parsing xml. if you're determined not use third party library other option write parser hand, seems pretty bad idea. why can't afford use third party libraries?

html - Data Protocol URl -

what reliable way use data uris images? know ie6/7 don't support them, work? i use data uris images default if browser ie6/7 shows image (not data actual image) using javascript include image (not data) in <noscript> . my question is: image fetched in <noscript> if browser supports javascript , data uris? if want go down road (and not bother), could it... // parse user agent , figure out if browser supports data // uris - e.g. `supportdatauri()`. also, store image path // somewhere - i'll assume convenience attribute called `data-image-src` if ( ! supportdatauri()) { var images = document.getelementsbytagname('img'); (var = 0, imageslength = images.length; < imageslength; i++) { var imgsrc = images[i].getattribute('data-image-src'); images[i].src = imgsrc; } }

javascript - KILL THE timed delay function "setTimeout redirecting to page" IF SOME UI elements are clicked -

hy question how kill onload redirection. i'v got between page opening, that's set 10 sec delay before going destination: var strurl = /*from query string, or somewhere else..*/ window.onload = function() { window.settimeout('redirect(strurl)', 10000); } function redirect(strurl) { document.location=strurl; } now in html body i'v got ui elements, 2 buttons (continue, bookmark), 1 checkbox (don't show anymore,..) something like: <body onorientationchange="smartorientation();"> <div id="img_logo"> <img src="#"> </div> <div id="txt"> <p> ...blabla... </p> </div> <div id="btn_bookmark"> <a href="" class="button green" name="name" type="submit" value="bookmark">bookmark </a> </div> <!-- check...

c# - Is it possible to have a compile time check that a type is marked with the Serializable attribute -

specifically we're making our application compatible out of process session state server types saved in session must serializable. is there way see @ compile time type put httpsessionstate marked serializable attribute. along lines of 'non-valid' code public static void put<t>( string key, t value ) t : ismarkedwitheserializableattribute { httpcontext.current.session[key] = value; } you write custom fxcop rule generate warnings scenario. jason block has sample rule on his site .

math - Jquery: how to produce 1 of 3 phrases when event happens -

i have bookmarking feature on site, when person clicks paragraph, box hovering on paragraph reads "bookmark this" inserts "sweet man" in place of "bookmark this". 'bookmark this' disappears , "sweet man" takes place, how make when click on paragraph, places 1 of 3 random phrases in there, lets 3 phrases "success", "sweet man", , "awesome". here's little bit of code show random phrase placed. $('p').click(function (e) { var offset = $(this).offset(); var top = offset.top if ($('#placebookmark').hasclass('placing')) { $('#placebookmark').trigger('click') $('#bookmark').css({left: offset.left - 30, top: top}).show(); $('#bookmarkthis').html('***sweet man.***').delay(1000).fadeout(400, function(){ $(this).html('bookmark this') }) } }); see in code says "sweet man.", ...

wpfdatagrid - WPF Toolkit Datagrid Copying Grid -

i'm using datagrid wpf toolkit 3.5. i have need textwrap 1 of columns in grid have embedded textblock in column. the issue have when copy grids content excel (ctrl a, ctrl c) column blank. any on resolving appreciated. below xaml grid. <tk:datagrid name="dgdatagrid" margin="3" autogeneratecolumns="false" headersvisibility="all" clipboardcopymode="includeheader" snapstodevicepixels="true" canuseraddrows="false" canuserdeleterows="false" isreadonly="true" selectionmode="extended" selectionunit="cell"> <tk:datagrid.columns> <tk:datagridtextcolumn binding="{binding id}" header="message id" visibility="hidden" fontweight="black" /> <tk:datagridtextcolumn binding="{binding userinitials}" header="user" w...

asp.net - How can i Access a control into a class? -

i have gridview in page.aspx. gridview want pass parameter constructor of class1.cs.can tel me, how can done? so you've got page gridview: <asp:gridview runat="server" id="gv1" autogeneratecolumns="true"> </asp:gridview> <div> count of rows of gridview displayed: <p> <strong><asp:label runat="server" id="lcount" /></strong> </p> </div> and, in codebehind populate this: this.gv1.datasource = fullname.getdemocollection(); //just returns list<string>; gv1.databind(); and have class gridviewrowcounter gridview, e.g. counts rows: public class gridviewrowcounter { private system.web.ui.webcontrols.gridview _gv; public gridviewrowcounter(){} public gridviewrowcounter(system.web.ui.webcontrols.gridview _gv){ this._gv = _gv; } public int getrowcount(){ return _gv.rows.count; } } so, pass grid...

javascript - complex jquery selector : challenge -

i've searched among jquery selectors time now, can't find solution problem. i've got html table filed foreach . on each line, several links pop tooltips. problem : can't find right selector. <table> <?php foreach($article) :?> <tr> <td> <div class="none" style="display:none;"> <div class="tooltip_1"> "the content of tooltip_1" </div> <div class="tooltip_2"> "the content of tooltip_2" </div> </div> <div class="cell"> <a href="#" class="link_to_tooltip_1">a link</a> <a href="#" class="link_to_tooltip_2">a link</a> </div> </td> <tr> <?...

.net - Find old messages in MSMQ -

i scenario there 2 queues. "error" , "myqueue". the messages dumped myqueue , processed there. if fail moved error queue. administration might move message myqueue processing again. my task if scan/peek 2 queue find , count messages has been cycling around more 1 hour. it seems message.senttime message.arrivedtime are both useless, since updated each time message enters queue. on solution place timestamp in body of message, require me open messages determine if message "old". any better alternatives? the problem is not same message cycling round queues. "moving" message deleting original , creating new 1 based on original contents, why can't use sent , arrived times. do moved messages have new unique messageid values each time? if not maybe generate table matching messageid time created. cheers john breakwell

Websphere AS 7.0 login -

Image
all, using websphere 7.0 along rad 7.5. when try use admin console in rad ( http://localhost:9061/ibm/console ) and different browser (ie/firefox), following 2 options: option 1: log out other user same user id. can recover changes made during other user's session. option 2: return login page , enter different user id i wanted know if there setting in was7 can tweak can access console in rad , different browser (on local system remote)? thanks. websphere console doesn't allow login same user more once, have log out on other machine before can log in. alternatively, darioo suggested, create new user required rights/role regards babajide (aka prince)

scala - Which JSON serialization library would fit to the following case? -

i've got following case: i'd serialize scala case classes extend parent class var of type java.util.uuid. serialization of case classes should happen without configuration of them - no annotations , definition of custom formats. serialization hints may situated in parent class. i tried sjson, reflection based serialization can't serialize uuid types , type based serialization forces me define formats every case class. json serialization library best fit case? here's 1 solution lift json . import java.util.uuid import net.liftweb.json._ import net.liftweb.json.jsonast._ import net.liftweb.json.jsondsl._ import net.liftweb.json.serialization._ sealed abstract class parent { def uuid: uuid } case class foo(uuid: uuid, name: string) extends parent object uuidtest extends application { implicit val formats = serialization.formats(notypehints) + new uuidserializer val f = foo(uuid.randomuuid, "foo") val ser = write(f) println(ser) va...

python: ftp get directory creation date -

i want connect ftp server directorys "01-26-2011" created on daily basis (no specific pattern, "jan2011-26" possible directory name). inside directory again directories. want write script checks every 10 minutes if new directory created. question is: how can get/read ftp directory creation date? best way (efficient way) check them? if have 1000 directories on ftp root (i mean: jan2011-26, jan2011-25, jan2011-24, jan2011-23, jan2011-22 , on...) bad check every single folder (i don't want that). it's fine if script checks last 5 directories (so jan2011-26, jan2011-25, jan2011-24, jan2011-23, jan2011-22), has check if new directory created in these 5 folders. how can that? thanks! depending on details need, can use ftplib list directories listing. save them list , compare in 10 min 2 sorted lists. can digg deeper , search in ftplib attributes. don't know ftplib, here solution.

Drupal 7 Theming individual pages -

i'm starting drupal 7 site , have noticed every page require separate layout. in order style individual node name template mode-nid-page.tpl.php or there more it? i think need add gallery widgets, etc.. think that's separate matter. involve displaying fields in above template? first off: don't think it's idea theme pages based on nid. that aside, here 2 possibilities how can achieve this: theme normal node template, include logic there. example include specific template files based on nid. not clean separation of course, such code should not go templates. cleaner separation attach custom field pages holds template file used themeing. as want create individual styles different nids assume number of not exorbitantly large. in case, create separate content types. each of nids should converted node of content type , of course each content type can have own theme template then. downside of second approach there might work involved if have lot of set...