Posts

Showing posts from January, 2010

c# - Is RegEx used by System.Net.Mail.MailAddress -

i have been trying find regex email validation. i have gone through comparing e-mail address validating regular expressions , didn't suffice validation needs. have google/bing(ed) , scan top 50 odd results including regular expressions info article , other stuff. so used system.net.mail.mailaddress class validate email address. since, if fails, email won't sent user. i want customize validation used constructor of class. so how go ahead , validation/regex mailaddress class using? no not use regex, rather complicated process take way long explain here. how know? looked @ implementation using .net reflector. , can :d http://www.red-gate.com/products/reflector/ (it's free)

php - Convert FLV to MP4 or 3GP -

can convert videos php or have use library? you'll need use libraries achieve this. the wordpress video solutions framework video conversion; written in php , uses ffmpeg , other tools conversion. may starting point you.

c# - How can I make a service that send mails every 5 minutes? -

hy, i have c# program sends emails gmail smtp server , want make service or running behind sends emails every 5 minutes. does have idea how can make c# , asp.net? two options spring mind: write windows service. kick off timer triggers every 5 minutes, , work there. set windows scheduled task ("task scheduler" in vista/win7) trigger every 5 minutes , launch application. i'd tend towards latter. windows services easy set up, nothing's simpler no code @ all.

NHibernate - Usefulness -

i work in software , hardware development farm. today 1 of colleagues told me nhibernate useful small projects, , complex or large scale projects must avoided. also, makes code harder change. are statements true? ebay uses hibernate (the java version nhibernate ported from). don't consider small project. as far changing code goes, consider this: let's assume need add new property object. here has done hand-rolled data access layer: add column db table. change every stored procedure deals object / table. several stored procedures in experience. change code in mapping layer add property object here has done nhibernate: add column db table. add property hbm file add property object.

Drawing an SVG file on a HTML5 canvas -

is there default way of drawing svg file onto html5 canvas? google chrome supports loading svg image (and using drawimage ), developer console warn resource interpreted image transferred mime type image/svg+xml . i know possibility convert svg canvas commands (like in this question ), i'm hoping that's not needed. don't care older browsers (so if firefox 4 , ie 9 support something, that's enough). edit november 5th, 2014 you can use ctx.drawimage draw htmlimageelements have .svg source in not browsers . chrome, ie11, , safari work, firefox works bugs (but nightly has fixed them). var img = new image(); img.onload = function() { ctx.drawimage(img, 0, 0); } img.src = "http://upload.wikimedia.org/wikipedia/commons/d/d2/svg_example_square.svg"; live example here . should see green square in canvas. second green square on page same <svg> element inserted dom reference. you can use new path2d objects draw svg (string) paths ( only ...

html - Data after <textarea> is not shown -

if go here: http://xcs.dyndns.info/piataterenuri/vinde.php can see footer appears. but if go http://xcs.dyndns.info/piataterenuri/vinde2.php here, can see nothing displayed after textarea. the differnce betweeen 2 second 1 has: <tr> <td class="optiune">info:</td> <td> <textarea cols="30" rows="5" class="field"/></td> </tr> why's happening? textarea tags not self closing (in html). code should be: <tr> <td class="optiune">info:</td> <td> <textarea cols="30" rows="5" class="field"></textarea> </td> </tr>

.net - Howto ensure objects are lazy loaded with (Fluent) NHibernate? -

i have application using fluent nhibernate on server side configure database. fluent uses lazyloading default, explicitly disabled this gave me problems when sending objects client side. client can't load objects lazily doesn't have access database. now try reenabling lazyloading parts of datamodel there parts want return toplevel objects client. however, don't seem lazyloaded. why?! what did disable lazyloading adding not.lazyloading() in mapping object, , on references in mapping. removing doesn't seem have effect. debugging see referenced objects, , them on client side. however, nhibernateutil.isinitialized(myobjectfromdb.somereference) correctly says false @ same time. so; how ensure objects lazy-loaded; getting object missing references client? ideas might got wrong? i have few classes (very simplified example..): public class customer { public virtual int id { get; set; } public virtual string name { get; set; } public virtual ilist<or...

SQL recursive CTE query, odd results set SQL Server 2005 -

i trying write recursive cte query in sql server 2005 getting odd set of results. table is: pairid childid parentid 900 1 2 901 2 3 902 3 4 this cte query: with tester (pairid, childid, parentid, level) (select a.pairid, a.childid,a.parentid, 0 level businesshierarchy union select b.pairid, b.childid, b.parentid, oh.level + 1 level businesshierarchy b inner join tester oh on b.childid = oh.parentid) select x.pairid, x.childid, x.parentid, x.level tester x order x.level, x.childid, x.parentid ok, getting dataset return, however, not expected in contains repetition in following manner: pairid childid parentid level 900 1 2 0 901 2 3 0 902 3 4 0 ... 900 2 3 1 901 3 4 1 ... 900 3 4 2 if explain me why happening , how ...

serialization - Custom serializer and inheritence in C# -

i'm learning serialization in c# , have basics down, trying little more complicated , i'm looking pointers on best practice (i can achieve want, want know 'right'/easiest/least code/most robust method of doing it). i have racing track made of sections. each section type inherits common tracksection class. tracksection class holds lot of data on geometry , other things don't want save out , needs context information when constructor called, have implemented iserializable interface , provided own methods handle (de)serialization. classes inherit tracksection lot simpler, , happy fields serialized automatically, assume since base class iserializable need manually (i have added deserialization constructor , call base class's deserialization constructor in each). when comes serializing though i'm not sure do, have expected iserializable's getobjectdata() method virtual extend serialization in sub-classes. need implement own virtual method called base cl...

PHP - make session expire after X minutes -

i using following technique... from login.php form posts page check.php this <?php $uzer = $_post['user_name']; $pass = $_post['user_pass']; require ('db_connection.php'); $result = mysql_query("select * accounts user_name='$uzer' , user_pass='$pass'"); if( mysql_num_rows( $result ) > 0) { $array = mysql_fetch_assoc($result); session_start(); $_session['user_id'] = $uzer; header("location:loggedin.php"); } else { header("location:login.php"); } ?> and on loggedin.php page first thing is <?php session_start(); if( !isset( $_session['user_id'] ) ) { header("location:login.php"); } else { echo ( "this session ". $_session['user_id'] ); //show rest of page , } ?> but once logged in when directly type url localhost\myproject\loggedin.php displays page...which makes perfect sense because sess...

webkit - Getting source HTML from a WebView in Cocoa -

i'm working on os x program user light wysiwyg html editing in webview. being new programming cocoa , webkit, have absolutely no idea how selected text webview - intention being take user selected, add html code (like div's or span's) around text, , replace selected text modified code. how can accomplished? i'm programming project macruby, i'd appreciate objective-c programmers well. thank you! you can ask webview 's -selecteddomrange , you'll domrange object back. can use object find out selected. domrange , webkit dom objects, objective-c representation of standard w3c domrange object, see domrange.h methods/properties supports. you can replace current selection using -replaceselectionwithmarkupstring: , -replaceselectionwithtext: or -replaceselectionwithnode: methods of webview .

actionscript - Flash AS2 (CS4) - setInterval causing for loop to not work -

i have simple code: function testing(){ (a=1; a<=4; a++) { this["btn"+a].enabled = true; } } if run function anywhere works fine. if run function mytimer = setinteval(testing, 3000); not work. if add other random code function (the newly added code only) work. have narrowed down this["btn"+a].enabled = true; causing not run. i hope makes sense, appologies, it's 3am :(. any ideas? what makes sense. when call function normally, "this" object. when run using setinterval, lose reference "this." - edited based on comments others - here 3 ways solve problem: this way involves passing in "this" function: var = this; setinterval(function() {testing(that)}, 1000); function testing(obj) { (a = 1; <= 4; a++) { obj["btn" + a].enabled = true; } } this way involves passing in "this" setinterval: setinterval(this, "testing", 1...

oracle - Does the compiled prepared statement in the database driver still require compilation in the database? -

in oracle jdbc driver, there option cache prepared statements. understanding of prepared statements precompiled driver, cached, improves performance cached prepared statements. my question is, mean database never has compile prepared statements? jdbc driver send precompiled representation, or there still kind of parsing/compilation happens in database itself? when use implicit statement cache (or oracle extension explicit statement cache) oracle driver cache prepared- or callable statement after(!) close() re-use physical connection. so happens is: if prepared statement used, , physical connection has never seen it, sends sql db. depending if db has seen statement before or not, hard parse or soft parse. typically if have 10 connection pool, see 10 parses, 1 of beein hard parse. after statement closed on connection oracle driver put handle parsed statement (shared cursor) lru cache. next time use preparestatement on connection finds cached handle use , not need send ...

javascript - myVar = !!someOtherVar -

this question has answer here: what !! (not not) operator in javascript? 31 answers can clarification on why want use this? myvar = !!someothervar; if need pass boolean value function, or anal evaluating booleans in conditional statements, casts someothervar boolean double-negating it.

iphone - UIView rotation, modal view landscape and portrait, parent fails to render -

i've hit bit of roadblock hope in here can me out with. i'll describe 'state of play' first, , issue is, here goes; i have series of view controllers chained navigation controller (this works fine), all of these view controllers support portrait mode (by design), in 1 of view controllers (the 'end' 1 actually) user can click table cell pop modal view controller (using presentmodalviewcontroller(...) of course) this modal view controller supports portrait , landscape modes (and works), when user clicks 'done' button on modal view controller pop , pass control parent view controller, however; if user in portrait mode when click 'done' parent displays fine, if user in landscape mode when click 'done' parent displays totally white, blank screen (that covers whole screen). if controller not know how render in landscape , doesn't bother. i'd able have parent view render in portrait no matter orientation of phone when u...

android - Pulling images from Web -

i'm using following code grab images web. uses gridview , depending on position, picks url array. works loading of images hit or miss. every time start app, different number of images load. it has issues when changing portrait landscape view, 5 out of 10 images may displayed i'll turn device , lose images. few show though. any ideas on making more robust? try { urlconnection conn = aurl.openconnection(); conn.connect(); inputstream = conn.getinputstream(); bufferedinputstream bis = new bufferedinputstream(is); bitmap bm = bitmapfactory.decodestream(bis); bis.close(); return bm; } catch (ioexception e) { log.d("debugtag", "error..."); } return null; one thing read there's known bug decoding bitmaps inputstream, , suggested fix google use flushe...

binary - WiX - how to create bin subdirectory? -

i'm missing obvious. how put .dll's in subdirectory called "bin" under install directory? i'm trying follow tutorial: http://www.tramontana.co.hu/wix/lesson5.php#5.3 deploy wcf web service. need copy .svc files , .bin files, along few other, starting these two. i'm using wix 3.5 under visual studio. <directory id="targetdir" name="sourcedir"> <directory id="programfilesfolder"> <directory id="installlocation" name="tfbic.rct.wcfwebserviceswixsetup"> <component id="productcomponent" guid="e9a375fb-df6a-4806-8b0b-03be4a50802f"> <file id='svc1' name='createupdatereturnservice.svc' diskid='1' source='../tfbic.rct.wcfwebservices/createupdatereturnservice.svc' /> </component> </directory> <directory id="i...

c# - Why does code with multiple semicolons compile? -

i curious know why allowed. int i=0;; i accidentaly typed that. program compiled. noticed after many days have typed ;; after tried different symbols ~, !, : etc etc why not allowed first 1 allowed. just curious know. you have typed empty statement: int i=0; // that's 1 statement ; // that's it's legal statement in c# have no body. from section 8.3 of c# language specification : an empty-statement nothing. empty-statement: ; empty statement used when there no operations perform in context statement required.

dynamic - Class based default value for field in Django model inheritance hierarchy -

how can 1 accomplish class-based default value in following scheme? mean, inherited classes set default value "number" differently: class orderdocumentbase(pdfprintable): number = models.positiveintegerfield(default=self.create_number()) @classmethod def create_number(cls): raise notimplementederror class invoice(orderdocumentbase): @classmethod def create_number(cls): return 1 class creditadvice(orderdocumentbase): @classmethod def create_number(cls): return 2 i have looked @ this stackoverflow question , doesn't address same problem. thing thought work overloading orderdocumentbase 's __init__ method this: def __init__(self, *args, **kwargs): """ overload __init__ enable dynamic set of default number """ super(orderdocumentbase, self).__init__(*args, **kwargs) number_field = filter(lambda x: x.name == 'number', self._meta.fields)[0] number ...

java - Login to site with HttpClient Post -

i trying make program logs site , performs automated activities. have been using httpclient 4.0.1, , using started: http://hc.apache.org/httpcomponents-client/primer.html . on particular site, cookies not set through "set-cookie" header, in javascript. so far, unable achieve login. i've tried following things: add headers manually request headers appear in firebug namevaluepair[] data = { new basicnamevaluepair("host",host), new basicnamevaluepair("user-agent"," mozilla/5.0 (macintosh; u; intel mac os x 10.5; en-us; rv:1.9.1.7) gecko/20091221 firefox/3.5.7"), new basicnamevaluepair("accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), new basicnamevaluepair("accept-language","en-us,en;q=0.5"), new basicnamevaluepair("accept-encoding","gzip,deflate"), new basicnamevaluepair("accept-c...

java - how to get column metadata in mybatis -

i need list of columns in table using mybatis/ibatis in java 1.5. that's not typical requirement (99.99% of applications using ibatis or whatever orm knows db schema). ibatis sql mapper, must write sql query yourself. , there no standard sql query (afaik) gives number of columns in table. i can suggest 2 approaches: make sql query selecting catalog tables. that's normal way of knowing db metadata. depends on particular database engine. , it's not related ibatis. quick , dirty: make ad-hoc query select * mytable limit 1 (replace limit db analog), map in ibatis through hashmap, , in dao count number of keys.

Weld - Asynchronous event observers -

i using weld observe events. thought there way specify if observer asynchronous or not, not finding annotation or documentation. can observers asynchronous, if so, need make happen? there open request this: cdi-31: asynchronous events . depending on requirements, can, indicated in comment, set different transactional observer : if use after_completion or after_success, should seem application asynchronous execution. until framework solves , have found example using jms asynchronous execution in cdi .

sql server - Is it possible to add a identity to a GROUP BY using SQL? -

is possible add identity column group each duplicate has identity number? my original data looks this: 1 aaa [timestamp] 2 aaa [timestamp] 3 bbb [timestamp] 4 ccc [timestamp] 5 ccc [timestamp] 6 ccc [timestamp] 7 ddd [timestamp] 8 ddd [timestamp] 9 eee [timestamp] .... and want convert to: 1 aaa 1 2 aaa 2 4 ccc 1 5 ccc 2 6 ccc 3 7 ddd 1 8 ddd 2 ... the solution was: create procedure [dbo].[rankit] begin set nocount on; select *, rank() over(partition col2 order timestamp desc) ranking mytable; end you try using row_number if using sql server 2005 declare @table table( id int, val varchar(10) ) insert @table select 1,'aaa' insert @table select 2,'aaa' insert @table select 3,'bbb' insert @table select 4,'ccc' insert @table select 5,'ccc' insert @table select 6,'ccc' insert @table select 7,'ddd' insert @table s...

html - Internet Explorer 7 strange behaviour for drop down list -

created simple html/css drop down navigation using nested unordered lists. works great firefox, chrome, ie8 in ie7 sub navigation doesn't sit below parent, instead sits below parent right. for example , html/ css have here http://webfe.omega.studiocoast.com.au/ i'm stumped! ie gets confused position: absolute inside floats auto layout. set explicit left: 0 on .sub_nav , position: relative on parent (floated) li avoid this. (is float: left; display:inline-block; intentional, work around other bug or something? doesn't make sense itself.)

c++ - what is the difference between friend function and friend class? -

what difference between friend function , friend class? , should use of friend keyword? in short, 1 class , 1 function. function, 1 function gets access private members. class, whole class , functions access private members of befriended class. the friend keyword used grant access private data members. @ times may need helper class or complimentary class access private members of different class. functions, common example operator overload. perhaps want overload + operator. may make operator+ function declared outside class (so can called without object) , need access private class data. check out this site detailed description of both , how use them.

c++ - Templates :Name resolution:Dependent template arguments : -->can any one tell some more examples for this statement? -

this statement iso c++ standard 14.6.2.4: dependent template arguments : a type template-argument dependent if type specifies dependent. an integral non-type template-argument dependent if constant expression specifies value dependent. a non-integral non-type template-argument dependent if type dependent or has either of following forms , contains nested-name-specifier specifies class-name names dependent type. a template template-argument dependent if names template parameter or qualified-id nested-name-specifier contains class-name names dependent type. i unable understand these points? can 1 give examples these statements? this understand. have marked individual code snippets in code inline marked according line numbers in op. struct a{ void f(){} }; template<class t> struct b{}; // template argument b<t> type depdent on template parameter t (1) template...

python - Doing something *after* handling a request in Google App Engine -

i gae else once app has sent response. the handler this: class foohandler(webapp.requesthandler): def post(self): self.response.out.write('bar') send_response() # need help! do_something_else() # @ point, response should have been sent in case wonder why try this: i need thread-like behaviour, not allowed gae's sandboxed environment. so, function sends several requests whithout caring response. each request starts time-consuming operation (fetching resources) , saves result datastore, can used first function. note: request handler has send response. if not provide any, wait post function complete , return default headers (which not behaviour i'm looking for, of course) if can help, solution might use custom wsgi middeleware, have no idea how works (yet)... as mentioned, can use task queues or deferred api . option outlined rafe kaplan towards end of section in this talk here : can asynchronous api call result h...

network programming - What more socket APIs are available? What are the differences between each of these Socket API? -

everyone referred socket programming or network programming in c , started using using including sys/socket.h & netinet/in.h . thought 100% true. question raised in mind when saw book internetworking tcp/ip volume iii: client-server programming , applications, available in 4 different versions linux/posix sockets at&t tli (transport layer interface) sockets bsd (berkeley) sockets window sockets i'm confused. shows there no standard socket api. also i'm surprised see sys/socket.h & netinet/in.h part of posix c library in http://en.wikipedia.org/wiki/berkeley_sockets . i'm more confused now. why isn't there standard this? what more socket apis available? what differences between each of these socket api? when people "network programming in c" / "socket programming" referring to? links further information? why isn't there standard this? the de facto standard bsd sockets, upon linux, posix , wi...

iphone - Change the searchDisplayController table view style to grouped? -

i have searchdisplaycontroller searches uitableview . after entering search terms, can see uitableview contains search results. however, want uitableview grouped, not plain (like default). how do this? if - me - think plain tableview way ugly, can abandon use of searchdisplaycontroller. i just: inserted in empty view searchbar , tableview iboutlet selected file's owner delegate both of them . at beginin number of section 0 ([mytab count]) used reloaddata , time mytab populated result. [self.resulttableview reloaddata] ; here can find method used delegates @interface myviewcontroller : uiviewcontroller <uiapplicationdelegate, uisearchbardelegate> { iboutlet uisearchbar *searchbar; iboutlet uitableview *resulttableview; } @property (nonatomic, retain) iboutlet uisearchbar *searchbar; @property (nonatomic, retain) iboutlet uitableview *resulttableview; //for searchbar 2 important methods - (void)searchbarsearchbuttonclicked:(uisear...

How to choose which port to use when building a windows service? (windows & .net) -

i'm writing windows service expose http restful web service other processes on machine. deployed lots of machines on various corporate desktops have little/no control over. how should choose port service should listen on? i'll make configurable, need know how choose reasonable default(s). fyi i'm planning on using .net 3.5 (unable use 4.0 deployment reasons) , wcf wcf rest starter toolkit . update : clarify, these corporate non-development machines. want choose port that's not used else. guess list of port numbers (thanks @pascal thivent) should choose 1 in dynamic/private range the dynamic and/or private ports 49152 through 65535 so there better way of choosing port within range, or choose randomly? the official assignments registred internet assigned numbers authority (iana) http are: 80: standard port http, 8080: http alternate (commonly used cache or proxy or web server running non-root user) the ports below non official ports (no...

valueconverter - is it a bad idea to have static wpf value converters? -

instead of declaring converter in resources, can like isenabled={binding path=someprop, converter={x:static namespace:converter.instance}}" where instance instantiated once (lazy sinlgeton) but i'm worried keeping references static variables might in way of garbage collection when disposing views (i'm using prism). think? indeed static instance of converter won't garbage collected, it's 1 instance, , typical converters have no (or few) data fields, it's nothing worry about... the converter has no reference views, shouldn't problem garbage collection of views.

c# - Casting and interface inheritance -

each item has interface, iitem . this, there interface known idrawableitem inherits item. the code below, trying draw drawable item, cannot collection class stores accepts iitem . can add inherits iitem class, using other methods can achieved casting. foreach (var item in items) { item.draw(); // casting go here. } i know how cast, as etc... acceptable? best practice? just wondering if there other ways handle such scenarios. use enumerable.oftype extract elements of items implement idrawableitem : foreach(var item in items.oftype<idrawableitem>()) { item.draw(); } to address question nanook asked in comments above code translated code equivalent following: foreach(var item in items) { if(item idrawableitem) { ((idrawable)item).draw(); } } of course, there iterator behind scenes looks this: public static ienumerable<t> oftype<t>(this ienumerable<tsource> source) { if(source == null) {...

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

a colleague of mine designing sql queries 1 below produce reports, displayed in excel files through external data query. @ present, reporting processes on db required (no crud operations). i trying convince him better use ruby orm in order able display data in rails/sinatra app. despite obvious advantages in displaying data, advantages there him in learning use orm sequel or datamapper? the sql queries writing quite complex, , being relatively new sql, complains time-consuming , confusing. possible write extremely complex queries orm? , if so, suitable(i have heard sequel legacy dbs)? , advantages of learning ruby , using orm versus sticking plain sql, in making complex database queries? i'm datamapper maintainer, , think complex reporting should use sql. while think someday we'll have dsl provides power , conciseness of sql, i've seen far requires write more ruby code sql complex queries. rather maintain 5 line sql query 10-15 lines of ruby code desc...

c++ - simple 2d collision problem -

i want find when collision between static , moving ball occurs, algorithm came with, doesn't detect collision , moving ball goes through static one. moving ball affected gravity , static 1 not. here's collision detection code: glfloat whenspherescollide(const sphere2d &firstsphere, const sphere2d &secondsphere) { vector2f relativeposition = subtractvectors(firstsphere.vposition, secondsphere.vposition); vector2f relativevelocity = subtractvectors(firstsphere.vvelocity, secondsphere.vvelocity); glfloat radiussum = firstsphere.radius + secondsphere.radius; //we'll find time when objects collide if collision takes place //r(t) = p[0] + t * v[0] // //d^2(t) = p[0]^2 + 2 * t * p[0] * v[0] + t^2 * v[0]^2 // //d^2(t) = v[0]^2 * t^2 + 2t( p[0] . v[0] ) + p[0]^2 // //d(t) = r // //d(t)^2 = r^2 // //v[0]^2 * t^2 + 2t( p[0] . v[0] ) + p[0]^2 - r^2 = 0 // //delta = ( p[0] . v[0] )^2 - v[0]^2 * (p[0]^...

json - Can Rails automatically parse datetime received from form text_field -

can rails automatically parse datetime received form's text_field? # in view <div class="field"> <%= f.label :created_at %><br /> <%= f.textfield :created_at %> </div> # in controller params[:product][:updated_at].yesterday currently i'm following error: undefined method `yesterday' "2010-04-28 03:37:00 utc":string if putting param model directly, rails generator boilerplate code does, activerecord takes care of you def create @product = product.new(params[:product]) @product.updated_at.yesterday #will succeed #rest of method end other stuck like: datetime.parse(params[:product][:update_at]) or datetime.civil_from_format(:local, year, month, day, hour, minutes, seconds) but, in experience .civil_from_format doesn't work you'd expect daylight savings time.

java - Connection with MySql is being aborted automatically. How to configure Connector/J properly? -

i read advice error message: you should consider either expiring and/or testing connection validity before use in application, increasing server configured values client timeouts, or using connector/j connection property 'autoreconnect=true' avoid problem. i'm using spring , jpa. should configure connector/j? (in persistence.xml , or in entitymanagerfactory spring configuration, or in datesource spring configuration, or somewhere else?) the text describes 3 solutions prevent connection aborts: configure connection string autoreconnect=true . property of url connection string, works @ driver level. need change connection string in data source configuration. url="jdbc:mysql://localhost:3306/confluence?autoreconnect=true" increase timeout. property of database. can increase value see if less connection abort. configure connection pool test connection validatiy. done @ pool, not driver level. depend on data source implementa...

C Array address confusion -

suppose have following code: main () { char string[20]; printf(" string %s \n " , &str); } what printf(" string %s \n " ,&str); give? suppose str points location 200, &str give?? not sure want, according question title, might want know couple of things array addresses: main () { char string[20]; char *str = &string; printf("the string addr %p \n" , &string); printf("the string addr %p \n" , &string[0]); printf("the string addr %p \n" , str); printf("the string addr %p \n" , &str[0]); } all these equivalent ways address of "array". address of array address of first element of array.

c++ - Lightest synchronization primitive for worker thread queue -

i implement worker thread work item queuing, , while thinking problem, wanted know if i'm doing best thing. the thread in question have have thread local data (preinitialized @ construction) , loop on work items until condition met. pseudocode: volatile bool run = true; int workerthread(param) { localclassinstance c1 = new c1(); [other initialization] while(true) { [lock] [unqueue work item] [unlock] if([hasworkitem]) { [process data] [postmessage pointer data] } [sleep] if(!run) break; } [uninitialize] return 0; } i guess locking via critical section, queue std::vector or std::queue, maybe there better way. the part sleep doesn't great, there lot of sleep big sleep values, or lot's of locking when sleep value small, , that's unnecessary. but can't think of waitforsingleobject friendly primitive use instead of critical section, ther...

iphone - Save video of last 30 second -

i want develop program in user can capture , save last 30 sec of video after stop button pressed. 1) have control on video recording? 2) how can last 30 sec of video? if can manage images @ rate of 15/fps using uiimagepickercontroller. then make buffer of size 15*30. make queue nsmutablearray remove first frame new frame , add new frame @ end of queue. at end when user press stop button. create video(using custom codac). i not sure can helpful.

asp.net - I'm using Ajax to populate my web page, but the populated HTML isn't working -

i'm using ajax dynamically populate div. have each page content stored in xml files cdata. when user clicks on link navigation bar, ajax loads xml particular page, parses it, , populates div it's content. everything working great, except 1 thing. have jquery modal popup markup loaded page's xml file. .js , .css files jquery plugin loaded, , when hard coded (i.e., not loaded xml), works fine. when it's loaded xml, modal doesn't work. when page loaded xml file- page supposed load html xml file, does, , there's hyperlink when clicked, it's supposed create modal popup window. instead, clicking on link not fire modal popup window. when page hard coded- it's supposed do. a live example at: http://mikemarks.net/clientsites/tabras/ click on "the band", , @ bottom you'll see hyperlink called "demo". clicking on should bring modal popup window, instead can see takes top of page. below markup (notice div id="copy"...

PHP errors shows orange table and 'call stack' -

recently, if have php errors on localhost, i'm seeing layout of orange table , call stack: php error http://www.doheth.co.uk/files/phperror.jpg is caused in particular, php module maybe? or part of php default? i'd go simpler plain message. i'm running php on apache 2 on ubuntu desktop. that's xdebug output. can remove xdebug library extension settings in php.ini , show default php stack traces or can set xdebug.default_enable off , disable xdebug stack traces.

Change the text direction in WPF FlowDocument TableCell -

i'm trying create simple table in wpf flowdocument has rotated text in of cells. in microsoft word can change text direction of table cell haven't been able find way in wpf flowdocument. any idea on how rotate text 90 degrees or change text direction. i've tried few things text doesn't wrap , size desired. any great. thanks look using blockuicontainer , rotatetransform example: <tablecell> <blockuicontainer> <textblock text="hello world"> <textblock.layouttransform> <rotatetransform angle="90"></rotatetransform> </textblock.layouttransform> </textblock> </blockuicontainer> </tablecell>

Identifying a C# or C++ function start in a line count program -

i have program, written in c#, when given c++ or c# file, counts lines in file, counts how many in comments , in designer-generated code blocks. want add ability count how many functions in file , how many lines in functions. can't quite figure out how determine whether line (or series of lines) start of function (or method). at least, function declaration return type followed identifier , argument list. there way determine in c# token valid return type? if not, there way determine whether line of code start of function? need able reliably distinguish like. bool isthere() { ... } from bool ishere = isthere() and isthere() as other function declaration lookalikes. start scanning scopes. need count open braces { , close braces } work way through file, know scope in. need parse // , /* ... */ scan file, can tell when in comment rather being real code. there's #if, have compile code know how interpret these. then need parse text prior scope open braces...

jquery - mouseover mouseout not working properly -

am trying show modal on mouse on , close modal on mouse out. give class div , calling on .hover. but blinking. open close open close. why behavior?? even mouse inside div closing . $('.divclass').hover(function(){ dialog.open() }, function(){ dialog.close() }); i use mouse on , mouseneter .. same behavior blinking..open close... why?? suggesion i suggest try $('.divclass').mouseenter(function() { //dialog open }); $('.divclass').mouseleave(function() { //dialog close });

qt - QUrl does not parse host name with underscore -

today found in qt 4.6, qurl not parse url if host name contains underscore. i understand according standard, underscore not allowed in domain name, however, there urls underscores, subdomain. for example, came across feed's url: http://hero_hki.mysinablog.com/rss.php and qurl(" http://hero_hki.mysinablog.com/rss.php ").tostring() returns "http:/rss.php" firefox , google chrome can access page anyway. (i tested qt 4.6 tp1. not sure whether issue fixed in release, cuz did not have time compile release version on laptop developing toy feed reader.) any advice? :) i read following qt 4.6.0 changelog : qurl's parser more strict when hostnames in urls. qurl enforces std 3 rules: each individual hostname section (between dots) must @ 63 ascii characters in length; only letters, digits, , hyphen character allowed in ascii range; letters outside ascii range follow normal idn rules that means qurl no longer...

SQL Server: Add Columns When In Production Environment -

are there issues/problems related adding new columns (not indexed) table when database online. assume database quite busy on constant basis , table in question has on 1'000'000 records. thanks. well, adding column running system cause interruptions , gobble system resources, @ best, database feel slow, @ worst, people won't able query , results. you need find window of quiet time - e.g. during night or on weekend or something.

VB6 - How to catch exception or error during runtime -

i developed application in vb6. in client's environment raises runtime errors can't reproduce under debugger. there way stacktrace or location of error? created log file and used err.description,err.source gives blank values. please me. method(...... on error goto error_handler ......... error_handler : writetologfile(err.source,err.description) you've done clear err object before writing log file. very, easy do. you'll want detect error has occurred, grab error message before doing anything else. pass error message whatever logging routine you're using. e.g.: dim smsg string on error goto errhandler ' ...code here... exit function errhandler: smsg = "error #" & err.number & ": '" & err.description & "' '" & err.source & "'" gologtheerror smsg

c++ - Convert big endian to little endian when reading from a binary file -

this question has answer here: how convert between big-endian , little-endian values in c++? 28 answers i've been looking around how convert big-endian little-endians. didn't find solve problem. seem there's many way can conversion. anyway following code works ok in big-endian system. how should write conversion function work on little-endian system well? this homework, since systems @ school running big-endian system. it's got curious , wanted make work on home computer also #include <iostream> #include <fstream> using namespace std; int main() { ifstream file; file.open("file.bin", ios::in | ios::binary); if(!file) cerr << "not able read" << endl; else { cout << "opened" << endl; int i_var; double d_var; while(!file.eof()) {...

java - Scrollbar event handling, how to keep number grabbed static -

as title suggests have program scrollbar interface. problem program uses same 3 scrollbars 4 sets of different numbers, once change has been made set of numbers scrollbar remains on same values previous set of numbers float redamount1 = lightdimmer1.getvalue(); float greenamount1 = lightdimmer2.getvalue(); float blueamount1 = lightdimmer3.getvalue(); diffuseswitch[0] = redamount1; diffuseswitch[1] = greenamount1; diffuseswitch[2] = blueamount1; float storecolours1[] = {redamount1,greenamount1,blueamount1}; int storecolourred = (int)storecolours1[0]; int storecolourgreen = (int)storecolours1[1]; int storecolourblue = (int)storecolours1[2]; if(diffuseswitch[0] != storecolourred) { lightdimmer1.setvalue(storecolourred); } this piece of code placed within scrollbars event handling section number trying compare float storecolourred , diffuseswitch[0] keep be...

Extract mail from Exchange and load into Mysql. Perl Win32::OLE or Perl Net::POP3, or try it in Ruby -

my problem this: need determine timestamp of first , last email sent exchange account every day mail exists for. also, each day need rank words appear in each email can report trend words each day. i have 2 approaches i'm considering, , welcome comments , suggestions relating either these approaches or entirely different. i've discounted exporting file outlook csv file include time stamp fields in output, crucial factor me. approach #1 is: use perl , net::pop3 pull messages out of inbox, mung them , insert them mysql database. approach #2 is: use win32:ole attempt act proper exchange client, same end. if use win32::ole you'll have either use outlook automation or cdo libraries. i've done both in previous life, , works, it's bit painful. i'd suggest approach #1 except can't imagine exchange allow fetch sent mail through pop. rather, though, exchange can enabled expose imap interface, , imap should let @ sent mail without running o...

ios - Using OpenSIPS between iPods? -

i'd work on sip project mobile devices. i've seen links siphon, sipdroid , opensips. does opensips allow me make phone calls between 2 ios devices in local network? in other words, i'm trying app voip company. i'd set own sip server , use theirs later. there reason not work? opensips sip server application includes variety of components needed sip infrastructure such registrar, proxy, presence agent etc. opensips not sip user agent (or @ least not 1 that's designed work person end user). means it's not built make or receive calls. if planning on using opensips sip proxy on network combined different piece of software, such sipdroid, acting user agent on mobile devices answer question yes. able configure opensips allow calls between devices on same local network.

Java Spring NtlmProcessingFilter second controller -

<bean id="ntlmfilter" class="org.springframework.security.ui.ntlm.ntlmprocessingfilter"> <security:custom-filter position="ntlm_filter" /> <property name="stripdomain" value="true" /> <property name="defaultdomain" value="company" /> <property name="domaincontroller" value="192.168.1.1" /> <property name="authenticationmanager" ref="_authenticationmanager" /> </bean> may know how set failover second controller? unfortunately, ntlm isn't supported spring 3. if using secondary domain controller critical requirement application, think you'll need jcifs source. jcifs doesn't want support ntlm anymore either. old libraries out there. i've hacked around app invisibly authenticate users whether they're domaina or domainb. it's possible, although possibly bit daunting.

jquery - "if" statement in javascript & displaying result in label -

i have registration form customer selects desired package via dropdownlist. select whether wish avail of multiyear discount choosing yes or no radio buttons. if yes radio button selected, dropdownlist shown (using javascript) selection of years 1-3. i'm not familar @ javascript, , need next when customer selects year 1, 2, 3 multiyear discounts, calculate discount, , show in label beside dropdownlist or hide label if customer has selected no multiyear discounts. here existing code: javascript hide yearly discount dropdownlist <script type='text/javascript'> $(function(){ $('#discountselection').hide(); $('#no').click(function(){ $('#discountselection').hide(); }); $('#yes').click(function(){ $('#discountselection').show(); }); }); </script> and here html code: <td width="343">package*</td> <td colspan="4"> ...

flex - DataGrid edits label instead of data -

i have editable datagrid in flex, data full of numbers. columns have no special itemrenderer, labelfunction, returns number as-is if positive, puts in parentheses if negative, so 27.3 => "27.3" -27.3 => "(27.3)" now, these cells editable. when try edit cell positive number, nothing wrong. if try edit negative number, starts editing (27.3) instead of editing -27.3 . because of this, when edit done, labelfunction evaluated new value in parentheses(i.e., labelfunction called "(30.5)" ), , converting number results in nan . so, want know if can make datagrid edit data in dataprovider instead of label shows. i hope clear condition. please ask if need clarification. thank you. is you're after? example: modifying data passed or received item editor - livedocs.adobe.com (you may still have scroll down once page loads... anchor doesn't seem working me.)

301 Redirect called from Flash crashes Internet Explorer -

i have flash game @ site. there button "download full version" calls javascript function: function download() { window.open('http://mysite.com/goto/game1'); } http://mysite.com/goto/game1 redirects via 301 redirect in .htaccess to http://mystatisticsite.com/goto/mysite/game1 redirects via php header('location: '.$downloadurl); to http://gamesite.com/downloadgame?id=mysite redirects to http://gamesite.com/game.exe and here new opened ie window closes (getting last url, not in middle of redirects). i have added html-link http://mysite.com/goto/game1 , javascript-link onclick="download()" @ same page. both working great, link flash game crashes ie. i have tried call download() "ie developer tools" -> script -> run script, crashes ie too. suppose might strange security ie thing doesn't show "are sure?" closes new window. firefox & chrome download game without problems. one of smart...

asp.net - NHibernate Collection Left Outer Join Where Clause Issue -

it seems when using following nhibernate query, not root entity when left outer join has no records. icriteria critera = session.createcriteria(typeof(entity)); criteria.createcriteria("subtable.property", "property", nhibernate.sqlcommand.jointype.leftouterjoin); criteria.add(expression.not(expression.eq("property", value))); the sql trying generate is: select * basetable left join ( select * subtable property <> value )sub on sub.foreignkey = basetable.primarykey notice clause inside left join's select statement. way if there arent maching sub records, still top level record. seems nhibernate producing following sql. select * basetable left join ( select * subtable )sub on sub.foreignkey = basetable.primarykey sub.property <> value is there anyway achieve first piece of sql? have tried: icriteria critera = session.createcriteria(typeof(entity)); criteria.createcriteria("subtable.property", "...