Posts

Showing posts from June, 2010

seekg - c++ reading from beginning of file to a specified byte -

trying write file reads first byte in file byte specified user. need on logic. if file has letters through z , want read , display first 10, example. here's piece of wrote: char byte; infile.seekg(0l,ios::beg); infile.get(byte); cout << byte; for(int = 0; < num; i++); //num int specified user. { infile.seekg(1, ios::cur); infile.get(byte); cout << byte; } first problem - semi-colon on end of for() line: for(int = 0; < num; i++); { ... } what compiler sees this: for(int = 0; < num; i++) { /* nothing num times */ } { // code run once } so, remove semi-colon. next, if you're reading bytes in succession, there's no need seek in between each one. calling get() next byte in sequence. remove seekg() calls. final problem - function calling infile.get() total of num + 1 times. first call before for loop. in for loop, get() called num times (ie. = 0, 1,

PHP Minecraft Votifier -

i'm trying me best thing working dont know why minecraft server consoles gives me: 05.04 01:40:29 [server] info /212.1.212.1:58215 lost connection my code php function: function votifier($public_key, $server_ip, $server_port, $username) { //pharse public key $public_key2 = wordwrap($public_key, 65, "\n", true); $public_key = <<<eof -----begin public key----- $public_key2 -----end public key----- eof; //get user ip $address = $_server['remote_addr']; //set voting time $timestamp = time(); //create basic required string votifier $string = "vote\ntest\n$username\n$address\n$timestamp\n"; //fill blanks make packet lenght 256 $leftover = (256 - strlen($string)) / 2; while ($leftover > 0) { $string.= "\x0"; $leftover--; } //encrypt string before send openssl_public_encrypt($string,$crypted,$public_key); //try connect server $socket = fsockopen($server_ip, $server_port, $errno, $errstr, 3); if ($socket) { var_dump(fwrite($socke

backbone.js - How to load only a subset of a collection's fields / have lazy model fields / lazy nested collections in a master detail scenario? -

i'm relatively new backbone, , i've searched while, , didn't find answer satisfies question (this 1 close, not sure it's applicable backbone.js master-detail scenario ) tl;dr: how represent subset (as in of collection's model's fields, not subset in paging / filtering) of collection? (e.g. list view shows name , modified date of something, when details includes not more fields, nested child collections) now detailed version, here structure of application: models documentcollection - collection of documents, should fetch name, , last modified date document - when fetched part of collection fetch, should fetch name, , modification date, when fetched "standalone" (e.g. in details view) should fetch description , child articles articlecolletion nested collection part of document, should fetched when document fetched in details view, should "lazy" , not fetched when documentcollection fetched article views do

Stable php api framework/CMF/CMS -

i'm searching php api not change , supported long time . use framework or cms depending on case of future works, it's nice have both. here's got research: framework: codeigniter 2 --> stable, questioning future of , miss modular approach(hard find up-to-date code). symfony 2 --> bit slower, seems nice overall. cmf/cms: wordpress --> seems it's 1 of stable api in category. is there other framework/cms consider? symfony 2 1 of best options php framework (my opinion , other big goys opinion), when came out symfony 1.4 seems total different framework, can have pretty option framework if still on version 2, if want upgrade in future hard, or may won't change lot did 1.4 2.0, it's chance. codeigniter stable found suitable small projects, because when have worked symfony or other frameworks, find out codeigniter let have messy file structure, specially many developers working @ same time. symfony helps have more organized. wor

c++ - Class Objects or Pointers to their Objects? Class object combination and Implementation -

background of issue i'm working on basic battleship-like spinoff game want continue add features on time in c++ (no graphics). have 50 x 75 game board, represented 2d vector (called gameboard ) of type char. create game board , set each location '.' char. guess coordinates, guessed locations marked '-' , hits marked 'x' where i'm @ program i decided modify game enable more features. i'm not far along, sketching design in pseudocode started making me think more how can go upgrade. instead of gameboard being chars, i'm creating class called block (an empty space on board), have x , y coordinate variables, along char variable visually display correct char. block has ability hold object " feature " breaks off derived classes of "feature." can scroll bottom more detail these classes. this how class hierarchy tree goes: feature item vehicle

prolog - Undefined procedure when procedure is defined -

i trying define simple binary search tree. stored in lists so: [key, left tree, right tree]. believe have done when try use bstadd on existing tree following error. ?- bstadd(19,[],t1), bstadd(9, t1, t2). error: bstadd/3: undefined procedure: right/3 exception: (8) right(9, [[], []], _g3233) ? i have defined right 3 arugments on line 8. follows code: % bstadd(key, tree, newtree) % add element key tree tree , return % new tree newtree. element in left subtree l must less key , % elements in right subtree r must greater key. means duplicates % not allowed in binary search tree. don’t put print statements in % predicate. right(key, [treekey|treetail], [treekey|newtree]) :- grabtail(key, treetail, newtree]). grabtail(key, [treekey|_], [treekey|newtree]) :- bstadd(key, treekey, newtree). bstadd(key, [], [key,[],[]]). bstadd(key, [treekey|treetail], [treekey|newtree]) :- key > treekey, grabtail(key, treetail, newtree). bstadd(key, [treekey|treetail], [treekey|newtree])

c# - EWS - Get a user's peers (same manager) -

i'm trying exchange query user's peers, shown in global address list. first thought run query returns users same manager. finditemtype request = new finditemtype(); distinguishedfolderidtype[] fid = { new distinguishedfolderidtype { id = distinguishedfolderidnametype.contacts } }; request.parentfolderids = fid; request.traversal = itemquerytraversaltype.shallow; itemresponseshapetype props = new itemresponseshapetype(); props.baseshape = defaultshapenamestype.allproperties; request.itemshape = props; // insert restriction "someone@somewhere.com" = contactsmanager finditemresponsetype response = _binding.finditem(request); unfortunately queries contacts list, not gal. how can correctly? i cannot query ad (app intended run off of internal network) , don't use ews managed api various other reasons. any appreciated. here's example of how access gal using ews exchange 2007 , above; taken here see link valid pointers. code searches gal par

c++ - g++ doesn't compile certain nested templates -

when break defined, g++ 4.7.2 not compile following, think valid c++. compile break defined if a<u> tmp changed else, a<int> tmp - while makes minimal test case here work, it's no in actual application. there here not legal c++? template <typename t> class b { }; template <typename t> class { public: template <typename u> b<u> *alloc_b( ); }; template <typename t> template <typename u> b<u> *a<t>::alloc_b( ) { return new b<u>( ); } #ifdef break template <typename t> class c { public: template <typename u> void x(b<u> &b) { a<u> tmp; b<u> *tmp2; tmp2 = tmp.alloc_b<u>( ); delete tmp2; } }; #endif int main( ) { a<int> a; b<float> *bp = a.alloc_b<float>( ); delete bp; #ifdef break c<int> c; b<float> b; c.x(b); #endif } the alloc_b function template dependen

php - How can I query my HTML using this jQuery expression? -

i'm processing html , need query particular subset of it, know how jquery selectors. here's php code: $words = array('word'); $baseurl = 'http://lema.rae.es/drae/srv/search?val='; //word goes @ end $resultindex = 0; foreach($words $word) { if (!isset($_request[$word])) continue; $contents = file_get_contents($baseurl . urldecode(utf8_decode($_request[$word]))); // doesn't work! how write in php $dataineed = $contents.find(".ul a").attr("href"); $contents = preg_replace('/(search?[\d\w]+)/','http://lema.rae.es/drae/srv/', $contents); echo "<div id='results' style=' //style ", (++$resultindex) ,"'>", $dataineed, $contents, "</div>"; } the query use in jquery this: .find(".ul a").attr("href") how can write using php , dom? using xpath: $doc = new dom

java - Option to ignore case with .contains method? -

is there option ignore case .contains method? i have arraylist of dvd object. each dvd object has few elements, 1 of them title. , have method searches specific title. works, i'd no case sensitive. i'm guessing mean ignoring case when searching in string? i don't know any, try convert string search either lower or upper case, search. // s string search into, , seq sequence searching for. bool doescontain = s.tolowercase().contains(seq); edit: ryan schipper suggested, can (and better off) seq.tolowercase(), depending on situation.

sql server 2008 - SQL query to output multiple columns based on the value of 1 column -

i have been banging head against wall @ few hours. have managed data need down 1 table, can not figure out how write select statement output way want. basically have table: id| date | cost 03/11 5 02/11 4 b 01/11 3 b 04/11 7 the column changes query column output date column. able group id's together, each row containing id , cost of each item per month pertains id, or null if there no items month (from jan-dec) output of query: id| jan |feb | march | apr | may | jun | jul |......| oct | nov | dec null 4 5 null null.................................null b 3 null null 7 null.................................null any in right direction appreciated! thank you. ;with data(id, date, cost) ( select 'a', '20110311', 5 union select 'a', '20110211', 4 union select 'b', '20110111', 3 union select 'b', '20110411', 7 ) --- above creates virtual dataset

Node.js cannot decode string.. Characters garbled (question marks) -

i expected work but... i getting base64 string in header... want encode utf8. strinit = req.headers['authorization'] buf = new buffer(strinit.length) = 0 while < strinit.length buf[i] = strinit.charcodeat(i) i++ str = buf.tostring() str2 = new buffer(str, 'base64').tostring() console.log("auth request :",strinit, buf, str, str2) auth request : basic dxnlckbnbwfpbc5jb206cxdlcnr5 <buffer 42 61 73 69 63 20 64 58 4e 6c 63 6b 42 6e 62 57 46 70 62 43 35 6a 62 32 30 36 63 58 64 6c 63 6e 52 35> basic dxnlckbnbwfpbc5jb206cxdlcnr5 �"q�͕������������Ý•�� i tried decoding online , shows expected (user@gmail.com:qwerty) for example here works fine: http://www.base64decode.org what missing?? solved: ok, found ... had remove "basic" string decoder not confused.. so solution just: new buffer(req.headers['authorization'].replace("basic ",""),"base64").tostring() this way work

Sorting output of a dictionary -

alright have following dictionary of planets, , each planet has own dictionary containing specs: d={ 'mercury':{ 'distance sun' : 58, 'radius' : 2439.7, 'gas planet?' : false, 'atmosphere?' : true, 'moons' : []}, 'jupiter':{ 'distance sun' : 483, 'radius' : 69911, 'gas planet?' : true, 'atmosphere?' : true, 'moons' : ['io', 'ganymede', 'callisto', 'europa', 'adrastea']}, 'uranus':{ 'distance sun' : 3000, 'radius' : 25559, 'gas planet?' : true, 'atmosphere?' : true, 'moons' : ['miranda', 'ariel', 'umbriel', 'titania', 'oberon']}, 'mars':{ 'distance sun' : 207, 'radius' : 3396.2, 'gas planet?' : false, 'atmosphere?' : true, &#

arrays - Java arraylist outofbounds -

i know question has been asked million times. , feel solution obvious hasn't been staring @ couple of hours. can't make head or tails of out of bound exception. here error: exception in thread "main" java.lang.indexoutofboundsexception: index: 207493, size: 207493 @ java.util.arraylist.rangecheck(arraylist.java:604) @ java.util.arraylist.get(arraylist.java:382) @ affysureselect.affysureselect.main(affysureselect.java:92) java result: 1 i thinking perhaps might happening due size of arraylist, if case have expected error when adding, rather getting. here code dying: string chrompos; arraylist<string> chromnum = new arraylist<string>(); while ((input2 = sbuff.readline()) != null) { prse = input2.split("\t"); chromnum.add(prse[0]); ... chrompos = prse[7]; } int cnt = 0; int cnt2 = 0; if (chromnum.get(cnt).equals(chrompos)) { // line causing untimely death end =

c# - WPF HD background video playback lags UI -

i've touch screen application built using wpf running @ hd resolution (1920 x 1080) , have looping background video in hd. background video runs long lifetime of app. ui placed "above" (in z order). ui's rendering seems jerky , laggy , want improve performance. when run app without video running, ui runs smoother expected. can suggest way improve ui responsiveness? below details of looping video file. edit: investigations did: on slower computers, video , ui becomes laggy. however, when running video alone, video runs smoothly. when running ui without video, runs smoothly. problem arises when have video , ui running together, somehow rendering becomes sluggish. using mediaurielement control wpfmediakit. tried use win7dsfiltertweaker change windows 7 default decoder no avail. suggestions? edit 2: bottleneck seems wpf rendering engine. when ran video, fps drops ~34fps. when paused video, running @ 60fps again. suggestions here? video id

php - Getting an 'html' type instead of 'image' from the browser -

i'm using curl fetch image file our server. after checking browser's developer tools, says returned type 'html' instead of 'image'. here's response: /f/gc.php?f=http://www.norbert.com/get/image/bts-005-00.jpg 200 text/html 484.42 kb 1.68 s <img> here's curl script: $ch = curl_init(); $strurl = $strfile; curl_setopt($ch, curlopt_url, $strurl); curl_setopt($ch, curlopt_useragent, "mozillaxyz/1.0"); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_timeout, 60); $output = curl_exec($ch); curl_close($ch); return $output; any additional specific code add in curl script? thanks! your php script doing curl , returning output without specific header of image. so, default, browser retrieve data html content. try add more specific header before returning output. try header('content-type: image/jpg'); to specify browser type of content script

Spring, Form tag based Datepicker in Jquery? -

Image
actually in spring application i'm using spring based form tag in jsp code. and add functionality <form:input> ,provide datepicker using jquery. and hear jsp code.. <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <link rel="stylesheet" href="resources/css/jquery-ui.css" type="text/css"> <link rel="stylesheet" href="resources/css/custom.css" type="text/css"> <script type="text/javascript" src="resources/jquery/jquery-ui.min.js"></script> <form:form action="form/form1" modelattribute="form1"> <label class="control_label_c">from : </label> <div class="controls_c"> <form:input type="text" path="f

c# - Autofac resolving a singleton creates a bottleneck -

i'm using autofac in asp.net mvc app , came across problem locking. anytime service depends on singleton, service resolved root lifetime scope. because autofac: resolves singleton components root scope resolves components root scope have dependencies must resolved root. further, when resolving scope, autofac locks scope. think these fine design decisions. problem misbehaving classes depend on singletons and have slow constructors. these create bottleneck else needing resolve singleton. since in mvc app, each request getting mapped mvc controller that's constructor injected. further, of controllers take dependencies on various singleton services (logging, caching, etc). for things fast constructors not problem. 1 poorly written class requested, throughput tanks because every new request blocked on misbehaving constructor. example: given these 3 classes //registered singleinstance() class mysingleton {} class badtransient { public badtransient(mysingl

Regular Expression to validate on continuous character or numbers in JavaScript? -

i need validate if string presents continuous characters abc, def, ghi or 123,234,345,456 , on using javascript, wants through error or alert message. there possibilities match patterns or expression validate such scenario. please if come across, let me know asap. thanks in advance!!! a regular expression not way go one. better loop through characters in string checking if each 1 greater last using str.charcodeat() .

perl - Net::FTP having trouble uploading ZIP-archives? -

i'm trying build perl-script zips directory , uploads ftp-server. got zipping-part working, unfortunately zip-files 'destroyed', when uploaded ftp-server (error when opening: 'unexpected end of archive'). am doing wrong here? my $ftp = net::ftp->new($host, debug => 0) or die "couldn't connect $host: $!"; $ftp->binary(); $ftp->login($user, $password) or die "couldn't login: $!"; $stat = $ftp->put($filename) or die "couldn't upload file: $!";

python - How to unittest multiple similar classes -

i have program multiple similar classes: class blackbox1(): def calc(self, a, b): return + b class blackbox2(): def calc(self, a, b): return * b ... now want write unittests classes. of course write separate tests each blackbox. anyway, since each blackbox has same method calc(a, b) tested, wonder, if there “best practise”, automatically give classes , expected results abstract test framework, like import unittest class testabstractbox(unittest.testcase): def setup(self): self.box = blackbox() self.param_a = self.param_b = b self.expected_result = result def test_calc_method(self): real_result = self.box.calc(self.param_a, self.param_b) self.assertequal(real_result, self.expected_result, "{0} gives wrong result".format(self.box.__class__)) tabstracttest = unittest.defaulttestloader.loadtestsfromtestcase(testabstractbox) is there way pass {"blackbox&quo

Difference between C 8 bit 16-bit 32-bit compilers -

this question may redundant, didn't found exact answer. what difference between c 8 bit 16-bit 32-bit compilers. how .exe differ generated different compilers same code........... 16 bit compilers compile program 16-bit machine code run on computer 16-bit processor. 16-bit machine code run on 32-bit processor, 32-bit machine code not run on 16-bit processor. 32-bit machine code faster 16-bit machine code. with 16 bit compiler type-sizes (in bits) following: short, int: 16 long: 32 long long: (no such type) pointer: 16/32 (but 32 means 1mb address-space on 8086) with 32 bit compiler object-sizes (in bits) following: short: 16 int, long: 32 long long: 64 pointer: 32 with 64 bit compiler object-sizes (in bits) following: short: 16 int: 32 long: 32 or 64 (!) long long: 64 pointer: 64 [while above values correct, may vary specific operating systems. please check compiler's documentation default sizes of standard types] following can exp

made $_SESSION[] data into php variable but it still won't work in a mysql query -

i have trouble checking $_session variable on mysql query. want details of user logged in, appears not working properly. i have $user = mysql_real_escape_string($_session['username']); puts code regular variable, , make query database is: $sql = "select * admin username='$user' limit 1"; and count if user exists use code: $usercount = mysql_num_rows($sql); // count output amount this not seem work. keep getting error: "warning: mysql_num_rows() expects parameter 1 resource, string given in /home/alexartl/public_html/crm/headercode.php on line 18" and way, user account exist , logged in when have been testing below full code // if session vars aren't set, try set them cookie if (!isset($_session['user_id'])) { if (isset($_cookie['user_id']) && isset($_cookie['username'])) { $_session['user_id'] = $_cookie['user_id']; $_session['username'] = $_cookie[

ios - Infinite horizontal scrolling in MKMapView -

i trying figure out how mkmapview scroll horizontally endlessly (as if spinning globe) per maps application in iphone. there setting within mapkit ? or have setup 2 mkmapviews side side? any advice or information appreciated. i have tried searching on forums seems question has not been asked before. please correct me if wrong. regards. leon this not possible in mapkit. if want suggest filing feature request this. if want in ios suggest using new google maps ios sdk available here . update - possible in ios7 , later natively

wordpress - Custom Permalink for Archive URL strucutre -

i want have custom url structure date/year archive. currently wordpress cms provides structure http://wordpress.com/2012/04/13/ for calendar url structure, want http://wordpress.com/**archive**/2012/04/13/ only calender url structure not single post. please guide me how it. regards, you can find explenation how rewrite permalinks here

jquery - rowspan is removed when using dataview in IE -

i have below template <ul class="sys-template" id="visitingcard"> <li id="{{uiid}}"> <div class="profiles"> <div class="profile"> <table border="1" style="width: 100%; "> <tr > <td rowspan="3" > hello dear </td> </tr> <tr> <td> abc : abc </td> </tr> <tr> <td> xxx : xxx </td> </tr> </table> </div> </div> </li> </ul> in script, creating dataview below: var data=$create( sys.ui.dataview, { data: { uiid: "uiid:1", uiname: "

django - check values in for loop python -

i have multi language site product have images has content in 2 languages english , spanish. i need differentiate them particular site, getting images in 1 loop {% image in images %} {% endfor %} in image names image.jpg image_en.jpg image_sp.jpg for english site need "image.jpg" , "image_en.jpg" , spanish need "image.jpg" , "image_sp.jpg" how can differentiate them? you can catch lengauge on server site. create set of name (in case of english , spanish) simple print images in templates. looks easy maybe it's not best.

c# - SQL Datareader return values -

i want return database values, in case: history of browser sql what have: // lezen van records public void lezen(string tabelnaam) { // parameters aanmaken en opvullen sqlparameter para1 = new sqlparameter(); para1.parametername = "@tabelnaam"; para1.value = tabelnaam; // maken van een sql verbinding sqlconnection conn = new sqlconnection(); conn.connectionstring = @"integrated security=true; initial catalog=opdrachtw3; data source=laptop-roy\sqlexpress"; conn.open(); // aanmaken van query sqlcommand cmd = new sqlcommand(); // aangeven dat de query plaatsvind op bovenstaande connectie cmd.connection = conn; cmd.commandtext = string.format("select * [{0}]", tabelnaam); cmd.parameters.add(para1); sqldatareader dr = cmd.executereader(); list<string> recordsinfo = new list<string>(); int = 0; browser brw = new browser(); while (dr.read()) { i++;

javamail - java mail api javax.mail.MessageException Connect failed pop3 -

i want read mails user account using java mail api. the mail server particular mail server: reademail.java - client properties props = system.getproperties(); props.put("mail.debug", "true"); props.put("mail.pop3.host", host); props.put("mail.pop3.port", port); props.put("mail.pop3.user", username); props.put("mail.pop3.timeout", "158000"); props.put("mail.pop3.connectiontimeout", "158000"); /* create session , store read mail. */ session = session.getinstance(props); store = session.getstore("pop3"); session.setdebug(true); store.connect(host,username, password); the error message on client side: debug pop3: mail.pop3.apop.enable: false debug pop3: mail.pop3.disablecapa: false debug pop3: connecting host "localhost", port 4444, isssl false s: +ok mail server ready c: capa s: javax.mail.messagingexception: connect failed; nested exception is: java.io.io

android - Sax parser with string xml + malformation error -

i trying read data xml string , set respective tag element using setter getter method xml shows malformation error in xml file. doing wrong here code. in oncreate.. saxhelper2 sh = null; try { sh = new saxhelper2(newxml); } catch (malformedurlexception e) { e.printstacktrace(); } sh.parsecontent(""); return null; } } /* * */ class saxhelper2 { private string data; stringbuffer chars = new stringbuffer(); public saxhelper2(string xmlstring) throws malformedurlexception { this.data = new string(xmlstring); } defaulthandler handler = new defaulthandler(); public rsshandler parsecontent(string parsecontent) { rsshandler df = new rsshandler(); try { saxparserfactory factory = saxparserfactory.newinstance(); saxparser saxparser = factory.newsaxparser(); saxparser.parse(new inputsource(newxml), new rsshandler()); } catch (exception e

textarea - Bizarre Internet Explorer 9 issue - duplicating text in multiline textbox -

i have found bizarre internet explorer issue think i've ever seen, , have absolutely no idea how around it, hoping maybe has seen similar before , knows causes / how fix it. i have multi-line textbox, follows: <asp:textbox runat="server" id="txtdoctornotes" textmode="multiline" rows="8" width="270"></asp:textbox> i noticed morning of words in textbox duplicated, , thinking i'd made mistake when typing clicked in box change contents, , strangely duplications disappeared, , read should be. have no "onclick" event on textbox, though jquery used when contents changed (so when tab out of box jquery flags contents of form have been changed). thinking 1 off rendering issue, reloaded page, , sure enough same duplications reappeared, clicked in box, disappeared. oddly duplicated words weren't @ beginning or end of contents, , weren't together, randomly duplicated them. tried in chrome, works perf

html - jQuery form validation not kicking in -

i have written following code form tries post if javascript not being found? the code within <head> of document: <script language="javascript" type="text/javascript"> $('.entrysend').click(function(e){ e.preventdefault(); var error = false; var name = $('#name').val(); var address = $('#address').val(); var phone = $('#phone').val(); var email = $('#email').val(); if(name.length == 0){ var error = true; alert("please complete fields"); } if(address.length == 0){ var error = true; alert("please complete fields"); } if(phone.length == 0){ var error = true; alert("please complete fields"); } if(email.length == 0){ var error = true; alert("please complete fields");

sql server - Mapping row values of one table to column name of another table -

i have table keeps track of updates on 15 tables called 'tracking_table'. wanted 1 table 15 tables kept 10 columns in 'tracking_table' max values of no of cols in 15 tables. now tracking_table i'm able latest updates done on particular column of particular table in following structure. p_key_no col_name value table __________________________________________________________________ 1 altemail abc@gmail.com emp_info 1 password aa321 emp_info 2 altemail xyz@gmail.com emp_info 2 email pqr@yahoo.com emp_info 2 password sb12321 emp_info this keep track of name of table, name of column, primary key value of particular row , changed value. and emp_info table shown below: pkey email fullname password time_stamp altemail 1 a123@xyz.com xyz1 aa123 2013-04-05 13:24:49.6

sharedpreferences - Android Preferences onBackButton -

i'm saving users login information sharedpreferences, has configure login data once. this onbackpressed method in preferences.class (extends preferenceactivity): @override public void onbackpressed() { //login again intent intent = new intent(preferences.this, loginactivity.class); startactivity(intent); } what need if-condition checks, if preferences changed or not .: if user opens preferences activity (edit: view(!)), , not change , clicks backbutton -> go last state. if preferences changed: call loginactivity. couldnt find solution yet , loginactivity gets called whenever hit backbutton. thanks in advance, marley to determine if there change in sharedpreferences have assign onsharedpreferencechangelistener sharedpreferences object this: prefs = preferencemanager.getdefaultsharedpreferences(this); prefs.registeronsharedpreferencechangelistener(this); in case i'm doing in application class that's implementing: public

c++ - Print out a static "deprecate" warning message with a suggested correction when an particular enum identifier is used? -

in c++ library used in many places in our collaboration, have mistakenly defined multiple enums in same lib namespace define constant values. enum distinct type not distinct namespace. consequence enum values end in same namespace. open door enum identifier collision , inconvenient when using automatic completion. in order solve considering moving different enums in distinct namespaces. to easy evolution of code using library able display @ compile time "deprecate" warning message suggesting code change when old enum identifiers met in code. the following question , answers does there exist static_warning? provide way define deprecate warning when condition met. how achieve same effect when enum identifier shows in user code ? if use visual c++ might able use #pragma deprecated . for gcc there __attribute__ compiler extension, might used mark variables or functions deprecated. don't know enumerations though.

php - Changing table background color through AJAX jquery? -

Image
scenario: when web page load automatically search cell has been input user , have value. if has been input table background color red else green. assume table has not been input yet. table background green and source-code of table: <table width="1023" height="200" border="1"> <tr> <th colspan="2" scope="col">a1</th> <th colspan="2" scope="col">a2</th> <th colspan="2" scope="col">a3</th> </tr> <tr> <td bgcolor="#00cc00"><div class="data" align="center" value="a1.4"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="a1.4" /></td> <td bgcolor="#00cc

javascript - window.open doesn't open with browser back button in Chrome -

i trying open link in new window using simple window.open . however want browser button, give below parameters. works fine in browsers except google chrome. have tried every possible permutation button doesn't come in chrome: <a onclick="window.open('http://www.google.com', 'popupwindow', 'height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=yes,directories=no, status=yes' );">click here</a> change menubar=no menubar=yes , here code. note : not open pop up, open new tab. <a onclick="window.open('http://www.google.com', 'popupwindow', 'height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes,directories=no, status=yes' );">click here</a>

c++ - shared_ptr not reporting referenced object deletion -

i'm running code in ms visual studio 10, #include <iostream> #include <memory> using namespace std; class { int i; public: a(int j) : i(j) {} ~a() {} void fun() { cout << "a::i = " << << endl; } }; int _tmain(int argc, _tchar* argv[]) { aobj(12); std::shared_ptr<a> const pobj (&aobj, [] (a* pa) { cout << "lambda deleter" << endl; }); aobj.~a(); pobj->fun(); return 0; } this prints / holds data members object, has been deleted, without reporting type of error. please write on: why shared_ptr pobj doesn't report (at run-time) underlying object has been deleted? since i'm creating const shared_ptr, means can't use refer other object, why lambda not invoked @ object deletion. can weak_ptr helpful in similar cases. weak_ptr used semantics lifetime of reference object outlives obje

Unable to paint on background setted images on my view android -

Image
here code able draw on view when set background view, unable paint on background imgae please me out. in advance public class fingerpaint extends graphicsactivity implements mycolorpickerdialog.oncolorchangedlistener { listview dialog_listview; string[] listcontent = { "stroke size 1", "stroke size 2", "stroke size 3", "stroke size 4", "stroke size 5","stroke size 10","stroke size 20","stroke size 30" }; string[] effectcontent = { "normal", "blur", "emboss", "srcatop" }; private static int font_size=5; private static int color_code=color.black; public int mpos; private bitmap mbitmap; myview mv; imageshowactivity imageshowactivity =new imageshowactivity(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mv= new myview(this); mv.setdrawingcacheenabled(true