Posts

Showing posts from April, 2015

changing selenium domain/subdomain within cucumber scenarios -

so, have rails webapp utilizes subdomains separating admin functionality public functionality using subdomain-fu. there functionality(that want test!) contained within 2 urls(eg admin.example.com , www.example.com ). want scenarios run against admin domain, , against www domain. my problem cant figure out how change domain selenium uses @ time after startup. can put in env.rb: webrat.configure |config| config.mode = :selenium config.application_address = "admin.example.com" end and work, scenarios need admin domain. if try like: host! "www.example.com" inside steps, seems ignored selenium, goes on using "admin.example.com" any ideas? or if not possible, ideas workaround? i haven't got working using webrat cabybara following works me. given /^i visit subdomain "(.+)"$/ |sub| # host! "#{sub}.example.com" #for webrat capybara.default_host = "#{sub}.example.com" #for rack::test capybara.a...

php - YouTube API, jQuery attr won't swap element attributes -

javascript (jquery) function display_youtube(new_url) { $('#movie_url').removeattr('value'); $('#embed_url').removeattr('src'); $(document).ready(function() { $('#movie_url').attr('value', new_url); $('#embed_url').attr('src', new_url); $('#shade').css('display', 'block'); $('#youtube_player').css('display', 'block'); $('#exit_youtube').css('display', 'block'); }); } html <object width="720" height="480"> <param id="movie_url" name="movie" value="http://www.youtube.com/v/_eatocsn7yu?f=user_uploads&app=youtube_gdata&autoplay=0" /> <param name="allowfullscreen" value="true" /> <param name="allowscriptaccess" value="always" /> <embed id="embed_url" src=...

http - Open a new tab in a browser with the response to an ASP request -

it's bit complicated one... lets have listing of pdf files displayed in user's browser. each filename link pointing not file, asp page, say <--a href="viewfile.asp?file=somefile.pdf">somefile.pdf</a> i want viewfile.asp fetch file (i've done bit ok) want file loaded browser if user had opened pdf file directly. , want open in new tab or browser window. here's (simplified) viewfile.asp : <% var fileid = request.querystring ("file") ; var responsebody = mygetrequest (someurl + fileid) ; if (myhttpresult == 200) { if (extractfileext (fileid).tolowercase = "pdf") { ?????? // return file contents in new browser tab } .... %> as daniel points out can control whether open in new window not new tab. if user has configured browser new windows should open in new tabs (like do) you're golden. if not open in new window. can't control tabs.

typography - Text highlighting (label effect) using CSS -

Image
i want create text style similar label. looky here: i can using just: http://jsfiddle.net/stape/ p{display: inline; background: yellow;} but, want add padding. when do, things go downhill. same happens if add border: http://jsfiddle.net/jn72d/ any ideas on simple way achieve effect? i able achieve modifying dom structure bit: http://jsfiddle.net/zp2cm/2/

ruby on rails - Active record model with remote data storage -

i want implement model "contact", data not stored in database, remotely. operations on data done via web service. model contact related other models, data stored locally. is there plugin/gem can take care of this? regards, pankaj no plugin or gem needed. see activeresource .

jquery - JavaScript: Keeping track of eventListeners on DOM elements -

what best way keep track of eventlistener function s on dom elements? should add property element references function this: var elem = document.getelementsbytagname( 'p' )[0]; function clickfn(){}; elem.listeners = { click: [clickfn, function(){}] }; elem.addeventlistener( 'click', function(e){ clickfn(e); }, false ); or should store in own variable in code below: var elem = document.getelementsbytagname( 'p' )[0]; function clickfn(){}; // using window sake of brevity, otherwise wouldn't =d // dom elements , listeners referenced here in paired array window.listeners = [elem, { click: [clickfn, function(){}] }]; elem.addeventlistener( 'click', function(e){ clickfn(e); }, false ); obviously second method less obtrusive, seems intensive iterating through possibilities. which best way , why? there better way? as other answers have mentioned, since tagged question jquery, doesn't make sense you're trying add , track events...

lotus notes - Assign a datetime array to a multivalue date field on the Domino form -

i accessing document view, read datetime field, figure out number of days between 2 date/time values fall 4 categories. in each category there loop add number of datetime values array of variant. array entries between 7 , 35. after loop assign array values date time field on form , save document. have used notes item follow: dim nitem notesitem set nitem = doc.replaceitemvalue("datefield", dtarray) it didn't work. used doc.replaceitemvalue "datefield, dtarray 1 didn't work either. field blank after agent runs. declared variable , assigned array variable assigned variable field on form: dim var1 variant var1 = dtarray doc.datefield = var1 still no luck see array values assigned field in document here main loop redim datearray(0) i=0 numberofdays -1 set notesitem = dtitem.datetimevalue call notesitem.adjustday(i) set datearray(i) = notesitem redim preserve datearray(i+1) next doc.replaceitemvalue "datefield", date...

popup - How do I change the window that appears when I insert my pen drive? -

basically has said has been said in title. how make window other default 1 pop when insert pen drive pc? can come program in usb well? not doing actual coding yet. btw- if default window al options has special name plz tell me. can word google searches better. appreciated. thx if default window al options has special name plz tell me ‘autoplay’. can come program in usb well? no. ‘autorun’ program on usb device come 1 option on autoplay window. user must select run it. it used autorun programs executed automatically under default settings. was, obviously, total security disaster. after years of flash-drive viruses disabled in vista, leading current option-in-autoplay situation.

c# - Find window with specific text for a Process -

i'm trying find if window specific has been open process. process spawns multiple windows, , need check them all. i have no trouble finding process, with foreach (process p in process.getprocesses()) { if (p.mainmodule.filename.tolower().endswith("foo.exe")) findchildwindowwithtext(p); //do work the problem next. cannot use process' mainwindowtext , because changes whichever window activated. then i've tried use windows function enumchildwindows , getwindowtext , not sure if i'm passing correct handle enumchildwindows. enumchildwindows works expected when passed mainwindowhandle, of course mainwindowhandle changes active window. passed process.handle , different handles , different results when switching app's windows. (i understand enumchildwindows returns handles not windows , controls in .net speak, that's no problem if caption of window too) maybe doing wrong way , need different approach - again, problem simple finding wind...

ruby on rails - Activerecord conditions and named scope - undefined method `created_at' -

subscriber has_and_belongs_to_many :skills. skill has_many :positions in subscriber.rb: scope :notify_today, includes(:skills => :positions). where("positions.created_at > ? , positions.created_at > ?", 1.day.ago, self.created_at) basically want find subscribers have positions 1) created 1.day.ago , 2) created after subscriber the error occurs because class of self here class , not subscriber , wanted. as solution, can make lamda , pass in parameter created_at : (i presume scope working otherwise, because have not tested your scope code specifically) scope :notify_today, lambda { |created_at| includes(:skills => :positions). where("positions.created_at > ? , positions.created_at > ?", 1.day.ago, created_at) } and use it: @subscribers = notify_today(time.now)

java - display stream of images without refreshing the webpage to give user a video like experience -

i have series of images generated @ servlet. want show images on jsp page. want show images in way jsp page not refreshed image gets refreshed , replaced new one. thought of doing of applet or ajax. still looking convenient way of doing it. can suggest way of doing it? appreciated. thanks in advance. i'd go javascript if you. should pretty simple have list of images , set timer change source of image tag every second (or whatever). don't need "real" ajax that... changing attributes in dom. admittedly may not great if images take while load - might want have cunning mechanism load all images beforehand, , change 1 visible @ 1 time, or that. still shouldn't need ajax or applet though. i'm not sure i'd describe "video-like" experience - more slide-show - should okay. if want real video, use video :)

android - How to not get my alarm on its own way? -

i'm using alarm manager trigger intentservice every hour. however, alarm gets registered when user runs app. problem when user opens app again makes manager create new service run , if current service running trip on each other because of database connection , dies! another problem alarm service stops. why? thought alarm should go on every hour no matter what! at beginning check existing database . if doesn't exist. make database , start alarm. next time app start if found database not start alarm again. or use saved value use semaphores check value 0 or 1.. rest functionality of alarm manager supposed work

c# - W3C, Google Gears and Loki Geolocation based on what? -

i understand these client-side apps, 3 must based on component of computer itself. which component this, , how can utilize programmatically c# app (not web)? they're client-side, , use different sources location information. w3c api in firefox uses google location services (a json api) , bet google gears uses google database well, while loki uses skyhook wireless service. , different browsers implement w3c api can use different location services. mobile safari uses skyhook, or gps info device itself. you @ of these providers accessing location through desktop app. google location services appears particularly simple web api, think can programmatic access skyhook. since you're writing in c#, might windows 7 location platform, provides easy-to-use os-level framework abstracts away different providers. (sorry typos , lack of links; answer posted tablet.)

c - Overflow in bit fields -

can trust c compiler modulo 2^n each time access bit field? or there compiler/optimisation code 1 below not print out overflow? struct { uint8_t foo:2; } g; g.foo = 3; g.foo++; if(g.foo == 0) { printf("overflow\n"); } thanks in advance, florian yes, can trust c compiler right thing here, long bit field declared unsigned type, have uint8_t . c99 standard §6.2.6.1/3: values stored in unsigned bit-fields , objects of type unsigned char shall represented using pure binary notation. 40) from §6.7.2.1/9: a bit-field interpreted signed or unsigned integer type consisting of specified number of bits. 104) if value 0 or 1 stored nonzero-width bit-field of type _bool , value of bit-field shall compare equal value stored. and §6.2.5/9 (emphasis mine): the range of nonnegative values of signed integer type subrange of corresponding unsigned integer type, , representation of same value in each type same. 31) a computation involving unsigned o...

python - Access files from web.py urls -

i'm using web.py small project , have files want user able access in /files directory on server. can't seem find how return file on request can't work how this. exactly want is: urls = ('/files/+', 'files') class files: def get(self) #return file is there simple way return file request? playing around came webpy method: def get(self): request = web.input( path=none ) getpath = request.path if os.path.exists( getpath ): getfile = file( getpath, 'rb' ) web.header('content-type','application/octet-stream') web.header('content-transfer-encoding','base64') return base64.standard_b64encode( getfile.read( ) ) else: raise web.notfound( ) other respondants correct when advise consider security implications. in case include code administrative web service (should be!) available within our internal lan.

Question about defining grammars -

i studying grammars , bit confused how design grammars 1 value dependent on another. for example, want define grammar produces following 3 sentences: i + = ii : base case iiii + ii = iiiiii (thats 4 i's + 2 i's equals 6 i's) iii + = iiii (3 i's + 1 equals 4 i's) how go this? part confuses me if first 'value' iiii second can 'ii' , not 'i' or 'iii'. thanks in advance! grammars trivial if language finite: s → "i + = ii" s → "iiii + ii = iiiiii" s → "iii + = iiii"

c# - Pass parameters to a user control - asp.net -

i have user control: <user:ratingstars runat="server" product="<%= getproductid() %>" category="<%= getcategoryid() %>"></user:ratingstars> you can see fill in product , category calling 2 methods: public string getproductid() { return productid.tostring(); } public string getcategoryid() { return categoryid.tostring(); } i not understand why, in user control, when take data received (product , category) gives me "<%= getproductid() %>" instead of giving id received method... any kindly appreciated... edit : solved with: product='<%# getproductid() %>' last problem : in user control have this: public string productid; public string product { { return productid; } set { productid = value; } } so, expect productid set ok in user control. unfortunately null when try use it... is there wrote that's incorrect? so compile-...

database - representing play in relational db -

i run project deals plays, shakespeare. right now, storage, parse them out json array formatted this: [0: {"title": "hamlet", "author": ["shakespeare", "william"], "noacts": 5}, | info 1: [null, ["scene 1 setting", "stage direction", ["character", ["char line 1", "2"]] | act 1 ...] and save them file. we'd move relational database variety of reasons (foremost search) have no idea how represent things. i'm looking outline of best way things? the topic 'normalization' begin identifying main classifications, such play, author, act, scene then add attributes - specifically, primary key play_id, act_id, etc. then add still more attributes name or other identifying information. then finally, add relationships between these object bby creating more tables play_author includes play_id , author_id.

apache - how to run fastcgi -

i have fastcgi installed , running. downloaded developerkit fastcgi.com. had examples in it. 1 of example files echos stuff. required .libs , .deps put folders along echo.fcgi file , webroot/cgi-bin. if got echo.fcgi url, works great. i created simple c file prints hello world. compile using gcc -wall -o main -lfcgi main.c what do now? require perl script or php script executed. or, should able put in webroot/cgi-bin folder , go it's url? thanks this guy found don't need wrapper. if add appclass "/library/webserver/documents/myfcgitest" to httpd.conf file. can executable running.

xml - xpath help substring expression -

hi have document trying extract date. problem within node along date text too. like <div class="postheader"> posted on july 20, 2009 9:22 pm pdt </div> from tag want date item not posted on text. like ./xhtml:div[@class = 'postheader'] getting everything. , precise, document have nodelist of elements eg 10 nodes of these elements different date values worse problem sometime inside these tags random other tags pops anchors etc. can write universal expath date out of div tag? with xslt 2.0 have xpath function matches() , replace(). have xpath 2.0 available?

sql - How to find Expr#### in Execution Plan -

when looking @ actual execution plan query in sql server management studio (ssms), how determine expression such expr1052 represents? when identify costly parts of query , @ properties of operation, there references these expressions, or scalar operators. want able figure out part of query referring to. in execution plan window of ssms , right click on operation first calculates expression , select properties . you see expression definition in pane right. alternatively, can browse xml plan , search entries that: <definedvalues> <definedvalue> <columnreference column="expr1018" /> <scalaroperator scalarstring="col1 + col2"> </scalaroperator> </definedvalue> … </definedvalues>

database - Duplicate value exception while inserting into an autoincremental-PK table -

i experienced sqlceexception : "a duplicate value cannot inserted unique index" while inserting record in table (sqlce 3.5). it seems insert statement violates primary key constraint. however, on relevant table, pk has been defined autoincrementing identity: [id] int identity(1,1) not null, the exception not systematical: happens once in while. what cause of exception? doesn't identity(1,1) guarantee unique id each insert, it? sqlce bug? if so, how circumvented? here exception trace (it explicitly refers pk_id constraint): system.data.sqlserverce.sqlceexception: duplicate value cannot inserted unique index. [ table name = historicaldata,constraint name = pk_id ] @ system.data.sqlserverce.sqlcecommand.processresults(int32 hr) @ system.data.sqlserverce.sqlcecommand.executecommandtext(intptr& pcursor, boolean& isbasetablecursor) @ system.data.sqlserverce.sqlcecommand.executecommand(commandbehavior behavior, string method, resultsetoptions opt...

java - constructor calling in array creation -

int[] a=new int[4]; i think when array created ..there constructor calling (assigning elements default values) if correct..where constructor.. no, there no such thing. primitive array elements initialized default primitive value ( 0 int ). object array elements initialized null . you can use java.util.arrays.fill(array, defaultelementvalue) fill array after create it. to quote jls an array created array creation expression (§15.10) or array initializer (§10.6). if use initializer, values assigned. int[] ar = new int[] {1,2,3} if using array creation expression (as in example), ( jls ): each class variable, instance variable, or array component initialized default value when created

android - Getting a gestureoverlayview -

i have been using nice tutorials on drawing graphics on android. wanted add in cool gesture demo found here: http://developer.android.com/resources/articles/gestures.html that takes these lines of code: gestureoverlayview gestures = (gestureoverlayview) findviewbyid(r.id.gestures); gestures.addongestureperformedlistener(this); this fine , dandy yet realize in demo i'm trying build using code "playing graphics in android". demos make sense, makes sense found out using: setcontentview(new panel(this)); as required playing graphics tutorials, findviewbyid seems no longer valid , returns null. @ first post stupider question why happening, quick test of playing setcontentview made me realize cause of findviewbyid returning null, not know how remedy issue. whats key missing here? realize new panel doinking reference not sure how make connection here. the: r.id.gestures defined right int main.xml as: (just tutorial) <android.gesture.gestureoverlayvie...

actionscript 3 - Object is a null reference only when using a method? -

i have object called "target" property called "movement": private function start() { var movement:imovement = new zigzagmovement(target); target.movement = movement; mediumdifficulty(); } private function mediumdifficulty(target:abstracttarget):void { var movement:imovement = target.movement; movement.mediummove(); } my abstract target class looks this: package { import flash.display.sprite; public class abstracttarget extends sprite { protected var __movement:imovement; public function abstracttarget() { } public function set movement(value:imovement):void { __movement = value; } public function movement():imovement { return __movement; } } } my "movement" class looks this: package { import flash.events.event; public class zigzagmovement implements imovement { ...

iphone - Alternate to control+drag to connect view element with file owner in xCode interface builder? -

working on iphone application through tightvnc connection mac mini; control+drag operation in interface builder connect view element file owner doesn't work - don't see connecting line. it work when connect keyboard, mouse , monitor mini , work on directly, lot more convenient me run through vnc connection. must quirk of tightvnc connection preventing this. tried different tightvnc settings cursor (let server handle , on) no luck. is there alternative control+drag hook outlets? you can try right-clicking holding control , clicking element (depending on keyboard settings, might command click instead), show popup, , can drag circle on right hand side of property want link up.

Google analytics Cookies -

in browser cookies creating name __utma,__utmb , on if reject cookie creation.i think cookie google analytics.anybody know how google creating cookie browser not supporting cookie creaton.thanks yes, google analytics' cookies. here's how ga sets/updates them: when browser requests web page contains ga tracking code (gatc), gatc sets/updates cookies in browser. gatc sends data held in cookies ga servers via http request __utm.gif (aka, "tracking pixel"). data held in cookies appended request along other information. can identify of information taken cookies checking request " utmcc "--the cookie values on right side, e.g.: utmcc =__utma%3d117243.1695285.22%3b%2b __utmz%3d117945243.1202416366.21.10. utmcsr%3db%7c utmccn%3d(referral)%7c utmcmd%3dreferral%7c utmcct%3d%252fissue%3b%2b in basic implementation, google analytics creates/sets/updates three first-party cookies: __utma : visitor id, persists 2 years; __utmb : session id, per...

javascript - qTip (jQuery plug-in) how can I remove all qtips in my page? -

i'm using jquery-plugin qtip. what's command destroy tooltips in page ? i tried: $('.option img[title], span.taxonomy-image-link-alter img[title]').qtip("destroy"); but didn't work... thanks i've solved $(".qtip").remove();

css, external fonts -

i have big problem css, how can pun font myriadpro-it.otf in css? thanks ! you can add css in style sheet. @font-face { font-family: "myriadpro"; font-style: normal; src: url(../fonts/myriadpro-it.eot); /*if ie */ src: local("grandesign regular"), url("../fonts/myriadpro-it.ttf") format("truetype"); /* non-ie */ }

c# - Thread.CurrentThread.CurrentUICulture not working consistently -

i've been working on pet project on weekends learn more c# , have encountered odd problem when working localization. more specific, problem have system.threading.thread.currentthread.currentuiculture. i've set app user can change language of app clicking menu item. menu item in turn, saves two-letter code language (e.g. "en", "fr", etc.) in user setting called 'language' , restarts application. properties.settings.default.language = "en"; properties.settings.default.save(); application.restart(); when application started up, first line of code in form's constructor (even before initializecomponent()) fetches language string settings , sets currentuiculture so: public form1() { thread.currentthread.currentuiculture = new cultureinfo(properties.settings.default.language); initializecomponent(); } the thing is, doesn't work consistently. sometimes, works , application loads correct language based on string saved i...

.net - WPF: How to make Contextmenu select and forget? -

i have contextmenu listbox inside. whenever right click control , select value contextmenu last selected value stays marked , can't select value again. the idea is, may select same value within contextmenu in order turn property on or off. should quite basic, missing? many thanks, edit: responses. have tried apply ideas without success. think major problem menuitems of contextmenu have no itemsource bound collection (e.g. possiblevalues in example). may insert code clarification: <border.contextmenu> <contextmenu> <contextmenu.itemcontainerstyle> <style targettype="{x:type menuitem}"> <setter property ="template"> <setter.value> <controltemplate targettype="{x:type menuitem}"> <contentpresenter x:name="header" contentsource="header" recognizesaccesskey="true"/> ...

c# - Adding button column to DataGridView but it won't show -

Image
i'm adding button column databound datagridview. column gets created, , button clickable, doesn't show. kinda hard explain i'm posting screenshot below. here's code private void loaddatagridview() { dgvclients.datasource = null; dgvclients.datasource = clients; datagridviewbuttoncolumn btndelete = new datagridviewbuttoncolumn(); btndelete.name = "btndelete"; btndelete.text = "delete"; btndelete.headertext = "delete"; dgvclients.columns.add(btndelete); //set column sizes. total width of dgv w/o scrollbar 544 dgvclients.columns[0].width = 100; dgvclients.columns[1].width = 344; dgvclients.columns[2].width = 100; dgvclients.columns[3].width = 100; dgvclients.show(); dgvclients.clearselection(); } screenshot: you need when define b...

database - Repeated elements counting for Sql datatables queries -

i have 2 tables: order table , orderdetails table. have written inner join: select order.id order inner join orderdetails on order.id=orderdetails.id i have got output as: id 100 100 100 101 101 from above data, want count of each record output as: id count 100 3 101 2 how this? select orderid , count(*) [count] orderdetials group orderid orderid foreing key column referencing order.id column of order table if orderdetails.id references order.id column query. select id , count(*) [count] orderdetials group id

html - iPhone Scroll images horizontally like in AppStore -

i wondering if it's possible create html div container css magic shows horizontal scrollbar 1 screenshots on itunes preview on web. want work in safari on iphone. e.g. http://itunes.apple.com/app/super-monkey-ball/id281966695?mt=8 i use display thumbnails in uiwebview on iphone. experimented overflow css property didn't work. thanks replies. i don't have time test right now, think along lines of following should work: ul#container { overflow: hidden; overflow-x: scroll; width: 500px; /* or whatever */ height: 200px; /* or whatever */ white-space: nowrap; } ul#container li { display: inline-block; width: 100px; /* or whatever */ height: 200px; /* or whatever */ } <ul id="container"> <li>item one</li> <li>item two</li> <li>item three</li> <li>...<!-- point --></li> </ul> you might need use float: left; on li elements, i'm not sure. , maybe depends on browser you...

.net - Query vs Stored procedure; difference between two approaches -

i developing web page search. have 2 options build page to build query on page according parameter enter user , send server. to send parameters stored procedure , build query there , executed. i want know approach should adopt , why. i want know advantages or disadvantages of both approaches. from side store procedure good. stored procedure not compile again , again simple query compile every time execute. stored procedure execute server side that's why reduces network traffic. sql query executes on server if have big query take more time comparison stored procedure traverse client side server.

android - Using the pre-installed Google Maps instead of an own activity by using Intents? -

i wanted know whether possible pass geocoords google maps app bis intents or similar. i wrote app displaying route, coordinations , on myself, wouldn't more elegant ask google maps displaying this? i don't know if possible, maybe, 1 of can answer question. if possible, possible ask google maps calculate route current position? it great if 1 of can show me skeleton/dummy code. have no idea how intents have like. the documentation on google intents here: https://developer.android.com/guide/appendix/g-app-intents.html unfortunately, (to knowledge) limited displaying location, not route. user use location plot own route, though.

Setting the default value of a C# Optional Parameter -

whenever attempt set default value of optional parameter in resource file, compile-time error of default parameter value 'message' must compile-time constant. is there way can change how resource files work make possible? public void validationerror(string fieldname, string message = validationmessages.contactnotfound) in this, validationmessages resource file. no, not able make resource work directly in default. need set default value null , resource lookup when parameter has default value in body of method.

JQuery Table Sorter - PHP related -

apologies off if amateurish question. trying jquery tablesorter plugin work table generated php mysql database. @ moment i'm unable sorting work. i'm thinking sequence of javascript , php operating , may need implement callback in javascript or something. anyway code have is: <html> <head> <script src="jquery/jquery.js" type="text/javascript"></script> <script src="jquery/jquery.tablesorter.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#table1").tablesorter({ sortlist: [0,0] }); }); </script> </head> <body> <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("database1", $con); $result = mysql_query("select * playerstats1 g>2 limit 0,20"); echo "<tab...

python - Getting progress message from a subprocess -

i want start program needs several minutes complete. during time want read progress message of program (which printed on stdout). problem cannot find way read out output during run. the function found read out output of program popen.communicate() , method waits until process finishes. impossible progress , make visible user in special formatted way. is possible way? when run process subprocess.popen script see output of program on screen. possible hide it? (ubuntu 10.10, normal terminal) simplest call popen keyword argument stdout=subprocess.pipe . p = subprocess.popen(["ls"], stdout=subprocess.pipe) while true: line = p.stdout.readline() if not line: break print line to see in action, here 2 sample scripts. make them both in same directory , run python superprint.py printandwait.py: import time import sys print 10 sys.stdout.flush() time.sleep(10) print 20 sys.stdout.flush() superprint.py: import subprocess import sys p ...

php - Which web application modular structure is better? -

backend/ module1 module2 module3 frontend/ module1 module2 module3 or modules/ module1/ frontend backend module2/ frontend backend module3/ frontend backend the choice depends on want achieve. first architecture sort of layering , second 1 components. similar struggle goes mvc versus components (as in desktop gui etc.). layers enable isolate modules layer layer, means, can build on existing layers. used in io/osi tcp/ip stack. on other hand components more granular , can reused such - e.g. can compose desktop guis "widgets". better web? loooking @ mainstream, imho mvc, first layers architecture seems used more. maybe question rlated asking if asp.net better sp.net mvc...

tkinter - Exit Tks mainloop in Python? -

i'm writing slideshow program tkinter, don't know how go next image without binding key. import os, sys import tkinter import image, imagetk import time root = tkinter.tk() w, h = root.winfo_screenwidth(), root.winfo_screenheight() root.overrideredirect(1) root.geometry("%dx%d+0+0" % (w, h)) root.focus_set() root.bind("<escape>", lambda e: e.widget.quit()) image_path = os.path.join(os.getcwd(), 'images/') dirlist = os.listdir(image_path) f in dirlist: try: image = image.open(image_path+f) tkpi = imagetk.photoimage(image) label_image = tkinter.label(root, image=tkpi) # ? label_image.place(x=0,y=0,width=w,height=h) root.mainloop(0) except ioerror: pass root.destroy() i add time.sleep(10) "instead" of root.mainloop(0) go next image after 10s. changes when press esc. how can have timer there? edit: should add don't want thread sleep though works. yo...

How do you list all the indexed views in SQL Server? -

how can list of views in sql server database have indexes (i.e. indexed views)? i've found it's pretty easy run "alter view" i'm developing , overlook i'm not editing view dropping existing index. thought nice have little utility query around list me off views indexes. select o.name view_name, i.name index_name sysobjects o inner join sysindexes on o.id = i.id o.xtype = 'v' -- view

asp.net - Membership.GetUser() vs Context.User -

what differences between membership.getuser() , context.user, , recommended use in getting information current user? if don't have membership configured site, getuser() won't yield anything. context.user identity token handed asp.net runtime, , yield user if authentication aside anonymous acces configured fo site.

python - Quicksort sorts larger numbers faster? -

i messing around python trying practice sorting algorithms , found out interesting. i have 3 different pieces of data: x = number of numbers sort y = range numbers in (all random generated ints) z = total time taken sort when: x = 100000 and y = (0,100000) then z = 0.94182094911 sec when: x = 100000 and y = (0,100) then z = 12.4218382537 sec when: x = 100000 and y = (0,10) then z = 110.267447809 sec any ideas? code: import time import random import sys #-----function definitions def quicksort(array): #random pivot location quicksort. uses memory. smaller = [] greater = [] if len(array) <= 1: return array pivotval = array[random.randint(0, len(array)-1)] array.remove(pivotval) items in array: if items <= pivotval: smaller.append(items) else: greater.append(items) return concat(quicksort(smaller), pivotval, quicksort(greater)) def concat(before, pivot, after): n...

function - OCaml: Currying without defined values -

i have 2 functions f , g , trying return f(g(x)) not know value of x , not sure how go this. a more concrete example: if have functions f = x + 1 , g = x * 2 , trying return f(g(x)) should function equal (x*2) + 1 it looks have right, f(g(x)) should work fine. i'm not sure why have return keyword there (it's not keyword in ocaml). here correct version, let compose f g x = f (g x) the type definition is, val compose : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c = <fun> each, 'a,'b,'c abstract types; don't care are, need consistent in definition (so, domain of g must in range of f ). let x_plus_x_plus_1 = compose (fun x -> x + 1) (fun x -> x * 2)

sql server - Loading Fact Table + Lookup / UnionAll for SK lookups -

i got populate facttable 12 lookups dimension table sk's, of 6 different dim tables , rest 6 lookup same dimtable (type ii) doing lookup same natural key. ex: primeobjectid => lookup dimobject.objectid => objectsk and got other columns same otherobjectid1 => lookup dimobject.objectid => objectsk otherobjectid2 => lookup dimobject.objectid => objectsk otherobjectid3 => lookup dimobject.objectid => objectsk otherobjectid4 => lookup dimobject.objectid => objectsk otherobjectid5 => lookup dimobject.objectid => objectsk for such multiple lookup how should go in ssis package. for using lookup / unionall foreach lookup. there better way this. i assume doing lookup, errors redirected derived column set default values failed lookups, followed union each of lookup/derived column values. pattern common , use in stages debug. however, since union partially blocking component (ie union creates new buffer when executes, pass...

c# - What's the difference between IEquatable and just overriding Object.Equals()? -

i want food class able test whenever equal instance of food . later use against list, , want use list.contains() method. should implement iequatable<food> or override object.equals() ? msdn: this method determines equality using default equality comparer, defined object's implementation of iequatable.equals method t (the type of values in list). so next question is: functions/classes of .net framework make use of object.equals() ? should use in first place? the main reason performance. when generics introduced in .net 2.0 able add bunch of neat classes such list<t> , dictionary<k,v> , hashset<t> , etc. these structures make heavy use of gethashcode , equals . value types required boxing. iequatable<t> lets structure implement typed equals method no boxing required. better performance when using value types generic collections. reference types don't benefit iequatable<t> implementation let avoid cast sy...

xml - How to output specific values with XPathQuery? -

when do account[@id=15] i get <?xml version="1.0" encoding="utf-8"?> <root> <account id="15" first_name="sandra" last_name="schlichting"> <private_address address_id="19" /> <profile_employee fk_id="15"> <date_created>2011-1-2t1:1:00</date_created> <address building="3" room="2" floor="1" /> </profile_employee> <profile_student fk_id="15"> <address address_id="19" /> </profile_student> <profile_student fk_id="15"> <address address_id="45" /> </profile_student> </account> </root> but output values of first_name last_name building room can figure out how that? update: these commands works account[@id=15]/profile_employee account[@id=15]/profile_employee/address but o...

iphone - Developer Tools: Instruments command line interface -

do know if possible launch or attach uiautomation tool process on actual ios device using instruments command line interface ? i know there command line interface instruments far haven't been able connect device. there bug in command line instruments interface. it's documented here: http://openradar.appspot.com/9150033 i filed bug through job, , closed dupe of one. when fixed, should work following: http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man1/instruments.1.html the workarounds hacky, instruments product lacks osascript extensions well. i'm going investigating hacks, while waiting fix come through.

Reading a large csv datafile with multiple lines of headerinfo into Matlab -

does have advice how read comma separated data file matlab? simple solutions (like dlmread, fscanf) not seem work, there multiple (10) lines of header information. closest got solution is: c=textscan(datafile) g=cell2mat(c{1,1}(34:endoffile)}) //34 line data starts v=str2num(g) the problem here data instance looks this: ;1.0345,937,18,763 ;1.0355,947,4,652 etc. when converting matrix strings in cell have of same size, otherwise error using 'vertcat' given. if no other option, delete header in lets notepad, many many files tedious job. dlmread accepts starting row/column parameters, or alternatively range parameter. if data starts on line 10, try v = dlmread(datafile, '', 9, 0); if prefer textscan , can specify number of headerlines skip: v = textscan(datafile, ..., 'headerlines', 10, ...); scan down "user configurable options" on documentation page more details.

sql - How can we check that table have index or not? -

how can check table have index or not ? if have how find index particular column table? regards, kumar in sql server management studio can navigate down tree table you're interested in , open indexes node. double clicking index in node open properties dialog show columns included in index. if use t-sql, might help: select sys.tables.name, sys.indexes.name, sys.columns.name sys.indexes inner join sys.tables on sys.tables.object_id = sys.indexes.object_id inner join sys.index_columns on sys.index_columns.index_id = sys.indexes.index_id , sys.index_columns.object_id = sys.tables.object_id inner join sys.columns on sys.columns.column_id = sys.index_columns.column_id , sys.columns.object_id = sys.tables.object_id sys.tables.name = 'table name here' order sys.tables.name, sys.indexes.name, sys.columns.name

css - In IE 7 background shift to 1 px top to but in FF it's ok? -

in ie 7 background shift 1 px top in ff it's ok? background: url(girl.jpg) top left repeat-x; position: relative; top: 0px;color: #666; border-bottom-color: white; you can use this top:0px; *top:1px; *background-position:0px 1px; work 4 ie7 can use this. you can enter value according design. in *top: px.

oracle - How can I get a COUNT(col) ... GROUP BY to use an index? -

i've got table (col1, col2, ...) index on (col1, col2, ...). table has got millions of rows in it, , want run query: select col1, count(col2) col1 not in (<couple of exclusions>) group col1 unfortunately, resulting in full table scan of table, takes upwards of minute. there way of getting oracle use index on columns return results faster? edit: more specifically, i'm running following query: select owner, count(object_name) all_objects group owner and there index on sys.obj$ ( sys.i_obj2 ) indexes owner# , name columns; believe should able use index in query, rather full table scan of sys.obj$ i have had chance play around this, , previous comments regarding not in red herring in case. key thing presence of nulls, or rather whether indexed columns have not null constraints enforced. this going depend on version of database you're using, because optimizer gets smarter each release. i'm using 11gr1 , optimizer used index in cases exc...

snmp - Why is Cacti showing an empty graph, even though the rrd file is created? -

i have developed own snmp service, , want plot graph of oid provided. so, have created graph in cacti. -) showing device up. -) creating rrd file. (rrdtool says ok). -) showing graph, it's empty. but when check it, say rrdtool fetch <rrd file> average it shows me nan values. monitored oid has value 47 , have set min=0 , max=100. i using cacti appliance rpath: http://www.rpath.org/ui/#/appliances?id=http://www.rpath.org/api/products/cacti-appliance still, can't show value on graph.. where problem? can please tell me? first of all, use cacti's "rebuild poller cache" function under utilities menu. if didn't work ,check if rrd file updating new data. use command: rrdtool last [filename.rrd] output last time (in unix timestamp) new value has been inserted rra file can compare current time date +%s output. if it's not updating data should change cacti log level debug via settings page on cacti's web ui , appropriate m...

iphone - How do i add a main menu before accessing a UITableView? -

i have built application revolves around uitableview, core data , xml. app complete want add main menu before accessing tableview. main menu allow navigate table , other functions. easiest way go doing this? i'm confused how change inital file loaded. one suggestion add navigation controller , new view serve 'main' view , show menu. in response 'menu' choices push existing table view or other views might want show.

Date and time in silverlight + ria services -

i'm facing weird problem in sliverlight 4 + ria services, or maybe it's not weird , i'm newbie anyway hope here can help, problem following i've created function on server side inside domain service function simple , has line in adds server current date , time database (it's hr application , employees should sign in , out thrue each it's own pc ) emp.timeout = system.datetime.now (c# syntax) the weird part users adds 3 hours current time(exp if signs out @ 5 shows 8) , others works perfectly. the server , stations in company have same time settings , same time zone, , anyway function on server side should no related users time. any ideas why happening? i've been trying find out why days no luck. you need use utc values ... everwhere there serialization involved ... whether db or client. convert local time when appropriate display/human readin (and in case of input)

DotNetNuke - Module settings disapear on new user control -

i have dnn module renders user control (view.ascx) all ok ( logged in ) , dnn settings menu. however when add control , load so: string url = globals.navigateurl(portalsettings.activetab.tabid, "view_details", "mid=" + moduleid.tostring()); response.redirect(url); i lose settings link when new control loads. any ideas? there property somewhere turn on settings loaded user control? when have "mid" in querystring, you're going using module isolation (i.e. module control show in edit skin's contentpane , module on page). when in module isolation, action menu doesn't include settings. fact of dnn. you have couple of options. first, choose navigation method (see michael washington's old (but still good) module navigation options dotnetnuke® module article). second, put own link settings on control. may able implement iactionable , add action menu (i'm not sure if work), or can add sort of button or navigati...

java - JPA 2.0 Eclipse Link -

i have code @column(updatable=false) @enumerated(enumtype.string) private examtype examtype; however, can still change value when update via merge. why? ok. first, if want examtype column included in sql update statements, shouldn't mark updatable=false . being said, appears updatable=false ignored when not used in combination insertable=false that's bug in eclipselink ( bug 243301 ), that's not jpa says. set true or remove it. secondly, following entity: @entity public class myentity { @id @generatedvalue private long id; @column(updatable = true) @enumerated(enumtype.string) private examtype examtype; ... } the following test method runs fine eclipselink: @test public void testupdateofenum() { myentity e = new myentity(); e.setexamtype(examtype.a); em.persist(e); em.flush(); assertnotnull(e.getid()); assertequals(examtype.a, e.getexamtype()); e.setexamtype(examtype.b); em.merge(...

Is there a "normal" EqualQ function in Mathematica? -

on documentation page equal read approximate numbers machine precision or higher considered equal if differ in @ last 7 binary digits (roughly last 2 decimal digits). here examples (32 bit system; 64 bit system add more zeros in middle): in[1]:= 1.0000000000000021 == 1.0000000000000022 1.0000000000000021 === 1.0000000000000022 out[1]= true out[2]= true i'm wondering there "normal" analog of equal function in mathematica not drop last 7 binary digits? in[12]:= myequal[x_, y_] := order[x, y] == 0 in[13]:= myequal[1.0000000000000021, 1.0000000000000022] out[13]= false in[14]:= myequal[1.0000000000000021, 1.0000000000000021] out[14]= true this tests if 2 object identical, since 1.0000000000000021 , 1.000000000000002100 differs in precision won't considered identical.

java - Hibernate: Programmatically binding UserTypes on Components -

i have several different usertypes (org.hibernate.usertype.usertype) in system. question focus on fact use joda time datetime , usertype, persistentdatetime. i have bound usertype programmatically persistentclass's by: public void customize(ejb3configuration config) { iterator<persistentclass> itr = config.getclassmappings(); while(itr.hasnext()) { persistentclass persistentclass = itr.next(); for(iterator<property> iter = persistentclass.getpropertyiterator(); iter.hasnext();) { if(property.gettype().getreturnedclass().equals(datetime.class)) { simplevalue original = (simplevalue) property.getvalue(); simplevalue value = new simplevalue(original.gettable()); value.settypename("org.joda.time.contrib.hibernate.persistentdatetime"); value.settypeparameters(new properties()); value.setnullvalue(original.getnullvalue()); iterator<colu...

c# - .NET Regex pattern? -

var flashvars = { "client.allow.cross.domain" : "0", "client.notify.cross.domain" : "1", }; for strange reason does not want parsed code (in c#). private void parsevariables() { string page; regex flashvars = new regex("var flashvars = {(.*?)}", regexoptions.multiline | regexoptions.ignorecase); regex var = new regex(@"""(.*?)"",", regexoptions.multiline | regexoptions.ignorecase); match flashvarsmatch; matchcollection matches; string vars = ""; if (!isloggedin) { throw new notloggedinexception(); } page = request(url_client); flashvarsmatch = flashvars.match(page); matches = var.matches(flashvarsmatch.groups[1].value); if (matches.count > 0) { foreach (match item in matches) { vars += item.groups[1].value.replace("\...