Posts

java - SAXParser - Escaping Special Characters -

i parsing below string using saxparser <xml> <firsttag>&amp;&lt;</firsttag> <secondtag>test</secondtag> </xml> i want same string retained getting converted below <xml> <firsttag>&<</firsttag> <secondtag>test</secondtag> <xml> here code. how can avoid being converted? saxparserfactory factory = saxparserfactory.newinstance(); saxparser saxparser = factory.newsaxparser(); myhandler handler = new myhandler(); values = handler.getvalues(); saxparser.parse(x, handler);

javascript - How to make the autocomplete search result contains hyperlinks -

hi doing search box search items in list. when users start type in words, original list fade out, while list of matched items fade in, , items in list contain hyperlinks. this right now, http://jsfiddle.net/x69chen/sbar6/5/ . i using fadein, fadeout change list, , autocomplete feature. this $(".form-search").keypress(function() { $("#nav-list123").fadeout({}); $("#search-result").fadein({}); $("#autocomplete").autocomplete({}}); however, not make hyperlinks search result, seems need customize autocomplete code. have no idea how it. could helps me please? thanks. you can manually open link that: $("#autocomplete").autocomplete({ source: source, select: function( event, ui ) { window.location.href = ui.item.value; //window.open(ui.item.value); // if want open in new tab } });

c# - asp.net mvc data logic structure -

so have bunch of entity models. lots of controllers , views , controllers go , linq query , making available view. however lets have model users and have linq query active users putting in controller might fine if done once, want repeat it, im wondering correct place putting model specific queries. ideally controller says users.getactiveusers() or similar. you should repository pattern. the repository pattern allows abstract database logic , reduce redundancy of common data calls. since formulating linq queries often, why not put them 1 common class? public class userrepository { private readonly _dbcontext mydbcontext; public ienumberable<user> getactiveusers() { // whatever find active users return _dbcontext.where(user => user.active == true); } } now can inject repository controller. public class homecontroller : controller { private readonly userrepository _userrepo; public homecontroller...

sql - Counting Policy Ages with a Query in tsql -

i have table containing insurance policies (let's call policies) in 1 field, along policies off of renewed in field: policy_id | prior_policy_id =========================== abc | abd | abc afp | anr | abd brc | afp fkz | i write query count total number of prior policies each policy, result looking this: policy_id | num_prior_policies ============================== abc | 0 abd | 1 afp | 0 anr | 2 brc | 1 fkz | 0 any suggestions appreciated. you need recursive cte this: with cte ( select p.policy_id, 0 num_priors policies p prior_policy_id null union select p.policy_id, 1 + cte.num_priors cte join policies p on p.prior_policy_id = cte.policy_id ) select * cte; here sql fiddle showing working.

Node.js & avconv — real-time video conversion -

i'm working on real-time video conversion demo app. video file parsed node-multiparty , file's part piped avconv.stdin , when processed, chunk pipes write stream . here's part of source code: var form = new multiparty.form(), args = ['-i', 'pipe:0', '-f', 'webm', 'pipe:1'], avconv = spawn('avconv', args), output = fs.createwritestream(filepath); form.on('part', function (part) { if (part.filename) { part.pipe(avconv.stdin); part.on('end', function() { console.log('===== video has been uploaded! ====='); avconv.stdin.end(); }); } }); avconv.stdout.pipe(output); i'm interested in end event attached file's part . event should fired when part parsed, means has been uploaded. i have test video file (~800kb) , low-level laptop testing. while running test on localhost, end event firing @ end of avconv conversion process, lasts ~15s. 800kb v...

ruby on rails - What is the process of creating a joining table which resolves a many-to-many relationship using migrations? -

i understand process can followed create models , migrations in turn create joining table within database resolve many-to-many relationship. instance. if have course table, students table , want create joining table called studies id course , students along data such grade , date started. process doing this? if use generate model command each of above 3 table names, create separate migration of them. if go models , add relevant associations not affect how database created? please give me guidance on steps must take in order create required foreign key relationships here examples? use has_many :through association . set manually. step 1: generate models separately. joining model study contain foreign keys, remember include columns. rails g model course title:string rails g model student name:string rails g model study course_id:integer student_id:integer start_date:date grade:string step 2: set associations: # models/course.rb class course has_many :studies ...

html - Linking an IMG inserted from CSS to another page when clicked? -

just wanting know if it's possible insert link html page when click image have inserted via css. width : 50%; height : 40px; float : left; background-image:url(buttons/btn_name.png); background-repeat: no repeat; background-size : 100% 100%; for example, when click "btn_name" image when it's displayed in div have inserted into, how link "home" page via css? appreciated. your requirement not clear far understood want make div clickable linked page. if so, there many ways way want this. put css rules in class .link { width : 50%; height : 40px; float : left; background-image:url(buttons/btn_name.png); background-repeat: no repeat; background-size : 100% 100%; } and anchor tag above class name <a class="link" href="page.html">link text</a> if don't want text visible add following property in .link css class text-indent:-9999px; now image linked "page.html". if...