Posts

Showing posts from April, 2014

php - Move from one table to another -

i need move data table archive table. now way: $sql = 'insert history_products select * products category_id='.$id; and delete data products table. $sql_delete = 'delete products category_id = '.$id; each product have unique id. want make in secure way, if row isn't inserted in history_products row deleted products table. don't want delete if insert fails. i expected have field called id (produktid), products must have same id in both tables then, following should work. delete products products.id in (select history_products.id history_products)

Determine if WPF WebBrowser is loading a page -

i have wpf system.windows.controls.webbrowser control in window. user can enter information , hit submit button webpage displayed webbrowser. after page posts uses scripting object communicate application. need make sure once submit button has been pressed, form doesn't close or otherwise stop waiting web page post back. great if check state of webbrowser or document via property "isloading" , cancel actions if loading. didn't see thinking of setting flag on navigating event , unsetting on navigated or loadcompleted event, there case click link on web page (tied javascript, doesn't go new page) navigating fired, navigated , loadcompleted never fire. there way determine state of browser on demand? as per msdn if navigating event gets invoked navigated event fired unless explicitly cancel navigation. tried below code-snippet seems working fine. (i.e) whenever navigated event getting fired following navigating event. void window1_loaded(object sende

ASP.NET ListBox: Display both text & value? -

i have listbox on aspx page. i'd display both text , associated values (not index). if add items this dim listitem = new listitem("horse", "2") dim listitem = new listitem("dog", "3") me.listbox.items.add(this) me.listbox.items.add(that) my listbox (please excuse list of artistic talent): -------------- |2 horse | |3 dog | -------------- is there way this? thanks, jason sure, why not combine text , value variable. dim nextitem listitem = new listitem(string.concat("2", " ", "horse"), "2") listbox.items.add(nextitem)

ANTLR: Heterogeneous AST and imaginary tokens -

it's first question here :) i'd build heterogeneous ast antlr simple grammar. there different interfaces represent ast nodes, e. g. iinfiexp, ivariabledecl. antlr comes commontree hold information of source code (line number, character position etc.) , want use base implementations of ast interfacese iinfixexp ... in order ast output commontree node types, set: options { language = java; k = 1; output = ast; astlabeltype = commontree; } the iinifxexp is: package toylanguage; public interface iinfixexp extends iexpression { public enum operator { plus, minus, times, divide; } public operator getoperator(); public iexpression getlefthandside(); public iexpression getrighthandside(); } and implementation infixexp is: package toylanguage; import org.antlr.runtime.token; import org.antlr.runtime.tree.commontree; // iinitializable has void initialize() public class infixexp extends commontree implements

c# - Add operator to third-party type? -

i have third-party library (mogre), in struct (vector3). add overload '+' operator (no override needed) type not sure how. i cannot use extension methods operator want extend; class not sealed not partial either, if try , define again new operator overload conflicts. is possible extend type this? best way it? you cannot add operator overload third-party type -- class don't have ability edit. operator overloads must defined inside type operate on (at least 1 of args). since it's not type, can't edit it, , struct s cannot extended. but, if non- sealed class , you'd have sub-class, ruin point because you'd have use subclass , not superclass operator, since can't define operator overload between base types... public class { public int x { get; set; } } public class b : { public static operator + (a first, second) { // won't compile because either first or second must type b... } } you overload between i

iphone - About making a mobile version of a website -

i want make mobile version of website (you know, .m in url). how done, , different regular website? can still make website in html/css/javascript, or need additional tools mobile sites? final question - there difference viewing mobile website on android phone versus iphone? thanks. how done? in same way websites, html/css/js , bit more. what different regular website? basically not only: the display size biggest (or in case, smaller) difference, have take care of small displays , viewports. the user interact finger , not mouse, clickable area must bigger. can still make website in html/css/javascript, or need additional tools mobile sites? yes can (and should) use html/css/js check different video/audio tags on webkit mobile. is there difference viewing mobile website on android phone versus iphone? both come webkit have small differences (like touch events) websites differences minimal.

c# - comparing two List<> -

i have gridview control checkbox on it when hit on save button able find checkbox have been checked , able far problem is: let if user tries uncheck checkedbox how track changes , save db has been checked. anyhelp?.. in regards have created 2 list comparision... hope make sense here. i want compare 2 list , if changes save else ....do something... <asp:templatefield headertext="select"> <itemtemplate> <asp:checkbox id="chkselected" runat="server" checked="false"></asp:checkbox> </itemtemplate> </asp:templatefield> list<employee> listfromdb = new list<employee>(); listfromdb = employeelistfromdb ; //loads list list<employee> selectedemployee = new list<employee>(); selectedemployee = myselectedemployee //loads list //employee object looks this: id name here got stuck , here doing... foreach (employee item in myselectedemployee ) { bool _flag = fal

java - The method getApplicationContext() - how to use without Activity -

i have async task called within activity: public class downloadfile extends asynctask<string, integer, string>{ protected string doinbackground(string... url) { because of there's things cannot do, 1 of it's using getapplicationcontext() there's way solve problem? pass application context in constructor public downloadfile(context context) { // fun stuff context, such assign class variable }

sql server - sqlserver scalar function returning result of select -

i want function find maximum allowable length of field. invoke in behind code, using cmd.executescalar(). however, can't function definition right. this 1 of things tried: create function getpwlen ( ) returns int begin return select max(len((password))) return_value tblsec end go any appreciated. no need column alias, wrap select in brackets ... return (select max(len(password)) tblsec) ...

c# - Dependency Injection / Constructor Injection Help -

i have following classes / interfaces: public interface iprojectrepository { iqueryably<project> getprojects(); } // depends on ef context public projectrepository : iprojectrepository { private mydbentities context; public projectrepository(mydbentities context) { this.context = context; } public iqueryable<project> getprojects() { return context.projects; } } my controller: // depends on iprojectrepository public class projectscontroller : controller { private iprojectrepository projectrepository; public projectscontroller(iprojectrepository projectrepository) { this.projectrepository = projectrepository; } public actionresult index() { return view(projectrepository.getprojects()); } } i need set dependency injection passes in projectrepository controller and needs pass in entity framework context project repository. need entity context http request

iphone - Comma inside a statement inside a macro being misinterpreted as a macro argument separator -

i created xcode project , wrote following code: #define foo(x) x - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { int n = 666; nsstring* string = foo([nsstring stringwithformat: @"%d", n]); nslog (@"string %@", string); [self.window makekeyandvisible]; return yes; } when try run this, bunch of errors, because preprocessor decides that comma after stringwithformat: supposed separating 2 macro arguments, therefore have used foo 2 arguments instead of correct one. so when want comma inside statement inside macro, can do? this c++ question suggests way put round parens () around comma, apparently leads preprocessor realize comma not macro argument separator. off top of head, i'm not thinking of way in objective c. adding additional parentheses around call works: nsstring* string = foo(([nsstring stringwithformat:@"%d",n]));

java - can't refer to non final variable password -

i writing standalone code sending mail java. in program taking info user on console . here problem authentication part. passing user name , password mail id , passwrd of sender. showing error can.t refer non final variable password , from. if final can't take user. plz me should do? package mypackage; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.util.properties; import javax.mail.message; import javax.mail.messagingexception; import javax.mail.passwordauthentication; import javax.mail.session; import javax.mail.transport; import javax.mail.internet.internetaddress; import javax.mail.internet.mimemessage; public class sendmailssl { public static void main(string[] args) throws ioexception { properties props = new properties(); string host=""; string port=""; string s_port=""; string =""; final string from="";

ruby on rails - Devise - Error message not showing up - redirects to update instead of create -

i've on written registration controller , i'm trying return form create user, works partly. def create u = user.find_by_email(params[:user][:email]) ... if u && u.unregistered self.resource = u if resource.update_with_password(params[resource_name]) ... set_flash_message :notice, :updated if is_navigational_format? ... sign_in(resource_name, resource) if u.confirmed? redirect_to consultations_path else redirect_to send_advisor_confirmation_path(u.id) end else clean_up_passwords(resource) # place has problem respond_with_navigational(resource) { render_with_scope :new } end return end super end (side note: in app possible create user hasn't signed in yet, defined being "unregistered", , can claim account going through sign process). this respond_with_navigational works first time (when new posting create ) when mess form again clears whole f

actionscript 3 - close air app, where is it? -

seems system.exit(0) , flash.system.system.exit(0) both throw error "[fault] exception, information=securityerror: error #2018: system.exit available in standalone flash player." i'm creating fullscreen app , im want add close button close windows , exit (i have secondary window via nativewindow open). tons , tons of googling nothing. makes me wonder if im missing super simple since "chromless" apps have have this. poking around found stage.nativewindow closing not exit whole app. *note building , testing in flashdevlop 4.0 pure as3, no flex. nativeapplication.nativeapplication.exit(); when in doubt, check docs! :) http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/flash/desktop/nativeapplication.html#exit()

javascript - Build a list with JSON and jQuery -

i need build list using parameters "name" taken file "sendjson.php" (in json, of course). how can create list using jquery one? <div id="firstresultname">firstresultname</div> <div id="secondresultname">secondresultname</div> i don't know how result possible detect , write right number on div? thanks! $.each(json, function(key, value){ $("body").append('<div id="'+value+'">'+value+'</div>'); }); or just $.each(json, function(key, value){ $("body").append('<div>'+value+'</div>'); }); to retreive json & proccess, following $.ajax({ 'url' : 'yoururl.php', datatype: 'json', success: function(json){ $.each(json, function(key, value){ $("body").append('<div>'+value+'</div>'); }); } });

Time complexity of set in Java -

can tell me time complexity of below code? a array of int. set<integer> set = new hashset<integer>(); (int = 0; < a.length; i++) { if (set.contains(arr[i])) { system.out.println("hello"); } set.add(arr[i]); } i think o(n) , i'm not sure since using set , contains methods well. calling add method of set . can confirm , explain time complexity of entire above code is? also, how space take? i believe o(n) because loop on array, , contains , add should constant time because hash based set. if not hash based , required iteration on entire set lookups, upper bound n^2. integers immutable, space complexity 2n, believe simplifies n, since constants don't matter. if had objects in array , set, have 2n references , n objects, @ 3n, still linear (times constant) space constraints. edit-- yep "this class offers constant time performance basic operations (add, remove, contains , size), assuming hash function

c# - DataGridView unwanted calls to EndNew -

i using class called simplefilteredlist got site: http://blogs.msdn.com/b/winformsue/archive/2007/12/06/filtering-code.aspx it allows me apply basic sorting business objects when added datagridview through bindgingsource. has served purposes well, don't understand 1 aspect. each time new row selected in datagridview prompts overridden endnew function in simplefilteredlist class called. particularly annoying when last row previous row selected because forces sorting algorithm executed. all columns , datagridview have readonly set true, , allowusertoaddrows , allowusertodeleterows set false. how can stop endnew function being called when new row selected in datagridview? endnew function in simplefilteredlist class: public override void endnew(int itemindex) { // check see if item added end of list, // , if so, re-sort list. if (sortpropertyvalue != null && itemindex > 0 && itemindex == this.count - 1) ap

Silverlight Wcf Ria service viewmodel combobox -

ok i'll make simple! here viewmodels : public class objectsmodel { public event propertychangedeventhandler propertychanged = delegate { }; private string _objectname; public string objectname { { return _objectname; } set { if (value != _objectname) { _objectname = value; propertychanged(this, new propertychangedeventargs("objectname")); } } } public ienumerable<object> objects {get;set;} public icommand addcommand { get; private set; } public icommand savechangescommand { get; private set; } mydomaincontext context = new mydomaincontext(); public objectsmodel() { objects = context.objects; context.load(context.getobjectsquery()); } } public class inventorymodel { public event propertychangedeventhandler propertychanged = delegate { }; public ienumerable&l

amazon ec2 - Update python itself using the apt module -

i writing python script run on ec2 machine user-data-script . i'm trying figure out how can upgrade packages on machine similar bash command: $ sudo apt-get -qqy update && sudo apt-get -qqy upgrade i know can use apt package in python this: import apt cache=apt.cache() cache.update() cache.open(none) cache.upgrade() cache.commit() problem happens if python 1 of packages upgraded. there way reload interpreter , script following upgrade , continue left off? right choice use shell script user-data script sole purpose of upgrading packages (including possibly python) , dropping python rest of code. i'd eliminate step of using shell script. i think figured out: def main(): import argparse parser = argparse.argumentparser(description='user-data-script.py: initial python instance startup script') parser.add_argument('--skip-update', default=false, action='store_true', help='skip apt package updates') # p

How can a link be provided in Alert box to redirect to another page using flex? -

i need provide link (like click here view.....) in alertbox redirects page. needed... then may want consider making isn't alert box. alert box that, box alerting of something. i'm sure pound square peg round hole, rather take easier route , make custom component looks alert box html link in it.

python - A way to store sensitive data to disk, without (serious) fear of user tampering? -

i'm writing application connects twitter , uses oauth api, issue storing consumer_key , consumer_key_secret how can safely store these values they're difficult user still have ability use them within application? i've had storing them within pyc , encrypting them suggestions far, i'm open other ideas. an alternative drm (which describing) proxy secured interaction through server application on own, controlled machine. since you're using oauth, can use same authentication credentials against own server connecting directly twitter. the advantage approach there no private key disclosure; don't share private key consumers, since that's stored on remote server cannot read, , consumers don't share passwords (instead, oauth token ties particular login specific service).

programming languages - Java setter method convention (is it OK to overload setters?) -

i have condition way construct string (finalvalue) based on number of non null values in input. wondering if ok on load setter method string (finalvalue) 1 diff no of parameters , call them based on values get? bad programming practice? public void setfinalstring(string a){ this.finalstring = a; } public void setfinalstring(string a, string b){ this.finalstring = + " --f " + b; } or can have method construct finalstring based on inputs , invoke setter (no overloading here) finalstring. pls tell me ok on load setters , suggest better approach? thanks yes, bad approach, setter supposed set passed parameter encapsulated private ivar. the other logic should somewhere else not in setter, although accepted have restrictions when set parameter in setter i.e. public setage(int age) { if (age >= 0) this.age = age; else this.age = 0; } that logic setter should have, should never receive more value assigning ivar.

java - JPA Hibernate HSQLDB - VARBINARY() field and error attempting to select -

i found similar question @ hsqldb: duplicate column name, unsupported internal operation: type, invalid character cast , there no intelligible answer. looked @ http://old.nabble.com/unsupported-internal-operation%3a-statementdmql-td27427172.html reports issue bug in hsqldb, should fixed in version using (2.2). so, here's details of problem: i have entity stores byte[] data in varbinary(128) field inside of hsqldb. table created successfully, when try select table, following stack trace: java.sql.sqlexception: java.lang.runtimeexception: unsupported internal operation: type java.lang.runtimeexception: unsupported internal operation: type @ org.hsqldb.jdbc.util.sqlexception(unknown source) @ org.hsqldb.jdbc.util.sqlexception(unknown source) @ org.hsqldb.jdbc.jdbcpreparedstatement.fetchresult(unknown source) @ org.hsqldb.jdbc.jdbcpreparedstatement.executequery(unknown source) @ com.mchange.v2.c3p0.impl.newproxypreparedstatement.executequery(newproxyprepare

c# - Where to store progress information in ASP.Net web application -

i'm creating page uploaded text files , builds them multiple pdfs. exports excel. each row in file corresponds new pdf needs created. anyway, once files uploaded want begin processing them, don't want user have stay on page, or still have session open. example close browser , come 10 minutes later, log in, , progress information 112/200 files processed or something. lot quicker though. so 2 questions really, how can pass processing job (handler?thread?) continue run when page closed, , return job has started (so browser isn't stopped)? secondly, can store information when user comes page, can see current progress. i realise can't use sessions, , since processing file second don't really want update db every second. there way can this? possible? i solved using link provided astander above. create object in httpcontext.application store progress variables, , set method processing inside new thread. // create new progress object batchprogress bs =

c# - How do I bind a datagrid in Silverlight? -

i new silverlight. how bind datagrid in silverlight project? the app has 1 mainpage.xaml user control. datagrid located in mainpage.xaml user control. list of objects retrieved in mainpage. how should go databinding list of objects datagrid? is there other way bind this? there 3 alternatives: databinding using xaml syntax databind in code behind setting itemssource property of datagrid instance in code behind for alternative 1 can idea reading following post: http://odetocode.com/code/740.aspx for alternative 2 take on following link: http://blogs.msdn.com/b/scmorris/archive/2008/04/14/defining-silverlight-datagrid-columns-at-runtime.aspx alternative 3 quick way things working. following link contains simple one: https://docs.google.com/doc?docid=0aqnzlafqzooazgzrc25ty3bfmwhzmno3c2c4&hl=en many don't consider alternative 2 , 3 best practice , suggest go take on mvvm (modelview-viewmodel) approach.

how to avoid memory leaks in android -

i dynamically updating tablelayout shown below appending imagebutton , textview each tablerow.whenever launch activity shows 4 rows (should display 10 actually) if keep break points in code , debug figure out problem displays 10 rows properly. doubt must memory problem in code getting images web feel takes lot of memory. tried releasing views memory after adding layout crashing time. please let me know doing wrong. for (int = 0; < parsedexampledataset.getappnamestring().size(); i++) { tablerow row = new tablerow(this); textview tv = new textview(this); tv.settext("appname: "+ parsedexampledataset.getappnamestring().get(i) +"\n" + "description: " + parsedexampledataset.getdescriptionstring().get(i)); imagebutton imgbtn = new imagebutton(this); url aurl = new url(parsedexampledataset.getimageurlstring().get(i)); urlconnection conn = aurl.openconnection(); conn.connect(); inputstream = conn.getinputstream(); bu

css - Animate opacity of an element on page-load using CSS3 -

using css 3, possible animate opacity of element 0 1 when page containing element has been loaded? possibly delay of 1 2 seconds... css has no idea load event. should take @ combination of jquery , css3 . or, since adding js anyway, why not animate whole thing in js ? give better cross-browser solution in opinion.

Google Buzz API - How do I access my entire followers ? - Google Error -

in google buzz api, need followers. let's assume have 1000 followers. google buzz api allows me 100 followers, there no paging varaible in api. , limited set max-results 100. if put max-results 1000, google automatically reduce 100. how can followers in api https://www.googleapis.com/buzz/v1/people/@me/@groups/@following?alt=json thanks sreeraj according http://code.google.com/apis/buzz/v1/using_rest.html#query-params there c parameter in addition max-results . defined an opaque continuation token allows paginating through large collection of entries. you receive 'c' value on fist request, , passing in subsequent requests give them proper offset.

c++ - Named sub-arrays of an array -

i want design data structure following properties: accessible single array of type t . example s[i] . ability access named ranges in it. example s.goodobjects[i] , s.badobjects[j] . iterate on whole (stl algorithms etc.). converting name-index index in whole array. here interface question too. also desired behaviour ability to i want ranges names checked @ compile time, not string-named ranges, c++ identifier-named. add or remove elements subarrays. s.badobjects.push_back(yourmom) . implement without using macros, c++ , templates, readability of usages of course #1 priority. possibly range arrays have element type of pointer derived class t pointer base class. so, how design such structure? edit looks haven't stated explicitly, 4th requirement (the first list) important one. maybe more general question follows: how design indexed collection of objects of different types (having common superclass) easy indexed access objects of particular subtype? so, havi

exslt - Best approach for combining several XSLT 1.0 passes which process the same nodes -

i'm doing complex xslt 1.0 transformation (currently using 8 xslt passes). want combine 8 passes without merging them in 1 file (this complex). solution using xsl:include , exsl:node-set merge passes , store temporary results in variables. but have 1 problem: transformation passes copies of nodes , modifying aspects. therefore need process same nodes in every pass, different xsl:template ! how do that? how tell after first pass want apply templates other xslt stylesheet? very simplified example i'm doing (2 xslt passes): source: <h>something here</h> after xslt pass 1: <h someattribute="1">something here</h> after xslt pass 2: <h someattribute="1" somemoreattribute="2">something here, , more</h> my current approach call xslt processor twice , saving results temporary on disk: xsltproc stylesheet1.xsl input.xml >temp.xml xsltproc stylesheet2.xsl temp.xml >finalresult.xml

iis - WCF Service hosting in IIS6 or IIS7 and calling it from a Windows form -

i have created wcf service application in vs2010 , done necessary implementations in it. i have created windows form calls service (have added service reference). bcos self hosting, working fine. i want move service iis , check clients working multiple locations (to note speed of operation performed). have checked everywhere in net how host wcf service in iis6 (or7) no clarity. please let me know how can publish service vs 2010 , created virtual directory etc etc client's reference points iis hosted service simplest way run visual studio admin go wcf project properties , in web tab want use local iis server. click button create virtual directory you need change address client talks to new iis hosted location

python - Flask vs webapp2 for Google App Engine -

i'm starting new google app engine application , considering 2 frameworks: flask , webapp2 . i'm rather satisfied built-in webapp framework i've used previous app engine application, think webapp2 better , won't have problems it. however, there lot of reviews of flask, approach , things i've read far in documentation , want try out. i'm bit concerned limitations can face down road flask. so, question - do know problems, performance issues, limitations (e.g. routing system, built-in authorization mechanism, etc.) flask bring google app engine application? "problem" mean can't work around in several lines of code (or reasonable amount of code , efforts) or impossible. and follow-up question: there killer-features in flask think can blow mind , make me use despite problems can face? disclaimer: i'm author of tipfy , webapp2. a big advantage of sticking webapp (or natural evolution, webapp2) don't have create own version

c# - Test cases to check if one string is present in another -

i had question in interview write test cases test function checks if 1 string present in didn't quite expect question pop in interview developer position, yesterday got heads on-site visit same company wanted pointers testing folks here idea (before head there) go answering type of questions. skeleton provided function ask me test it. public static boolean checksubstring(string str1, string str2) { //first string source // second string reference if(str1.contains(str2)) return true; else return false; } thanks reading. forward replies eagerly. just 1 tip: consider part: str1.contains(str2) , when result in true , when in false , needed make throw exception. that test cases.

c++ - Assigning heap objects to a std::map -

this crashes @ runtime. std::map<std::string, myclass> mymap; myvalue = new myclass(); mymap["mykey"] = *myvalue; i have 2 requirements: that instances of myclass held on heap (hence use of new); that able reference these via associative array (hence use of std::map). why can not use dereference operator succesfully in example? how can fulfill both @ once? ps. i'm using gcc. if lose scope of myvalue it's memory leak. it's better store myclass* in map. std::map<std::string, myclass*> mymap; myvalue = new myclass(); mymap["mykey"] = myvalue; in given example, make sure delete element while erasing or removing map<> . can use smart pointer (e.g. boost::shared_ptr ) if don't want worry memory management. also, given example don't know why should crash while dereferencing *myclass . doing weird stuff in copy constructor myclass::myclass(const myclass&) ?

Executing client side vbscript block with jquery -

im trying change bahavior in ads written in javascript , load them after page load completed. these ads filled document.write:s(doesnt work after page loaded) had overwrite function , append code jquery instead. thing script contains part document.write('<scr' + 'ipt language="vbscript"> \n'); document.write('on error resume next \n'); document.write('shockmode = (isobject(createobject("shockwaveflash.shockwaveflash.9")))\n'); document.write('<\/scr' + 'ipt>\n'); that gives me code overwritten document.write <script language="vbscript"> on error resume next shockmode = (isobject(createobject("shockwaveflash.shockwaveflash.9"))) <\/script> but when append script jquery seems ignored. is there way append vbscript after page done loading? if remember correctly easy call vbscript function javascript. why not create seperate file holds vbscript, link ht

ruby - Segmentation fault on Lion creating NSData from RubyCocoa with any bytes > 127 -

the following rubycocoa fine on max os x 10.6, segfaults on 10.7 require 'osx/cocoa' include osx bytes = [128].pack('i1') nsdata.alloc.initwithbytes_length(bytes, bytes.length) in cases works when top bit not set. in fact nsdata.alloc seems fail when passed buffer of bytes have top bit set. the version of ruby 1.8.7 on both os's, i'm @ loss diagnose why nsdata interpreting buffer differently. can shed light? you should go macruby replace rubycocoa. it's possible rubycocoa not (and never) work on lion. i don't have macruby experience lion yet, chances work.

java - Jsp Project not running -

i have created web project includes .jsp , java beans pages. when run project eclipse, using tomcat works fine, deployed project successfully, program runs , receive web page in browser. but when try deploy war file in webapps folder of tomcat6 , run on browser gives error – error see on page: http status 404. description: requested resource not available. what might problem? check if have file index.html/index.jsp in war if not there have either need change name of file opened in context "/" or have make changes in list.

Undefined reference errors in gcc -

gcc link results errors: dns.cpp: undefined reference '__res_querydomain' dns.cpp: undefined reference '__dn_skipname' dns.cpp: undefined reference '__dn_expand' dns.cpp: undefined reference '__res_query' is there library need link to? adding -lresolv solved me.

sql - Chat efficiency in Silverlight with MsSql 2008 DB -

in sl navigation application need chat function. so, i've created one. have linqtosql on server side , silverlight-enabled wcf service has insert/get messages. on client side use timer check every second if there new messages not created user , has creation time later last user update time. works fine. have no possibility check whether method fast, convenient , efficient larger amount of users , chats. thinking changing partly cached system. inserting new messages db when number of messages example 100. to sum worrying performance of solution. confirm or resolve doubts. thanks.

export - Exporting Entity-Relationship-Diagram from SQL with Visio 2010 (Professional Plus) -

i'm searching opposite solution question exporting sql viso diagram . have sql statement creation of multiple tables of mysql database. there way use reverse-engineering feature of visio 2010 create diagram thereof? i'm wondering if possible create access database sql statement (mysql) visio connect ... alternative i'll try use mysql database, create tables there, , try connect visio database. instructions how this? other ways? 1) import sql access , use visio : access incompatible mysql statements. have translate statements , 1 statement allowed @ time. not convenient. more info at: http://help.lockergnome.com/office2/sql-text-file-import-access--ftopict720045.html if have finished use these instructions: http://blog.pearltechnology.com/creating-entity-relationship-diagram-in-visio/ 2) create tables again in new mysql environment , use visio: follow instructions listed here http://sajjadhossain.com/2009/02/12/reverse-engineering-mysql-database-with-m

java - Lose contact with resources - why -

im developing in eclipse 5 activities, loose contact resources. have experienced phenomenon , knows it? have tried cleaning project no luck update: managed resolve issues deleting project , importing older version, worked. copying , pasting new , damaged version old version.. check edited resources errors (e.g. malformed xml in layout file changed). if there 1 error, whole resource generation stopped , can't reference anything.

firebird - entity framework triggers don't fire -

can't after insert trigger fire after savechanges() done. using t-sql executestorecommand() doesn't help. triggers fired on server, not entity framework. what doing: create new row in parent table: orders order = new orders { guid = guid.newguid().tostring(), orderdate = datetime.now, }; db.addtoorders(order); db.savechanges(); and put data child table trigger must fired after insert: foreach (sparepart item in somecollection) { orderitems orderitem = new orderitems { order_id = order.order_id, //here order.order_id 0, why? price = item.income_price }; db.orderitems.addobject(orderitem); db.savechanges(); } the trigger updates parent table: as begin update orders o set o.sum = o.sum + new.price o.order_id = new.order_id; end also can't increased order.order_id generated firebird generator, 0 after savechanges() done. my db schema generated out of firebird database. if order_id 0 means not configured returned

android - Changing Layout Background Colors in Java -

i made app several xml layouts (and gave them colorful backgrounds too!) however, friend noted little 'too' colorful. so, decided add checkbox main.xml file, checked default. if unchecked, want every background color go black, buttons' colors change background color "@drawable/buttoncolor" "@drawable/colorless", , text in buttons change white ("#ffffff"). if checked again, program should restore default. so question is... how this? established this: view colorbox = findviewbyid(r.id.nocolor); colorbox.setonclicklistener(this); where colorbox checkbox. and later on... public void onclick(view v) { switch (v.getid()) { // (other code have here) case r.id.nocolor: // go here..? break; } } all appreciated. (on side note, solution didn't work me either: how change textview's background color color defined in values/colors.xml file? ) colorbox.setbackgroundresource(r.drawable.co

php - How to specify foreign key column for Class Table Inheritance in Doctrine2? -

how can specify columns used foreign key relation class table inheritance in doctrine 2? example, take following 2 classes: /** * @entity * @inhertancetype("joined") * @discriminatorcolumn(name="type", type="string") * @discriminatormap("person" = "person", "employee" = "employee") */ class person { /** @id */ public $id; /** @column(type="string") */ public $ssn; } /** @entity */ class employee { /** @column(type="decimal") */ public $salary; } with this, doctrine expects table structure along this: create table `person` ( `id` int(11) not null auto_increment, `ssn` varchar(255) default null, primary_key(`id`) ) create table `employee` ( `person_id` int(11) not null, `salary` decimal(10,2) default null, primary_key(`person_id`) ) alter table `employee` add constraint `person_fk` foreign key (`person_id`) references `per

security - Javascript hijacking, when and how much should I worry? -

ok, i'm developing web app has begun more ajaxified. read blog talked javascript hijacking , , i'm little confused when it's problem. want clarification question 1: problem/vulnerability? if site returns json data 'get' request has sensitive information information can wrong hands. i use asp.net mvc , method returns json requires explicitly allow json requests. i'm guessing trying save uninitiated security vulnerability. question 2: hijacking occur sniffing/reading response it's being sent through internet? ssl mitigate attack? question 3: led me ask question myself. if i'm storing page state in local javascript object(s) of page, can hijack data(other logged in user)? question 4: can safely mitigate against this vulnerability returning json 'post' request? the post linked talking csrf & xss (see comment on question), in context: is problem/vulnerabiliy ("if site returns json data 'get' re

database - SQL SELECT only when all items match -

so have 2 tables: courses: -course_id (primary key) -course_code -title sections: -section_id (primary key) -course_id (foreign key) -day each course has number of sections belong it. let's use example. the tables: course_id course_code title 1 abc title1 2 bbc title2 section_id course_id day 1 1 monday 2 1 tuesday 3 2 monday 4 2 monday i want able run query asks courses give me ones of sections fit criteria. in case, let's want see "all courses have of sections on monday". desired output be: course_id course_code title section_id day 2 bbc title2 3 monday 2 bbc title2 4 monday notice how entry (2, abc, title1, 1, monday) omitted? can't seem think of way this. in advance! try this: select * courses c1

c# - Thread Context Switching Issue -

i have function that, argument sake, has 2 lines of code. line line b both lines calls third party web service work. appears though service call on line b contingent on being called (time-wise) after call line a. works fine in non-threaded environment application threading lots (potentially 100) of these calls. the problem threading, believe, context switching between threads causing enough time (a small amount of time) elapse between call on line , call on line b it's causing call on line b throw custom soap exception. my knowledge of threading doesn't extend situation this. there anyway make sure call on line b happens after call on line without thread context switching occurring in between? if need these lines called can lock them, meaning nothing else enter section until complete: lock(lck) { line line b } however, may cause problems if 100 threads doing - lose parallelism. in fact, whatever do, if general requirement, lose degree of paralle

linux - Saving webpages to localbox -

is there way in can download first visits webpage local box , subsequent visits retrieve data local box rather internet? is, service running on port , if access port , not http port, data local box? i need use service parsing webpages contents might change every time, same content work with. you can use caching proxy such squid . the squid service stores webpages locally , next requests return stored file.

oracle10g - Oracle - Use of XMLType or Name=Value Pairs (EAV) -

i working on designing data model log information. the log information can have variable elements , dynamic. what type of data model should work better? use of xmltype column or child table name=value pairs? i want avoid creating multiple columns columns dynamic nature , can change frequently. i know eav model not querying, have heard oracle 11g provides pivot function can transpose rows columns , how impact performance? the data loaded used downstream etl systems , occasional querying technical analysts thanks rajesh... plan create 2 tables: parent table common attributes part of every log event while child table have parent table id (logid) , have other transactional elements. currently there 200 elements apart standard elements , log event can have unto 10 different elements. number volatile , can change frequently. not make sense keep changing table data structure every time there new elements. also data not stored more 7 days , table not going used (or oc

.net - Get selected radio button from dynamically generated set in ASP.NET -

i'm working asp.net (2.0), , want generate group of radio buttons data source. simple enough using radiobuttonlist, want text associated each radio button have more formatting...in particular, of text should regular weight, bold. doesn't seem match radiobuttonlist. using repeater, can create single radiobutton each item in dataset, give them same groupname, , they'll work correctly on client side...but when form submitted, it's not clear me how discover button selected (server side). unlike radiobuttonlist, don't have single containing object can ask selected item from. we use bit more interactive, posting information server on radio button click, we'd avoid postbacks if possible. am missing simple? put radiobutton's in panel, iterate control collection of panel foreach (control ctrl in panel1.controls) { if (ctrl.gettype().name == "radiobutton") { if (((radiobutton)ctrl).checked)

jquery - json result to strongly typed List -

in typed view have dropdownlist filled "instruments" list viewmodel. everytime user clicks on item musiciansinstrument should appear underneath dropdownlist. this viewmodel public class registermusicianmodel { public registermusicianmodel() { instrumentrepository = new instrumentrepository(); instrumentlist = instrumentrepository.findallinstruments().tolist<instrument>(); musicianinstrumentlist = new list<musiciansinstrument>(); } private instrumentrepository instrumentrepository; private list<instrument> instrumentlist; private list<musiciansinstrument> musicianinstrumentlist; public list<musiciansinstrument> musicianinstrumentlist { { return musicianinstrumentlist; } set { musicianinstrumentlist = value; } } public list<instrument> instrumentlist { { return instrumentlist; } set { instrumentlist = value; } } private musi

string - What is the most efficient method using Request.UserLanguages to render a page based on the browser language?? -

i making page pulls user's browser preferred language, via request.userlanguages....which returns 2 letter code (ex. "en") or detailed code (ex. "en-gb") . i string of user languages (they in order of preference) , store them in string array. use loop check if language code in first position of string array of codes language (another string array hard coded in). is there better way this? i'm noticing increased load time , worried additional languages further slow page load... if (!ispostback) { //holds possible user languages preferences check client machine against string[] compjapaneselang = { "ja-jp","ja","jp","jpn","euc","shift-jis" }; } //get client machines langugage preferences string[] userlang = request.userlanguages; //loop through variation of preferences possible user langugaes (int = 0; < compjapaneselang.length; i++)

ruby - Rails String Interpolation in a string from a database -

so here problem. i want retrieve string stored in model , @ runtime change part of using variable rails application. here example: i have message model, use store several unique messages. different users have same message, want able show name in middle of message, e.g., "hi #{user.name}, ...." i tried store in database gets escaped before showing in view or gets interpolated when storing in database, via rails console. thanks in advance. if want "hi #{user.name}, ...." in database, use single quotes or escape # backslash keep ruby interpolating #{} stuff right away: s = 'hi #{user.name}, ....' s = "hi \#{user.name}, ...." then, later when want interpolation could, if daring or trusted yourself, use eval : s = pull_the_string_from_the_database msg = eval '"' + s + '"' note you'll have turn s double quoted string in order eval work. work isn't nicest approach , leaves open sor

php - getJson + Twitter -

im not programation i've been trying edit base code 1 ones display more 1 tweet dosen't work, me? $.getjson("http://twitter.com/status/user_timeline/user.json?count=3&callback=?", function(data) { $("#tweet").html(data[0].text); }); thanks! data array. data[0] accesses first tweet returned twitter. need iterate on array , append other tweets div. $.getjson("http://twitter.com/status/user_timeline/user.json?count=3&callback=?", function(data) { $(data).each(function() { $("#twitter").append($(document.createelement('div')) .html(this.text).addclass('tweet')); } }); edit : changed selector target #twitter div , add tweet class each tweet.

email - Open local mbox mail archive with imap_open() in PHP -

i'm attempting read mbox email archive exported server locally, via file access, whatever reason i've tried fails. there magical trick parse local file , access php's built-in imap functionality? you should able use php's built-in imap functionality. have tried this: function openlocal($file_path) { $mbox = imap_open("$file_path",'',''); if (!mbox) { $errormsg = imap_last_error(); // error... return false; } else { return true; } } and call respective correct path: openlocal('/home/email/temp/mailbox')

sql query to find the duplicate records -

what sql query find duplicate records , display in descending, based on highest count , id display records. for example: getting count can done select title, count(title) cnt kmovies group title order cnt desc and result title cnt ravi 10 prabhu 9 srinu 6 now query result below: ravi ravi ravi ...10 times prabhu prabhu..9 times srinu srinu...6 times if rdbms supports on clause... select title ( select title, count(*) on (partition title) cnt kmovies ) t order cnt desc

Converting bitwise AND/NOT from VB.NET to C# -

original code (vb.net): curstyle = curstyle , (not es_number) changed code (c#): curstyle = curstyle & (!es_number); but giving me error: operator '!' cannot applied operand of type 'long' es_number of data type long. tried changing int, string, etc. doesn't work. how solve problem? and same & ; got correctly. not in front of long bitwise not operator. c# equivalent ~ . the c# code be: curstyle = curstyle & (­~es_number); check out bitwise operators in c# or(|), xor(^), and(&), not(~) , explaining c# bitwise operators.

android - Gravity problem (When registerUpdateHandler?) -

i have problem gravity. make map of game add elements boxes, brick etc. using code: private void addface2(final scene pscene, final float px, final float py, final int pwidth, final int pheight, final string ptype, final string gbodytype) { final sprite face; final body body2; bodytype bodytype; face = new sprite(px, py, pwidth, pheight, this.mboxtextureregion); bodytype = bodytype.dynamicbody; body2 = physicsfactory.createboxbody(this.mphysicsworld, face, bodytype, boxfixturedef); pscene.attachchild(face); this.mphysicsworld.registerphysicsconnector(new physicsconnector(face, body2, true, true)); boxy.add(face); } everything "ok" elements bouncing!? think problem lies in this.mscene.registerupdatehandler(this.mphysicsworld); . i want ask how stop bouncing not removing gravity? http://s3.ifotos.pl/img/fail_hsrpxhe.png sorry english, work on it.. check boxfixturedef , fixturedef

C# CodeDom Multiple CompilerOptions -

i add multiple compileroptions codedom, cannot figure out how so. what trying: compilerparameters cp = new compilerparameters(referencedassemblies, "executable file path", false); cp.compileroptions = "/unsafe"; cp.compileroptions = "/t:winexe"; the issue latter of 2 parameters being incorporated output executable file. there way add compileroptions parameters array? thank help, evan based on usage i'm guessing can like cp.compileroptions = "/unsafe /t:winexe"; if wanted build string in array need loop on array holds compiler options , append them string. assign string cp.compileroptions msdn http://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters.compileroptions.aspx

design patterns - Algorithm problem- with the picture attached -

Image
i attaching picture have shown diagram need check good/bad blocks. basically, have information of size of each block , number of rows , column. know if row has or odd number of blocks. i need make cluster of 2 blocks , check if resultant block(with combination of 2) or bad. if 2 blocks good, resultant block , otherwise bad. i need know algorithm of it. if row has odd numbers of blocks, ignoring middle block , considering last blocks. the diagram in shape of circle blocks on circumference ignored. so, have consider middle block shown in picture. i need iterate on each row, make group of 2, find result. if row has odd number of blocks, ignore middle one, , make group of last 2 blocks @ corner. the shape inside circle shown in picture, real figure. i guess, have given enough information time. note: in example, making group of two, need make group of 2, 3 or 4 blocks in row ,just generic case. if block in group bad,the whole group bad whether group of ,3, or 4.i need wr

How to do this in Android? (C# Source) -

the objective send data on http post json in it. c# source this: http.addfilefield("file", "file.text", ms); string json = jsonconvert.serializeobject(d, formatting.none, jsettings); ioutil.writestringtostream(json, ms); ms.position = 0; how on android? try - httpurlconnection urlconn = null; url murl = new url(url); urlconn = (httpurlconnection) murl.openconnection(); urlconn.setrequestmethod("post"); urlconn.addrequestproperty("content-type", "application/" + "json"); urlconn.setdooutput(true); //query json string if (query != null) { urlconn.setrequestproperty("content-length", integer.tostring(query.length())); urlconn.getoutputstream().write(query.getbytes("utf8")); } urlconn.connect();