Posts

c++ - Passing an object to a function taking a reference, an interview test -

i had interesting (or stupid) interview question. well, know code below not compile, not give answer on how modify class c make code compile. told answers test(c(1)); or void test(c c) unacceptable. can me? here's question: q11. following code compile? if not, make changes want class c in order code compile. class c { public: c(int i) {} ~c() {} }; void test(c &c) { } int main(int, char*) { test(1); return 0; } the code not compile. there no way make compile changing class c first because signature main wrong (char* never type of second argument). but if signature of main correct test(1); wants implicitly create temporary object of c , pass test . however, cannot bind temporary non-const reference, , can't see way change class c create implicit temporary can bind parameter test . edit: closest i've come putting friend void test(int i) { } c . compile sun's cc compiler fails compile g++ 4.4, 4.5, or 4.8 ideone. edi...

javascript - Detecting if inputs match by having common elements -

i have 2 input boxes , trying compare them, in order see if have common elements. reason, though, not working. code: html: personal address line 1: <input type = "text" id = "persadd1" /> address line 1: <input type = "text" id = "addline1" /> <input type = "submit" value = "continue" onclick = "vali()" /> javascript: function vali() { var add1str = document.getelementbyid('persadd1').value; var add2str = document.getelementbyid('addline1').value; var arr1 = add1str.split(" "); var arr2 = add2str.split(" "); var arr3 = []; (var = 0; < arr1.length; i++) { (var j = 0; j < arr2.length; j++) { if (arr1[i] === arr2[j]) { arr3.push( arr1[i] ); if(arr3 !== ""){ alert("error"); } } } } } jsfiddle ...

javascript - Audio Glitch in jQuery -

i've developed audio player plays radio station's stream. host audio on streamon , when click play button in player in lower right of streaming widget audio, after buffering, plays via inserting iframe styled invisible. however, people on staff have complained if click on play button multiple times whilst it's loading, play multiple streams (as can seen here: glitched page ). so, on test page attempted below code prevent such scenarios occuring. however, audio isn't being loaded on requested (as can seen here: test page ). appreciated. <script> $playing = 0; $(document).on("click", "button#mute", function(){ $('iframe#audiostreamon').remove(); $playing = 0; }); if ($playing =0) { $(document).on("click", "button#play", function(){ $(this).after('<iframe id=...

ruby - Rails 4: How to upload files with AJAX -

i want upload files ajax. in past accomplished using magical jquery form plugin , worked great. i'm building rails app , trying things "the rails way" i'm using form helper , paperclip gem add file attachments. the rails docs warn form helper not work ajax file uploads: unlike other forms making asynchronous file upload form not simple providing form_for remote: true. ajax form serialization done javascript running inside browser , since javascript cannot read files hard drive file cannot uploaded. common workaround use invisible iframe serves target form submission. it seems clear there's no off-the-shelf solution. i'm wondering what's smartest thing do. seems have several options: use form helper , iframe trick. use form helper + load jquery form plugin submit file (not sure if play nice rails's authenticity token, etc) use form helper + paperclip + [some other gem] extend it's functionality allow ajax form submissi...

security - @RunAs and Role Propagation -

glassfish-3.1.2.2. i have 1 servlet , 2 ejb in project. servlet--------->init--------------->print // ejb init code @stateless @runas("system") @declareroles({"system"}) public class init { @resource ejbcontext ejb; @ejb private print print; public void initialize() { system.out.println("**********" + ejb.getcallerprincipal().getname()); system.out.println("**********" + ejb.iscallerinrole("system")); print.printline(); } } // ejb print code: @stateless @declareroles({"system"}) public class print { @resource ejbcontext ejb; public void printline() { system.out.println("**********" + ejb.getcallerprincipal().getname()); system.out.println("*********" + ejb.iscallerinrole("system")); } } // execution result: info: **********anonymous (ok) info: **********false (ok) info: **********system (ok) info: **********false (? ) why getting second false (i expecting true)...

Magento Disabled Product shows 500 internal server error -

i facing weird issue out here. for product, if disable admin end, , run product url in browser, shows me 500 internal server error. for eg: http://domain.com/product.html now if add random param url , again run it, gives me 404 error page expected. eg: http://domain.com/product1.html this thing happening whenever disable product live site while staging site working if disable product. what issue server error if product disabled admin ? i checked .htaccess , has no issues. thanks in advance. try disable compilation , see if error persists. bug, described here: http://www.magentocommerce.com/boards/viewthread/310970/ the suggested solution is: in lib/varien/autoload.php :: registerscope, change include include_once : static public function registerscope($code) { self::$_scope = $code; if (defined('compiler_include_path')) { // change include_once prevent including multiple times !!! //@include compiler_include_path . directo...

sql - Checkbox hell - webmatrix/razor -

i'm having trouble checkboxes on site. here's code have far: @{ layout = "~/_sitelayout.cshtml"; websecurity.requireauthenticateduser(); var db = database.open("stayinflorida"); var rpropertyid = request.querystring["propertyid"]; var propertyinfo = "select * propertyinfo propertyid=@0"; var qpropertyinfo = db.querysingle(propertyinfo, rpropertyid); if(ispost){ var sql = "insert propertyinfo (fepool, fejac, fegames) values (@0, @1, @2) propertyid=@3"; db.execute(sql, request["check1"], request["check2"], request["check3"], rpropertyid); } } <form method="post"> <div> <input type="checkbox" name="check1" value="true" /> value 1 <br/> <input type="checkbox" name="check2" value="check2" /> value 2 <br/> <input type="checkbox" name="check3" value="c...