Posts

Showing posts from July, 2010

WPF UserControl is not filling parent container when bound at runtime -

i have window has stackpanel, , stackpanel has contentcontrol, gets usercontrol bound @ run time. (in mainwindow.xaml) <stackpanel margin="6,14,5,6" grid.row="1"> <contentcontrol name="windowcontent" content="{binding}" horizontalcontentalignment="stretch" verticalcontentalignment="stretch" /> </stackpanel> (in mainwindow.xaml.cs) windowcontent.content = new mainwindowview(); i want usercontrol (and it's children) fill space in stackpanel. i have checked of heights , widths set auto, , horizontal/verticalalignments set stretch, , horizontal/verticalcontentalignments set stretch. is there i'm missing? seems silly question, can't work! thanks the stackpanel container sizes content's minimum size. believe want use grid rather stackpanel; grid attempt use available space. <grid margin="6,14,5,6" grid.row="1"> <contentcontrol name=...

android - Update SurfaceView by passing though some variables to this Class -

i'm still quite new android , java programming , newer draw images dynamically. what update line within activity main . keep drawing separate main therefore added new file , class called panel . when run code fc java.lang.nullpointerexception . when remove draw(); oncreate() don't fc. so form within main.java calculate values want pass through panel use draw figure. this simplified version of code, think fundamentally wrong because first time use more 1 java file. thanks lot help! main.java (simplified) package com.tricky_design.app; import com.tricky_design.app.*; public class main extends activity { private panel drawing; @override public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); drawing = (panel) findviewbyid (r.id.drawing); draw(); } private void draw() { drawing.redraw( 10, 20, 30, 40); } } panel.java package com.tricky_design.app; impo...

javascript - Design pattern to support last-in callbacks (e.g. handling hashchange) -

on web page, have multiple independent plug-ins (for lack of better word) interact location.hash of browser. (i have bit of code keeps work separated, that's irrelevant question.) example, have: // file1.js $(window).bind('hashchange', function(){ ... } ); // file2.js $(window).bind('hashchange', function(){ ... } ); the above works desired when hash changes after page loads. however, need code process whatever hash page loads with. if write code: // file1.js $(window).bind('hashchange', function(){ ... } ).trigger('hashchange'); // file2.js $(window).bind('hashchange', function(){ ... } ).trigger('hashchange'); ...then first set of code run twice. not desirable. what's pattern triggering hashchange event once, after event handlers have been put in place? one option namespace event handlers , triggers: // file1.js $(window).bind('hashchange.file1', function(){...} ).trigger('hashchange.file...

java - How can I add a .jar file dependencies when building it with the command line tool? -

pretty straightforward question. can done without use of ants or maven? (and that, mean command line tool specifically) please notice don't want create uberjar, want archived unit "know" external dependencies are. presuming you're talking command line invocation of javac , you're talking "can provide libraries arguments javac fulfill requirements during compilation". top entry man javac says -classpath classpath sets user class path, overriding user class path in classpath environment variable. if neither classpath or -class- path specified, user class path consists of current directory. see setting class path more details. effectively suspect need say javac -classpath path/to/library1.jar main.java

javascript - jquery change current row class -

i have table rows in it. i want highlight different rows use down or enter key. have keypress event working i'm having issue changing current row original non-highlighted class. i have figured out how change value of next row, need reset value row i'm coming from. this code i'm using change next "tr" highlighted class: $(a).closest("tr").next().toggleclass("lugridrowhighlight"); please let me know. update: i have table 5 rows of data. keypress code move or down table 5 rows "a" represents tablerow element when press down arrow (keycode 40) want change selected row has class lugridrowhighlight lugridrow. want change row below highlight class. right can change row below highlighted class. want change class of row i'm coming from. you can set of "non-highlighted" rows "non-highlighted" class: $('#table_id tr').removeclass("lugridrowhighlight");

php - No require, no include, no url rewriting, yet the script is executed without being in the url -

i trying trace flow of execution in legacy code. have report being accessed http://site.com/?nq=showreport&action=view this puzzle: in index.php there no $_get['nq'] or $_get['action'] (and no $_request either), index.php , or sources includes, not include showreport.php , in .htaccess there no url-rewriting yet, showreport.php gets executed. i have access cpanel (but no apache config file) on server , live code cannot take liberty with. what making happen? should look? update funny thing - sent client link question in status update keep him in loop; minutes latter access revoked , client informed me project cancelled. believe have taken enough care not leave traces code ... i relieved has been taken off me now, itching know was ! thank time , help. there "a hundreds" ways parse url - in various layers (system, httpd server, cgi script). it's not possible answer question information have got provided. you lea...

xml - XSLT Advance a node without using for-each -

pretty green on xslt , 1 of systems i'm working on using generate tables on front end. performing query against db2 instance result set being parsed xml , output similar to... <resultset> <row> <node1></node1> <node2></node2> <etc> </row> <row> </row> </resultset> i'm wondering how advance node without being required use for-each loop. understanding of variables inside of xslt (which limited). at end of page have create table using variables create above. assumed of result set return 3 rows , no more/less. of code xslt follows... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="html"/> <xsl:template match="/"> ....after html population... <tbody> <tr> <td>column</td> <td cla...

java - Manipulate Thread Implementation in JVM -

recently, i've been working on deployment of concurrent objects onto multicore. in sample, use blockingqueue.take() method specification mentions blocking . means method not release enclosing thread's resources such can re-used other concurrent tasks. useful since total number of live threads in jvm instance limited , if application need thousands of live threads, vital able re-use suspended threads. on other hand, jvm uses 1:1 mapping application-level threads os-level threads in java; i.e. each java thread instance becomes underlying os-level thread. the current solution based on java.util.concurrency in java 1.5+. still, need worker threads such scalable large number. now, interested find following answers: is there way replace implementation of java.lang.thread in jvm such can plug own thread implementation? is possible through tweaking c++ sections of thread implementation in jvm , recompiling it? is there library provide way replace classical thread in java?...

c++ - STL lower_bound not spec compliant -

the following code doesn't compile in c++builder 2009 or in visual c++ 2005 when macro _has_iterator_debugging equals 1 if commented out will. appears lower_bound function isn't spec compliant. library swapping arguments. here's excerpt form spec. value should second argument. wrong? note: test code wasn't designed run. designed illustrate library bug. c++ spec excerpt template<class forwarditerator, class t, class compare> forwarditerator lower_bound(forwarditerator first, forwarditerator last, const t& value, compare comp); 25.3.3.1.3 returns: furthermost iterator in range [first, last] such iterator j in range [first, i) following corresponding conditions hold: *j < value or comp(*j, value) != false visual studio error message msg: error c2664: 'double mike::operator ()(const double,const char *) const' : cannot convert parameter 1 'const char [1]' 'const double...

search - ssh command for searching inside files -

some weeks ago 2 of sites have been exploited ftp bruteforce attack corrupting lots of websites files. found out insert following code in js or php files: [trojan code removed irrelevant question.] i want login via ssh , run grep command searching files , giving output ones have code included. any help? i use command find files contain specified string: find /path/ -name "*.ext" -exec grep -l "sting" {} \;

Determine length of SQL Server 2005 XML Data returned -

is there way predermine length of returned xml data sql server. ex: select * products xml raw, root('products') i using sql server 2005. select datalength ( (select * products xml raw, root('products') ) ) it give size in bytes. details, see here: http://msdn.microsoft.com/en-us/library/ms173486(v=sql.90).aspx

java - check if user-entered filename/path is valid -

possible duplicate: is there way in java determine if path valid without attempting create file? i'm trying let user enter path wants saved. open editor, , let him enter path... but how can check if entered string valid path? if user forgets type in "/" @ end - not problem, can manually check that... but cant manually check everything: a space @ end (/folder /) question marks. greater - less symbols (/folder:->/ (back)slashes \folder\ and stuff is there convenient way in java check that? generic java file directory or exists, this answer : file file = new file("c:\\cygwin\\cygwin.bat"); if (!file.isdirectory()) file = file.getparentfile(); if (file.exists()) { ... } however, android (question tagged android), i'll have into...

c++ - How do promotion rules work when the signedness on either side of a binary operator differ? -

consider following programs: // http://ideone.com/4i0dt #include <limits> #include <iostream> int main() { int max = std::numeric_limits<int>::max(); unsigned int 1 = 1; unsigned int result = max + one; std::cout << result; } and // http://ideone.com/ubufz #include <limits> #include <iostream> int main() { unsigned int = 42; int neg = -43; int result = + neg; std::cout << result; } how + operator "know" correct type return? general rule convert of arguments widest type, here there's no clear "winner" between int , unsigned int . in first case, unsigned int must being chosen result of operator+ , because result of 2147483648 . in second case, must choosing int , because result of -1 . yet don't see in general case how decidable. undefined behavior i'm seeing or else? this outlined explicitly in §5/9: many binary operators expect operands of arithmetic o...

ruby - how to format `20134859` into `20 - 13:48:59` -

is there nice (maybe 1 line) way how format 20134859 20 - 13:48:59 ?? i started "20134859".unpack('a2a*').join(' - ') don't know how tackle : thinking if or how can split , join(':') second element return unpack. in 1 line. this works sure there out there i'll more s = "20134859" "#{s[0,2]} - #{s[2,2]}:#{s[4,2]}:#{s[6,2]}" irb(main):001:0> "%s - %s:%s:%s"%"20134859".unpack('a2'*4) => "20 - 13:48:59" or scan borrowed digitalross irb(main):002:0> "%s - %s:%s:%s"%"20134859".scan(/../) => "20 - 13:48:59"

authentication - authenticating mock user when testing rails 3.1 -

i trying test rails 3.1 app (i'm learning testing go) , , stuck how authenticate user since sets session tests aren't using browser session undefined method. using new rails 3.1 has_secure password. how can correctly set , test authentication, test parts of app require user authenticated? my set follows: rspec 2 capybara guard factory_girl thank you! when you're doing controller tests sessions hash last parameter. let's have in session controller tests: post :create, :user => { :email => "blah@blah.com" }, :color => "red" this sends through 2 params through controller: params[:user] , params[:color]. what session variables ? session variables sent through last parameter. if wanted set last_logged_in session variable, change above to: post :create, {:user => { :email => "blah@blah.com" }, :color => "red"}, {:last_logged_in => time.now} notice set braces put around user , color par...

javascript for array rotation -

trying understand how code below brings number between 0-6 var dayinmili = 86400000; var weekinmili = 604800000; //datetime() returns miliseconds since thurs, jan 1 1970, need account week starting monday not thursday. while (currenttime.getday() != 1){ currenttime.settime(currenttime.gettime() - dayinmili); } //we need find number of weeks since beginning of year can // use determine schedule rotation var weeks = math.floor(currenttime.gettime() / weekinmili ); var startpoint = weeks % 7; the modulo operator in last line returns remainder after dividing seven. in case, result assigned startpoint going 0 - 6.

php - Creating randomly generated, secure token and storing in database -

i trying generate unique token every user on site. token generated when user registers, , ideally secure possble. best method of doing allow me display token user? this token not password, , user not going create themselves. if hash , salt upon registration, not able retrieve obviously, because it's hashed , salted. want simple way via php , able display user easily. hashes one-way way reverse hash store original value making hash redundant. if need display value once, store value variable, print on page, , don't save it, that's secure you. another option use database encryption store token, decrypt before displaying user. assuming use mysql might find helpul: mysql encryption

javascript - Jquery top panel -

hey guys have question is... want panel @ top of website stays @ top of web browsers view. here http://webeffectual.com/ in website top panel stays @ top though scroll through website my question can point me in right direction on how or tell me how this? this used on site referenced. specifically, using 'position:fixed; keep in place , z-index: 20; keep on top. #header { background: url("../images/header.png") repeat-x scroll 0 top transparent; position: fixed; width: 100%; z-index: 20; height: 116px; top: 0; margin: 0; padding: 0; } that should started.

PHP regex optional non-matching groups? -

i'm trying make date regex allows years 1900 2099, 19 or 20 optional. i'm there, can't find way allow 19 or 20 optional part. here's i've got: (?:20)(?:19)?[0-9][0-9] testing results: string preg_match ok? ====== ========== =========== 55 yes yes 1955 yes yes 2055 yes yes 201955 yes no can out? this it: ^(?:19|20)?\d{2}$ it says: ^ = start of string (?:19|20)? = match 19 or 20 without capturing, 0 or 1 times \d{2} = 2 decimal digits $ = end of string

.net - EF: Sql Compact 4 and identity -

as know, ef didn't support sql compact identity fields. hasn't changed in sql compact 4 release? yes it has changed there complains performance .

asp.net mvc 3 - How do I inject something into request header for testing? -

i implementing siteminder site, looks key called sm_user in request header. retrieve using function below: public string readuser() { return httpcontext.current.request.headers["sm_user"]; } i wish test if functionality releated function work; have tried unit testing using mock class looking create key sm_user in request header. how can that? i implementing application mvc3. as long using httpcontext.current not able test unit test not have httpcontext.current. try use interface method returning string, readuser(). implement interface in class in application. use interface variable whichever class using method in. in class' default constructor set interface variable value 'new' implementer class. add overload of constructor take parameter of type interface , set parameter interface variable. now in unittest project implement same interface in class. in implementation can pass whatever mock value want test. public interface ireaduser...

linux - How to embed a program inside another using GTK, XLib or any similar? -

i'm trying make "simple" program, list opened programs and, once choose one, opens inside window (like thumbnail may say, can interact). one thing, has 1 way (i can't alter embbeded program , add "socket" or "plug" instance). want able embbed program (e.g. opera, evince, jdownloader etc). does have idea of how can it? if can't done using gtk, can done using x or similar? how? it appears you're looking xembed. tutorial in python , gtk @ http://www.moeraki.com/pygtktutorial/pygtk2tutorial/sec-plugsandsockets.html

drawing - C# - easy to use graphic library -

good day everyone. i have question regarding drawing libraries c#. use xna because it's easy use , convenient in aspects, but... for new project 1 of requirements is not needed install additional libraries or other stuff on client's pc. can't use xna :( can suggest me easy use 2d library? don't need 3d. need 2d premitives , sprite rendering. i looked in dx , gl direction complete overkill... , tell truth have no idea how use neither of it... nor i'm particularly happy learn :) so anyway, easy 2d drawing library can suggest me use? it'd if library written c# , include detailed tutorials / documentation. thank in advance, , sorry if asked before. as alternative try 1 of 2 strategies: static linking ilmerge static linking bit of misnomer in c#. guess better phrase "compiled-in". if have source code library, include directly in project rather referencing external library. ilmerge utility microsoft (found here ) can take mu...

iphone - Display text with one word apearing after another word effect -

i want display label or uitextview text in manner text appear 1 word @ time. mean first display first word second , third , on… can please me? thanks in advance pankaj i'm not familiar enough core-animations, acheived using simple nstimer , on each interval append uilabel's text

How to control a serial device on Android? -

i want develop application whitch control serial device on usb, on linux android. android os 3.1 supports usb host. q1: please let me know how port serial device mounted . i got usb device information when got "dump device state" on dalvik debug monitor. and, checked /dev/tty* on android device using adb. don't know one(/dev/tty??) serial device is. adb shell $ ls /dev/tty* /dev/tty /dev/ttyfiq0 /dev/ttyhs0 /dev/ttyhs2 /dev/ttyhs3 /dev/ttyhs4 /dev/ttys0 /dev/ttys1 /dev/ttys2 /dev/ttys3 q2: please let me know how control serial device on android without root permission. i have application(exe) can control serial device on linux. tried on android , couldn't permission denied. and, tried redirect serial port(maybe) $ ls > /dev/ttys0 couldn't. cannot create /dev/ttys0: permission denied. please let me know how control , access serial device. there great review of in xda forum thread: how talk modem @ commands ...

android - How to create button in my own View -

i'm creating simple game learn game development's basics on android. there class gameview extends view i'm extend view (should extend view? or viewgroup? or other? - there basicly bitmaps in game , may custom wigets) there sprites in view , want create custom "strike" button using imagebutton (should use imagebutton wiget?) how can add wiget without using xml layout(!) //for example simple button class gameview extends view { private button btn; public gamemainview(context context) { super(context); btn = new button(context); } } how display button in game? you should extend viewgroup : when override ondraw canvas . you'll have manually set position of button view if call draw method canvas should display fine. edit: http://developer.android.com/guide/topics/ui/custom-components.html has info need. @ compound controls section.

mysql - Help needed in PHP include function! -

while including php file (eg: include'filename.php';), necessary source file (filename.php) has starting , ending php tags in it? php tags not required. if don't use them, you'll have security , confidentiality issues. can sourcecode of file (config stuff, database access, passwords, ...)!!

iphone - check if file exist -

i want check folder.if found "test.jpeg" in "path" if 's true nothing if false have download picture that uiimage *image = [[uiimage alloc] initwithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:[dico objectforkey:@"photo"]]]]; nomphoto = [[cell.pseudo text]stringbyreplacingoccurrencesofstring:@"\n" withstring:@""];; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask,yes); nsstring *document = [paths objectatindex:0]; filename = [nsstring stringwithformat:@"%@/%@.jpeg",document,nomphoto]; nsdata *data2 = [nsdata datawithdata:uiimagejpegrepresentation(image, 0.1f)];//1.0f = 100% quality [data2 writetofile:filename atomically:yes]; edit: try don't work. path good nsstring* documentspath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring* pict = [documentspath stringbyappendingpathcomponent :@"porto...

database - How to create more than one table in sqlite in android? -

i have 3 tables in db. try out many sample regarding creating db in sqlite, , works out find of them 1 table only.... i try many ways execute queries db.execsql(query) create each table in oncreate errors .. so strategies create more 1 table??? should create many class represent each table extends sqliteopenhelper??? thx here part of class extends sqliteopenhelper public void oncreate(sqlitedatabase db) { // todo auto-generated method stub try{ db.execsql(create_table_1); db.execsql(create_table_2); db.execsql(create_table_3); }catch( exception e){ log.e("dbadapter", e.getmessage().tostring()); } } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub db.execsql("drop table if exists " + table_1); db.execsql("drop table if exists " + table_2); db.execsql("drop table if exists " + table_3); oncreate(d...

xcode - Check web server is up or down in iphone -

i need little here!!! if string 'url' contains address web server, how check whether web server or down? got codes check internet connectivity. if have internet connectivity how know server or not? there better way that? thank you you request, nsurlrequest *therequest=[nsurlrequest requestwithurl:[nsurl urlwithstring:url] cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:20.0]; nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:therequest delegate:self]; now if implement (along other delegate methods) -(void)connectiondidfinishloading:(nsurlconnection *)connection -(void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error you either succes or error.

soap - Extracting the content of a downloaded zipfile without storing it to the disc in PHP -

i'm retrieving zip-archive via soap call in php. there way extract content without writing file first? far found seemed rely on storing data in local file, extract content , delete file again seems superfluous me. there php classes use gzuncompress functions zip decompression. think can take zip file inside string , if not can adapt code purposes. this example of 1 such class (code here under lgpl, requires registration).

xcode - how to make MKAnnotationView has A Number Or Title? -

i have annotationview want give number @ annotationview example: i have 20 annotationview @ mkmapview, want give number each annotationview, user use application can see number, know target annotationview, because there number @ each annotationview have been declared before mkmapview showing how can that? you need customize mkannotationview -- 1 of simplest ways set image property on it. if have 20 numbers, might consider generating 20 images each, storing them in app, , setting image property on annotation view. further -- can customize mkannotationview implementing drawrect, draw requested number view.

joomla1.5 - Email subscription/unsubscribing extension for joomla -

i need simple extension collect email id's users want hear discount offers me , allows unsubscribe mailing list. which simple , best 1 joomla 1.5? i used following components: communicator , jnews , acajoom easy use. of them provided component admin, subscribtion module , plugin integrate subscribtion form article. simple communicator. used more others i hope helpfull.

C++ portable array serialization -

on project work on, have send arrays of float / double , forth on network, i'm using boost.asio network stuff, need communication async, , seemed best (the real one?) out there... the arrays sent floats / doubles, , type known both sides. afaik, there possible problems floating point storage standards + same stuff goes on longs/ints, endians etc. logically, arrays sent dense matrices, handled eigen on 1 end, using blas / [mkl|atlas] , whatnot on other end, quite possible other uses needed, i'm going generic way possible & seems passing around arrays. the key requirement high performance , portability, both client , server possibly run on combination of 32 / 64 bit , communication pretty intense (real-time monitoring, refreshes every-something-seconds client), serialization overhead has minimal. from have found far, 2 big players consider here boost.serialization , google's protobuf. the big pro bs use boost quite alot in project (though unit testing in goo...

ios - I don't know why my Tableview did not push the DetailView when row is selected -

i find sample code , modified code make want. tableview load data plist, works datas displayed in sections, works when row selected, want push detailviewcontroller show more details. grrrr, not work, , don't know why. difference between code , other 1 works fine, icb_sectionedtableviewdemoviewcontroller declared class in appdelegate , don't know if incidence when want push detailviewcontroller. here code of rootcontroller named icb_sectionedtableviewdemoviewcontroller.m // icb_sectionedtableviewdemoviewcontroller.m // icb_sectionedtableviewdemo // // created matt tuzzolo on 12/10/10. // copyright 2010 elc technologies. rights reserved. // #import "icb_sectionedtableviewdemoviewcontroller.h" #import "icb_sectionedtableviewdemoappdelegate.h" #import "detailviewcontroller.h" @implementation icb_sectionedtableviewdemoviewcontroller @synthesize books, sections ; - (void)viewdidload { self.books = [nsmutablearray arraywithcontentso...

java me - How to make the format of a DateField to dd/mm/yyyy? -

there datefield in form , want field value displayed in format dd/mm/yyyy after dismissing ( choosing ) date date-popup. how achieve ? afaik can't change format of date in datefield component in java-me.

Need Java Expert Help on Executing HTTP GET with Cookie -

my problem want use java implement application sends http request website. however, target website needs 1 cookie set: shippingcountry=us if cookie not set returns bad indications. below code segment , null connect(). string urlstring = "http://www1.macys.com/catalog/index.ognc?categoryid=5449&viewall=true"; try{ url url = new url(urlstring); urlconnection connection = url.openconnection(); connection.addrequestproperty("cookie", "shippingcountry=us"); connection.connect(); // create file filewriter fstream = new filewriter("d:/out.txt"); bufferedwriter out = new bufferedwriter(fstream); bufferedreader rd = new bufferedreader(new inputstreamreader(connection.getinputstream())); stringbuffer sb = new stringbuffer(); string line; while ((line = rd.readline()) != null) { out.write(line); } rd.close(); //close output stream out.close(); } can me? ...

xml - Registering a bunch of custom schemas in IntelliJ -

i have bunch of custom xsd schemas in 1 of sub-modules other modules depends on. i'm start heavy xml development i'd know if there way auto-register namespaces inside these schemas intellij idea xml editors? i know can register each namespace 1 one through resources settings, since have many namespaces i'm looking way i.e. register them @ once. i.e. right click schema , select "register namespaces" type of thing... br if schema visible internet - can set cursor on xmlns element, press alt+enter , choose fetch external resource . should automatically added resource. upd. ok, far know can't add pack of xsd's - one. think can more comfortable add them via text editor. open userfolder\.intellijidea10\config\options\other.xml and find there tag <component name="com.intellij.javaee.externalresourcemanagerimpl"> <resource url="urn:ui:com.google.gwt.uibinder" location="d:\..."/> hth ...

Convert 1200 to 1.2K in ruby/rails -

i think there method within ruby or rails can't remember find or how search it, hoping stackoverflow's collective wisdom might help. don't mind writing method this, i'm sure has better solution. number_to_human(1200, :format => '%n%u', :units => { :thousand => 'k' }) # 1200 => 1.2k

c# - Modal popup not generating postback to page -

<ajaxtoolkit:modalpopupextender runat="server" id="modalpopupextender1" cancelcontrolid="btncancel" okcontrolid="btnokay" targetcontrolid="button1" popupcontrolid="panel1" drag="true" backgroundcssclass="modalpopupbg" /> <asp:button id="button1" runat="server" text="test modal popup" onclick="button1_click" /> <br /> <asp:updatepanel id="up" runat="server"> <contenttemplate> <asp:button id="button2" runat="server" text="post back" onclick="button2_click" /> <asp:label id="label1" runat="server" autopostback="true" text="nothing has happened yet..."></asp:label> <asp:panel id="panel1" runat="serve...

c# 4.0 - After first click_event was fired, the second click_event does not fire -

i have 2 linkbuttons added dynamically depending on conditions, whether display 1 or another. these buttons have events also. firstly displayed button's event fires, when conditions change , second button displayed, it's event not fire. source code: //conditions bool wanttochangeblogpost = false; string textboxonchangeid = ""; protected void displayblogpost() { somearraylist[] arr = valuesfromddatabase(); foreach(blogpost y in arr) { string contentstr = y.blogmailingtext;//"some content in mailing"; //div displaying content in webpage system.web.ui.htmlcontrols.htmlgenericcontrol contentdiv = new system.web.ui.htmlcontrols.htmlgenericcontrol("div"); contentdiv.innerhtml = contentstr; //tb changes textbox tbcontent = new textbox(); tbcontent.text = contentstr; tbcontent.autopos...

internet explorer 9 - WymEditor problem with IE 9 -

i added web wymeditor. works fine on firefox , google chrome. problem ie9, when opening page wymeditor, new empty tab opens also. kind of problem iframe, searching in wymeditor code , found : " //this function executed twice, though called once! //but msie needs that, otherwise designmode won't work. //weird." does know how fix it?

php - Joomla: Sending mail takes ages -

i have joomla website , running , need set simple contact form. the problem is, whenever joomla tries send email, page hang minute before response. mail sent fine, delay way big. i've tried setting outgoing mail setting php mail, sendmail , smtp server, same effect. curiously, if edit components/com_contact/controllers/contact.php , replace lines send mail simple call mail(), works fine. using joomla 1.6.5, centos5 php 5.3. anyone experienced similar? in advance! (also, case stackoverflow or serverfault? seems borderline!) updated : narrowed down phpmailer using uniqid generate boundary strings. seems on platforms, uniqid (without more_entropy flag) extremely slow. if else ever comes across same problem, edit libraries/phpmailer/phpmailer.php , in first few lines of createheader() function, pass true second argument of uniqid(). seems have fixed it. narrowed down phpmailer using uniqid generate boundary strings. seems on platforms, uniqid (without more_en...

Using javascript/jquery, validate URL that should have http or https and www -

please advice how validate url should have http or https , www in it thanks amit try use function: (function isurl(s) { var regexp = /http(s?):\/\/www\.[a-za-z0-9\.-]{3,}\.[a-za-z]{3}/; return regexp.test(s); })("https://www.google.com") you may play here

ColdFusion: Using CFINCLUDE in Dreamweaver -

i having trouble displaying <body> data....... </body> in "design" view when include <cfinclude template="file.cfm"> tag in dreamweaver. when include <cfinclude template> tag shows template file, when remove it shows <body> data...... </body> without template in live view? causing <body> data </body> not appear in "design" view <cfinclude template> tag in code? code below........... <head> <title>site name</title> <cfinclude template="header.cfm"> </head> <body> <p><img src="imgname.jpg" alt="" name="home" width="843" height="493" id="home" /></p> </body> its bit difficult see trying achieve here doing cfinclude server side process won't see results of include in dreamweaver design view since not running through server. you'll see in live...

java - guava: best practices with ImmutableList.of(E[]) -

i noticed immutablelist.of(e[]) deprecated in favor of immutablelist.copyof() , obvious reason list can't made immutable if raw array used elsewhere. what if have method returns array, , know fact method doesn't hold onto reference array, , code doesn't hold onto reference array other passing immutablelist.of() ? should i... continue use immutablelist.of(e[]) (seems bad idea since method go away) use collections.unmodifiablelist(arrays.aslist()) use immutablelist.copyof() -- seems best idea performance/resource issues don't arise, otherwise copy unnecessary. immutablelist.of(e[]) not , has never stored array it's given directly (it wouldn't immutable if did, defeat point of class). deprecated naming reasons. if take @ implementation, is: public static <e> immutablelist<e> of(e[] elements) { return copyof(elements); } so advice use immutablelist.copyof() in general. if know you're wrapping array internal use or su...

c# - How to display values in list view -

i have code if(data.resourcepolicy == null) subitems.add(resourcepolicyavailsystemslvi.m_nullstring); else subitems.add(data.resourcepolicy.name); if (data.agentversion == null || data.agentversion.equals("0.0.0.0")) subitems.add(resourcepolicysystemscontrol.m_nullversion); else subitems.add(data.agentversion); subitems.add(data.agentstate.tostring()); i need display resourcepolicyavailsystemslvi.m_nullstring if data.resourcepolicy == null, if (data.resourcepolicy == null) , data.agentversion != null should display resourcepolicyavailsystemslvi.unknown how achieve this, if mean? bool isnullversion=(data.agentversion ?? "0.0.0.0") == "0.0.0.0"; string policy= isnullversion ? resourcepolicyavailsystemslvi.m_nullstring : resourcepolicyavailsystemslvi.unkno...

Audio and video mixing with php or .net -

here queries : [1] audio file mixing need mix (not merge) 2 audio files (.mp3) create 1 single file (.mp3). bit rates of audio files mixed same , bit rate of final mixed file should remain same. [2] create custom video also need create video (.mp4 or .mpg) few different transitions (atleast 5-6) using available images show slide show , audio file played in background. all required achieved using .net , php both. need suggestions related 3rd party tools/libraries ( free or paid ) can used. let me know if more details required. you want investigate http://sox.sourceforge.net/ , command line audio processing utility. can invoke either php or .net (a win binary available) executing via shell. never used it, , it's not clear how , want mix. have consult manpage http://sox.sourceforge.net/sox.html unless need effects it's just: system("sox input1.mp3 input2.mp3 mix output.mp3"); merging audio , images video file quite simple ffmpeg , it...

c++ - Luabind: return_stl_iterator for std::map -

is there way return stl iterator std::map (e.g. std::map<const std::string, int> )? luabind definition example class: class_<someclass>( "someclass" ) .property( "items", &someclass::getitems, return_stl_iterator ) getitems() returns const reference std::map container. when accessing in lua this: for item in some_class.items ... end luabind throws std::runtime_error saying "trying use unregistered class" . iterating on std::map s not possible? (the documentation says containers having begin() , end() work...) perhaps "unregistered class" std::pair<const std::string, int> . can try registering luabind , see if works then?

java - What can cause ReadableByteChannel.close() to block? -

i'm attempting run external process timeout , read of output produces. proving surprisingly herculean task. basic strategy start process using processbuilder , read it's output in main thread. thread farmed off waits timeout expire , (if needed) call close() on readablebytechannel have passed it, call destroy() on process passed it. this appears work fine on process prints infinite output, getting expected asynchronouscloseexception. however, when testing against program sleeps infinitely thread blocks on close: private void terminateprocess() { try { system.out.println("about close readchannel."); readchannel.close(); system.out.println("closed readchannel."); } catch (ioexception e) { // not relevant } } i never see second print statement , test hangs forever. javadoc says close() can block if close in operation, there no other calls close() in code. else can cause this? the reason test hangs f...

canvas fill color, stays black -

i have code draw triangular canvas. can't manage fill color other black. it's stated work ctx.fillstyle doesn't. must missing in code can guys have look? function drawshape(){ // canvas element using dom var canvas = document.getelementbyid('balkboven'); // make sure don't execute when canvas isn't supported if (canvas.getcontext){ // use getcontext use canvas drawing var ctx = canvas.getcontext('2d'); var ctxwidth = window.innerwidth; // filled triangle ctx.canvas.width = window.innerwidth; ctx.beginpath(); ctx.moveto(0,0); ctx.lineto(ctxwidth,0); ctx.lineto(0,105); ctx.fill(); ctx.fillstyle="red" } } fillstyle , strokestyle have set before draw object, not afterwards! think of loading paint onto paintbrush. must before stroke brush! see: http://jsfiddle.net/f8smr/

Problem with XML parsing using jQuery -

the code here supposed place random images xml file layers. works display first image in xml instead of taking random nodes out of xml file. know why is? $(function () { $.ajax({ type: "get", url: "myfakechanneldata.xml", datatype: "xml", success: changechannel }); }); function changechannel(xml) { $('#layer').fadeout(1000); var $limit = 4; $(xml).find("channel").each(function($limit) { var $channel = $(this); var image = $channel.attr('image'); $("#click").click(function () { $(".layer-container").empty(); $(".layer-container").append('<div class="layer1">' + '<img class="" alt="" src="' + image + '" />' + '</div></div>'); $(".layer-container").append('<div class=...

How to parse nested XML file using Javascript? -

<types> <type id='1' name='sport'> <subtypes id='1' name='football' /> <subtypes id='2' name='tennis' /> </type> <type id='2' name='education'> <subtypes id='1' name='school' /> <subtypes id='2' name='university' /> </type> </types> i have previous xml file, , want parse using javascript, how can access subtypes specific type ? i used var x=xmlhttp.responsexml.documentelement.getelementsbytagname("type"); to parse types , how can parse subtypes each type ? var x=xmlhttp.responsexml.documentelement.getelementsbytagname("type"); (var = 0; < x.length; i++) { var subtypes = new array(); var y = x[i].getelementsbytagname("subtypes") (var j = 0; j < y.length; j++){ subtypes.push(y[j]) // or process them...

Ajax with jQuery works in Firefox and gets 404 error in Chrome -

i have ajax request: $.ajax({ datatype: 'json', error: function(result) { alert('error: ' + result.status); }, type: 'get', data: "", success: function(data) { //do stuff }, url: 'info/' + hash + '.json' }); and while in firefox works great, in chrome 404 error, how can fix work in chrome too? try use full url- url: 'http://yoursite.com/yourdirectorys/info/' + hash + '.json or none relative url- url: '/yourdirectorys/info/' + hash + '.json

f# - Use of typeof<_> in active pattern -

given following contrived active pattern: let (|typedef|_|) (typedef:type) (value:obj) = if obj.referenceequals(value, null) none else let typ = value.gettype() if typ.isgenerictype && typ.getgenerictypedefinition() = typedef some(typ.getgenericarguments()) else none the following: let dict = system.collections.generic.dictionary<string,obj>() match dict | typedef typedefof<dictionary<_,_>> typeargs -> printfn "%a" typeargs | _ -> () gives error: unexpected type application in pattern matching. expected '->' or other token. but works: let typ = typedefof<dictionary<_,_>> match dict | typedef typ typeargs -> printfn "%a" typeargs | _ -> () why typedefof (or typeof ) not allowed here? even if you're using parameterized active pattern (where argument expression), compiler parses argument pattern (as opposed expression), syntax more restricted. i think sa...

binary - Difficulty coverting unsigned int16 and unsigned int32 in javascript -

i'm working api sends data in series of base64 strings i'm converting array of bytes. i'm been able parse time values sent in data (year, day, hour etc. api lists datatype unsigned char). i'm using parseint(..., 2) in javascript. the difficulty i'm having converting signed int32 , unsigned int16 decimal values. example, these bit stings voltage , power: voltage (unsigned int16 ) 01101010 00001001 - should around 120.0 power (signed int32) 10101010 00010110 00000000 00000000 - should 0-10 kwh does know how can convert these values? also, wrote simple function convert base64 array of bytes i'm pretty sure correct, above values don't make sense maybe isn't. if that's case, know of plugin converts base64 binary. thanks, tristan i can't see how 0110101000001001 converts 120... it's either 27415 or 2410 depending on endianness

Have 3 tabs where the data is coming from XML and each part has different Data - using jQuery -

so need have 3 divs. when click on each link appropriate div shown info coming xml file. here xml file: <dynamic_div> <div set="1"> <p>lorem ipsum dolor sit amet, consecter adipiscing elit. ut ac ipsum et metus cursus feugiat nec @ purus. in imperdiet lectus eu metus mollis nec mollis sem tincidunt.</p> <p>vestibulum lortis est eu ante bendum convallis ornare dolor consectetur. proin gravida turpis non odio lacinia sit amet elementum justo dapibus.</p> <p>duis eget lacus id lectus adipiscing bibendum @ ut dolor. sed laoreet leo id nunc elementum rhoncus leo bibendum.</p> </div> <div set="2"> <image> <name>image</name> <source>/img/jpeg.jpg</source> <alt>some alt info</alt> </image> </div> <div set="3"> <links> <title>web links</title> <link>...

c# - Get data from another computer using sqlite -

now, planning have 1 main computer , 2 client computer in same domain. want run form application in main computer uses sqlite database. want query data in main computer client computers. suggestions 2 questions of mine: what best way implement server-client structure communicate computers. what best way big datatable main computer uses sqlite. i using .net framework 4.0 form applications. you may share directory, either via netbios (aka samba, linux users) or nfs. however, not idea, since sqlite locks file, may break implementation if filesystem fails whatever reason. might want use real distributed architecture, helping concurrency , load balancing. another way use sqlite, proxy through web service, made this. serve requests, , run in same server want sqlite file, can avoid sharing file/directory containing database

Forcing Django Login Form to take username over 30 characters -

i'm trying use emails usernames, , have got working perfectly. followed these directions: http://www.micahcarrick.com/django-email-authentication.html the problem is, login form still throwing error says username can 30 characters. i've changed input form accept 75 chars , database table well. in django still blocking this. any ideas? update: <form method="post" action="." class="full"> {% csrf_token %} <ul> {% if form.non_field_errors %}<li>{{ form.non_field_errors }}</li>{% endif %} <li> {{ form.username.errors }} <label for="id_username">email/username</label> <input type="text" id="id_username" name="username" maxlength="75"> </li> <li> {{ form.password.errors }} <label for="id_password">{{ form.password.label }}</label> {{ form.password }}...

mercurial - How do I reference the repository's hgrc sections from within my custom hook? -

i've written generic changegroup hook function customize each repository setting hgrc section variables, so: [my_hook_params] name = whatever version = 1.0 how should go doing this? bah. see 4.2 reading configuration files

c# - Is it possible to force TeamCity to create one build for each SVN commit? -

i have follow configuration in teamcity: 2 projects , each project build configurations my problem whenever teamcity building project , new tag created (e.g: tag-5.9.0 revision 533) tag goes “pending” list. if tag created (e.g: tag-5.9.1 revision 539) have 2 tag’s in pending list. what happens teamcity compile newest tag. my output folder supposed contain follow folders: c:\deploy\client\version\tag-5.9.0-rev.533 c:\deploy\client\version\tag-5.9.1-rev.539 however have last committed tag. c:\deploy\client\version\tag-5.9.1-rev.539 is there way force individual build each commit ?? thanks, teamcity version 6.5.1 (build 17834) this feature not implemented answed jetbrains developper, can check post jetbrains developer , have workarounds this. thanks.

java - Which way of setting something when it is null, is faster? -

which faster in java, , why? try { object.dosomething() } catch (nullpointerexception e) { if (object == null) { object = new .....; object.dosomething(); } else throw e; } or if (object == null) { object = new .....; } object.dosomething(); and why? the code called often, , object null first time it's called, don't take cost of thrown npe into account (it happens once). p.s. know second better because of simplicity, readability, etc, , i'd surely go in real software . know evil of premature optimization, no need mention it. i'm merely curious these little details. to answer question, version 1 slower when explodes because creating exceptions quite expensive, not faster version 2 because jvm must null check anyway you're not saving anytime. compiler optimize code it's no faster anyway. also exceptions should reserved exceptional. initial state of null not exceptional. use lazy initialization pattern: someclass ge...

php - testing with phpunit -

i'm trying test controllers. followed guide: http://www.zendcasts.com/unit-testing-a ... s/2010/11/ everything ok until wanted use call in test function: $this->dispatch('/'); thing problem bootstrapping, don't know how resolve this. paste files involved in testing: application.ini = http://pastie.org/2248669 phpunit.xml = <phpunit bootstrap="./application/bootstrap.php" colors="true"> <testsuite name="application test suite"> <directory>./application</directory> </testsuite> <testsuite name="library test suite"> <directory>./library</directory> </testsuite> <filter> <!-- if zend framework inside project's library, uncomment filter --> <whitelist> <directory suffix=".php">../application</directory> <directory suffix=".php">../library/kolcms</directory> <exclude> ...