Posts

sql server - Random Weighted Choice in T-SQL -

how randomly select table row in t-sql based on applied weight candidate rows? for example, have set of rows in table weighted @ 50, 25, , 25 (which adds 100 not need to), , want select 1 of them randomly statistical outcome equivalent respective weight. dane's answer includes self joins in way introduces square law. (n*n/2) rows after join there n rows in table. what more ideal able parse table once. declare @id int, @weight_sum int, @weight_point int declare @table table (id int, weight int) insert @table(id, weight) values(1, 50) insert @table(id, weight) values(2, 25) insert @table(id, weight) values(3, 25) select @weight_sum = sum(weight) @table select @weight_point = floor(((@weight_sum - 1) * rand() + 1), 0) select @id = case when @weight_point < 0 @id else [table].id end, @weight_point = @weight_point - [table].weight @table [table] order [table].weight desc this go through table, setting @id each record's id value while @ ...

asp.net - What is the best way to keep an asp:button from displaying it's URL on the status bar? -

what best way keep asp:button displaying it's url on status bar of browser? button defines this: <asp:button id="btnfind" runat="server" text="find info" onclick="btnfind_click"> </asp:button> update: this appears specific ie7, ie6 , ff not show url in status bar. i use ff never noticed this, link in fact appear in status bar in ie.. i dont think can overwrite :( thought maybe setting tooltip (al la "title") property might it.. seems not.. looking @ source, appears found, browser issue, don't think can in code.. :( update yeah, looks ie posts whatever form action is.. can't see way override it, yet.. perhaps try explicitly setting via js? update ii done more googleing. don't think there "nice" way of doing it.. unless remove form , post data other way.. is worth much? tends page name?

Why do all methods in the Google Analytics tracking code start with an underscore? -

prefixing variable , method names underscore common convention marking things private. why methods on page tracker class in google analytics tracking code ( ga.js ) start underscore, ones public, _gettracker , _trackpageview ? because google can't bothered follow module pattern , therefore don't want accidental collisions in global namespace?

What's the better database design: more tables or more columns? -

a former coworker insisted database more tables fewer columns each better 1 fewer tables more columns each. example rather customer table name, address, city, state, zip, etc. columns, have name table, address table, city table, etc. he argued design more efficient , flexible. perhaps more flexible, not qualified comment on efficiency. if more efficient, think gains may outweighed added complexity. so, there significant benefits more tables fewer columns on fewer tables more columns? i have few simple rules of thumb follow when designing databases, think can used make decisions this.... favor normalization. denormalization form of optimization, requisite tradeoffs, , such should approached yagni attitude. make sure client code referencing database decoupled enough schema reworking doesn't necessitate major redesign of client(s). don't afraid denormalize when provides clear benefit performance or query complexity. use views or downstream tables impleme...

user interface - Native Tongue as Default Language For an Application -

when downloading both firefox , chrome, i've noticed default version got in native tongue of hebrew. don't applications in hebrew, since i'm used english ui conventions embedded in me since long ago by: the lack of choice: programs don't offer interfaces in multiple languages , when do, languages english , developer's native tongue. programming languages bound english language. my question this: if translate applications, limit ui user's native tongue or give them choice enabling more 1 language pack default? which language application default (which interesting if install 1 language pack application)? and i'd know how value put translating applications on whole. i've helped develop application used dutch, english, spanish , portuguese speaking users. because application installed cd added language packs. because saved lot of work not having maintain 4 different versions. if application distributed website , have support mo...

WPF - Programmatic Binding on a BitmapEffect -

i able programmatically bind data dependency properties on bitmapeffect . frameworkelement textblock there setbinding method can programmatically these bindings like: mytextblock.setbinding(textblock.textproperty, new binding("someproperty")); and know can in straight xaml (as seen below) <textblock width="auto" text="some content" x:name="mytextblock" textwrapping="wrap" > <textblock.bitmapeffect> <bitmapeffectgroup> <outerglowbitmapeffect x:name="myglow" glowcolor="white" glowsize="{binding path=myvalue}" /> </bitmapeffectgroup> </textblock.bitmapeffect> </textblock> but can't figure out how accomplish c# because bitmapeffect doesn't have setbinding method. i've tried: mytextblock.setbinding(outerglowbitmapeffect.glowsize, new binding("someproperty") { source = someobject }); but doesn...

iphone - NSFetchedResultsController - phantom row -

just run tricky nsfetchedresultscontroller problem. the following code works fine in cases except first entry core data database when reports 2 rows! id <nsfetchedresultssectioninfo> sectioninfo = [[fetchedresultscontroller sections] objectatindex:section]; numberofrows = [sectioninfo numberofobjects]; if add additional entries these reported correctly. , if delete both of 2 initial rows works fine. any suggestions? if it's help, using: -com.apple.coredata.sqldebug 1 i can see there 1 insert , 2 selects. also, problem doesn't seem happen if i've visited view containing nsfetchedresultscontroller code (i.e. before doing inserts). ==== update 1: wonder if walk through code help... 1. viewcontroller starts background nsoperation download 2. when completes sends notification appdelegate 3. when appdelegate gets notification imports data (doing check make sure it's on main thread before doing so) here's relevant bit of importerdidsa...