Posts

c# - Use DataTable.Load() without creating all column properties -

i'm loading data sql server database this: sqlcommand cmd = new sqlcommand("select * x", conn); cmd.commandtype = commandtype.text; datatable dt = new datatable(); sqldatareader rd = cmd.executereader(); dt.load(rd, loadoption.preservechanges); issue: the load() function initializes table columns columnname , datatype , looks deeper database, , adds constraints allowdbnull , autoincrement , maxlength , etc. however, leads problems in application, because want further process data internally. so, possible load() setting basic properties (which come directly select statement), without setting allowdbnull , maxlength , , on? or need clean these values after load() ? or there alternative calling load() ? if don't want behaviour don't use datatable.load dbdataadapter.fill(datatable) : datatable dt = new datatable(); using(var da = new sqldataadapter("select * x", conn)) da.fill(dt); the fill operation adds rows des...

javascript - How to change text in this case using ng-if or other expression? -

i'm trying change text in title tag based on tag 's direction value: <li ng-repeat="t in tags"> <div class="tag" ng-class="{'green-up': t.direction == 'positive', 'red-down': t.direction == 'negative', '' : t.direction == 'stagnant'}" title="percentage increase" ng-if="">{{t.name}}</div> </li> the direction either positive , negative or stagnant , should correspond title="percentage increase" title="percentage decrease" or title="percentage" what angular syntax best used in case? why not set tag settings object $scope.taginfo = { positive:{ class:"green-up", title:"percentage increase" }, negative:{ class:"red-down", title:"percentage decrease" } } and call...

html5 - Javascript Object print object value -

i'm trying value object , prit on screen no success... http://jsfiddle.net/lbascg4v/5/ app.js // função construtora function keydown(e) { this.faq = e.keycode; alert(e.keycode) } // prototype com os métodos keydown.prototype = { printr: function() { alert(this.faq); } } window.addeventlistener('keydown', keydown, true); index.html <canvas id="canvas" width="300" height="300" style="border: 1px solid red"></canvas> <script> teste = new keydown(); teste.print(); </script> when push key on canvas, want value of key , put in object, want print object , value. the real answer question you don't need prototyping : function keydown(){ // initialize properties this.faq = 0; this.update = function(e){ // set faq this.faq = e.keycode; } this.print = function(){ // alert faq alert(this.faq); } } and then: window. test = ne...

why do we use 'pass' in error handling of python? -

it conventional use pass statement in python following piece of code. try: os.makedirs(dir) except oserror: pass so, 'pass' bascially not here. in case, why still put few codes in program? confused. many time , attention. it's parser. if wrote this: try: # code except error: and put nothing in except spot, parser signal error because incorrectly identify next indentation level. imagine code: def f(x): try: # except error: def g(x): # more code the parser expecting statement greater indentation except statement got new top-level definition. pass filler satisfy parser.

javascript - Web Worker - How to reference worker file when packaged with Bower -

i'm writing small javascript text expansion library. library use web worker , packaged bower. when installed via bower parser script not found (i 404) because browser looking relative root of consuming site , not relative bower script being consumed (both scripts contained in same folder). appears correct behavior . my question: how should workers used in combination bower such required scripts can loaded without hard-coding bower_components/ path? function expander(args) { ... this.parser = 'parser.js'; this.worker = new worker(this.parser); ... } i use grunt. gulp might bit easier starting out since can debugged missing key component needs. there set of libraries wiredep, build-file , watch enable wanting do. wiredep watches bower directory , automatically add js files dependencies in bower.json html , watch can configured watch type of file in directory change. build-file enables configure template , pass variables use dynamically build j...

How to configure RESTEasy to use the Jackson afterburner module -

with large payloads, seeing when json converted pojo, taking lot of time. internally uses jackson. wondering if there way can configure resteasy use afterburner module seems better performace. you can configure objectmapper used. 1 way can done through contextresolver , see here . register module objectmapper (as seen in documentation ).

mysql - Can Sphinx match against terms or phrases that are similar to the provided search params? -

i've got mysql free-text search , running in rails app. if search 'regular guitar cable' 'guitar' , 'cable', want. now i've installed sphinx , thinking-sphinx gem, , i've found search 'regular guitar cable' doesn't return results @ all. what's worse if search 'guitars' nothing! instead i'm finding have search 'guitar' instead i.e. need enter exact term. this problematic because few of users search 'guitar' , instead it's more search 'red guitar' or 'cheap guitar' , need sphinx bit smarter. how can make want without having add every single adjective in english dictionary stop-word file the following resolved problem! product.search "\"#{search_text}\"/1" the /1 @ end makes work, , it's called quorum operator .