Posts

Showing posts from May, 2013

c++ - Why do college computer science classes promote 'using namespace std'? -

i've taken 2 classes on c++ far, 1 each @ different school, , both of them have used 'using namespace std;' teach basic programming. may coincidence had go out of way find out it's not practice so. because best practices when writing sample code not best practices when writing large projects. in c++ course, write small programs (up few hundred lines of code) have solve relatively small problem. means little no focus on future maintenance (and avoiding sources of confusion future maintainers). because many teachers not have coding experience in large projects, problem doesn't acknowledged (let alone discussed) in c++ courses.

android - Do I need to call getWritableDatabase() everytime I manipulate data -

i have newbie question sqlite databases in android: do need retrieve writeable database everytime manipulate data? so can write dao this: class dao { private final sqlitedatabase database; public dao(sqliteopenhelper databasehelper){ database = databasehelper.getwritabledatabase(); } public void insert(...){ contentvalues cv = new contentvalues(4); database.insertorthrow(table, null, cv); ... } public void update(...){ contentvalues cv = new contentvalues(4); database.update(....); } } or must write dao this: class dao { private final sqliteopenhelper databasehelper; public dao(sqliteopenhelper databasehelper){ this.databasehelper = databasehelper } public void insert(...){ sqlitedatabase database = databasehelper.getwritabledatabase(); contentvalues cv = new contentvalues(4); database.insertorthrow(table, null, cv);

javascript - ng-repeat performance over thousands of elements without limit filter -

i'm generating svg graph in angular template based on array of following format: [{x: 0, y: 1}, {x: 1, y: 2}, ...] -- array contain thousands of points. while can render <path> element thousands of points, unacceptable performance occurs when use ng-repeat create <circle> element each point. to ensure performance not due svg performance , copied angular generated svg output , created static .html file included 5 graphs containing 10,000 <circle> elements. static file rendered instantly. confirmed it's not boiler plate code generating , scaling points because without <circle> elements (only 2 <path> elements) performance exceptional. i've narrowed down either ng-repeat 's dom injection mechanics or fact ng-repeat creates child scope each element own dirty checking watchers. based on exhaustive research appears it's more latter. here's template generates graph: <svg width="1020" height="220&q

xml - How to compare the value of the current for-each element? -

xml: <a>1</a> <a>2</a> <b>3</b> <a>4</a> <b>5</b> desired output: value value value b value value b xslt: <xsl:for-each select="a | b"> <xsl:if test="? = 'a'"> value </xsl:if> <xsl:if test="? = 'b'"> value b </xsl:if> </xsl:for-each> how compare value of current element in line <xsl:if test="? = 'a'"> , <xsl:if test="? = 'b'"> ? you need name() , strange way of going it. posted, want output names of nodes. in case: <xsl:apply-templates select='a|b' /> <xsl:template match='a|b'> value <xsl:value-of select='name()' /> </xsl:template>

Python: Create a "Table Of Contents" with python-docx/lxml -

i'm trying automate creation of .docx files (wordml) of python-docx ( https://github.com/mikemaccana/python-docx ). current script creates toc manually following loop: for chapter in mychapters: body.append(paragraph(chapter.text, style='listnumber')) does know of way use "word built-in" toc-function, adds index automatically , creates paragraph-links individual chapters? thanks lot! the key challenge rendered toc depends on pagination know page number put each heading. pagination function provided layout engine, complex piece of software built word client. writing page layout engine in python not idea, not project i'm planning undertake anytime :) the toc composed of 2 parts: the element specifies toc placement , things heading levels include. the actual visible toc content, headings , page numbers dotted lines connecting them. creating element pretty straightforward , relatively low-effort. creating actual visible content, @

javascript - FormData Object Parsing Only One Input -

i have formdata object create using form's id. form has multiple input values. send formdata using xmlhttprequest(). however in request (which have debugged using google chrome's developer tool) can see in form data, when view "parsed" version sending first input value. when view source of formdata input values there. my question why when viewing parsed version of formdata can see 1 value whereas viewing source can see of them? this may cause of other issues on server end not retrieving of parameters correctly. edit - code form <form id='properties'> <input type='text' name='name' value='previous'/> <input type='text' name='occupation' value='unknown'/> <input type='hidden' name='id' value='23'/> </form> javascript xmlhttprequest method function sendrequest() { var request = gethttprequest(); request.onreadystat

python - Improving Performance of Multiplication of Scipy Sparse Matrices -

given scipy csc sparse matrix "sm" dimensions (170k x 170k) 440 million non-null points , sparse csc vector "v" (170k x 1) few non-null points, there can done improve performance of operation: resul = sm.dot(v) ? currently it's taking 1 second. initializing matrices csr increased time 3 seconds, csc performed better. sm matrix of similarities between products , v vector represents products user bought or clicked on. every user sm same. i'm using ubuntu 13.04, intel i3 @3.4ghz, 4 cores. researching on read ablas package. typed terminal: ~$ ldd /usr/lib/python2.7/dist-packages/numpy/core/_dotblas.so which resulted in: linux-vdso.so.1 => (0x00007fff56a88000) libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f888137f000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8880fb7000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8880cb1000) /lib64/ld-linux-x86-64.so.2 (0x00007f888183c000) and underst

javascript - How to remove the city label in openlayer? -

i have wms layer this var wms_layer = new openlayers.layer.wms( 'openlayers wms', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layers: 'basic,clabel,ctylabel,statelabel', transparent: true}, {isbaselayer: false, opacity: .7} ); how remove ctylabel or statelabel wms layer? i want remove labels on fly. not @ creation of layer. when user interact map want add/remove labels ctylabel or statelabel. how do this? if have created layer , want remove labels later: wms_layer.mergenewparams({layers: 'basic,clabel'});

Jquery accordion change link function after second click -

i've got simple accordion, , wondering how change link after second click goes actual url. first click opens accordion, working fine, second click goes href. my accordion code is $(".mobile-main-nav ul ul").accordion({ collapsible: true, active: false, header: "a.level2" }); i know event:false option disable click event, unsure best method apply it. thanks in advance! you can hook 'beforeactivate' event of accordion attach flag attribute element. run through conditional , should close want. $("ul.testnav").accordion({ collapsible: true, active: false, beforeactivate: function(e, ui){ if(ui.newheader.attr('data-visited')){ window.location = ui.newheader.attr('href'); } else { ui.newheader.attr('data-visited', 'true'); } } }); http://jsfiddle.net/p6jef/1/ (the actual linking won't work jsfiddle doesn't ha

php - validation always showing enter all fields -

the problem whenever loading page, getting enter fields, there anyway bypass whenever load page first time. <form action="brand_upload.php" method="post" enctype="multipart/form-data"> <label for="file">filename(logo):</label> <input type="file" name="file" id="file"><br> <br>brand:<input type="text" name="brand"> <br>serial no.:<input type="text" name="serial_number"> <input type="submit" name="submit" value="submit"> <?php if (isset ($_post['submit']) && isset($_post['brand']) && isset($_post['serial_number']) && !empty($_post['brand']) && !empty($_post['serial_number'])){ { echo 'do something'; } else { echo '<br>enter fields'; } ?> </form> you can check if r

android - How can I identify the current fragment of my activity while using tabs and fragment container? -

i want call fragment method activity, describe in so-question: findbyid testfragment testfrag = (testfragment) getfragmentmanager().getfragmentbyid(r.id.testfragment); if(testfrag != null && testfrag.isadded()) testfrag.testmethod("test"); as seen identify fragment id set in xml. have fragment container none of fragment layouts have id. so seconds thought using function getfragmentbytag `like in tags fragmenttransaction.replace(r.id.frametitle, casinodetailfragment, "fragmenttag"); but use action bar tabs don't have tags: my activity: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_fragmentcontainer); // actionbar gets initiated actionbar actionbar = getactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); // define tabs actionbar.tab basicinfotab = actionbar.newtab().settext( r.string.tab_baseinfo); .

java - Empty JSP param object after servlet forwarding -

i'm sorry if trivial issue, revolting amount of time has been wasted. i'm getting started java servlets/jsp, trying render template parameters passed on servlet. code servlet goes follows (doget() method): request.setattribute("attr", "an attribute"); request.getrequestdispatcher("/comissoes").forward(request, response); in jsp template, try: <c:out default="no such attribute..." value="${attr}" /> i've checked , servlet routs correct urls , jsps, jstl expressions correctly evaluated (using tomcat 7.0 + jstl 1.2), no data being embedded in forwarded request servlet jsp template. older scriptlet syntax apparently not allowed server. so, what's happening?

oracle - how to declare a variable in pl sql the right way? -

here code vjs varchar2(3500); --25065 gmaxdays s_criteria%rowtype := get_criteria_rec('max_days_booking'); begin if not sec_pkg.chk_sec('atlas_inv_overbook') -- exit procedure if security did not pass return; end if; -- vjs := ' gmaxdays;'||chr(10)|| 'function checkfields() {' ||chr(13) || ' // setting target here' ||chr(13) || ' document.frminvselect.target="_top"' ||chr(13) || i created gmaxdays,at first had hardcoded on table called s_criteria , max_days_booking part of s_criteria. im calling right way? this how use , work vjs varchar2(3500); --25065 begin if not sec_pkg.chk_sec('atlas_inv_overbook') -- exit procedure if security did not pass return; end if; -- vjs := 'var gmaxdays = 366;'||chr(10)|| 'function checkfields() {' ||chr(13) || '

excel - One Google Docs workbook as a database for another using a script? -

disclaimer: started working spreadsheets in depth week, prior basic usage. i've read rules , relate programming, it's ignorance of programming keeps me asking specific question. i'm new this, want learn, have start somewhere. i want create 2 separate spreadsheet documents, 1 database another. want 1 able query other in way similar vlookup() function or along lines. these large files hence need separate documents. i learning scripting , think there might way there. if that's case please appreciate literally started reading scripts morning , know nothing (yet) them. all need know is, if it's possible , functions use, i'll figure out how use them. don't have working knowledge of script functions, , limited knowledge of spreadsheet functions. the importrange() function limited 50 per spreadsheet, given how want use it, not enough. unless know work around. , want 1 cell of information @ time , doesn't need displayed, usable. also, effi

excel - Morningstar expected return -

i have code have tweaked below. use scrape other morningstar data, can't seem make work "expected return" etfs(exchange traded funds). on code right set data need having problem getting on excel spreadsheet. when msgbox tbltr under code: set tbltr = doc.getelementsbyclassname("pr_text3")(4).innertext i expected value on message box. however, when take msgbox code out, value doesn't appear in excel spreadsheet. have been trying work out hours , need help! below entire code. under tab "tickers2" have tickers pull data. examples jke, jkf, jkd...which have 1000. under tab "expectedreturn" want data displayed. think has me pulling elementsbyclassname versus when used pull elementsbytagname. there wasn't in tagnames in information needed switched class name. below entire code. i mention have signed in morningstar.com in order actual data, assuming forum can point me in right direction without needing signed in. the

titanium - How to post to facebook page feed? -

i using ti studio 3.1.1 ga build native ios app (6.1) integrated facebook. trying post story 1 of fan pages own. story written "recently posted others" section in facebook using facebook page id. fb.requestwithgraphpath('me/accounts', {}, 'get', function(e) { if (e.success) { fb.permissions = ['publish_stream', 'read_stream','manage_pages']; fb.authorize(); access_tokens = json.parse(e.result); (var = 0; < fanpages.length; i++) { ( var j=0; j < access_tokens.data.length; j++) { if (fanpages[i].id === access_tokens.data[j].id){ var data = { link: "http://www.example.co/index.html", picture: returneddata[0].image, }; fb.requestwithgraphpath(fanpages[i].id + '/feed' , data, 'post',showrequestresult); } } }

c# - Encoding UTF8 weird characters? -

Image
i working tapi api in c#. 1 of call property has byte[] data , converting string format. string json format. working fine machine. when ran same code different machine string (json) format showing in weird characters. please see both below code // event handler called when new incoming call received. void onincomingcall(object sender, tapieventargs args) { // display message in log string msg; msg = string.format("incoming call {0} {1} on line '{2}'. , {3}", args.call.calleridname, args.call.callerid, args.line.name.clone(),args.call.tag); msg = msg + "\n" + string.format("devicespecificinfo data {0}", system.text.encoding.utf8.getstring(args.call.devicespecificinfo)); addtolog(msg); } my machine image url my machine other machine image url other machine what issue? encode issue?

jquery - MVC 4 client side validation not working for the form which is loaded using Ajax -

i have admin page in user clicks on links , corresponding partialview , containing web form loaded inside particular div on admin page using ajax. all of the "~/scripts/jquery-2.0.3.js", "~/scripts/jquery.unobtrusive-ajax.js", "~/scripts/jquery.validate.js", "~/scripts/jquery.validate.unobtrusive.js" are referenced within admin page , when partialview loaded, jquery client side validation won't work. but when reference scripts within partialview , works fine don't intend each partialview because numerous , each time each 1 loads, @ least 2 of .js files must requested server again . is there way can have scripts inside parent ( admin ) page without issue ? you need on each 1 of partial views: $(document).ready(function () { $.validator.unobtrusive.parse("#yourformid"); }); basically validation not bound on dynamically rendered form...

javascript - how to execute the JS before rendering the HTML page? -

i writing html page,in fire ajax request , check response receive , depending upon response,i decide whether render page or not.at present depending upon request,i redirecting url html page gets rendered. you can't pre-html effort. logic have server side. create 'blank' page redirects content or shows content. loading elements tho needed act on logic (js / html code, etc;) workflow be: load blank looking page js logic identify if should loading content or denying further access

javascript - Is jQuery UI dependable? -

i use jquery ui build web based gui hardware product. important gui accessible 24/7 , compatible years , years down road. not computer genius, may seem dumb question, concerned fact code generated jquery ui points .js files located on webserver. example: <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> these 2 lines of code exist in html head tags. these files not exist on physical server, if these webservers go down? believe lose functionality web gui. would make difference if copy , paste code in these .js files , place them on web server? way gui's lifeline in hands of own server. basically, asking if knows how safe use jquery ui web based gui must not ever go down. missing here , helpful if 1 explain me in more detail how use jquery ui in safe , dependable way not depending on code exists on server. thank you! for many

Selenium RC -html suite hangs on "Preparing Firefox profile..." -

i'm having trouble when execute following command in cmd windows 8; java -jar selenium-server.jar -htmlsuite "*firefox" "http://www.konga.com" "c:\users\tunji\desktop\seleniumtestscorefunctionality\deliverywidgettest.html" "c:\users\tunji\desktop\seleniumtestscorefunctionality\results.html" -firefoxprofiletemplate "c:\users\tunji\appdata\roaming\mozilla\firefox\profiles\0srebkp2.selenium" output: 19:00:37.664 info - java: oracle corporation 23.25-b01 19:00:37.665 info - os: windows 8 6.2 amd64 19:00:37.667 info - v1.0-snapshot [1123], core v1.0-snapshot [2101] 19:00:37.747 info - version jetty/5.1.x 19:00:37.749 info - started httpcontext[/selenium-server/driver,/selenium-server/driver] 19:00:37.750 info - started httpcontext[/selenium-server,/selenium-server] 19:00:37.750 info - started httpcontext[/,/] 19:00:37.757 info - started socketlistener on 0.0.0.0:4444 19:00:37.757 info - started org.mortbay.jetty.server@

Google Search Individual pages show up in search -

quick question... when search sites in google, individual pages on site show example. when search website, shows pages gallery , contact when want show main index/homepage site.. , not show individual page sections (gallery , contact).. thanks it because in google's eye, subpage (contact, gallery, ..) optimized keyword instead of homepage. need optimize homepage keyword if want show homepage keyword.

css3 - Safari css width transition not working with different unit measurements -

i'm having issue -webkit-transition in safari. these transitions work fine in chrome, ff, , ie10 (using non-prefixed transition property). in site, there 3 panels can viewed. main 1 opens default , other 2 collapsed on right of window showing sliver of content. when collapsed panel clicked additional class added via js , transitions 100% width. css: .panel-1{ width: 100%; } .panel-2{ width: 8rem; position: absolute; top: 0; right: 0; overflow: hidden; z-index: 500; transition: 0.5s; -webkit-transition: 0.5s; } .panel-2:hover{ width: 10rem; } .panel-2.panel-open{ width: 100%; } .panel-3{ width: 4rem; position: absolute; top: 0; right: 0; overflow: hidden; z-index: 501; transition: 0.5s; -webkit-transition: 0.5s; } .panel-3:hover{ width: 6rem; } .panel-3.panel-open{ width: 100%; } the problem seems difference of measurement units. hover transitions work intended ( rem rem ), widt

c# - Getting OS, Platform and Device information on Windows 8 -

how following information on windows 8? platform, os version, device name, device id , carrier (not sure if carrier applicable windows 8) with windows phone 8, retrieve them using: platform: environment.osversion.platform os version: environment.osversion.version device name: microsoft.phone.info.devicestatus.devicename device id: windows.phone.system.analytics.hostinformation.publisherhostid carrier: microsoft.phone.net.networkinformation.devicenetworkinformation.cellularmobileoperator i looking windows 8 equivalent of above windows phone 8 information using c#. you can below information here windows version processor architecture device category device manufacturer device model for unique id, see udid windows 8 you can below information here app version os version machine name

javascript - error injecting $dialog in angularjs -

i want show dialog angularjs controller . using angular-ui , angular-strap while injecting $dialog in controller following error : error: [$injector:unpr] http://errors.angularjs.org/1.2.0rc1/$injector/unpr?p0=%24dialogprovider%20%3c-%20%24dialog @ error (<anonymous>) @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:6:450 @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:31:145 @ object.c [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:296) @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:31:213 @ c (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:296) @ d (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:473) @ object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:30:123) @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angul

mechanicalturk - Get multiple HIT submissions or auto-generated answers in MTurk Worker Sandbox -

using mturk, during testing phase, might useful execute same hit multiple times collect enough data webapplication. however, in worker's sandbox, 1 assignment can submitted. is there way multiple results same hit? e.g. way fill in form multiple times same user account, or method auto-generate inputs , submit crowd-sourced forms?

javascript - Hide one div, unhide another div, scroll to the new unhidden div -

i have function closegeneralhelp takes 1 parameter: idtag . function supposed following: a) slideup "help" div, b) slidedown set of divs , c) scroll, jump, or otherwise go specific (but dynamically determined) other div of set of divs exposed via slidedown . i have 2 classes of divs ("divstoshow" , "divtohide"). "divstoshow" has few other divs contained in , each of divs has unique id (this idtag is). parts (a) , (b) work fine. scrolling specific (but dynamically determined) div seems fail no matter try. here code. each /* */ comment block represents separate, failed (and flailing) attempt @ making work. any on getting (c) work? javascript / jquery infant. reasonably related advice / pointers appreciated. function closegeneralhelp(idtag){ $(".divstoshow").slidedown("slow"); $(".divtohide").slideup("slow"); /* var divid = document.getelementbyid(idtag); divid.style.display

javascript - The sort-button doesn not work in Backbone.js -

i have json file, need parse collection , render html pageand need add button, sort collection , redraw on page. code, made: that's part model, collection , sorting: var profile = backbone.model.extend(); var profilelist = backbone.collection.extend({ model: profile, url: 'profiles.json', selectedstrategy: "count", comparator: function (property){ return selectedstrategy.apply(model.get(property)); }, strategies: { count: function (model) {return model.get("count");}, name: function (model) {return model.get("name");} }, changesort: function (sortproperty) { this.comparator = this.strategies[sortproperty]; }, initialize: function () { this.changesort(

Select a distinct row based on the max value of another column SQL Server 2008 R2 -

i have query pulls in information other tables created in query. final output final select statement looks this: visit_id | mrn | days score | ip score | er score | cc score | total 123456 | 123 | 3 | 3 | 2 | 0 | 8 123456 | 123 | 3 | 3 | 2 | 2 | 10 123456 | 123 | 3 | 3 | 2 | 4 | 12 ... what row max(total), in case row total = 12 i have looked @ post cannot seem right. have looked here. here query producing results: -- @lace_mstr table declaration ###################################// declare @lace_mstr table( mrn varchar(200) , visit_id varchar(200) , [lace days score] int , [lace acute ip score] int , [lace er score] int , [lace comorbid score] int ) --###################################################################// insert @lace_mstr select q1.mrn , q1.encounter_id , q1.[lace days score] , q1.[acute admit score] , case when q1.visit_count null 0 when q1.vis

c++ - Detecting mounted drives on Linux and Mac OS X -

i’m using qdir::drives() list of drives. works great on windows, on linux , mac returns single item “/”, i. e. root. expected behavior, how can list of drives on mac , linux? non-qt, native api solutions welcome. clarification on "drive" definition: i'd list of mount points visble "drives" in finder or linux built-in file manager. as far filesystem concerned, there no concept of drives in unix/linux (i can't vouch macosx i'd it's same). closest thing mount points, normal application shouldn't bother them since available under filesystem root / (hence behaviour of qdir::drives() observe). if want see mount points in use, parse output of mount command (without arguments) or, @ least on linux, contents of /etc/mtab file. beware though, mount points can pretty hairy real quick (loop devices, fuse filesystems, network shares, ...) so, again, wouldn't recommend making use of them unless application designed administer them.

jquery - javascript multiply input by number -

i'm trying create simple function table have been tasked creating. want user enter number first input field, , have number multiplied 30, , have result show in second input field, keyup or onchange. here's have far, please keep in mind i'm very new @ this. <table> <tr> <td>costs</td> <td>$ <input type="text" id="daily"> </td> <td>$ <input type="text" id="result"> </td> </tr> </table> <script> $(function () { $('#daily').keyup(function () { var daily = $('#daily').val(); var month = 30; $('#result').val(daily * month); }); }); </script> $(function () { $('#daily').on('keyup', function (){ var daily = parseint($('#daily').val()); var month = 30; $('#result').val

excel - Finding Values in an array with duplicates values -

i have array of customer names. array full of duplicates, , needs since other data in order row may vary. there no unique identifiers data , need compare data 1 order against rows have customer in array. i'm having trouble getting loop search rows have customer match. any appreciated! dim prodlog string dim orddate variant dim cus string dim owner string dim orddate2 variant dim owner2 string dim logcusts variant logcusts = application.transpose(range("f3", range("f" & rows.count).end(xlup))) dim loglen integer loglen = ubound(logcusts) - lbound(logcusts) dim cust2 variant each cust2 in logcusts dim custrow integer custrow = application.match(cust2, logcusts, false) + 1 prodlog = range(cells(custrow, 5), cells(custrow, 5)).value orddate = range(cells(custrow, 2), cells(custrow, 2)).value cus = range(cells(custrow, 6), cells(custrow, 6)).value owner = range(cells(custrow, 7), cells(custrow, 7)).value databook.activate

C++ Polymorphism need assistance -

i had take inheritance between class person , class student , write test program using polymorphic pointer pindividual. program compiles isn't listing student1 stats me. here code: #include <iostream> #include <string> using namespace std; class person { public: string m_name, m_address, m_city, m_state; int m_zip, m_phone_number; void virtual list_stats(); }; void person::list_stats() { cout << "this function show_stats() in class person show person1's " << endl; cout << "information:" << endl << endl; cout << "name: " << m_name << endl << "address: " << m_address << endl << "city: " << m_city << endl; cout << "state: " << m_state << endl << "zip: " << m_zip <<

Rails Migrating Foreign Keys -

i have discovered relationship between 2 of tables wrong , make necessary changes - involves dropping foreign key on accommodations table , adding foreign key on users table. i have created migration file using: rails g migration foreignkeyadjustment and added new migration file: class foreignkeyadjustment < activerecord::migration def self.up remove_column :accommodations, :user_id add_column :users, :accommodation_id, :integer end end i ran migration using: bundle exec rake db:migrate and used console check column names in each table , changes have not taken effect! rails console and user.column_names what missing? p.s. major issue if deleted models , database migration files , generated new models terminal? wouldn't take me long , no important data consider. have established active record associations? allow map records 1 table another. otherwise column name arbitrary name in table. did add foreign key attribute model? cre

node.js - Deploying a TCP server to Heroku -

i have tcp server coded in node.js. i'd put on heroku because it's free service , don't need more free plan offers. now, know little inner workings of heroku , i'm pretty new whole thing have few questions. firstly, possible deploy tcp (non-web) server? i've read heroku doesn't node.js's net because doesn't support websockets , should use socket.io. so i've switched server socket.io. think. because code more or less looks same. i've done well: https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku what put in procfile instead of "web"? also, when tried deploy have, logs said application failed bind $port. what's $port? , how change port want? in fact, if don't change it, how know application can connect server? heroku doesn't support generic tcp server should able functionality want socket.io. you need put web in procfile. that's lets heroku bind external connection port 80

sql - Get database session expire time -

how value of database session expire time? i have session want kill, don't have enough privileges it. can see session in v$session: select * v$session osuser = 'osuser' , username='username'; as far understand session expire time set in sqlnet.ora. (obviously don't have access check.) there select can execute value of session expire time? i'm using oracle database 10g. yes, indeed, sqlnet.expire_time set in sqlnet.ora configuration file. is there select can execute value of session expire time? unfortunately no, there no data dictionary view available allow display content of sqlnet.ora. so, if have no access file view content, , has not been granted alter system privilege, should ask system administrator or dba help.

linux - Cannot display xclock program on xserver client - Mobaxterm -

i using mobaxterm(free version) on windows 7 desktop connect suse 11 enterprise server on aws. trying display xclock program on xtrem client error saying 'error: can't open display:'. have used following syntax set display on server: export display=<ip_addr>:0.0 suse 11 not come xclock default had download , install it. hosts file on pc has localhost entry commented out, not sure if make difference. ideas on how debug this? thanks. fixed! earlier looking @ xclock program's error msg. when scanned mobaxterms client terminal's output, found following msg: x11 forwarding request failed on channel 0 after google hunting, found 1 of reasons happens when xauth package not installed on remote server. so, checked , found case. command ran: zypper in -name xorg* this command tells if package installed , if dependencies exist. package comes bundled xclock program. zypper uninstalled other xclock had installed source , replaced right version.

c# - Migrating WSE Client to WCF - how to replace SecurityPolicyAssertion and UsernameToken? -

i have web service implemented in java being invoked wse 3.0 client, , migrate wse wcf. using standard tools, have created client can invoke web service, returns soapexception message of "required parameter value missing". web service uses https , requires username & password provided. in existing wse client code, credentials area supported subclassing securitypolicyassertion , sendsecurityfilter , follows: public class utclientassertion : securitypolicyassertion { public utclientassertion() { } public override soapfilter createclientoutputfilter(filtercreationcontext context) { return new clientoutputfilter(this, context); } public override soapfilter createclientinputfilter(filtercreationcontext context) { // don't provide clientinputfilter retur

Issue with adjacent CSS Selector in Chrome and in Safari -

consider following (fiddle found here http://jsfiddle.net/burninromz/yduzc/8/ ) what should happen when click checkbox, appropriate label should appear. not work in safari , chrome, on ie, firefox , opera. when inspect elements in both chrome , safari, see style applied element, not rendered correctly. ideas why is? see below. html <div> <input type="checkbox"></input> <span>unchecked</span> <span>unchecked</span> css input[type="checkbox"]:checked + span { display:none } input[type="checkbox"] + span { display:block } input[type="checkbox"]:checked + span + span { display:block } input[type="checkbox"] + span + span { display:none } this selector not work input[type="checkbox"]:checked + span + span { display:block } you can try using sibling combinator. ~ similar + , h

css - Moving my sharepoint site title from left to right -

Image
i have modified master page move site collection title body, inside upper suite bar. move following h1 div code inside suite bar div follow:- <div id="suitelinksbox"> <sharepoint:delegatecontrol id="id_suitelinksdelegate" controlid="suitelinksdelegate" runat="server" /> </div> <h1 id="pagetitle" class="ms-core-pagetitle" style="color:white;float:left"> <sharepoint:ajaxdelta id="deltaplaceholderpagetitleintitlearea" runat="server"> <asp:contentplaceholder id="placeholderpagetitleintitlearea" runat="server"> <sharepoint:sptitlebreadcrumb runat="server" rendercurrentnodeaslink="true" sitemapprovider="spcontentmapprovider" centraladminsitemapprovider="spxmladmincontentmapprovider">

Can't make JQuery's .show and .hide work -

i have problem using .show , .hide in jquery. want 2 options appear once hit register button, code: html <div id='register'> <form> <input type='button' class='register-button' name='register-button' value='r e g s t e r !'> </form> <form id='register-type'> <span class='register-type-background'> </span> <input type='button' class='register-type-band' name='register-type-band' value='band'> <input type='button' class='register-type-user' name='register-type-user' value='user'> </form> </div> jquery: $(document).ready(function(){ $('#register-type').hide(); $('.register-button').click(function(){ $('#register-type').show(); }); }); and more html: <head> <title> title </title> <link rel=&

Android: FrameLayout not respecting draw order -

i have framelayout 4 surfaceviews arranged in 2x2 grid. user can resize each of views. i'd views drawn in order of area, largest view drawn first , on. each time view resized, order views area, , update framelayout: public void reorderviews() { plotview child1; plotview child2; boolean swap = false; for(int = 0; < layout.getchildcount(); i++) { child1 = (plotview) layout.getchildat(i); for(int j = + 1; j < layout.getchildcount(); j++) { child2 = (plotview) layout.getchildat(j); if(child1.area < child2.area) { layout.removeviewat(j); layout.addview(child2, i); } } } } this works, in sense framelayout's children array holds views in correct order. after re-ordering, views continue draw in original order (i.e. order in added). i've tried requesting layout on framelayout, on individual chil

c# - Event Ordering in .NET -

got quick question on event ordering in c#/.net. let's have while loop reads socket interface (tcp). interface taking care of ordering (it's tcp). let's packet interface written each "packet" in stream, forward next "layer" or next object via event callback. so here pseudocode: while (1) { readsocket(); if (data received = complete packet) raiseevent(packet); } my questions are: are events generated in order? (i.e. preserve ordering) i assuming #1 correct, means block while loop until event finishes processing? you never know how event implemented. it's possible events executed synchronously, in order, , based on meaningful value. it's possible they'll executed synchronously in arbitrary , inconsistent ordering. it's possible won't executed synchronously, , various event handlers executed in new threads (or thread pool threads). it's entirely implementation of event determine of tha

sql - Converting DatePart and grouping on one line -

i'm doing best turn days of week x can mark them on weekly schedule - combining them on 1 line crux. expected output: agrmntid description repairid su m tu w th f sa 2 landscaping 2 x 3 landscaping 2 x x x x x x current output: agrmntid description repairid 2 landscaping 2 current code: select agreements.agrmntid, laborcodetypes.description, agreementschedules.repairid agreements inner join agreementschedules on agreements.agrmntid = agreementschedules.agrmntid inner join laborcodetypes on laborcodetypes.repairid = agreementschedules.repairid inner join (select agreementschedules.agrmntid, agreementschedules.repairid, case when datepart(dw, agreementschedules.scheddate) = 1 'x' end sunday agreementschedules agreementschedules.repairid = 2 union select agreementschedules.agrmntid, agreementschedules.repairid, case

javascript - AngularJS: filter a dropdown directive -

here code how can filter dropdown directive using custom attribute? $scope.mykeyword = [ {id: 1, keyword:"activitytype", description: "active"}, {id: 2, keyword:"activitytype", description: "inactive"}, {id: 3, keyword:"activitytype", description: "deleted"}, {id: 4, keyword:"marketsegment", description: "fashion"}, {id: 5, keyword:"marketsegment", description: "it"}, {id: 6, keyword:"marketsegment", description: "f&b"}, {id: 7, keyword:"marketsegment", description: "manufacturing"}, ]; directive tag <keywords supplier-id="supplier.id" keyword-type="marketsegment" title="choose status" label="" array="mykeyword" opt-value="id" opt-description="description"></keywords> i want filter dropdo

android - Share Intent does not work for uploading video to youtube -

i trying share video being created , stored on external sdcard path has been obtained by. environment.getexternalstoragepublicdirectory(environment.directory_movies).getabsolutepath() i using send_intent follows: intent shareintent = new intent(intent.action_send); shareintent.addflags(intent.flag_activity_clear_when_task_reset); shareintent.settype("video/mp4"); shareintent.putextra(android.content.intent.extra_subject, "my subject"); shareintent.putextra(android.content.intent.extra_text,"my text"); shareintent.putextra(intent.extra_stream, uri.parse(video_path)); startactivityforresult(intent.createchooser(shareintent, "share video"),share_intent); problem: while share through gmail, shows me compose window video attached. no size being shown of video , when either send or cancel window, gmail crash inputstream npe on contentresolver. in case of youtube, says cannot upload videos cloud service, video resi

jquery - $().toggleClass(); not working -

here fiddle. trying make own checkbox using <div> , , applying colors $().css() . when click div , trying use $().toggleclass() in click function change background-color #96f226 jquery: $('div').mouseenter(function(){ $(this).css('background','#656565'); }); $('div').mouseleave(function(){ $(this).css('background','#4a4a4a'); }); $('div').click(function(){ $(this).toggleclass('active'); }); html: <div></div> css: div { width: 15px; height: 15px; background: #4a4a4a; cursor: pointer; } .active { background: #96f226 } with .css call 'background' property, change corresponding inline style of element, specified attribute. in other words, mouseenter handler turns <div> <div style="background: ##656565"> . mouseleave works similar way, it's value of style attribute different. the problem style rule set in way -

php: what does . and .. mean in the output of dir->read() -

<?php $d = dir('css'); echo "handle: " . $d->handle . "<br>"; echo "path: " . $d->path . "<br>"; while (($file = $d->read()) !== false){ echo "filename: " . $file . "<br>"; } $d->close(); ?> result: handle: resource id #4 path: css filename: . filename: .. filename: css filename: img filename: index.html filename: js filename: lightbox question: in result, . , .. mean? . current directory , .. 1 up. code examples have if-statement s skip on em. here example out of php docs: http://php.net/manual/en/function.readdir.php#example-2318 even on docs, shows code ignore.

r - nlsList() error Error in object[[3L]][[1L]] : object of type 'symbol' is not subsettable -

i'm trying run series of non-linear regression in r. models i'm trying fit describe progress of viral population through time @ 3 different temperatures. i'm trying use function nlslist() groupeddata object: surv <- groupeddata(log10n ~ t | temp, data.frame(cbind(rbind(surv4, surv22,surv56), temp=rep(c(4, 22, 56), each=8)))) where log10n log10 of population, t time , temp temperature. nlstools package i'm trying fit mafart model, used mafart model formula create self starter: mafart.self <- selfstart(~ log10n0-(t/delta)^p, surv, parameters=c('p', 'delta', 'log10n0')) getinitial(log10n~mafart.self, data=surv56) when try initial values following error: error in object[[3l]][[1l]] : object of type 'symbol' not subsettable if skip getinitial() step , use nlslist() function follows same e