Posts

Showing posts from March, 2010

algorithm - Given an array of 2n elements of which n are similar and n are different -

algorithm - Given an array of 2n elements of which n are similar and n are different - given array of 2n elements of n elements same , remaining n elements different. write c programme find out value nowadays n times in array i thought in next way- compare a[i] , a[i+1] , compare a[i] , a[i+2] , homecoming element this run in o(n) time..can give improve solution? i going through solutions saying this- declare 2 variables a) count variable maintain track of count of bulk element. majority element. do loop , repeat next steps 4-6 until end of array reached. if current array element equals bulk element, increment count else, if count 0, update bulk element current array element , increment count. else if count not 0 decrement count. do loop , count number of occurrences of bulk element in array, if it's half array size have found bulk element, else there's no bulk element. you can utilize bulk element algorithm basis o(n) sol...

app store - How to get iPad only Customer Reviews on iTunes -

app store - How to get iPad only Customer Reviews on iTunes - i'm wondering if there way ipad client reviews universal application on itunes? can filter version i'd want filter iphone/ipad only. thanks i don't believe possible... might wrong this. app-store itunes review

Android binder security -

Android binder security - is interprocess communication provided binder in android protected against man in middle attacks? there documentation provides info? binder uses capability-based security model. each binder object represents capability; handing object process grants process access capability. perspective, prevent man in middle attacks not handing of import binder object man in middle. if process doesn't handed binder object, can not access in way. regarding "cross-binder reference forgery" issue discussed in paper, if understanding specific scenario talking about, think addendum user space little weaker agree with. create error think of looking @ special c code written servicemanager. formally, consider c++ user space code (consisting in particular of parcel) beingness part of binder architecture. code in particular makes sure deal such attempts @ spoofing when phone call readbinder() , related methods. i don't agree statement flaw...

diff and patch using wrong line ending when creating new files or line end changed -

diff and patch using wrong line ending when creating new files or line end changed - i'm trying create patch using diff, can't patch utilize line end characters used in files when creating new file or alter line ending when file changes it. basically, i'm doing: cp -r dir1 dir3 diff -run dir1 dir2 > dir3\patch.txt cd dir3 patch -p1 < patch.txt all changes between dir1 , dir2 apply, except end of line character new files defaulting cr+lf , file in dir2 uses lf end of line marker. also, files difference between them line end alter not patched in way -- diff doesn't seem see change. so running diff -rq dir2 dir3 gives bunch of files aaa , bbb differ , diff -rwq dir2 dir3 works fine. i'm using diff - gnu diffutils version 2.7 , patch 2.5 unxutils on windows xp. is there way create new , changed files included in patch maintain line ending original file? this works: cp -r dir1 dir3 diff --binary -run dir1 dir2 > dir3\pa...

multithreading - Java, how to make a thread that watches the state of a program? -

multithreading - Java, how to make a thread that watches the state of a program? - i want create thread running in background checking state of programme runs. want know how maintain running , how create thread. executors.newsinglethreadexecutor().submit(new applicationmonitor()); class applicationmonitor implements runnable { public void run() { // monitoring stuff } } applicationmonitor should never homecoming , never allow exceptions thrown. alternately, , maybe more safely, create applicationmonitor 1 check, , set submit() phone call in loop. monitoring can fail, , restarted later: while (true) { seek { future<?> future = executors.newsinglethreadexecutor().submit( new applicationmonitor()); future.get(); // can add together timeout here limit monitoring thread } grab (exception e) { reportmonitoringexception(e); } sleepuntilnextmonitoringcycle(); } finally, can have j...

math - How to manipulate mathematical symbols? -

math - How to manipulate mathematical symbols? - this more of "educational" question. :) although, eventually. so, let's got equation. kind of equation, long it's not ridiculous , human @ math, solve it. let's say... 0 = (x-1)(x+2) or... y = (x^2), y = 1/x or sine functions, etc. basically, doing math did in school. the question is, how write computer programme solve this? know it's possible, because programs mathematica, maple, etc, have been doing decades! can't find documentation on how create simple equation solver. i don't expect answers tell me "this how it" because of course of study such thing entire big program, not code snippet. but general overview, or links documents? great! :) especially kind of info structures , algorithms needed. failing that, i'll have figure out how solve equations, , encode that. takes literally months right (i've done sort of thing before, formalising own thinking pro...

recursion - Php recursive directory listing flow -

recursion - Php recursive directory listing flow - i have various projects going on need document , display pictorial progress on. set project\year\month\pic.jpg... planning on having in root of section index.php list directorys , create link when clicked pass project\ directory listing.php page. listing php read contents of project\ files in directory create initial page content. listing.php read \project\year\month\ directorys in order. @ bottom of listing.php page href=year\month. if 1 of links year-month clicked open page view pictures in abc-123 order. have dropdown selecting other year/month's , next/previous button. i readdir / scandir part , can list single dir eaisly enough. have no thought how create callback work or if/how create dynamic global arrays store info in. memory comsumption isnt troubling me directorys 2-3 deep couple projects have 40k or images. average looks 3k or less photos if php bad way of doing way listing.php type page current ,...

java me - Switching between LWUIT Form and LCDUI Form -

java me - Switching between LWUIT Form and LCDUI Form - i have built lwuit ui class contains midlet. using theme midlet. need jump lcdui form contains lcdui controls , need set display lcdui form. possible jump lwuit form lcdui form , set display lcdui form ? if possible how ? i used next code show both lwuit form , lcdui form. see sample code. com.sun.lwuit.form lwuitform; protected void startapp() throws midletstatechangeexception { display.init(this); lwuitform = new com.sun.lwuit.form("lwuit form"); lwuitform.addcomponent(new textfield("")); final midlet midlet = this; final command abtuscmd = new command("next") { public void actionperformed(actionevent evt) { javax.microedition.lcdui.form frm = new javax.microedition.lcdui.form("lcdui form"); stringitem item = new stringitem("text", "sample text"); frm.append(item); final javax...

How do I import variable packages in Python like using variable variables ($$) in PHP? -

How do I import variable packages in Python like using variable variables ($$) in PHP? - i want import bundle depending on value user chooses. the default file1.py : from files import file1 if user chooses file2 , should : from files import file2 in php, can using variable variables: class="lang-php prettyprint-override"> $file_name = 'file1'; include($$file_name); class="lang-php prettyprint-override"> $file_name = 'file2'; include($$file_name); how can in python? python doesn't have feature that's straight equivalent php's "variable variables". "variable variable"'s value (or value of other expression) can utilize eval function. foo = "hello world" print eval("foo") however, can't used in import statement. it possible utilize __import__ function import using variable. package = "os" name = "path" imported = ...

umbraco - Cannot open database "UmbracoDB.myDB" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE' -

umbraco - Cannot open database "UmbracoDB.myDB" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE' - i receiving next error: cannot open database "umbracodb.mydb" requested login. login failed. login failed user 'nt authority\network service'. previously error running fine. database running user instance described @ http://our.umbraco.org/wiki/install-and-setup/using-umbraco-with-embeded-sql-database-(sqlexpress-user-instance). seemed cause issue attaching db sql server studio express , unattaching 1 time again (i resetting umbraco admin password). nil changed or different (that aware of). i presume kind of authentication error or database owner error. have tried adding user described @ http://blog.sqlauthority.com/2009/08/20/sql-server-fix-error-cannot-open-database-requested-by-the-login-the-login-failed-login-failed-for-user-nt-authoritynetwork-service/ did not work me. have tried few other...

What is the Android equivalent to iOS / iPhone's UICatalog sample app? -

What is the Android equivalent to iOS / iPhone's UICatalog sample app? - i'm looking app demos of android ui elements. similar following: http://developer.apple.com/library/ios/#samplecode/uicatalog/introduction/intro.html any ideas? if asking api demos, follow link http://developer.android.com/resources/samples/apidemos/index.html and can find api demos application in android emulator too. and source code them shipped platforms itself. can see source in android sdk folder-> platforms->android x.x->samples iphone android ios user-interface

.net - Issue with running a bat file programatically from a com interop dll on classic asp -

.net - Issue with running a bat file programatically from a com interop dll on classic asp - i facing predicament running bat file using system.diagnostics.process object. have code running bat file in class library compiled dll. made dll com interoperable registering using compile time. signed using strong key, exported type library , set dll gac using regasm , gacutil commands. created object of specific class in dll has method bat file execution using server.createobject method in vbscript. called method bat execution. method gets invoked alright cmd prompt not popping nor bat file beingness executed. checked see if problem interop dll dll worked fine vb6 code. can help me issue? not sure if permission issue on iis server. or cmd executions not possible via vbscript on asp dlls? thanks, geo. apparently may need run cmd , inject input it: // total file path string strfilepath = "c:\\temp\\test.bat"; // create processinfo object system.diagnostics.proce...

ruby on rails - Apatana Studio 3 Shortcut For File Navigation -

ruby on rails - Apatana Studio 3 Shortcut For File Navigation - this driving me nuts....in aptana 3, shortcut navigate file?? ctrl + o navigates within file, how open file? the reply question ctrl+t ** edit ** if press ctrl+shift+l twice land on shortcut preferences ruby-on-rails aptana

python - What's the correct include path in this template? -

python - What's the correct include path in this template? - i editing file: /templates/account/base.html and in want include: /templates/profiles/includes/sub_nav.html i have tried following: {% block subnav %}{% include "profiles/includes/sub_nav.html"%}{% endblock %} result: no error no inclusion of side bar and have tried {% block subnav %}{% include "../profiles/includes/sub_nav.html"%}{% endblock %} result: template error page: exception value: caught templatedoesnotexist while rendering: ../profiles/includes/sub_nav.html with next line highlighted: {% extends "account/base.html" %} thus, below, should xxx contained /templates/account/base.html? {% block subnav %}{% include "xxx/sub_nav.html"%}{% endblock %} "result: no error no inclusion of side bar". logical conclusion your sub_nav.html has problems. or base.html has problem include working. must html, css or django tags. ...

iphone - PresentModel View Controller Problem -

iphone - PresentModel View Controller Problem - hi every 1 have have problem nowadays model view controller. here's scenario: this navigation bar application have uiviewcontroller class in add together class of uiview controller using statement [self.view addsubview:controllerclass] ; in controllerclass have insert tab bar @ bottom , write delegates on each tab bar click i'll add together uiviewcontroller class subview i'll create height or frame controller (0,0,320,369) . tab bar shown through out when click on different tabs. by clicking on first tab scannerviewcontroller add together subview. there gallery button in view. when user clicks on presentmodel view controller insert , hide navigation bar when select image gallery , create navigation bar hidden =no , dosen't work , tab bar on bottom disappeared. it sounds you're abusing tab bar construct. each tab on tab bar should have it's own uinavigationcontroller rather sharing 1 con...

caching - ASP.NET - Cache & Filter or SQL w/ a large results set? -

caching - ASP.NET - Cache & Filter or SQL w/ a large results set? - i have big set of relatively static info (50,000+ rows) needs accessed .net mvc application on regular basis. each phone call info needs 5-20 rows @ time - filtered on 1 or 2 columns (usually "starts with" filter.) i'm trying determine if has info on performance benefits of using filtered .net dataview (rowfilter) cached vs. hitting database each time. saves database - how efficient filtered dataviews? putting undue stress on web server? a cache should used small, frequently-accessed bits of data, when same info required on , over. since getting different rows each time big dataset, bet database faster @ rummaging through 50,000+ rows couple of rows if table indexed. best way tell fire proof-of-concept both approaches , compare speed , amount of memory used between 2 approaches, , justice whether each falls in line requirements. hope helps! asp.net-mvc caching

android - blur and emboss an image -

android - blur and emboss an image - i'm working on android application, , have drawable i'm loading source image. on image want create image blur , embross ,i have read how alter colors of drawable in android? can give me advice?thank you edit:i have emboss image,but cannot bluish image,can give me blue public bitmap fudiao(bitmap bmporiginal) { int width, height, r,g, b, c,a, gry,c1,a1,r1,g1,b1,red,green,blue; height = bmporiginal.getheight(); width = bmporiginal.getwidth(); int depth = 30; bitmap bmpsephia = bitmap.createbitmap(width, height, bitmap.config.rgb_565); canvas canvas = new canvas(bmpsephia); paint paint = new paint(); // colormatrix cm = new colormatrix(); // cm.setscale(.3f, .3f, .3f, 1.0f); // colormatrixcolorfilter f = new colormatrixcolorfilter(cm); // paint.setcolorfilter(f); canvas.drawbitmap(bmporiginal, 0, 0, null); for(int y=1; y< height-1; y...

Spring 3, rest controller, mvc:annotation-driven, jdk 6 but spring refuses to send back xml responses -

Spring 3, rest controller, mvc:annotation-driven, jdk 6 but spring refuses to send back xml responses - this has been driving me nuts days now. i've read understand have 2 choices when comes auto-handling content spring mvc. can utilize messageconverters autodetect request through @requestbody , response through @responsebody, or (but not and!)... can utilize view resolvers autodetect based on various other criteria such request extensions. i'm trying utilize @requestbody , @responsebody. i've read multiple posts here , blogs , cannot see why not working. spring-servlet.xml file contains: <context:annotation-config /> <context:component-scan base-package="au.com.mypackage.service" /> <mvc:annotation-driven /> my controller looks this: @controller public class mycontroller { @requestmapping(value = "/data/{id}", method=requestmethod.get) @responsebody public bean getdata(@pathvariable string id) { bean...

c++ why doesn't a copy of an object allow access to a private variable of the original? -

c++ why doesn't a copy of an object allow access to a private variable of the original? - for example, number operator+(number a, number b) { homecoming number(a.x + b.x); } would cause kind of "unable access private fellow member error". understand if don't pass reference, number a, , number b copied on stack , used in body of function. however, don't see why not allow access originals' private members. how misunderstanding concept of object? how come friend , fellow member function don't need pass reference? operator+ unbound function, i.e. not fellow member of number so, rule, has no implicit access private members. the rule not affected passing number objects value or reference. access protection applied every access number object, if private, stack-based copy. there @ to the lowest degree 3 ways out: declare number operator+(number, number) friend of number add public getter x variable accessible. implement...

activerecord - Rails 3: how to update has_one and has_many pointing to the same table at the same time -

activerecord - Rails 3: how to update has_one and has_many pointing to the same table at the same time - thanks helping out noob. have next relationships in 2 models: class reader < activerecord::base has_many :books, :dependent => :destroy has_one :last_book, :class_name => "book" end class book < activerecord::base belongs_to :reader end i want last_book recent book associated reader. right in book controller creating book follows similar code in update def create @reader = reader.find(params[:reader_id]) @book = @reader.books.new (params[:book]) @reader.last_data = @book end i think ends writing book twice database. there cleaner/more efficient way this? has_one allows :order clause, this: class reader < activerecord::base has_many :books, :dependent => :destroy has_one :last_book, :class_name => "book", :order => "books.created_at desc" end then in controller action drop 1 of ...

Why arrows in jQuery UI Datepicker make wrong change of the date? -

Why arrows in jQuery UI Datepicker make wrong change of the date? - i having standard jquery ui datepicker this: $('.text_input').live('focus', function () { $(this).datepicker('destroy').datepicker({dateformat: 'dd.mm.yy'}); }); in input date, e.g. 14.7.2010. when click input, datepicker appears , shows selected date filled in input. however, when seek navigate using left , right arrows @ top of datepicker, unusual thing happens - changes date in datepicker nov 1899 or jan 1900, depending arrow click. anybody has thought why happening ? , how prepare ? using jquery ui 1.8.14 , jquery 1.4.2. don't destroy it. :) $('.text_input').live('focus', function() { $(this).datepicker({ dateformat: 'dd.mm.yy' }); }); jquery jquery-ui datepicker

When would you store metadata on a filesystem rather than a database? -

When would you store metadata on a filesystem rather than a database? - i want store documents metadata in web application such person can view them in hierarchy. i gather typical way create database entry each document, store metadata in database , store files on filesystem. it seems much simpler , faster store both documents , metadata on filesystem. directory might this $ ls subdirectory .json subsubdirectory bar.pdf bar.json foo.tex foo.json and metadata json files (or whatever format use). render subdirectory/foo.html based on contents of subdirectory/foo.json. , render subdirectory.html based on contents of subdirectory/.json , contents of other kid json files. the main disadvantage i've thought of might harder search based on contents of metadata file (though search based on filesystem-level metadata). other disadvantages there? , if people utilize approach, why don't hear it? edit: i'm not concerned searching; if build sort of searching, it'...

Using Galleria jQuery plugin with an asp.net ListView -

Using Galleria jQuery plugin with an asp.net ListView - i trying utilize galleria asp.net listview gets image sources database after images uploaded. next listview : <div id="photoalbumdiv" class="photoalbumdiv"> <asp:listview id="listview1" runat="server" datakeynames="id" > <alternatingitemtemplate> <td runat="server" style=""> </td> </alternatingitemtemplate> <edititemtemplate> <td runat="server" style=""> </td> </edititemtemplate> <emptydatatemplate> <table style=""> <tr> <td> no info returned.</td> </tr> </table...

java - how to check if a response is in xml format instead of HTML? -

java - how to check if a response is in xml format instead of HTML? - im working server sends me xml responds. when server lack or reports me sending me html page (it html page informing error) didn't expect , xml parser crashed. im using defaulthttpclient() , send header mhttprequest.setheader("accept", "text/xml"); proper way ensure got xml (or other specific format) response? as kristian suggested, see if provides different content-type when html emitted. failing check <?xml... line, apposed doctype or whatever on html page. java android xml http

sql server 2008 - Schema Binding with Computed Column Function -

sql server 2008 - Schema Binding with Computed Column Function - i have table tablea computed column fielda bound function returns float. function getfielda calls 2 sub functions. i have view includes getfielda function not computed column value field. tried add together index view said required getfielda schema bound in order have index on it, changed schema bound (which involved removing computed column) when went seek readd computed column said in order utilize getfielda schema bound must removed. is there way have computed column schema bound function or need rework how im getting field in order able have view index? it's impossible add together index on computed column, unless it's deterministic. "deterministic functions homecoming same result time called specific set of input values , given same state of database. nondeterministic functions may homecoming different results each time called specific set of input values if database state a...

command line - Creating a large file from Windows' commandline -

command line - Creating a large file from Windows' commandline - on mac can create random 5gb file this dd if=dev/urandom of=~/random5gb bs=1000000 count=5000 is there equivalent command in windows xp? want able run in '.bat' file i'm creating. try fsutil file createnew <filename> <length> windows command-line batch-file

Using :before CSS pseudo element to add image to modal -

Using :before CSS pseudo element to add image to modal - i have css class modal absolutely positioned, z-indexed above it's parent, , nicely positioned jquery. want add together caret image (^) top of modal box , looking @ using :before css pseudo selector cleanly. the image needs absolutely positioned , z-indexed above modal, haven't found way add together appropriate class image in content attribute: .modal:before{ content:url('blackcarrot.png') /* class modalcarrot ??*/ } .modalcarrot{ position:absolute; left:50%; margin-left:-8px; top:-16px; } second best option- can add together styles inline in content attribute? http://caniuse.com/#search=:after :after , :before content okay use, they're supported in every major browser 5 versions back, except in ie, supported 3 versions safe utilize on browsers. is you're looking for? .modal:after{ content:url('blackcarrot.png'); /* class modalcarrot ??*/ ...

c# - How to enable inPrivate mode in the WebBrowser control -

c# - How to enable inPrivate mode in the WebBrowser control - i have create ie type browser features on it. in visual studio, have component named "webbrowser" uses current ie browser installed in user's pc. however, unable find property enables access inprivate mode hoped exposed control. is there way utilize inprivate mode webbrowser control, or have create own browser supports this? according ericlaw's answers on related question, sounds might not possible. you might stuck making own command or looking alternative one. c# winforms web-applications webbrowser-control

c# - spring.net nhibernate session/transaction per request -

c# - spring.net nhibernate session/transaction per request - does spring.net have back upwards (integration) nhibernate eneble per request isession , transactions? i foung this blog, bit old 1 want know if things have moved forwards bit , may integrated in spring framework , can set configuration? yes has, it's called "open session in view". transaction back upwards available too, it's not automatically "one transaction per request". i think place start the nhibernate quickstart in spring documentation. both concepts explained there. only noticed asp.net mvc tag; think should work, i'm not quite sure. if you're using asp.net mvc 3, should utilize spring 1.3.2, due release soon. c# asp.net-mvc nhibernate spring.net

php - Fatal error: Could not convert the script from the detected encoding "UTF-32LE" -

php - Fatal error: Could not convert the script from the detected encoding "UTF-32LE" - copied working website 1 server another, i'm getting error - browsing main page of website. fatal error: not convert script detected encoding "utf-32le" compatible encoding in /usr/local/share/zf/library/zend/application.php on line 320 and global httpd-error.log shows, server runnign other vhosts, pretty sure it's related above error. [notice] kid pid 8012 exit signal segmentation fault (11) the servers both run freebsd 8.1, 1 32bit (with error) , other 64bit. updated 1 having error newest versions of apache , php, available in ports-catalog. error occurred before update. please note that, intention of re-create utilize big parts new website, have been doing deletion of files, should not have impact on error above. to solve had remove again, download tar website origin server mac. extracted on mac, , uploaded new server ftp - error go...

c# - Can ProtoBuf-Net deserialize to a flat class? -

c# - Can ProtoBuf-Net deserialize to a flat class? - protobuf-net uses nested protobuf constructs back upwards inheritance. however, can made force properties flat target class has same properties inherited "serialized" version? see test illustration below. needless result of flat namespace null both properties. possible solution: re-create info flat.b first on property property basis. note: not prefered option. using system; namespace hierarchy { using protobuf; [protocontract] public class { [protomember(1)] public string prop1 { get; set; } } [protocontract] public class b : { public b() { } [protomember(1)] public string prop2 { get; set; } public override string tostring() { homecoming "prop1=" + prop1 + ", prop2=" + prop2; } } } namespace flat { using protobuf; [protocontract] p...

flex - Capture Event Generated By Value Object in Component -

flex - Capture Event Generated By Value Object in Component - let me seek explain best can. i have component containing info grid next info grid column <mx:datagridcolumn datafield="email" headertext="email address"> <mx:itemrenderer> <mx:component> <mx:vbox width="100%" horizontalscrollpolicy="off" verticalscrollpolicy="off" horizontalalign="center"> <mx:textinput id="tiemailaddress" width="95%" text="{data.email}" invalid="{data.isnotvalidemail(event);}" valid="{data.isvalidemail(event);}"/> <mx:emailvalidator id="validatoremailadd...

CSS center item with position:relative; -

CSS center item with position:relative; - i've got question css gurus out there! i've got menu appears on hover on absolutely positioned div. of menu items have relatively positioned because absolutely div appear multiple times on page , appear in multiple sizes in 1 instance. how center multiple items 'position:relative' both vertically , horizontally when won't know the size of parent div? i know 'position:absolute' trick negative margins situation calls different. your help hugely appreciated. edit: here's code: .outercase { position : absolute; width : 100%; height : 100%; text-align: center; } .inneritem { width : 38px; height : 38px; display: inline-block; } i've got center items horizontally getting vertical that's beingness bit elusive. thanks! alternatively, may utilize css3 flexible box model. it's great way create flexible layouts can applied center content so: #p...

android - Listview , open new activity onClick -

android - Listview , open new activity onClick - hey i've looked hours trying find solution this, goal have listview when opens open activity. got able open activity when click how each list item open own activity? terribly sorry if question answered links found doesn't describe code doing [yes newbie :)] this code im using @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); string[] countries = getresources().getstringarray(r.array.countries_array); setlistadapter(new arrayadapter<string>(this, r.layout.newfile, countries)); listview lv = getlistview(); lv.settextfilterenabled(true); lv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { // when clicked, show toast textview text intent myintent = new intent(view.getcontext(), html_file.class); ...

internet explorer 7 - Double scroll in ie 7 with ul -

internet explorer 7 - Double scroll in ie 7 with ul - i have problem double scroll in ie 7 ul/li tree. can in case remove scroll generated ie real scroll donot work- doesnot scroll tree of elements. short version of tree: should scroll? <ul id="pref1_tree" class="tree ui-widget-daredevel-checkboxtree ui-widget ui-widget content"> <li id="rootmultiselect" class="expanded"> <span class="ui-icon ui-icon-triangle-1-se"></span> <input id="pref1_chb_0" type="checkbox" value="0" name="pref1_lvlchb"> <label id="pref1_label_0">Российская Федерация</label> <ul style=""> <li id="rootmultiselect" class="expanded"> <li id="rootmultiselect" class="expanded"> <li id="rootmultiselect" class="expanded"> <li id="ro...

ruby on rails - delete_all vs destroy_all? -

ruby on rails - delete_all vs destroy_all? - i looking best approach delete records table. instance, have user user id across many tables. want delete user , every record has id in tables. u = user.find_by_name('johnboy') u.usage_indexes.destroy_all u.sources.destroy_all u.user_stats.destroy_all u.delete this works , removes references of user tables, heard destroy_all process heavy, tried delete_all . removes user own user table , id other tables made null, leaves records intact in them. can share right process performing task this? i see destroy_all calls destroy function on associated objects want confirm right approach. you right. if want delete user , associated objects -> destroy_all however, if want delete user without suppressing associated objects -> delete_all according post : rails :dependent => :destroy vs :dependent => :delete_all destroy / destroy_all : associated objects destroyed alongside object calling destroy metho...

Passing parameter to invoked event handler, i.e. element.onchange(); javascript -

Passing parameter to invoked event handler, i.e. element.onchange(); javascript - i have function this: function dosomething() { // select element } document.getelementbyid("selectel").onchange = dosomething; // phone call onchange event document.getelementbyid("selectel").onchange(); now, recognize phone call function straight , pass parameter. i'd know if it's possible pass parameter onchange() event handler after it's evoked. tried document.getelementbyid("selectel").onchange("hello"); , didn't work. thank help. you need bind parameter function. i'm going re-create paste function ext-js lets that. warning: not beginners /** * create new function provided <code>fn</code>, alter <code>this</code> provided scope, optionally * overrides arguments call. (defaults arguments passed caller) * * @param {function} fn function delegate. * @param {object} scope (optio...

html - IE9 adjacent image overlaps/appears in the pop-up image -

html - IE9 adjacent image overlaps/appears in the pop-up image - i using css hover create pop-up image when smaller image moused over. works fine in firefox , chrome in ie9 adjacent(side) image appears overlap pop-up image. thank you! css: .thumbnail{ position: relative; z-index: 0; float: left; clear: both; text-decoration: none; } .thumbnail:hover{ background-color: transparent; z-index: 50; text-decoration: none; } .thumbnail span{ position: absolute; background-color: white; padding: 0px; left: -1000px; border: 1px ridge gray; visibility: hidden; text-decoration: none; text-align:center; } .bdecor{ background-color:#cd2626; text-align: center; text-decoration: none; font-size: 16px; font-family:calibri; color: white; padding-bottom: 1px; } /*css enlarged image*/ .thumbnail span img{ border-width: 0; padding: 0px; width: 180px; height: 200px; text...

draw smooth line between html elements using Jquery? -

draw smooth line between html elements using Jquery? - i wants draw smooth line between html element using jquery. jquery has plugins draw smooth line using jquery ? have used svg plugin not supported in ie7,ie8. have used div draw line has many jaggies. any thought gratly appriciated. plugin should back upwards atleast ie7 , greter version, mozila , crome. thanks. http://servut.us/akx/stackoverflow/jquery-canvas-lines.html wants made above link. problem above link is not working in ie 7,8. there complicated ways accomplish this, want utilize html5 canvas , methods moveto , lineto . if need back upwards older browsers without canvas back upwards (like ie7, , ie8), can utilize canvas polyfill help accomplish that. jquery jquery-ui jquery-plugins javascript jquery-layout

javascript - how to add attribute to each list item -

javascript - how to add attribute to each list item - i have string looks this: .a,.b,.c,.d i add together value attribute of every 1 of these items. i used before add together value items alter height: $(this).attr("heightwert", parseint($(this).css('height'))); i utilize attribute sorting. if know how sort dynamical height of elements great too. this utilize sorting: onclick="$('ul.dataa&gt;li').tsort('a',{attr:'heightwert',order:'desc'});" this written assumption .a,.b,.c,.d reference class-names of elements on page, though reading comments follow posting reply i'm not sure is, indeed, case. however, on original assumption, next seems (i thought) asked: $('.a, .b, .c, .d').attr('data-heightwert', function(i, val) { homecoming $(this).height(); }); js fiddle demo. please note i'm using attribute data-heightwert rather heightwert invalid attrib...

xcode - How do I automatically perform unit tests on each build? -

xcode - How do I automatically perform unit tests on each build? - how automatically perform unit tests on each build? i tried add together unit tests target project target dependency, doesn't seem run actual tests. set test after build build setting yes. take product > build > build testing build project , run tests. xcode 5 update xcode 5 not back upwards test after build build setting. don't know of way automatically run tests on each build in xcode 5. os x menu bar take product > test or press command + u run unit tests in xcode 5. xcode unit-testing xcode4 dependencies

C# Catch Exception -

C# Catch Exception - which exception utilize in try/catch find out when user has inputted info in wrong format? example: try { string s = textbox1.text; // user inputs int // input error messagebox.show(s); } catch(what exception) { messagebox.show("input in wrong format"); } thanks don't this. it's misuse of exception handling. attempting considered coding exception, anti-pattern. an exception sounds like, an exception norm. it's defined either haven't accounted for, or can't business relationship through traditional validation. in situation, can business relationship format issue ahead of time. if know there possiblity inputted info in wrong format, check case first. e.g. if(!validatetext(textbox1.text)) // false validation method, you'd create. { // input wrong. } else { // process. } c# try-catch

arrays - C# What is the difference between byte[] and char[] -

arrays - C# What is the difference between byte[] and char[] - what difference between byte[] , char[]? differentiate more usage perspective. can used interchangeably? byte represents byte. 8-bits wide. char represents unicode character, , 2 bytes (i.e. 16 bits) wide. utilize byte[] if you're dealing raw bytes, , char[] (or improve yet string ) if you're dealing strings. c# arrays

list - Dealing with the surprising lack of ParList in scala.collections.parallel -

list - Dealing with the surprising lack of ParList in scala.collections.parallel - so scala 2.9 turned in debian testing, bringing newfangled parallel collections it. suppose have code equivalent to def expensivefunction(x:int):int = {...} def process(s:list[int]):list[int} = s.map(expensivefunction) now teeny bit i'd gleaned parallel collections before docs turned on machine, expecting parallelize switching list parlist ... surprise, there isn't one! (just parvector , parmap , parset ...). as workround, (or one-line equivalent) seems work enough: def process(s:list[int]):list[int} = { val ps=scala.collection.parallel.immutable.parvector()++s val pr=ps.map(expensivefunction) list()++pr } yielding approximately x3 performance improvement in test code , achieving massively higher cpu usage (quad core plus hyperthreading i7). seems kind of clunky. my question sort of aggregated: why isn't there parlist ? given there isn't p...

php - Perplexingly included meta http-equiv headers -

php - Perplexingly included meta http-equiv headers - my friend runs on standard lamp configuration , lately users started experiencing delays. alleviate issue suggested should set client-side caching in order lessen number of http requests. i, however, nail upon don't understand. header of main html page concocted php script goes this: <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="content-language" content="cs" /> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="author" content="orsi, cjorsi@gmail.com, http://orsi.ic.cz" /> <meta name="copyright" content="© 2010 orsi" /> <meta name="description" content="<?php popis();?>" /> <meta name="keywords" content="<?php klicova_slova();?>" /> <meta name="robots" content=...

php - Independent getter/setter methods, or combined? -

php - Independent getter/setter methods, or combined? - while working on project, i've been making changes , browsing around existing framework api docs insight. while perusing kohana docs, noticed getters/setters of given class typically combined: public function someproperty($value = null){ if(is_null($value){ homecoming $this->_someproperty; } $this->_someproperty = $value; homecoming $this; } rather than: public function setsomeproperty($value){ $this->_someproperty = $value; homecoming $this; } public function getsomeproperty(){ homecoming $this->_someproperty; } is there value in doing (the former), beyond lessening method count of given class? under understanding methods (functions in general) should more descriptive of action. other experienced developers cringe, tiny bit, when see this? i surprised see popular framework utilize such conventions (i haven't used kohana of course) i consider...

asp.net - FileStream.Write Upload a image, but damaged or corrupted -

asp.net - FileStream.Write Upload a image, but damaged or corrupted - hi utilize filestream upload file web server, using asp.net, upload works fine when utilize chrome or firefox, when utilize ie, file damaged or corrupted, not open it. here code seek { using (filestream = new filestream(savelocation, filemode.create, fileaccess.write)) { var length = 4096; var bytesread = 0; var buffer = new byte[length]; { bytesread = request.inputstream.read(buffer, 0, length); filestream.write(buffer, 0, bytesread); } while (bytesread > 0); filestream.flush(); } } grab { result = "{\"success\":\"false\"}"; } { if (filestream != null) filestream.close(); } i debugg...

c# - Cannot find and add SurfaceUserControl -

c# - Cannot find and add SurfaceUserControl - i can create usercontrol , add together textbox in surface environment. here sample code: <usercontrol x:class="scatterviewsizingsample.fixedsizechild" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:scatterviewsizingsample" mc:ignorable="d" local:popupwindow.initialsizerequest="300,250" d:designheight="300" d:designwidth="250"> <grid background="mediumseagreen"> <textbox horizontalalignment="left" name="textbox1" verticalalignment="top"/> </grid> </userc...

Plugin eclipse auto start in product -

Plugin eclipse auto start in product - i trying create plugin loads different resources taken loaded project. trying register resourcechangelistener of workspace in stage, notification of resources added workspace. earlystartup of org.eclipse.ui late(if projects loaded workspace). how or extension point can utilize in order register listener in time can hear workspace resource changes ? thanks, clint you should investigate having workspace save participant handle situations before plug-in started normally. few plug-ins of import plenty warrant starting without user involvement. http://help.eclipse.org/indigo/index.jsp?topic=%2forg.eclipse.platform.doc.isv%2fguide%2fresadv_saving.htm eclipse plugins resources startup

html - Clicking on URL 'bumps' the text/image a bit -

html - Clicking on URL 'bumps' the text/image a bit - i'm working on website after while started notice how text , images 'bump' little when click on them. have no thought how started happen , have no thought how rid of either. there's few other problems started happening around same time. examples: clicking logo makes move around bit. clicking 1 of breadcrumbs makes it's bold the titles posts in white (thus invisible), though set them semi-black. when clicking on them text shows (changes color it's supposed do) decreases in font-size significantly. i tried css , html validator says website valid. help much appreciated! you have things in css: #breadcrumbs a, a:visited, a:active { ... this same as: #breadcrumbs { ... a:visited { ... a:active { ... you accidentally giving anchor elements padding when clicked, why logo jumps bit. the boldness caused similar expression: .post-title a, a:active, a:visited { colo...

Trying to use Greasemonkey to create a button that can run Javascript. -

Trying to use Greasemonkey to create a button that can run Javascript. - website i'm on has bunch of chat rooms can accessed via dropdown menu. problem dropdown menu generated via vbscript while buttons javascript. have no problem using net explorer, friend of mine needs utilize these rooms , cannot on mac. i'm trying create greasemonkey script create these buttons elsewhere on page can click on them, have no experience greasemonkey or javascript @ all. when right click button in ie , take properties code gives me. hope you'd need help, if not please allow me know , i'll seek need. javascript:openwindow('/portal/chattransfer.aspx? chatroom=attnesting1&url=https://chat02.arise.com/chat/ ','','width=800px,height=600px,status=no,menubar=yes, scrollbars=yes,titlebar=no,resizable=yes,toolbar=no,location=no'); in short... // create button var btn = document.createelement( 'input' ); with( btn ) { setattribute( ...

iphone - Creating a file browser -

iphone - Creating a file browser - i need file selector in iphone application developing select file encrypt? thought how go accessing files on iphone? it this: http://iphone.heinelt.eu/?applications:ifile:file_browser if you’re making file browser, you’re taking wrong approach. design philosophy of ios—and human interface guidelines—strongly recommend not expose filesystem unless really, have to. generally, collections of documents in ios apps displayed flat list—witness built-in notes app apple’s own iwork (pages / keynote / numbers) suite. can display list in uitableview, can find plenty of documentation , tutorials googling it. iphone cocoa-touch file encryption selector

Rails 3 rendering form with an array of nested attributes after failing validation -

Rails 3 rendering form with an array of nested attributes after failing validation - i have question model has many options. in question controller new action create 5 options ready user def new @question = question.new 5.times.with_index |index| @question.options.build(:order => index) end respond_to |format| format.html # new.html.erb format.xml { render :xml => @question } end end in view loop through options - form_for(@question) |f| .field = f.label :title, t("question.title") = show_errors_for(@question, :title) = f.text_field :title - @question.options.each |option| - f.fields_for :options, alternative |o| .field = o.label :option, t("question.option_no", { :index => option.order }) = o.text_field :option ...

Can I copy a Python interpreter and rename it without ill effect? -

Can I copy a Python interpreter and rename it without ill effect? - because of some asinine problem i'm having multiple python interpreters , windows 7, re-create interpreter, rename it, , run scripts without problems? my python 2.6 install came python.exe , python26.exe identical according fc . seems convenient arrangement unambiguously pick python version when multiple can found on path envvar, reason version-tagged python.exe 's weren't included in default 2.7 msi installer. yes, depending on doing. should able move whole installed interpreter (i.e. libs , everything) moving just executable cause problems. you might want create .bat file can utilize in place of script selects right interpreter. in case can things pick virtualenv instance. c:\python26\python.exe c:\tools\myscript.py %* python

blackberry - Passing xml parameter to get response from web server -

blackberry - Passing xml parameter to get response from web server - i working on blackberry app needs access web server , xml response. need know how pass xml info containing username , password along url necessary response. problem passing xml parameters. connectiondescriptor cd = newfactory.getconnection("10.20.25.6:8080/atpclientservicetestv1.0/…); if(cd != null) { connection c = cd.getconnection(); displaycontent(c); } else { labelfield t=new labelfield("connection failed"); add(t); } now access contents need give <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="w3.org/2001/xmlschema-instance"; xmlns:xsd="w3.org/2001/xmlschema"; xmlns:soap="schemas.xmlsoap.org/soap/envelope/">; <soap:body> <userlogin xmlns="tempuri.org/">; <username>username</username> <password>password...

linux - Error on building OpenCV (C++) -

linux - Error on building OpenCV (C++) - building code (below) returns error 'imread' not fellow member of 'cv' . i using: ubuntu 11.04. libcv @ 2.1.0-3ubuntu1 cmake build scheme (with project(foo) , add_executable(foo main.cpp) in it.) main.cpp: #include <opencv/cv.h> int main(int argc, char **argv) { cv::mat src = cv::imread("frame_original.png", 0); homecoming 0; }` what need include cv::imread work? imread part of opencv 2.1: http://opencv.willowgarage.com/documentation/cpp/highgui_reading_and_writing_images_and_video.html?highlight=imread#imread on system? need include? can find documentation tells me header file need opencv utilize specific function? you should include opencv/highgui.h . c++ linux ubuntu opencv

.net - C# and immutability and readonly fields... a lie? -

.net - C# and immutability and readonly fields... a lie? - i have found people claim using readonly fields in class not create class's instance immutable because there "ways" alter readonly field values after initialization (construction). how? ways? so question when can have "real" immutable object in c#, can safely utilize in threading? also anonymous types create immutable objects? , linq uses immutable objecst internally. how exactly? you've asked 5 questions in there. i'll reply first one: having readonly fields in class not create class's instance immutable because there "ways" alter readonly field values after construction. how? is possible alter readonly field after construction? yes, if sufficiently trusted break rules of read-only-ness. how work? every bit of user memory in process mutable. conventions readonly fields might create bits appear immutable, if seek hard enough, can mutate the...

c - MPI Asynchronous/One-Sided Communication -

c - MPI Asynchronous/One-Sided Communication - i have situation similar code below: worker processes work on subset of info , must send unknown amount of info master. possible have master wait , receive unknown number of sends worker processes? there way using one-sided communication? in advance! #include <errno.h> #include <mpi.h> #include <stdio.h> #include <stdlib.h> #include <time.h> /* sample run/output: $mpirun -np 5 practice.exe @[1]: i=30 @[2]: i=0 @[2]: i=75 @[4]: i=40 @[4]: i=55 @[3]: i=85 @[3]: i=65 */ int main(int argc, char *argv[]) { int i, rank, size, np, nw, num; mpi_init(&argc, &argv); mpi_comm_rank(mpi_comm_world, &rank); mpi_comm_size(mpi_comm_world, &np); nw = np -1; srand(time(null)*rank); if (rank > 0) { (i=(rank-1); i<(nw*10); i+=nw) { num = rand() % 100; if (num % 5 == 0) { ...