Posts

dependency injection - ASP.NET 5 DI Connection String into ADO.NET -

good morning, we migrating away ef using ado.net our backend. ef, easy inject connection string. however, unable figure out how standard service. code is: services.addscoped<idatacatalogrepository, sqldatacatalogrepository>(); currently going through dependency injection test project on github not seeing need. want is: services.addscoped<idatacatalogrepository, sqldatacatalogrepository>("connectionstring") sqldatacatalogrepository have connectionstring 1 of constructor properties. using beta 4, ideas? steven m. what need factory. addscoped method use have few overloads including ones implementationfactory parameter. your code this: private static readonly func<iserviceprovider, idatacatalogrepository> repofactory = (_) => { var connectionstring = "get connection string somewhere"; return new sqldatacatalogrepository(connectionstring); } and calling addscoped this: services.addscoped<idatacatalog...

python - Matching range of timestamps in pandas -

i having trouble doing in pandas df1 (my left join): name | timestart | timeend | values | order john 12/24/2014 08:10:32 12/24/2014 08:14:21 2 1 john 12/24/2014 08:15:03 12/24/2014 08:22:49 2 2 df2 name | timestart | timeend | values john 12/24/2014 08:12:57 12/24/2014 08:13:31 8 timestart in df2 greater timestart in df1 (this typically happens during interaction). , match, have less next row of data individual. here thought process. shift row columns see if match. compare df2 timestart > initial timestart on df1 less next row timestart (same name). df1.sort(['name', 'timestart'], ascending=[1, 1], inplace = true) df1['name_r'] = df1['name'].shift(-1) df1['matching row'] = np.where((df1['name_r'] == df1['name']), 1, 0) df1['next timestamp'] = np.where(df1['matching row'] == 1, df1['timesta...

regex - htaccess 301 redirect -- remove a string -

i trying htaccess 301 redirect, stuck. what want remove string in url, string is: style=5& i want redirect pages may string in url removed. -- in advance. from: /viewtopic.php?style=5&f=45&t=1980&p=19136 to: /viewtopic.php?f=45&t=1980&p=19136 you can use code in document_root/.htaccess file: rewriteengine on rewritecond %{query_string} ^(.+?&)?style=5(?:&(.*))?$ [nc] rewriterule ^viewtopic\.php$ %{request_uri}?%1%2 [r=302,nc,l]

objective c - iOS Messages App UITableViewCell Insert Animation -

what wondering how can go achieving animation ios messages app animation whenever send message. animation takes text text field inside inputaccessoryview , animates uitableviewcell. you may wanna try cocoacontrol, gives full messaging ui ios one. i tried find animation code , achieved (is not close solution, didnt find observer called): - (void)finishsendingmessageanimated:(bool)animated { uitextview *textview = self.inputtoolbar.contentview.textview; textview.text = nil; [textview.undomanager removeallactions]; [self.inputtoolbar togglesendbuttonenabled]; [[nsnotificationcenter defaultcenter] postnotificationname:uitextviewtextdidchangenotification object:textview]; [self.collectionview.collectionviewlayout invalidatelayoutwithcontext:[jsqmessagescollectionviewflowlayoutinvalidationcontext context]]; [self.collectionview reloaddata]; if (self.automaticallyscrollstomostrecentmessage) { [self scrolltobottomanimated:animated]; ...

excel - Matching a cell to the closest highest value in another range -

i have number on "buildup" tab of excel workbook , list of random numbers on "oh" tab of same workbook. trying match number on buildup tab closest highest value on oh tab. found formula online , tweaked cell references , sheet names, seems match closest number , not highest closest number: =index(oh!$b$2:$b$250,match(min(abs(buildup!ac8-oh!$b$2:$b$250)),abs(buildup!ac8-oh!$b$2:$b$250),0)) oh sheet list of random numbers. buildup!ac8 cell reference of number i'd match closest highest value on oh tab. i use array formula small or min function, entered ctrl + shift + enter : using small : =small(if(oh!$b$2:$b$250>=buildup!ac8,oh!$b$2:$b$250),1) using can increment 2nd highest, 3rd highest, etc. based on second parameter. return #num! if no match found. using min : =min(if(oh!$b$2:$b$250>=buildup!ac8,oh!$b$2:$b$250)) as @byron pointed out, will return 0 when there no large number match, small might preferred.

java - Comparing current date time(live) with file last modified -

Image
i want program output such that, whenever receives text file client, print "a new file has been received!". text files store in c:/users/%userprofile%/desktop/ad. the code below check whether new text file has been received directory. import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.io.file; import java.text.dateformat; import java.text.simpledateformat; import java.util.calendar; import java.util.date; import javax.swing.timer; public class test { final dateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); static int count = 0; static file[] f = null; static date date = new date(); static calendar = null; public static void main(string[] args) { dateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); while(true) { try { thread.sleep(2000); } catch (interruptedexception e1) { e1.print...

Generics C# No Boxing Conversion - No Implicit Conversion -

i'm going try make clear possible! the end goal being able access protected method within abstract class. method inherited abstract class too. the abstract class has generic, need class generic (ie creating generic adapter). here abstract class (well similar structure). public abstract class myabstract<t> : abaseclass<t> t : someclass { } here base class inherited abstract class(has method need) public abstract class abaseclass<t> : anotherbase, idisposable t : someclass, someclass2 { protected void foo(t somevar); } the classes above within dll, not have access to. here's trying do, need in right direction! public mainclass<t> : myabstract<t> t : someclass { public void somefunct() { this.foo(avariable); } } your class should this: //uncomment ", new()" if want create new instance within somefunct method public class mainclass<t> : myabstract<t> t : someclass//, new() {...