I wish to make a generic extension method :  public static IList&lt;ValidationResult&gt; ValidateMany&lt;T&gt;(this IValidator validator, IList objectsToValidate) {     var results = new List&lt;ValidationResult&gt;();     foreach (var obj in objectsToValidate)     {         var validationResult = validator.Validate((T) obj);         results.Add(validationResult);     }     return results; }   I would like T to be passed in. That may seem easy by adding a template param, but then from the calling code I would like to do :  // calling code var typeOfT = WorkOutTypeFromObjects(objectsToValidate); var objectsToValidate = RowsToObjectsFactory.Create(typeName, tableRows); var results = validator.ValidateMany&lt;typeOfT&gt;(objectsToValidate);   the top line there is the critical part that is hard to get, I need some dynamic way of working out the type and passing it in the T param. Or is there a good alternative?
What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime?  Consider the following sample code - inside the Example() method, what's the most concise way to invoke GenericMethod&lt;T&gt;() using the Type stored in the myType variable?  public class Sample {     public void Example(string typeName)     {         Type myType = FindType(typeName);          // What goes here to call GenericMethod&lt;T&gt;()?         GenericMethod&lt;myType&gt;(); // This doesn't work          // What changes to call StaticMethod&lt;T&gt;()?         Sample.StaticMethod&lt;myType&gt;(); // This also doesn't work     }      public void GenericMethod&lt;T&gt;()     {         // ...     }      public static void StaticMethod&lt;T&gt;()     {         //...     } }
Travelling with two different passports I was just wondering if you have two passports (a Chinese one and an Australian one), and you booked your airline ticket with the Chinese one, will you have to show both of your passports or just one?  The thing is, on my Chinese passport, it has my birth name, but then when I became an Australian citizen, I legally removed my Chinese name and replaced it with my English name. So I don't know whether I should just show the passport officials the one that I booked the airline ticket with. How to make dried desert/cracked ground I am trying to create a cracked ground appearance for an animation that takes place in the desert. something like the image here:I would like to do this all in blender, and have blender generate the texture so I will not have to worry about unwanted ridges like those you would get in an image from the internet: I am wondering if there is a way to procedurally generate these cracks and use them with microdisplacements. Thank you! I already searched the internet but could not find a solution to this. Maybe it is the same question as  but there was no answer.  I want to render a video with tracking, but the output "loses" color information and gets kind of greyish. I first thought that it is related to the renderer, but it happens in Cycles and Eevee. Therefore i made a sample image, added it to the image sequence editor and rendered it as 1 frame. Resulting in the same problem.  I placed the original image beside blenders output so that you can see the difference. The only idea I came up with is that something with the lighting is not correct but I can't find a setting for that.  I am using Blender 2.80 with the default settings. Only set the output resolution to match the input resolution. I want to plot this graph, but I don't know how to code the words in the nodes.     Here is my code:  \documentclass{article} \usepackage{amsmath} \usepackage{titletoc} \usepackage{tikz} \usetikzlibrary{trees,positioning,fit}  \begin{document}{\allowdisplaybreaks[4]}  \tikzstyle{bag} = [text width=2em, text centered] \tikzstyle{end} = []  \begin{center} \begin{tikzpicture}[sloped] \node (a) at ( 0,0) [bag] {$\ln r_0$}; \node (b1) at ( 3,1.5) [bag] {$\ln r_{10} + \sigma_1\sqrt{\Delta t_1}$}; \node (b2) at ( 3,-1.5) [bag] {$\ln r_{10}$}; \node (c1) at ( 6,3) [bag] {$\ln r_{20} + 2\sigma_2\sqrt{\Delta t_2}$}; \node (c2) at ( 6,1.5) [bag] {$\textrm{Mean} = \ln r_{20} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2}$\\$\textrm{Mean Change} = \mu_{11}\Delta t_2 = \ln\dfrac{r_{20}}{r_{10}} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2} - \sigma_1\sqrt{\Delta t_1}$}; \node (c3) at ( 6,0) [bag] {$\ln r_{20} + \sigma_2\sqrt{\Delta t_2}$}; \node (c4) at ( 6,-1.5) [bag] {$\textrm{Mean} = \ln r_{20} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2}$\\$\textrm{Mean Change} = \mu_{11}\Delta t_2 = \ln\dfrac{r_{20}}{r_{10}} + \dfrac{3}{2}\sigma_2\sqrt{\Delta t_2} - \sigma_1\sqrt{\Delta t_1}$}; \node (c5) at ( 6,-3) [bag] {$\ln r_{20}$}; \draw [-&gt;] (a) to node [below] {} (b1); \draw [-&gt;] (a) to node [above] {} (b2); \draw [-&gt;] (b1) to node [below] {} (c1); \draw [-&gt;] (b1) to node [below] {} (c2); \draw [-&gt;] (b1) to node [below] {} (c3); \draw [-&gt;] (b2) to node [below] {} (c3); \draw [-&gt;] (b2) to node [below] {} (c4); \draw [-&gt;] (b2) to node [below] {} (c5); \end{tikzpicture} \end{center}  \end{document}       Update code use  \draw [-&gt;] (a) to node [below] {} (b1.south east); \draw [-&gt;] (a) to node [above] {} (b2.north east); \draw [-&gt;] (b1.south east) to node [below] {} (c1.west); \draw [-&gt;] (b1.south east) to node [below] {} (c2.west); \draw [-&gt;] (b1.south east) to node [below] {} (c3.west); \draw [-&gt;] (b2.north east) to node [below] {} (c3.west); \draw [-&gt;] (b2.north east) to node [below] {} (c4.west); \draw [-&gt;] (b2.north east) to node [below] {} (c5.west); I have a question about XTP_CHECKPOINT.  I'm using SQL Server 2014. I have a database that is in SIMPLE recovery model mode. It is also being replicated.  There are no open transactions. I've run DBCC OPENTRAN and it returns:     "No active open transactions."   But I keep getting this message whenever I try to create or drop a table or delete data: (I've replaced my actual database name with the word database_name)     "The transaction log for database 'database_name' is full due to 'XTP_CHECKPOINT'"     Does anyone know why this might be happening, and, more importantly, how can I make it stop?  And yes, the database really is in SIMPLE recovery model mode. i.e. The transaction log should truncate automatically.  Incidentally, another database that I have in full recovery mode did the same thing, started returning the same error:     The transaction log for database 'database_name' is full due to 'XTP_CHECKPOINT'   I tried to change the log growth settings to unlimited growth, but it wouldn't let me, returning the same error.  I can reproduce the problem without any XTP stuff at all, except for just the filegroup. Here's how: What is PECS (Producer Extends Consumer Super)? How to install pygments on windows 7 When I run LaTeX file its gives error as  "! Package minted Error: You must have pygmentize installed to use this package", you must have pygments installed. when I go through minted documentation minted itself required pygments, so Tex friend How do I install this pygment, I don't know the procedure to install. Please guid me or any link pygement.exe file The new top bar layout is fine, but the black color is very visually jarring/intrusive.  Is using a lighter color an available option? LaTeXiT is cropping the pdf I am using LaTeXiT (pierre chachatelier, www.chachatelier.fr) - latex equation editor for Powerpoint for mac.  It's producing pdf that appear to be "cropped" on top (see attached) - I've tried already with changing the "margins" option (Preferences>General) but unsuccessfully - don't think that's the problem.   Any hint?   Thanks error: file '/grub/i386-pc/normal.mod' not found error: file '/grub/i386-pc/normal.mod' not found. grub rescue&gt;   What can I do? I just sit and stare at it.   I found my old netbook (Dell Inspiron 1010) which I have not used for about four years. I replaced Windows XP with Ubuntu 12.10. I used my bootable USB drive. I installed and rebooted. I got the message that normal.mod is not found.   What should I do? Type exit, reboot, or quit? Should I re-install? I bought two pieces of land. One from Morthal, and one from Falkreath. Morthal was the first plot of land I purchased. I only finished half of it. I bought the plot of land in falkreath because I liked the nature better. I finished the house completely in Falkreath. Every time I try to adopt a child off the streets it keeps saying "I have a place but no room for you" Even though I have the bedrooms in my Falkreath house. Why can I not adopt a child and have him/her live at my house in Falkreath? I would like to remove my Raspberry Pi from my iPhone 8 (running iOS 11.2.1) as a connected bluetooth device.  Normally, I would go into my Settings -> Bluetooth and select the Info button (a small blue circled "i") to show the "Disconnect" and "Forget Device" dialogs:    Unfortunately, iOS does not give me this option for my device. The bluetooth device list does not contain an "i" for the item, and there is seemingly no other way to disconnect.    How do I unpair this device if there is no button to trigger to the unpair prompt?  Due to work restrictions I cannot completely reset the device. "He didn't know where New Jersey was" What does Superman do with his regular clothes after changing in the phone booth? We all know that Superman changes in the phone booth. But where does he put his regular clothes while he's on a mission? He doesn't throw it out, because he changes back. But we don't see him carrying a bag of dirty laundry while he's on a mission.  ("In his right hand, Superman has Lois Lane, and in his left hand he seems to be holding... boxers??)  And I can't imagine he leaves it in the phone booth.  So where does Superman leave his regular clothes after he changes? If $E[X|Y]=Y$ almost surely and $E[Y|X]=X$ almost surely then $X=Y$ almost surely Confused AUC ROC score I am working on binary classification problem, I try to evaluate the performance of some classification algorithms (LR,Decission Tree , Random forest ...). I am using  a cross validation technique (to avoid over-fitting) with AUC ROC as scoring function to compare the performance of the algorithms, but I am getting a weird results with Random forest and AdbBoost, I have a perfect AUC_ROC score (i.e. =1) despite the fact that the recall(TPR) and FPR of this algorithms are different from 1 and 0 respectively .  def FPR(y_true, y_pred):     tn, fp, fn, tp = confusion_matrix(y_true, y_pred).ravel()     result = fp / (fp+tn)     return result def FNR(y_true, y_pred):     tn, fp, fn, tp = confusion_matrix(y_true, y_pred).ravel()     result = fn / (tp+fn)     return result FPR_scorer = make_scorer(FPR) FNR_scorer = make_scorer(FNR)     def get_CrossValResults2(model,cv_rst,bestIndx):     best=pd.DataFrame.from_dict(cv_rst).iloc[bestIndx]     roc=&quot;{:.12f}&quot;.format(best['mean_test_roc_auc'])     acc =&quot;{:.0%}&quot;.format(best['mean_test_accuracy'])     prec =&quot;{:.0%}&quot;.format(best['mean_test_precision'])     rec =&quot;{:.0%}&quot;.format( best['mean_test_recall'])     f1 =&quot;{:.0%}&quot;.format(best['mean_test_f1'])     r2=&quot;{:.2f}&quot;.format(best['mean_test_r2'])     g_mean=&quot;{:.2f}&quot;.format(best['mean_test_gmean'])     pr_auc=&quot;{:.8f}&quot;.format(best['mean_test_pr'])     fnr=&quot;{:.0%}&quot;.format(best['mean_test_fnr'])     fpr=&quot;{:.0%}&quot;.format(best['mean_test_fpr'])     rst = pd.DataFrame([[ model, acc,prec,rec,fpr,fnr,f1,roc,pr_auc,g_mean,r2]],columns = ['Model', 'Accuracy', 'Precision', 'Recall','FPR','FNR', 'F1-Score','ROC_auc','PR_auc','gmean','r2'])     return rst        cross_val_rst = pd.DataFrame(columns = ['Model', 'Accuracy', 'Precision', 'Recall','FPR','FNR', 'F1-Score','ROC_auc','PR_auc','gmean','r2'])              scoring = {'accuracy':'accuracy','recall':'recall','precision':'precision','fpr':FPR_scorer,'fnr':FNR_scorer,'f1':'f1' ,'roc_auc':'roc_auc','pr':'average_precision','gmean':Gmean_scorer,'r2':'r2'}     param_grid = {'n_estimators': [200],               'max_depth': [80,90],               'min_samples_leaf': [2,3, 4],             'min_samples_split': [2,5,12],             'criterion': [ 'gini'],              'class_weight' : [class_weights], 'n_jobs' : [-1]}  clf = GridSearchCV(RandomForestClassifier(class_weight=class_weights), param_grid, cv=kfold,scoring=scoring,refit=refit)#Fit the model bestmodel = clf.fit(X,Y)       cross_val_rst = cross_val_rst.append(get_CrossValResults2(model='Random Forrest',bestIndx=bestmodel.best_index_,cv_rst=bestmodel.cv_results_),ignore_index=True) How can be solved the equation $x^3+x-1=y^2$ in positive integers?    I know this equation defines an elliptic curve, but this seems to be a non-elementary way to solve this question. Is there a more elementary solution?   By the way I found three solutions: $(1,1), (2,3)$ and $(13,47)$. Is this related to the law group property of elliptic curves? Thanks for further answers. Soving a Complex Integral along a circle Fatal error: Call to undefined function add_action() - an untouched problem The question was asked many times in many ways, but unfortunately is not covered well in most of the answers. I'm having the same issue doing things using include-files.  In my TwentyFourteen child theme's functions.php I used:  require_once get_stylesheet_directory_uri() .'/admin-panel/theme-options.php';   And I'm using . I've used it in many of my projects, the same way mentioned here, without having the error. But recently I'm having the issue in several of my projects. If I take the code to functions.php then everything's fine. But it's occurring only when I'm trying to include/require external file.  I'm having the error:     Fatal error: Call to undefined function add_action() in C:\xampp\htdocs\project\wp-content\themes\my-theme\admin-panel\theme-options.php on line 2   In this case I'm having the error using a child theme (of T14). But even in one of my parent theme I'm facing the issue. But in the same environment my other projects are running well with all the includes and/or requires (where several add_action()s are defined). I'm having issues in ALL the add_action() calls, like CPT assigning, Custom Taxonomy assigning etc. But I'm successfully developing another two projects including external files from inc/ folder where all my CPTs are assigned and their meta boxes too.  I tried reinstalling WordPress, deactivating all my plugins, tried from Child Theme, tried only the same thing by modifying TwentyFifteen (applying default theme), tried require(), require_once(), include(), include, require_once, and require one after another with failure. And I'm using WP 4.1.1 in all the good and problematic installs.  Majority of the previous questions are answered with a simple line:     As the message says, you haven defined the function add_action() and yet you're trying to use it.   But,   how come (isn't it already defined by WordPress)? and why it's differing project to project in the same environment (How come it's out of the scope now only in particular project[s])? How can I install packages without starting their associated services? As you're probably aware, by default when you install a package on a Debian or Ubuntu based system, if the package contains a service, that service will generally be enabled and started automatically when you install the package.  This is a problem for me.  I've found myself needing to manage templates for building LXC containers. There are several containers, each corresponding to a Debian or Ubuntu release. (There are also Red Hat-based containers, but they aren't relevant here.)  /var/lib/libvirt/filesystems/debian6_template /var/lib/libvirt/filesystems/debian7_template /var/lib/libvirt/filesystems/ubuntu1004_template /var/lib/libvirt/filesystems/ubuntu1204_template   Occasionally I will find that the templates have a missing package or need some other change, so I will chroot into them to install the package. Unfortunately when I do that, I wind up with several copies of the package's service running!  By way of example, I found the templates didn't have a syslog daemon, so I installed one:  for template in /var/lib/libvirt/filesystems/{debian,ubuntu}*_template; do     chroot $template apt-get install rsyslog done   And promptly wound up with four copies of rsyslog running. Not to mention two copies of exim4. Oops!    I read somewhere (though I can't find it again now) that it's not supposed to start services when running in a chroot, but that clearly isn't happening here.  One potentially viable  calls for temporarily replacing the various commands which actually start services, such as start-stop-daemon and initctl, though this is a lot more work than I really wanted to do. If I have no other choice, though...  The ideal solution here would be for Debian-based systems to stop doing this crap, but failing that, perhaps an obscure or undocumented command line option for apt-get?  In case it wasn't clear, I really want to keep anything related to managing the templates outside the templates, if possible.