id
stringlengths
5
27
question
stringlengths
19
69.9k
title
stringlengths
1
150
tags
stringlengths
1
118
accepted_answer
stringlengths
4
29.9k
_softwareengineering.245613
Is there a specific reason that this would break the language conceptually or a specific reason that this is technically infeasible in some cases?The usage would be with new operator.Edit: I'm going to give up hope on getting my new operator and operator new straight and be direct.The point of the question is: why are constructors special? Keep in mind of course that language specifications tell us what is legal, but not necessarily moral. What is legal is typically informed by what is logically consistent with the rest of the language, what is simple and concise, and what is feasible for compilers to implement. The possible rationale of the standards committee in weighing these factors are deliberate and interesting -- hence the question.
Why doesn't C++ allow you to take the address of a constructor?
c++
Pointers-to-member functions make only sense if you have more than one member function with the same signature - otherwise there would be only one possible value for your pointer. But that is not possible for contructors, since in C++ different constructors of the same class must have different signatures.The alternative for Stroustrup would have been to choose a syntax for C++ where constructors could have a name different from the class name - but that would have prevented some very elegant aspects of the existing ctor syntax and had made the language more complicated. For me that looks like a high price just to allow a seldom needed feature which can be easily simulated by outsourcing the initialization of an object from the ctor to a different init function (a normal member function for which pointer-to-members can be created).
_unix.75898
what is the use of .. in linux scripting and in the following makefile?MODULE = EQUALIZER = .. SRCS = include ${EQUALIZER}/xyz.mak include ${EQUALIZER}/pqr.mak
Use of .. in Linux scripting and makefiles
linux;scripting;make
null
_softwareengineering.212734
Sometimes when I create an API that should enable getting a single value or all values I use the following pattern (passing NULL to the API, means get all rows):@Usernames - comma separeted list of usersCREATE PROC GetUsers (@Usernames VARCHAR(100) = NULL)ASBEGIN SELECT * FROM Users Where @Usernames IS NULL OR dbo.in_list(@Usernames,Username) = 1 ENDIs this a good practice to use the OR condition the get both functionalities, or should i write something like this:CREATE PROC GetUsers (@Usernames VARCHAR(100) = NULL)ASBEGIN IF(@Username IS NULL) BEGIN SELECT * FROM Users END ELSE BEGIN SELECT * FROM Users Where dbo.in_list(@Usernames,Username) = 1 ENDEND*Note: This is only SQL for example, this is not a specific coding language question.Thanks.
Is it good practice to not filter values according to nullability?
design patterns;api;interfaces;null
Your question title is different from the question within your posting, so I try to answer both questions.IMHO it is a perfectly valid idiom to have a function with an optional filter condition, and when you leave that filter out, you get the full unfiltered result set. That's true for SQL as well as for many other programming languages.As for which implementation is better: your first one is more comprehensive with less repetition of the same code (SELECT * FROM Users) and less boilerplate code (IF .. END ELSE ...) - so in general I would prefer this, since it is clearly better maintainable. Only if you suffer from an unexpected loss of performance you may test if the second alternative is faster. That will probably depend on your database system (maybe on the version), so do this only if you are 100% sure that it will be worth the hussle.
_unix.180311
I have a CentOS 7 virtual machine with an internal network as well as 2 bridged connections, I am unable to find the config file for the third network card. Any ideas where it could be? or what the issue is.I have added 2 images.
Network card seems to be active but config file is missing?
networking;systemd;udev
null
_webmaster.53409
Let's say you have a small website that has a PR of 3. On top of that you have on the domain itself a blog that is not linked to the website. The blog along with its posts are however listed in the sitemap.xml. Because they are listed in the sitemap.xml Google will index them. Do they however gain any PageRank as well?
Does PageRank flow to pages that are only listed in the sitemap.xml?
pagerank;xml sitemap
Websites don't have PageRank, web pages have PageRank.XML sitemaps do not affect PageRank in anyway. If two websites are using the same domain name but do not link to each other they will not influence the PageRank of each other's pages. Domains have no influence PageRank.PageRank is only influenced by incoming links, both internal and external. So any pages in that blog or website that incoming links to them will see an increase in its PageRank. How much is determined by the PageRank of the pages that link to them as well as the number of links on those pages. The higher the PageRank of the linking page, and the lower the number of links on that page, the more PageRank is sent to the linked to page.Every page has a default starting PageRank (I think it is .15).PageRank is a relative scale (10 is the highest) so you can get more links that send more PageRank to your pages but still see your PageRank drop. PageRank is no longer an important ranking factor. The time it took me to write this answer is longer than PageRank is worth discussing.
_unix.26178
I am running a Suse Linux 11.04 system. My problem is that when I do a fresh login into a shell as root, a new Xauthority file of the form xauth***** gets created in the /root/ directory. Upon exiting from the shell, a few .xauth files remain behind. I tried it on other systems but this does not happen. Also why is the XAUTHORITY environment variable set only for root and not for my other users in the system?man xdm says the follwing about the XAUTHORITY environment variable DisplayManager.DISPLAY.userAuthDirWhen xdm is unable to write to the usual user authorization file ($HOME/.Xauthority), it creates a unique file name in this directory and points the environment variable XAUTHORITY at the created file. It uses /tmp by default.So in my system I do this:xauthUsing authority file /root/.xauthPpRsfUxauth> I exit [Ctrl+d] and I log back in, I see that now it is starting to use a different .xauth* file.xauthUsing authority file /root/.xauthq1xt4zxauth>Why does it need to keep on creating a diffent xauth file everytime I login? Also why in root because the default location is /tmp/? I have not set .DisplayManagaer.DISPLAY.userAuthDir to /tmp in the xdm configuration file. I don't see this behaviour on any other system. In RHEL and Ubuntu all is fine. For pointers I am not the only one who faces this issue. I guess this post is similar: `$XAUTHORITY` appears from 'nowhere' on su+tmux.Does anyone know how I can fix this?
XAUTHORITY environ variable set repeatedly on every login
ssh;xorg;x11;xauth
null
_unix.170099
I've just installed apticron to get mails as available update notifications. Now I was wondering if there was a way to set up mutt to manage my mails from /var/spool/mail/daedalus?I'm on Debian Jessie, if that is relevant.
How use mutt to manage /var/spool/mail/user
email;mutt
You can set up the mailbox(es) to use in mutt via ~/.muttrc.It would be something like this (see the manpage for muttrc for the full details):set folder=/var/spool/mailset mbox=+daedalus
_unix.105592
If I time a process using the time command, I get output for 'real', 'user', and 'sys'.My understanding from this discussion is that 'real' is wall time, whereas 'user' and 'sys' are process time.Does this imply that 'user' and 'sys' will be unaffected by other processes? In other words, if the computer is under heavy load or light load from other processes, it may take more time on the wall clock ('real') to finish my process. But my process may have only required 5 seconds of running time, even though it was spread out over 20 seconds of real-world time.Am I guaranteed that I'll be told '5 seconds user time' regardless of whatever else the system is doing?
How can other processes affect measurements made with `time`?
performance;time;benchmark
No. Process/context switches aren't free.How much other processes running will slow yours down is very system-dependent, but it consists of things like:Every time a processor switches to a different address space (including process), then the MMU cache must be flushed. And probably the processor L1 caches. And maybe the L2 and L3 caches. This will slow down memory access right after your process is resumed (and this counts against your user time).On a SMP (or multi-core) box, if two processes are trying to access the same parts of (physical) RAM, the processors must cooperate. This takes time. It is often done at a architecture level, below even the OS. This will count against your user or sys time, depending on when it hit.Quick kernel locking (that doesn't actually schedule another process) will count against your sys time. This is similar to the point above.on NUMA boxes, you may get moved to a different node. Memory access may now be cross-domain, and thus slowerother processes may influence power management decisions. For example, pegging more cores will reduce Intel Turbo Boost speeds, to keep the processor package inside its electrical & thermal specs. Even without turbo boost, the processor may be slowed due to excess heat. It can work the other way toomore load may cause the CPU speed governor to increase the CPU speed.There are other shared resources on a system; if waiting for them doesn't actually involve your process sleeping, then it'll get counted against your user or sys time.
_softwareengineering.328749
I'm working on a Spring-based REST api that has v1 and v2 variants:/api/v1/dates/api/v2/datesCorrespondingly, there are v1 and v2 packages in the code base:com.company.api.v1com.company.api.v2Is it a good practice to postfix class names with version number like below:DatesControllerV1.java (in v1 package)DatesControllerV2.java (in v2 package)I prefer not postfixing version in the class name as: their package names should tell you about the version already, redundant;I simply don't like numeric character in class name.However, not postfixing version(ie. same class name but in different packages) will increase the probability of using the wrong class accidentally due to IDE auto-complete/auto-import by careless developers. I tried looking for a github repo that has similar code base structure and see how they deal with it. But could not find one unfortunately.I'm wondering which approach do you think is better and the reason. I'm also wondering if there is a better approach(for the current code base setup) than these two?UPDATEWith the help from Azuaron and CormacMulhall, I realized that I really don't have other options to improve my current situation, given that both the v1 and v2 APIs reside in the same code base and I cannot change this setup.For those who are seeking for the proper way of doing this(having different versions of APIs), please see Azuaron's answer below.
Version-postfixed class name for REST api
java;rest;coding standards;naming;spring mvc
null
_unix.374629
I fetched cryptodev source from http://nwl.cc/pub/cryptodev-linux/cryptodev-linux-1.9.tar.gz to directory ~/cryptodev, I unpacked tar archive and I entered into ~/cryptodev/cryptodev-linux-1.9 directory. I followed instructions on https://github.com/cryptodev-linux/cryptodev-linux/blob/master/INSTALL and I enter make command and I got below error:hubot@hubot-vps:~/cryptodev/cryptodev-linux-1.9 $ makemake -C /lib/modules/4.9.24-v7+/build M=/home/hubot/cryptodev/cryptodev-linux-1.9 modulesmake[1]: *** /lib/modules/4.9.24-v7+/build: No such file or directory. Stop.Makefile:27: recipe for target 'build' failedmake: *** [build] Error 2I stopped at this error and I do not know what should I do next. I count on help. Thank you in advance.
make[1]: *** /lib/modules/4.9.24-v7+/build: No such file or directory. Stop
raspbian;cryptsetup
null
_scicomp.27503
I need to have a finite difference stencil for the mixed derivative$$f_{xy}$$on nonuniform grids such as this one:Since I could not find a stencil in the literature, I tried to derive it by my self. As usual I started with a Taylor series expansion:$(I)\qquad f(x+b,y+d)\approx f + b f_x+d f_y +\frac{b^2}{2}f_{xx} +bdf_{xy} +\frac{d^2}{2}f_{yy}$$(II)\qquad f(x+b,y-c)\approx f + b f_x-c f_y +\frac{b^2}{2}f_{xx} -bcf_{xy} +\frac{c^2}{2}f_{yy}$$(III)\qquad f(x-a,y-c)\approx f - a f_x-c f_y +\frac{a^2}{2}f_{xx} +acf_{xy} +\frac{c^2}{2}f_{yy}$$(IV)\qquad f(x-a,y+d)\approx f - a f_x+d f_y +\frac{a^2}{2}f_{xx} -adf_{xy} +\frac{d^2}{2}f_{yy}$I would like to find a combination of the equations above ($I - IV$) where all derivative terms on the right hand side ($f_x, f_y, f_{xx}, f_ {yy}$) except the mixed derivative vanish. This leads to the following linear system of equations:$\begin{bmatrix} bf_x && bf_x && -af_x && -af_x \\ df_y && -cf_y && -cf_y && df_y \\\frac{b^2}{2}f_{xx} && \frac{a^2}{2}f_{xx} && \frac{a^2}{2}f_{xx} && \frac{a^2}{2}f_{xx}\\\frac{d^2}{2}f_{yy} && \frac{c^2}{2}f_{yy} && \frac{c^2}{2}f_{yy} &&\frac{d^2}{2}f_{yy}\end{bmatrix}$ $\begin{bmatrix} P \\ Q \\ R \\ S \end{bmatrix}$ = $\begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}$A solution to this problem is $P=1, Q=-1, R=1, S=-1$.Multiplying the equations $I,II,III,IV$ with the respective factors $P,Q,R,S$ and adding them together:$f(x+b,y+d) - f(x+b,y-c) + f(x-a,y-c) - f(x-a,y+d) = (bd + bc + ac +ad)f_{xy}$And thus:$f_{xy} = \frac{f(x+b,y+d) - f(x+b,y-c) + f(x-a,y-c) - f(x-a,y+d)}{bd + bc + ac +ad}$Can anybody assure me that this is a correct stencil for the mixed derivative for nonuniform grids? What worries me a little bit is that the individual terms ($f(x+b,y+d)$ etc.) do have a uniform weight. So the value at $x+b,y+d$ has equal weight as the point $x-a,y-c$ even though the latter is much closer to the center point $(x,y)$.
Finite difference for mixed derivatives on nonuniform grid
finite difference
Here we shall follow two procedure to calculate $f_{xy}$ one using Taylors series and another using polynomial fitting. Though both the procedure end up in the same formulation there is some advantages and disadvantage for each one.Using Taylors series:The advantage of this procedure is: having control over truncation error is easy because we can easily decide what order we want by choosing the order equations that we desired. Programming this is slightly tedious than polynomial series.Let's expand all the points using Taylors series will end up in$(I)\qquad f(x+b,y+d)\approx f + b f_x+d f_y +\frac{b^2}{2}f_{xx} +bdf_{xy} +\frac{d^2}{2}f_{yy} + \frac{b^3}{6}f_{xxx} + \frac{d^3}{6}f_{yyy} + \frac{1}{2} b^2df_{xxy}+ \frac{1}{2} d^2bf_{xyy} +\frac{1}{4} d^2b^2f_{xxyy}$$(II)\qquad f(x+b,y-c)\approx f + b f_x-c f_y +\frac{b^2}{2}f_{xx} -bcf_{xy} +\frac{c^2}{2}f_{yy}+ \frac{b^3}{6}f_{xxx} - \frac{c^3}{6}f_{yyy} - \frac{1}{2} b^2cf_{xxy}+ \frac{1}{2} c^2bf_{xyy}+\frac{1}{4} c^2b^2f_{xxyy}$$(III)\qquad f(x-a,y-c)\approx f - a f_x-c f_y +\frac{a^2}{2}f_{xx} +acf_{xy} +\frac{c^2}{2}f_{yy}- \frac{a^3}{6}f_{xxx} - \frac{c^3}{6}f_{yyy} - \frac{1}{2} a^2cf_{xxy}- \frac{1}{2} a^2cf_{xyy}+\frac{1}{4} a^2c^2f_{xxyy}$$(IV)\qquad f(x-a,y+d)\approx f - a f_x+d f_y +\frac{a^2}{2}f_{xx} -adf_{xy} +\frac{d^2}{2}f_{yy}- \frac{a^3}{6}f_{xxx} + \frac{d^3}{6}f_{yyy} + \frac{1}{2} a^2df_{xxy}- \frac{1}{2} a^2df_{xyy}+\frac{1}{4} d^2a^2f_{xxyy}$$(V)\qquad f(x,y+d)\approx f +d f_y +\frac{d^2}{2}f_{yy} + \frac{d^3}{6}f_{yyy} $$(VI)\qquad f(x,y-c)\approx f -c f_y +\frac{c^2}{2}f_{yy} - \frac{c^3}{6}f_{yyy} $$(VII)\qquad f(x+b,y)\approx f + b f_x +\frac{b^2}{2}f_{xx} + \frac{b^3}{6}f_{xxx} $$(VIII)\qquad f(x-c,y)\approx f - c f_x +\frac{c^2}{2}f_{xx} - \frac{c^3}{6}f_{xxx} $$(IX)\qquad f(x,y)= f $Let $a_1$ is the weight of equation (I), $a_2$ is the weight of equation (II) by equating $\sum a_i$*(equation number) =$0*f+0*f_x+...+ 1*f_{xy}+...+0*f_{xyy}$Since we are having nine points we need nine equations to solve this but we are having more equations than unknown but only some combinations can give results. Choosing those combinations could be based on what order of accuracy required. Let fix our highest derivative term shouldn't be more than 3. If we tried to solve we can't obtain an exact solution for 9*9, the easiest way to get a solution is freeing some variables. clc clear all syms a1 a2 a3 a4 a5 a6 a7 a8 a7 a8 a9 a b c d % weight to each points eq1=a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8+a9; % first order equation eq2= a1*b - a*a4 - a*a3 + a2*b + a7*b - a8*c; eq3=a1*d - a3*c - a6*c - a2*c + a4*d + a5*d; eq4=a^2*a3 + a^2*a4 + a1*b^2 + a2*b^2 + a7*b^2 + a8*c^2; eq5=a*a3*c - a2*b*c - a*a4*d + a1*b*d-1; eq6=a2*c^2 + a3*c^2 + a6*c^2 + a1*d^2 + a4*d^2 + a5*d^2; eq7=a1*b^3 - a^3*a4 - a^3*a3 + a2*b^3 + a7*b^3 - a8*c^3; eq8=a1*d^3 - a3*c^3 - a6*c^3 - a2*c^3 + a4*d^3 + a5*d^3; eq9=a^2*a4*d - a2*b^2*c - a^2*a3*c + a1*b^2*d; eq10=- a3*a^2*c - a4*a^2*d + a2*b*c^2 + a1*b*d^2; eq11 =d^2*b^2*a1+c^2*b^2*a2+a^2*c^2*a3+d^2*a^2*a4; sol1=solve(eq1,eq2,eq3,eq4,eq5,eq6,eq9,eq10,'a1','a2','a3','a4','a5','a6','a7','a8') % one of the possible solutions sol1=solve(eq1,eq2,eq3,eq4,eq5,eq8,eq9,eq10,'a1','a2','a3','a4','a5','a6','a7','a8') % another possible solution sol1=solve(eq1,eq2,eq3,eq4,eq5,eq7,eq9,eq10,'a1','a2','a3','a4','a5','a6','a7','a8') % another possible solution a9=1; % free variable w1=sol1.a1; w2=sol1.a2; w3=sol1.a3; w4=sol1.a4; w5=sol1.a5; w6=sol1.a6; w7=sol1.a7; w8=sol1.a8; w9=a9;% Test problem syms x y f=@(x,y) 1 +1*x +1*y +2*x*y +1*x^2 +1*y^2 +1*x^2*y+1*x*y^2+1*x^3+1*y^3+x^4*y;f_x=diff(f,x);f_xy=diff(f_x,y);f_xy_00=subs(f_xy,[x y], [0 0]);f_00=subs(f_xy,[x y],[0 0]); disp('exact solution is')disp(f_00)a=0.1;b=0.1;c=0.1;d=0.1;P00=f(0,0);P10=f(b,0);P11=f(b,d);P01=f(0,d);P_11=f(-a,d);P_10=f(-a,0);P_1_1=f(-a,-c);P0_1=f(0,-c);P1_1=f(b,-c);f_xyn=w1*P11+w2*P1_1+w3*P_1_1+w4*P_11+w5*P01+w6*P0_1+w7*P10+w8*P_10+w9*P00; % numerical solutiondisp('Numerical solution is')disp(f_xyn) %sry I'm unable to use subs here so pls copy paste it agin in command windowThough all the answers are more or less same, they differ slighly based on what order we have considered. Similar to another answer, this sytem can be closed by omitting $f_{xxx}$, $f_{yyy}$ because they needs 4 points in $x$ or $y$ direction but we have only 3 points but we can calculate $f_{xxyy}$, it needs only 3 points in both the directions. If we include then the code becomeclcclear allsyms a1 a2 a3 a4 a5 a6 a7 a8 a7 a8 a9 a b c d % weight to each point eq1=a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8+a9; % first order equation eq2= a1*b - a*a4 - a*a3 + a2*b + a7*b - a8*c; eq3=a1*d - a3*c - a6*c - a2*c + a4*d + a5*d; eq4=a^2*a3 + a^2*a4 + a1*b^2 + a2*b^2 + a7*b^2 + a8*c^2; eq5=a*a3*c - a2*b*c - a*a4*d + a1*b*d-1; eq6=a2*c^2 + a3*c^2 + a6*c^2 + a1*d^2 + a4*d^2 + a5*d^2; eq7=a1*b^3 - a^3*a4 - a^3*a3 + a2*b^3 + a7*b^3 - a8*c^3; eq8=a1*d^3 - a3*c^3 - a6*c^3 - a2*c^3 + a4*d^3 + a5*d^3; eq9=a^2*a4*d - a2*b^2*c - a^2*a3*c + a1*b^2*d; eq10=- a3*a^2*c - a4*a^2*d + a2*b*c^2 + a1*b*d^2; eq11 =d^2*b^2*a1+c^2*b^2*a2+a^2*c^2*a3+d^2*a^2*a4; sol1=solve(eq1,eq2,eq3,eq4,eq5,eq6,eq9,eq10,eq11,'a1','a2','a3','a4','a5','a6','a7','a8','a9'); w1=sol1.a1; w2=sol1.a2; w3=sol1.a3; w4=sol1.a4; w5=sol1.a5; w6=sol1.a6; w7=sol1.a7; w8=sol1.a8; w9=sol1.a8;% Test problem syms x y f=@(x,y) 1 +1*x +1*y +2*x*y +1*x^2 +1*y^2 +1*x^2*y+1*x*y^2+1*x^3+1*y^3+x^4*y;f_x=diff(f,x);f_xy=diff(f_x,y);f_xy_00=subs(f_xy,[x y], [0 0]);f_00=subs(f_xy,[x y],[0 0]); disp('exact solution is')disp(f_00)a=0.1;b=0.1;c=0.1;d=0.1;P00=f(0,0);P10=f(b,0);P11=f(b,d);P01=f(0,d);P_11=f(-a,d);P_10=f(-a,0);P_1_1=f(-a,-c);P0_1=f(0,-c);P1_1=f(b,-c);f_xyn=w1*P11+w2*P1_1+w3*P_1_1+w4*P_11+w5*P01+w6*P0_1+w7*P10+w8*P_10+w9*P00; % numerical solutiondisp('Numerical solution is')disp(f_xyn) %sry I'm unable to use subs here so pls copy paste it again in the command windowUsing polynomial fitWe can fit a 2-D polynomial over the domain and you can find the derivative value. First, we shall consider 2-D cubic polynomial then we shall find $f_{xy}$. and matlab code is:clcclear allclose allsyms a0 a10 a01 a11 a20 a02 a12 a21 a30 a22 x ysyms a b c dsyms P00 P10 P11 P01 P_11 P_10 P_1_1 P0_1 P1_1f=@(x,y) a0 +a10*x +a01*y +a11*x*y +a20*x^2 +a02*y^2 +a21*x^2*y+a12*x*y^2+a30*x^3;f_x=diff(f,x);f_xy=diff(f_x,y);f_00=subs(f_xy,[x y],[0 0]);p00=f(0,0);p10=f(b,0);p11=f(b,d);p01=f(0,d);p_11=f(-a,d);p_10=f(-a,0);p_1_1=f(-a,-c);p0_1=f(0,-c);p1_1=f(b,-c);sol1=solve(p00-P00,p10-P10,p11-P11,p01-P01,p_11-P_11,p_10-P_10,p_1_1-P_1_1,p0_1-P0_1,'a0','a10','a01','a11','a20','a02','a12','a21');F_xy=sol1.a11$f_{xy} =\frac{(P_{10} - P_{11} - P_{-10} + P_{-11})}{(d*(a + b))}$ + $\frac{(P_{00} - P_{01} - P_{10} + P_{11})}{(b*d)} $- $\frac{(P_{00}*c^2-P_{01}*c^2-P_{-10}*c^2+P_{-11}*c^2-P_{00}*d^2+P_{0-1}*d^2+P_{-10}*d^2-P_{-1-1}*d^2)}{(a*c*d*(c + d))}$The notation used here. $P_{xy}$ is the point located in the quadrent where $(x,y)$ =($0+x$, $0+y$) lies.Similar to previous arguments, for $f_{xxyy}$ we can fit a quartic polynomial without $x^3$ and $y^3$ and the Matlab code isclcclear allclose allsyms a0 a10 a01 a11 a20 a02 a12 a21 a22 x ysyms a b c dsyms P00 P10 P11 P01 P_11 P_10 P_1_1 P0_1 P1_1f=@(x,y) a0 +a10*x +a01*y +a11*x*y +a20*x^2 +a02*y^2 +a21*x^2*y+a12*x*y^2+a22*x^2*y^2;f_x=diff(f,x);f_xy=diff(f_x,y);f_00=subs(f_xy,[x y],[0 0]);p00=f(0,0);p10=f(b,0);p11=f(b,d);p01=f(0,d);p_11=f(-a,d);p_10=f(-a,0);p_1_1=f(-a,-c);p0_1=f(0,-c);p1_1=f(b,-c);sol1=solve(p00-P00,p10-P10,p11-P11,p01-P01,p_11-P_11,p_10-P_10,p_1_1-P_1_1,p0_1-P0_1,p1_1-P1_1,'a0','a10','a01','a11','a20','a02','a12','a21','a22');F_xy=sol1.a11 %f_xy result$f_{xy} =\frac{(P_{00}*a^2*c^2 - P_{01}*a^2*c^2 - P_{10}*a^2*c^2 + P_{11}*a^2*c^2 - P_{00}*a^2*d^2 - P_{00}*b^2*c^2 + P_{01}*b^2*c^2 + P_{10}*a^2*d^2 + P_{0-1}*a^2*d^2 - P_{1-1}*a^2*d^2 + P_{-10}*b^2*c^2 - P_{-11}*b^2*c^2 + P_{00}*b^2*d^2 - P_{0-1}*b^2*d^2 - P_{-10}*b^2*d^2 + P_{-1-1}*b^2*d^2)}{(a*b*c*d*(a + b)*(c + d))}$Test case:clcclear allclose allsyms x yf=@(x,y) 1 +1*x +1*y +2*x*y +1*x^2 +1*y^2 +1*x^2*y+1*x*y^2+1*x^3+1*y^3+x^4*y;f_x=diff(f,x);f_xy=diff(f_x,y);f_xy_00=subs(f_xy,[x y], [0 0]);f_00=subs(f_xy,[x y],[0 0]);a=0.1;b=0.1;c=0.1;d=0.1;P00=f(0,0);P10=f(b,0);P11=f(b,d);P01=f(0,d);P_11=f(-a,d);P_10=f(-a,0);P_1_1=f(-a,-c);P0_1=f(0,-c);P1_1=f(b,-c);disp('exact solution is')disp(f_00)f_22=(P00*a^2*c^2 - P01*a^2*c^2 - P10*a^2*c^2 + P11*a^2*c^2 - P00*a^2*d^2 - P00*b^2*c^2 + P01*b^2*c^2 + P10*a^2*d^2 + P0_1*a^2*d^2 - P1_1*a^2*d^2 + P_10*b^2*c^2 - P_11*b^2*c^2 + P00*b^2*d^2 - P0_1*b^2*d^2 - P_10*b^2*d^2 + P_1_1*b^2*d^2)/(a*b*d*(a + b)*(c^2 + d*c));disp('Numerical solution is')disp(f_22)Though there are a lot of ways to derive it, I personally prefer FD derived using polynomial because of its simplicity and accuracy of last $f_{xy}$ is higher than the previous one because it satisfies more terms in Taylors series.
_softwareengineering.337026
I'm building my own utility functions to master ES6:const contains = (array, value) => { return array.indexOf(value) > -1}const keys = (object) => { return Object.keys(object)}const find = (array, value) => { return array.filter(item => { return item[keys[0]] === value[keys[0]] })[0]}So far, I've encountered only one problem: naming my arguments. I'm checking Lodash's naming conventions. I think it's clear when to use array, object, etc... I also saw the keyword value. When to use this one? When I'm unsure of the argument's type?
When should I use value as an argument name?
javascript;naming;functions;naming standards
In this context, value is being used as a synonym for item in an array or collection. It's as good a guideline as any.
_codereview.70837
#include <iostream>using namespace std;class Math{private: int answer;public: /*void getAn() { cout << answer; }*/ int add(int x, int y){ cout << Add two numbers:\n; cin >> x; cin >> y; answer = x + y; return answer;} int sub(int x, int y){ cout << Subtract one number from the other:\n; cin >> x; cin >> y; answer = x - y; return answer;} int multi(int x, int y){ cout << Multiply two numbers:\n; cin >> x; cin >> y; answer = x * y; return answer;} int divi(int x, int y){ cout << Divide two numbers:\n; cin >> x; cin >> y; answer = x / y; return answer;}};int main(){ int choice; int x,y; int learning = 1; Math doMath; cout << This is a calculator!\n << endl; while(learning==1) { //doMath.getAn(); cout << endl; cout << Menu:\n1) Addition\n2) Subtraction\n3) Multiplication\n4) Division\n5) Quit\n << endl; cout << Choose your option.\n; cin >> choice; if(choice==1) { cout << doMath.add(x,y) << endl; }else if(choice==2) { cout << doMath.sub(x,y) << endl; }else if(choice==3) { cout << doMath.multi(x,y) << endl; }else if(choice==4) { cout << doMath.divi(x,y) << endl; }else if(choice==5) { learning = 0; }else { cout << THAT WASN'T A CHOICE, YOU LITTLE SHIT!!! << endl; learning = 0; } } return 0;}
Calculator with four arithmetic operations
c++;calculator
Do not insult usersTHAT WASN'T A CHOICE, YOU LITTLE SHIT!!! is absolutely not acceptable.You are repeating yourself a lot, in programming you should avoid as much as possible code repetition as it leads to bugs and is not easily reusable.Instead do this:template<typename Function>int do_operation(int x, int y,Function operation,string message) { cout << message cin >> x; cin >> y; answer = operation(x,y); return answer;}You can then do:int add(int x,int y) { return do_operation(x, y, std::plus<int>(), Add two numbers:\n);}I see many many if and elif, it is better to use a switch statement. You may even use an array but perhaps then it would be overkill.learning is quite puzzling as a name. A more standard running is more intuitive.//doMath.getAn(); and /*void getAn(){ cout << answer;}*/are really puzzling. Either uncomment them or delete them because commented out code confuses the readers.Use constants for your strings and put them at the top. You can modify them in a simpler and faster way.static const string Menu = Menu:\n1) Addition\n2) Subtraction\n3) Multiplication\n4) Division\n5) Quit\nstatic const string ErrorMessage = Invalid choice, enter a valid number.and thencout << Menu << endl;cout << Choose your option.\n;and else { cout << ErrorMessage << endl; running = 0;}Do not use while(learning==1) because it is redundant and weird, use the simpler while(learning) (or even better while(running))Do not use using namespace std;, if you are curious to know why, look herePut the first brace on the same line of the function title and indent the function body.int add(int x, int y) { cout << Add two numbers:\n; cin >> x; cin >> y; answer = x + y; return answer;}
_unix.271682
MAC Pro 15 inchOS: GentooWonder if someone can shed some light on how to deal with unclaimed PCI devices. I have the following list of unclaimed PCI devices. I am also pretty sure I have included the necessary kernel config to accommodate for the below. *-generic UNCLAIMED description: System peripheral product: Intel Corporation vendor: Intel Corporation physical id: 0 bus info: pci@0000:08:00.0 version: 00 width: 32 bits clock: 33MHz capabilities: pm msi pciexpress msix bus_master cap_list configuration: latency=0 resources: memory:b0e00000-b0e3ffff memory:b0e40000-b0e40fff-- *-communication UNCLAIMED description: Communication controller product: 8 Series/C220 Series Chipset Family MEI Controller #1 vendor: Intel Corporation physical id: 16 bus info: pci@0000:00:16.0 version: 04 width: 64 bits clock: 33MHz capabilities: pm msi bus_master cap_list configuration: latency=0 resources: memory:b0d19100-b0d1910f-- *-serial UNCLAIMED description: SMBus product: 8 Series/C220 Series Chipset Family SMBus Controller vendor: Intel Corporation physical id: 1f.3 bus info: pci@0000:00:1f.3 version: 05 width: 64 bits clock: 33MHz configuration: latency=0 resources: memory:b0d19000-b0d190ff ioport:efa0(size=32) *-generic UNCLAIMED description: Signal processing controller product: 8 Series Chipset Family Thermal Management Controller vendor: Intel Corporation physical id: 1f.6 bus info: pci@0000:00:1f.6 version: 05 width: 64 bits clock: 33MHz capabilities: pm msi bus_master cap_list configuration: latency=0 resources: memory:b0d18000-b0d18fff
Linux PCI devices - unclaimed
pci
null
_webapps.6063
Is it possible to get notified by email or RSS of new activity in your Facebook Page?
Get notified of Facebook Page activity?
facebook;rss
You can get the rss feed of a page from http://www.facebook.com/feeds/page.php?format=atom10&id=xxxxx . It includes any post to your page but sadly not the comments.
_webapps.53363
I opted out of the New Google Maps, but I have changed my mind.How do I get back to the new Google Maps?
How can I get back to New Google Maps, after having opted out?
google maps
null
_cs.35994
Randomized Quick Sort is an extension of Quick Sort in which pivot element is chosen randomly. What can be the worst case time complexity of this algo. According to me it should be $O(n^2)$.Worst case happens when randomly chosen pivot is got selected in sorted or reverse sorted order. But in this and this text its worst case time complexity is written as $O(n\log{n})$What's correct?
Why does randomized Quicksort have O(n log n) worst-case runtime cost?
algorithm analysis;runtime analysis;sorting
Both of your sources refer to the worst-case expected running time of $O(n \log n).$ I'm guessing this refers to the expected time requirement, which differs from the absolute worst case.Quicksort usually has an absolute worst-case time requirement of $O(n^2)$. The worst case occurs when, at every step, the partition procedure splits an $n$-length array into arrays of size $1$ and $n-1$. This unlucky selection of pivot elements requires $O(n)$ recursive calls, leading to a $O(n^2)$ worst-case.Choosing the pivot randomly or randomly shuffling the array prior to sorting has the effect of rendering the worst-case very unlikely, particularly for large arrays. See Wikipedia for a proof that the expected time requirement is $O(n\log n)$. According to another source, the probability that quicksort will use a quadratic number of compares when sorting a large array on your computer is much less than the probability that your computer will be struck by lightning.Edit:Per Bangye's comment, you can eliminate the worst-case pivot selection sequence by always selecting the median element as the pivot. Since finding the median takes $O(n)$ time, this gives $\Theta(n \log n)$ worst-case performance. However, since randomized quicksort is very unlikely to stumble upon the worst case, the deterministic median-finding variant of quicksort is rarely used.
_softwareengineering.187297
I am really confused.The GPL states that if you start with GPL code, and modify that code, that you must release your code with modifications free of charge also under a GPL.But what if you simply use the existing GPL code without modifications as a library? Can you then write software to interface with that code, unchanged, that is closed source?
Sell code using dynamically linked Open Source GPL code?
licensing;gpl
null
_unix.64084
I have a ssh server. I allow people to connect to it if they want. I do my programming homework on it. I am in trouble with my teacher because people were cheating off it. I need to know how to require sudo just to access the file.
how to require sudo to view files?
ssh;security;sudo
null
_softwareengineering.250863
The question is how to cope with absence of variable declaration in Python, PHP, and the like.In most languages there is a way to let the compiler know whether I introduce a new variable or refer to an existing one: my in Perl (use strict) or \newcommand vs. \revewcommand in LaTeX. This prevents from two major sources of errors and headache: (1) accidentally using the same name of a variable for two different purposes, such as in (PHP)$v = $square * $height;<...lots of code...>foreach ($options as $k => $v) echo For key $k the value is $v\n;<...lots of code...>echo The volume is $v;or a lot nastier (PHP)$a = [1, 2, 3];foreach ($a as $k => &$v) $v++;foreach ($a as $k => $v) echo $k => $v\n;(can you see a bug here? try it!); and(2) prevent from typos (PHP):$option = 1;$numberofelements = 1;if ($option){ $numberofelenents = 2;}echo $numberofelements;(can you see a bug here? PHP will execute silently). Using something like my (Perl)use strict; my $option = 1;my $numberofelements = 1;if ($option){ $numberofelenents = 2;}say $numberofelements;(Perl will immediately report the bug) is a tiny effort and HUGE benefit both in debug time and (much more importantly) in losses (potentially huge) from incorrect programs.However, some languages, notably Python, PHP, and JavaScript, do not give any protection from these types of bugs.My question is how can we effectively cope with this?The only way I can foresee is to create two functions (PHP):function a ($x){ if (isset ($x)) die(); else return &$x;}andfunction the ($x){ if (isset ($x)) return &$x; else die();}and use them always:a($numberofelements) = 1;the($numberofelenents)++;say the($numberofelements);but of course this is extremely cumbersome. Any better way of effectively protecting from such errors? No, use another language, be careful and don't make errors, and split your code in tiny functions are not good answers (the latter may protect from the errors of type 1 but not type 2).
Declaring variables in Python and PHP
programming languages;debugging;errors;declarations
In my experience, there are three ways to prevent the problems you described above:Limit the scope of your variablesName your variables something meaningful and descriptiveUse a pre-compiler to notify of any errors (Doval mentioned pylint for Python)1) Limiting the scope of your variables will limit the first error. You will have fewer variables that have the possibility of containing the same name. Odds are that you won't have any collisions. You can limit scope by declaring variables only in the scope that they will be used. The reason this works is because variables will be disposed of as a result of the natural cycle in your code. I've provided an example below for clarify.class: classVariable = classVar; function ThisIsAFunction(functionVar) { var functionVar2 = functionVar2; if functionVar > functionVar2 : var ifStatementVar = ifStatementVar; for i in range(0,2): ifStatementVar += i; // i will go out of scope here // ifStatementVar will go out of scope here // functionVar and functionVar2 will go out of scope here2) Naming your variables something meaningful will go a long way to preventing re-use of the same variable name. The key in naming your variables is to make them specific enough that their name cannot be reused. When refactoring code it is a good idea to look for function, variable and class names that can be renamed to better reflect their purpose and meaning. An example of good variable names is the following:function GetSumOfTwoIntegers(intFirstNum, intSecondNum): return intFirstNum + intSecondNum;There is a lot of discrepency when deciding on good names. Everyone has their own style. The main thing to ensure is that you it is clear to yourself and others what the method, parameter or class is supposed to do and be used for. GetSumOfTwoIntegers as a method name tells anyone calling this method that they need to pass in two integers and they will be receiving the sum as a result.3) Finally, you can use a pre-compiler to tell you of any mistakes that have been made. If you are using a good IDE, it will notify you of any errors. Visual Studio uses Intellisence to let the developer know of any errors before compiling. Most languages have an IDE that supports this functionality. Using one would certainly solve your second problem.The reason someone might choose to create the syntax of a language in a specific way is hard to determine. I can posture that in Python's case it was likely that the creator wanted to type less when writing code. It only takes a print statement to create a Hello World program in Python. Creating a comparable program in Java requires a lot more typing. Anyways, I don't really know why the creator chose this syntax.
_cstheory.8344
As far as I know, following operations convert a $PCP_{1,s}[O(\log n),O(1)]$ , to a $PCP_{1,s}[O(\log n),O(1)]$, with following $s$ :By constant number of applications of serial repetition: can get every constant s>=1/2;By constant number of applications of parallel repetition: can get every constant s>0;By $\theta(\log n)$ number of applications of Dinurs gap amplification transformation: can get some constant $s\geq1/2$; (see Gap Amplification Fails Below 1/2)My questions:Could you please correct me if I have made any mistakes?What is special with in serial repetition or Dinurs transformation? why not another constant, like 1/3 or else?Are such a results true for PCPs with imperfect completeness?remark:with $PCP_{c,s}$, I mean PCP with completeness c and soundness error s.
Effect of serial repetition on soundness of a PCP, and what is special with 1/2?
cc.complexity theory;pcp
Sequential repetition can give you any constant soundness error larger than 0, not just soundness error $\geq 1/2$.Dinur's approach gives you a constant soundness error which is not only at least half, but, in fact, extremely close to 1, maybe 0.99999.The note of Andrej Bogdanov that you linked to shows that getting a soundness error smaller than half inherently won't work using Dinur's approach. The reason is specific to this approach, and is explained well in the note.The soundness amplification results work for imperfect completeness as well. It's pretty straightforward to convince yourself of that in the case of sequential/parallel repetition. Dinur's approach can also be adapted to imperfect completeness.Remark: Dinur's approach, just like the other two approaches, requires a number of iterations/repetitions that depends on the soundness you start with and the soundness you want to get. In her case it's $\Theta(\log(\frac{1}{1-s}))$ iterations to get to constant soundness. Irit starts with $s\approx 1-\frac{1}{n}$, and that's why she needs $\Theta(\log n)$ iterations.
_unix.158922
I am installing wine 1.6.2 on Ubuntu 12.04 by compiling the source, since I can't find a binary from a ppa.But as I am now compiling the source in /tmp, the free space of my / has dropped to 70Mb. It has been quite a while, and I don't know how long it will take to finish compiling, or where I am in the progress towards finishing compiling. Now I have stopped the compiling. I am stopped atgcc -c -I. -I. -I../../../include -I../../../include -DWINE_STRICT_PROTOTYPES -DWINE_NO_NAMELESS_EXTENSION -DWIDL_C_INLINE_WRAPPERS -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-2 -gstrict-dwarf -fno-omit-frame-pointer -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -o automation.o automation.cgcc -c -I. -I. -I../../../include -I../../../include -DWINE_STRICT_PROTOTYPES -DWINE_NO_NAMELESS_EXTENSION -DWIDL_C_INLINE_WRAPPERS -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-2 -gstrict-dwarf -fno-omit-frame-pointer -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -o db.o db.cgcc -c -I. -I. -I../../../include -I../../../include -DWINE_STRICT_PROTOTYPES -DWINE_NO_NAMELESS_EXTENSION -DWIDL_C_INLINE_WRAPPERS -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wwrite-strings -Wpointer-arith -Wlogical-op -gdwarf-2 -gstrict-dwarf -fno-omit-frame-pointer -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -o format.o format.c^Z[1]+ Stopped makeIs it possible to know how long and much space an installation from compiling source might take?What would you do better, if you were me? Thanks.
Possible to know how much space and time the installation of some application from source takes?
software installation
null
_unix.279256
I am running Debian Jessie with xfce. I used to have the system in English (en_US.utf8 as LANG since I installed debian only with English).Lately, I installed new locales and even if I made sure I chose None for the default locale, as advised on the wiki, I noticed that one of the installed locale, German is now set (LANG=de_DE.utf8 when I run locale).I followed the instructions on the other wiki about changing the locale, ie.# export=en_US.utf8and thendpkg-reconfigure localesand then restarting.But I still get LANG=de_DE.utf8 and de_DE.utf8 for all the LC_* variables (LANGUAGE is set to English though).I even removed the German local, rerun the export and dpkg-reconfigure locales and restarted but I still have LANG=de_DE.utf8.What am I missing here?Could it come from xfce session and startup settings? I looked a bit there but I'm not sure if I might not break other stuff by playing around with those settings.
Debian Jessie with Xfce: cannot change locale (LANG) after installing new locale
unicode;debian;locale
null
_webapps.22056
Let's say there's a channel that churns out a lot of content, but I am only interested in a subset of it. That content cannot be made into a show, as per some YouTube guideline or whatever, but the channel owner helpfully compiles it into a playlist.I know it's possible to subscribe to a show, but what about a playlist?(I actually remember doing so about 3 design iterations back, but I can't find it now.)
How do I subscribe to a YouTube playlist?
youtube;youtube playlist
null
_unix.138706
I would like to accomplish the following.Copy the contents of all search results into a single file.I don't want to copy the search result but the file contents of the search result.For example my search result returned a list of 10 files then I would like to copy the contents of those 10 files into a single file (e.g dump.test).I hope I have clearly explained the requirement.
How to copy contents of command line search result in unix to a file?
search;copy
null
_unix.204958
I have multiple files to rename leng-1494-001 leng-1464-002 leng-2414-004 leng-7894-005 leng-1323-006I want to rename it ferr-1494-001 ferr-1464-002 ferr-2414-004 ferr-7894-005 ferr-1323-006I know how to do for ferr and leng,but how to replace characters from 6 to 10( 1464,7894) with blank line for example,or string like aaaa bbbb cccc using sed?Also awk or perl solution is welcome.Thanks
awk or sed or perl: remove only characters on specific position
sed;awk;perl
POSIXly:$ sed -e 's/-[^-]*-/-/' file leng-001 leng-002 leng-004 leng-005 leng-006
_unix.57364
A bit of backgroundI'm a developer and I install most of my tools in my home folder. So my shell's rc file is full of JAVA_HOME, GROOVY_HOME, MAVEN_HOME, ... variables. To expose all these environment variables to my GUI applications (think my IDE) I used to write a shell script by first defining those variables again and then running the application; and finally adding a launcher in my application menu to run that script.One day I realized that I could just run my application via my shell. As all the variables defined in the shell's rc files were going to be set in the application environment. So the entry in my application menu became something like /usr/bin/my-shell ~/my-ide/bin/start.shNow the questionCan I instruct my DM to always use my shell to run all my applications?Side notesI use ZSH and Gnome, but a more generic solution would be appreciated.I've already set my default shell to ZSH, but Gnome doesn't seem to considered that a good enough reason to use that shell for everything.
Can I change the shell used to run GUI applications from a Desktop Manager?
shell;gnome;configuration;environment variables;desktop environment
null
_webapps.52430
How do we use Google Groups to browse Usenet groups? Specifically, if I am looking at comp.os.linux.networking, how do I go up on level to comp.os.linux?In the old days before Google changed the interface, the elements of an Usenet group were linked and clicking one would allow us to navigate up (see the red box below). And searching just sucks: comp.os.linux groups returned one result of comp.os.linux.misc (even though there are probably tens to hundred in that branch).I don't think a traditional Usenet agent is a viable option anymore (like Forte's Agent). I'm not sure telco's like Verizon even offer them any longer. I could not find Verizon's news server settings when searching their site.
How do I navigate between Usenet groups in Google groups?
google groups;usenet
null
_scicomp.11688
I am curently using R package nleqslv for solving a non-linear system of equations with 300 variables. I need to scale this to the system with ~50k variables and naturally this does not scale very well, since the jacobian then takes up to ~30G of RAM, and I do not have access to a machine with such amount of RAM. The jacobian is a sparse matrix, but nleqslv does not have the ability to exploit this feature. What are available solvers (preferably open source) which can exploit sparsity of the jacobian and can work with large systems? I've searched around and found lots of software for optimization problems, which does not exactly suit me, since I am reluctant to minimize the sum of squares of the system. I can always hack nleqslv code to use sparse matrices, but first I would like to now what are available ready-made solutions.
Solver for large non-linear system of equations
sparse;libraries;nonlinear equations
PETSc is a solver package that has interfaces to a number of different methods for solving sparse linear systems, and many different nonlinear equation solvers (that make use of the linear solvers as subroutines). Although the framework is involved, the flexibility it gives you is worth it.Taking advantage of sparsity and possibly parallelism (if you can decompose the vectors and matrices in your problem appropriately) should help mitigate the memory bottleneck you mentioned because a sparse representation should require less memory, and parallelism should enable you to use memory across multiple machines, with should increase the amount of memory you can use for your simulation runs.
_datascience.19732
[Note : There is some serious problem with logic used to get the best banner. I got it late. Directly read the answer to get general info, or you can also try to the find the mistake.] Problem: Given a set of user features, select an ad with the highest probability to be clicked.Dataset - https://www.kaggle.com/c/avazu-ctr-prediction/data (First 100000 tuples from training set and split that it 80:20 training:testing)Tutorial followed - https://turi.com/learn/gallery/notebooks/click_through_rate_prediction_intro.htmlC14 is my ad id.Problem :- Given ('device_type', 'C1', 'C15') return ad id.Training:-I have taken 'click' as my target and ('device_type', 'C1', 'C15', 'C14') as my input features.I used logistic regression classifier in graphlab library to train the model.I am doing ad selection in the following way:-Given a set of features ('device_type', 'C1', 'C15', X) Iterate X over all possible values of C14 and pass the features to predictor to get the probability that X ad will be clicked. Return the ad with maximum click probability.MY PROBLEM IS LOGISTIC CLASSIFIER IS ONLY RETURNING ONE AD for every test tuple, though with different click probability, it means only one ad is getting the highest probability to be clicked. Can anyone explain this observation?When using boosted tree classifier instead of logistic classifier for the above prediction, I am able to get different ads as my prediction and hence getting better results.
Explain output of logistic classifier
machine learning;predictive modeling;logistic regression
It means your logistic classifier is biased towards one class, this could be because of below reasons that I can think of.Class Imbalance: ThisThis article explains how to identify and overcome the class imbalance problem. Overfitting- This article explains how to tackle over fitting.Logistic classifier works better if data is linearly related, if you find non linear relationships in data I would suggest use better algorithms like GBM/SVM/Random forest. Which will give you much better and accurate results.
_vi.12797
I want to use yt<anyChar> for yanking and for jumping, so that cursor moves to the first char before <anyChar>. For backward moving this is working by default (after yT<anyChar> cursor moves to the first char after <anyChar> and I even can use ; and , for additional jumps).In my Emacs+Evil config I've done it by simply advising evil-yank function: (defun evil-yank-after (beg end type register yank-handler) (if (= (point) beg) (goto-char (1- end)) (goto-char beg))) (advice-add #'evil-yank :after #'evil-yank-after)In vim I guess approach is totally different?
Move cursor after yank according to direction
vimscript;cursor movement
null
_reverseengineering.15182
Is there and easy way to decompile a C# DLL (like ILSpy does, for example), but instead of method bodies, have the methods return default values (or throw runtime exceptions for that matter)?Why do I need this? I am trying to replace some classes in a .dll library. I can't decompile the entire library, since it contains many lambda function and iterators that cause problems when decompiled.I had, however, success doing this: Copy the decompiled source of the class I want to change, paste it into a new project and include the original .dll as a library. Then, change the class to my liking (change methods implementation for now), and then compile the project and inject the compiled IL code into the original .dll via a disassembler.This has worked out so far with a success, however now I have run into a problem. The class (let's say A) that I'm trying to change now, passes this as an argument to other classes (let's say B), and it's generating a compile error (since the original B class expects the original A class, and not the fake A class that I'm editing).This, of course, would not be a problem if I had the complete source code to the .dll library, but I don't. Fortunately, I don't have to. If I had a structure-only source code (declarations of classes, fields, methods, interfaces and what not, but no method implemetations), I could copy-paste the source of class A into this sructure-only sorce code, make the changes I need, compile, and then inject the IL code as before.So, can I easily get the sructure-only sorce code (again, method implementation can be eighter returning default value, or throwing runtime exception), or is there a better to replace a class in a .dll library like that?
Decompile C# DLL without method bodies
disassembly;dll;decompiler;c#
null
_cstheory.9237
Would there be any major consequences if SAT had at most subexponential unsat proofs or even more strongly, SAT had subexponential-time algorithms?
Consequences of sub-exponential proofs/algorithms for SAT
cc.complexity theory;sat;proof complexity
If SAT had a subexpoential-time algorithm, the you would disprove the exponential time hypothesis. For fun cosequences: if you showed that circuit SAT over AND,OR,NOT with $n$ variables and $poly(n)$ circuit gates can be solved faster than the trivial $2^n poly(n)$ approach, then by Ryan Williams' paper you show that $NEXP \not\subseteq P/poly$.
_cogsci.5559
Developing software is simultaneously artistic and scientific, which accounts for its appeal for some of the smartest and intuitive people on the planetThere is a generally observable and most likely a statistically provable scarcity of women in the programmer community.Would it be right to conclude from this that men are generally more intelligent than women? If so, what's the cause of this? And if not, why?
Does the scarcity of female programmers, suggest that men are more intelligent than women?
intelligence;sex differences
The short answer: No, sex differences in professions is not a good basis for judging the intelligence of males and females.I would like to address some of the assumptions and misconceptions in the question. First, I would like to deconstruct the question, and then answer it.Deconstructing the questionOne of the earlier titles of the question was Are men more intelligent than women?. It starts with the observation that there are more males who work in areas related to mathematics and programming, therefore males are more intelligent.I think this is a common bias in humans. People know a lot about their area of expertise and then judge others by their lack of understanding of what they are experts in. To take a stereotypical example, perhaps a female clinical psychologist, doctor, or lawyer may wonder why so many males are mathematicians and programmers. She might think that this is because they lack the intelligence to function effectively in domains that require strong interpersonal skills. I am not defending this point of view either. I merely intend to highlight that to judge others by your own standards of what represents intelligence is problematic. Answering the questionHave a read of page 91 of Intelligence: Knowns and Unknowns, which represents the position of a large reputable APA task force of leading intelligence researchers. Summarising a huge literature, males tend to perform much better on visual-spatial intelligence test items such as mental rotation and tracking moving objects. Females often perform better on verbal abilities such as synonym generation and verbal fluency. Overall, there is minimal difference in full-scale IQ.You could also have a read of Hide's (2005) summary of meta-analytic sex differences across a wide range of cognitive tests. Here, the author advances a very different view, the gender similarities hypothesis, which holds that males and females are similar on most, but not all, psychological variables.However, this only addresses mean differences, and there is certainly much greater differences within sexes than between.ReferencesNeisser, U., Boodoo, G., Bouchard Jr, T. J., Boykin, A. W., Brody, N., Ceci, S. J., ... & Urbina, S. (1996). Intelligence: Knowns and unknowns. American psychologist, 51(2), 77. PDFHyde, J. S. (2005). The gender similarities hypothesis. American psychologist, 60(6), 581. PDF
_webapps.51979
Facebook allows subscribers to create Interest List pages and share their existence on the Timeline.How can I go to a Facebook Friend's page and discover all of their public interest lists?
How do I see my Facebook Friends' Public Interest Lists?
facebook
null
_unix.41334
I have three problem, all of them are about crontab.Can I access $HOME variable in crontab ? for example, use $HOME like this:PATH=$HOME/bin:$HOME/scripts:$PATH ? or * * * * * echo test > $HOME/test.txt ?I want let crontab redirect normal stdout to /dev/null, but mail stderr to user. For example, when computer is not connected to network, then an entry in crontab like * 2 * * * getmail -n -q ... will return error, so crontab will send email to user with this error.based on upper example, getmail will let crontab mail user when system is not connected to network, so I want a method to detect whether user is connected to network.About this method of detecting, it should has bellowing:fastsimpleeasy to combine with other crontab jobs, (like use control: &&, ||, | etc)
crontab sets up user variable, redirect output, and detect connetcted network
networking;cron;environment variables;email
null
_scicomp.773
I have heard that some journals are rated more highly than others. Is this true? And if so, what are the criteria for judging the value of one peer reviewed journal over another? How do I find out its rating? Will my publication be of less worth if it is accepted in a less reputable journal than, say, the SIAM Review?
Is there a standard rating system for scientific journal publications?
publications;journals
What factors determine where I will publish a paper? Will the people I want to read this paper see it? If I'm following up on the work of another group (perhaps to show a different viewpoint, sometimes to show algorithmic improvements or to fix problems with a previous paper), I will want to submit the paper to the same journal, even if there's an impact factor issue. As a young computational scientist still in the career development phase of my career, I would submit that there is an additional, and perhaps even more critical aspect to this question. . . .Will people who may be in a position to evaluate me see this paper? I've often spoken with peers in the computational science field about the need to have a home turf: computational science is a highly interdisciplinary field. Unfortunately, we are not really able to be considered as computational scientists when it comes time to be considered for a permanent position. In the absence of working in a computational sciences department, We will have to apply for tenure in an existing department, which usually means that our peers will be other engineers, scientists, and mathematiciansmany of whom do not really have a strong background in computational science. This means that even if you want to go in the cross-fertilizing direction, you still need to focus some of your publications in the go-to journals for your discipline. This is a challenge that many of our peers will not necessarily have to face, and it's an additional complication in our lives. But it's something we have to be aware of before we start working!How much competition do I have right now? The more crowded a field, the more important it is to get the results in early. While it's great to try to go to Nature or Science with every paper out of your group (presuming you're not in pure math, or something similar), being first out of the gate in a hot field matters much more than publishing in the best journal in a field.How important is this paper? A paper that represents a body of work that provides a lot of new data, but not really much in the way of ground-breaking insight, probably doesn't merit going to a top-level journal. It's probably better to look for a reputable journal. However, if you've really found something big, shoot high, so long as you're not worried about the time crunch that affects the big journals. (It can take longer, for instance, to publish in Physical Review Letters than in one of the other Physical Review series, which are of comparable quantity.)After all of these are taken into account, then I'll start worrying about issues like impact factor, but then only as a loose quality control measure. Differences of 10-20% are essentially meaningless, but a 1.0 versus a 2.0, or a 2.0 versus a 3.0, does represent a measurable level of difference between journals.
_webapps.44593
I'm an IT specialist for a small company in Indianapolis, and we want to switch our email, calendar, and cloud storage (though not hosting or DNS registration YET - one step at a time) to Google Apps for Business.The question is, how? We're a company in full stride, and can't take three weeks off to transfer all the services. How do I/is there a way to simply transfer the email at least from GoDaddy to Google Apps? Is there a way to make sure incoming emails never touch GoDaddy's glacial servers (that's what I'd most like to make sure of)?
GoDaddy -> Google Apps for Business
email;google apps;google apps email
You need to set MX records on your server to do that.http://support.google.com/a/bin/answer.py?hl=en&answer=33353&topic=1611273&ctx=topic
_codereview.5957
Topic 1: Switching to another form from the project startup formI use the following code that calls an instance of my form for payment (frmPayment) from my startup form (frmMainMenu) using a click event:Private Sub btnPayment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPayment.Click, PaymentToolStripMenuItem.Click Dim frmPaymentX As New frmPayment() 'declare payment form Me.Visible = False frmPaymentX.ShowDialog() End SubShould I use something other than Me.Visible = False in handling my startup form (frmMainMenu) during my form switch?Topic 2: Switching back to the startup formLikewise, I use the following code to return to my startup form (frmMainMenu) from my form for payment (frmPayment):Private Sub btnMainMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMainMenu.Click frmMainMenu.Show() Me.Close()End SubShould I directly call my startup form (frmMainMenu) as I am doing in my example or should I be calling an instance of my starup form (frmMainMenu)?I believe that I should use show() and not showdialog() for this. Is this correct?Should I use something other than Me.Close()?
Switching back and forth between forms
vb.net;winforms
Firstly, I think you need to clarify why you are wanting to show the payment form and hide the main form. In most applications, when you want to show a dialog of some description, you would show it modally (using dialog.ShowDialog()) so that it appears over the top of your current form and prevents the user from interacting with the other form until the opened dialog is closed.Secondly, if you are wanting your current main form and payment dialog as two screens as opposed to a form and a dialog, then you may be better off creating some shell form that can contain a UserControl. You can then build the main form and payment form as two UserControl's and simply switch which is being displayed on your window.
_softwareengineering.99195
Javascript has a feature called Automatic Semicolon Insertion where basically if the parser encounters an invalid token, and the last token before that was a line break, then the parser will insert a semicolon where the linebreak is. This enables you to basically write all your javascript code without semicolons, but you have to be aware of some edge cases, mostly if you have a return keyword and then the value you want to return on a new line.function test(){ // This will return 'undefined', because return is a valid statement // and john is a valid statement on its own. return john}Because of these gotchas there are dozens of articles with titles like 'Automatic semicolon insertion is Evil', 'Always use semicolons in Javascript' etc.But in Python no one ever uses semicolons and it has exactly the same gotchas.def test(): # This will return 'undefined', because return is a valid statement # and john is a valid statement on its own. return johnWorks exactly the same, and yet no-one is deadly afraid of Pythons behaviour. I think the cases where the javascript behaves badly are few enough that you should be able to avoid them easily. Return + value on a new line? Do people really do that a lot? Any opinions? Do you use semicolons in javascript and why?
How does Python's handling of line-breaks differ from JavaScript's automatic semicolons?
python;javascript
null
_webapps.101526
I tried conditional formatting but that changed only cell with date fill in..Or can I somehow extend value of date on another columns because I need to use it for different data and than change the color of based date of cells...Gray Bars are passed and I want them auto-changing by the date
I want change backround color on the cell where is no date, but the change have to be by the date
google spreadsheets
null
_codereview.149693
I just read this post on how to avoid memory leaks with AsyncTask. The post proposed using a WeakReference and supplying a TextView as the object of the WeakReference.In my code, I need to supply multiple parameters to the AsyncTask (not just one as shown in the post). So what I did was create an inner class with the parameters needed in the AsyncTask and use the said class as the object of the WeakReference.private static class AddBooksToDatabase extends AsyncTask<String, String, String> { private final WeakReference<AddBooksDbParams> mReference; private String TAG = TownFragment; Context mContext; WaveLoadingView waveView; TextView infoText; String townName; File mFile; public AddBooksToDatabase(AddBooksDbParams params) { this.mReference = new WeakReference< >(params); mContext = mReference.get().mContext; infoText = mReference.get().infoText; townName = mReference.get().townName; mFile = mReference.get().mFile; waveView = mReference.get().waveView; } @Override protected String doInBackground(String... strings) { TownHelper helper = TownHelper.getInstance(mContext, dbName); SQLiteDatabase database = helper.getWritableDatabase(); int booksSize = getFilesInFolder(mFile).size(); //Stuffs return null; } @Override protected void onPreExecute() { if (waveView != null) { waveView.setVisibility(View.VISIBLE); } } @Override protected void onPostExecute(String s) { if (waveView != null) { waveView.setVisibility(View.GONE); } } @Override protected void onProgressUpdate(String... values) { super.onProgressUpdate(values); Log.d(TAG, Progress report = + values[0]); infoText.setText(values[0]); } @Override protected void onCancelled() { cancel(true); } } //Parameters for AddBooksToDatabase. This is to enable holding of a //single object of this class in WeakReference private class AddBooksDbParams { Context mContext; WaveLoadingView waveView; TextView infoText; String townName; File mFile; AddBooksDbParams(TextView infoText, Context context, File file, String townName, WaveLoadingView waveView) { this.infoText = infoText; mContext = context; mFile = file; this.townName = townName; this.waveView = waveView; } }When I want to execute the AsyncTask:AddTownsDbParams params = new AddTownsDbParams(infoText, getActivity(), folder, mShelfLabel, mWave);addBooksTask = new AddBooksToDatabase(params).execute();The code is working quite aright but I want to know if I am doing wrong.
Class with multiple parameters as the object of a WeakReference
java;android;weak references
null
_unix.278857
I'm using a 32-bit Linux Mint Rosa 17.3 with MATE DE (for the record, the same issue exists on a 64-bit flavor as well, and I have had this issue with every ubuntu-based distro). It is installed on a Fujitsu Siemens Amilo Laptop with 2GB RAM. All updates are installed.The problem is, there is no fan control, either actively or passively. That is, I have no way of controlling the fan speed, and the system doesn't control it either. It's always running at a constant, high speed. There are no overheating problems (temperature monitors are working and report temps at ~58-60C). But the noise is bothering me.What I have done:1) lm-sensors is installed.2) I have run sudo sensors-detect, without anything happening (i.e. it doesn't detect any fans, I only get this:#----cut here----# Chip driverscoretemp#----cut here----Here's the output of sensors:acpitz-virtual-0Adapter: Virtual devicetemp1: +50.8C (crit = +109.8C)coretemp-isa-0000Adapter: ISA adapterCore 0: +48.0C (high = +100.0C, crit = +100.0C)Here's the output of inxi -FxzSystem: Host: chris-AMILO-mint Kernel: 3.19.0-32-generic i686 (32 bit gcc: 4.8.2)Desktop: MATE 1.12.0 (Gtk 3.10.8~8+qiana) Distro: Linux Mint 17.3 RosaMachine: System: FUJITSU SIEMENS product: AMILO Li1705 v: 20Mobo: FUJITSU SIEMENS model: AMILO Li1705 v: 0.4Bios: FUJITSU SIEMENS v: 1.0C-2308-8A20 date: 02/15/2007CPU: Single core Intel Celeron M 520 (-UP-) cache: 1024 KBflags: (lm nx pae sse sse2 sse3 ssse3) bmips: 3191 speed: 1595 MHz (max)Graphics: Card: VIA CN896/VN896/P4M900 [Chrome 9 HC] bus-ID: 01:00.0Display Server: X.Org 1.17.1 drivers: openchrome (unloaded: fbdev,vesa) Resolution: [email protected] Renderer: Gallium 0.4 on llvmpipe (LLVM 3.6, 128 bits)GLX Version: 3.0 Mesa 10.5.9 Direct Rendering: YesAudio: Card VIA VT8237A/VT8251 HDA Controller driver: snd_hda_intel bus-ID: 04:01.0Sound: Advanced Linux Sound Architecture v: k3.19.0-32-genericNetwork: Card-1: VIA VT6102/VT6103 [Rhine-II] driver: via-rhine port: 4800 bus-ID: 00:12.0IF: eth0 state: down mac: <filter>Card-2: Qualcomm Atheros AR2413/AR2414 Wireless Network Adapter [AR5005G(S) 802.11bg]driver: ath5k bus-ID: 05:01.0IF: wlan0 state: up mac: <filter>Drives: HDD Total Size: 160.0GB (8.3% used) ID-1: /dev/sda model: WDC_WD1600BEVS size: 160.0GBPartition: ID-1: / size: 15G used: 7.7G (57%) fs: ext4 dev: /dev/sda2ID-2: swap-1 size: 5.24GB used: 0.00GB (0%) fs: swap dev: /dev/sda5RAID: No RAID devices: /proc/mdstat, md_mod kernel module presentSensors: System Temperatures: cpu: 59.8C mobo: N/AFan Speeds (in rpm): cpu: N/AInfo: Processes: 133 Uptime: 10 min Memory: 457.1/1758.2MB Init: Upstart runlevel: 2 Gcc sys: 4.8.4Client: Shell (bash 4.3.111) inxi: 2.2.28What's going on here?For the record, the laptop fans worked fine (i.e. they are detected and are controllable) when using Windows Vista (also installed)
Yet another fan control problem
ubuntu;linux mint;fan;sensors
null
_unix.287291
Today I downloaded the latest VMware image of Kali Linux (Kali Linux 64 bit VM). After that, I configured the hostname in /etc/hostname and adapted also the /etc/hosts to set permanently a hostname. Then, I executed the following commands:apt-get upgrade && apt-get updatedpkg --add-architecture i386apt-get updateapt-get install wine32apt-get install clamavapt-get install clamav-freshclamand rebooted afterwards. Then, something strange happened. I was no longer able to login with the default credentials root and toor. Although, I did not get the error message Sorry, that didn't work. Please try again., I could not get past the login screen. However, I noticed that I am able to login when selecting GNOME on Wayland and also booting in recovery mode.Any idea what is causing this issue?
Cannot bypass login screen with correct credentials and no errors in Kali Linux
kali linux;login;root
null
_unix.44859
I need to install a compatible video driver on a Fedora machine.The resolution proportion isn't very well and I can't change the brightness and contrast (xbacklight and xgamma) either.Please answer me with a complete solution or a final successfully tutorial.Some information about the system is:$ lspci | grep VGA00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)$ cat /etc/issueFedora release 17 (Beefy Miracle)Kernel \r on an \m (\l)
How to install a specific video driver on Fedora?
fedora;drivers;video
null
_cs.40167
Given a directed graph $G = (V, E)$ and an edge $e \in E$, I'm trying to come up with an algorithm to construct the minimum induced subgraph $H$ of $G$ with the property that every circuit in $G$ that traverses $e$ is in also in $H$.As an example, suppose graph $G$ has vertices $V = \{1,2,3,4\}$ and edges $\{(1,2), (2,1), (2,3), (3,2), (3,1), (2,4), (4,3)\}$, and $e = (4, 3)$. The subgraph $H$ that the algorithm should output consists of the two circuits $2,4,3,2$ and $2,4,3,1,2$.Of course, this problem can be solved by enumerating all circuits of $G$, but I'm hoping that someone here can come up with something better (that is, with strongly polynomial complexity, in the size of the graph) than that.EDIT: I just found this post that solves the problem for undirected graphs, but it doesn't provide any directions for directed graphs. I don't see a straightforward generalisation to directed graphs from that post.
Finding all circuits that contain a given edge
algorithms;graph theory;graphs;search algorithms
It should be NP-complete to compute, given an arc $e = uv$ of a directed graph $D = (V,A)$ whether there is a cycle containing some vertex $w$ using the arc $e$. The instance to this problem is $(D,e,w)$.By reducing from back-and-forth (two-disjoint paths from $a$ to $b$ and from $b$ to $a$), given an instance $(D',a,b)$ of back-and-forth, construct the instance $D$ where you make two copies of $a$, $a_1$ and $a_2$ and an arc going from $a_1$ to $a_2$. The constructed instance is $(D,(a_1a_2),b)$.Now, suppose there are two-disjoint paths from $a$ to $b$ and back, then there is a cycle from $a_2$ to $b$ and from $b$ to $a_1$, hence $b$ is on a cycle containing the arc $a_1a_2$. For the reverse direction suppose that $b$ is on a cycle traversing the arc $a_1a_2$. Then, in the original graph, there is a path from $a$ to $b$ and one from $b$ to $a$. qed
_softwareengineering.52961
This is slightly different to most questions (trying to avoid duplicates)When would you consider not using a framework (i'm talking PHP here for websites) when does one choose pure html/css/jquery over a PHP frameworkIt seems to me that a framework can be a bit bloated in some cases and overkill for certain circumstances, so at what level does a site drop to (in scale, not quality) before its considered OTT to use a PHP framework?
Need for a framework
web development;php;frameworks
Your question should be the other way around. You should start with no frameworks and then ask, does the time saved with framework X's benefits outweigh its implementation/maintenance costs? There are definitely cases where a framework contains more overhead than it is worth, in those cases (mostly very simple sites), you are find to do things by hand.
_datascience.15420
Reading some Computer Vision / Machine learning papers, I wonder what I should print and why for validation curves (or report in tables). (I am aware of the fact that error = 1 - accuracy; still, there could be an advantage of reporting one or the other)Tables / Text:Error rate: DenseNet, Inception-v4, AlexNet, DeepFace, GoogleNetAccuracy: Tiramisu, DeepFace, FaceNet, LightenedPlotsError: DenseNet, Inception-v4, AlexNetLoss: DenseNetAccuracy: Dmytro16, LightenedIt seems to me that it depends on the sub-field (e.g. face recognition uses accuracy, object recognition uses error).So my question is: Is there any reason for plotting the accuracy or the error, or is it completely personal preference?(Of course, there are more specialized error metrics which depend on the data set and might be better than either of those two.)ReferencesDenseNetTiramisuInception-v4Dmytro16AlexNetDeepFaceFaceNetLightenedGoogleNet
Should I plot the error or the accuracy for validation curves?
image classification;accuracy
null
_unix.58903
I have a script that runs a series of scripts numbered 001,002,003,004... etc down to 041 right now, will be more in the future - and these scripts them selves use some cursor control to print a progress bar and other status information and get the width and height of the terminal from tput cols and tput lines respectively. Without rewriting the sub-scripts, I would like to reserve one line at the bottom for overall status information for the outer script. I was curious if there was a way to set what tput replies for lines and cols.There must be a way because tmux achieves it. I was thinking there may be an environmental variable but the only change I can see that tmux makes when running env is setting the $TERM to screen.Any help would be greatly appreciated
How to set Cols and Lines for a Subprocess
shell script;scripting;gnu screen;tmux;subshell
The following will let you customize the number of lines and cols tput returnsexport LINES=1000export COLUMNS=1000
_softwareengineering.114037
I have a method like this in my UI code:void MyDialog::OnCommandSaveData(){ std::list<MyClass*> objects; service_->GetAll(objects); dataService_->SaveObjects(objects); AddMessage(Saved data.\n);}Because this method can take some time, I want to kick off a thread to do this. I'm using C++ and I plan on using Boost.Thread. So my question is how to best do this. My understanding is that I need to create a static function, static method, or functor which will contain the above code. Where should this live, in the dialog class? That just seems wrong, but then again maybe not.And then I will need a mutex and lock around at least the SaveObjects method. Where should the mutex live and where do I put the lock?Most examples of threading, as with examples of so many things, don't show the threading in the context of a real application. They show a main method with a global function and that's it. So if you can point me to example of a class that manages threading for an operation that would be great.I buy the logic in the accepted answer to this question: Is It Wrong/Bad Design To Put A Thread/Background Worker In A Class? However, the answer only tells you why to do it, not how.UPDATEI've refactored my code using MVP (Model View Presenter)/Humble Dialog Box pattern:void MyDialog::OnCommandSaveData(){ presenter_->SaveData();}So now I will need to look at adding multi-threading in the context of MVP.UPDATE 2I found this article which talks about creating mulithreaded winforms using MVP. It's in C# so I'll have to translate it into C++ but it looks good:http://aresterline.wordpress.com/2007/04/17/multi-threaded-winforms-application-mvp/Basically it involves 1) creating a ThreadSafeView which is a wrapper or proxy around your view that allows your view to be updated from a worker thread. And 2) creating a ThreadedPresenter which allows presenter methods to spawned in a new thread. I really like how this isolates the threading code from the view and the presenter code.
Thread class design?
design;c++;multithreading;boost
null
_unix.144039
Playing around with awk I noticed this behavior:[root@ror6ax3 ~]# grep open * | awk '$2 ~ /opens*/ {print $0}'install.log:Installing openldap-2.4.23-32.el6_4.1.x86_64install.log:Installing openssl-1.0.1e-15.el6.x86_64install.log:Installing openssh-5.3p1-94.el6.x86_64install.log:Installing openssh-clients-5.3p1-94.el6.x86_64install.log:Installing openssh-server-5.3p1-94.el6.x86_64install.log:Installing b43-openfwwf-5.2-4.el6.noarch[root@ror6ax3 ~]# grep open * | awk '$2 ~ /opens */ {print $0}'install.log:Installing openssl-1.0.1e-15.el6.x86_64install.log:Installing openssh-5.3p1-94.el6.x86_64install.log:Installing openssh-clients-5.3p1-94.el6.x86_64install.log:Installing openssh-server-5.3p1-94.el6.x86_64Why would opens* match openldap ?
awk regex matches wrong?
awk;regular expression
* means 0 or more, so effecively 0 or more s characters. There's the documentation here, that says For example, ph*' applies the*' symbol to the preceding h' and looks for matches of onep' followed by any number of h's. This also matches justp' if no `h's are present.In your case, you're doing opens* while you're probably expecting something like opens+, where + means 1 or more. Check out the docs on the + operator here
_codereview.123222
I need to find the percentile where a list of values is higher than a threshold. I am doing this in the context of optimization, so it important that the answer is precise. I am also trying to minimize compute time. I have a O(n) solution which is not very precise, then I use scipy's minimize optimizer to find the exact solution, which is time-intensive. The numbers in my problem are NOT normally distributed.Is there a more time-efficient way to do this while preserving precision?from scipy.optimize import minimizemy_vals = []threshold_val = 0.065for i in range(60000): my_vals.append(np.random.normal(0.05, 0.02))count_vals = 0.for i in my_vals: count_vals += 1 if i > threshold_val: breakpercKnot = 100 * (count_vals/len(my_vals))print minimize(lambda x: abs(np.percentile(my_vals, x[0]) - threshold_val), percKnot, bounds=[[0,100]], method='SLSQP', tol=10e-9).x[0]
Quickly find percentile with high precision
python;performance;time limit exceeded;numpy
Use comprehensionsI understand that my_vals is not necessarily the real data and that you might have other means to generate them, but anyway building a list using append is often an antipattern. Use a list comprehension instead:my_vals = [np.random.normal(0.05, 0.02) for _ in range(60000)]Same for your actual computation, you basically want to count the amount of values lower than the threshold; use a generator expression and feed it to sum:sum(1 if x <= threshold_val else 0 for x in my_vals)This is still \$O(n)\$ and will compute the required value right away (after dividing by len(my_vals)).Better is to use int(x <= threshold_val) instead of the ternary. Or even the comparison directly (even if more implicit) since True + True is 2.Use functionsIn order to improve reusability and testing.This also means that you can wrap your demo code into bits that won't necessarily be called every time. For instance:from scipy.optimize import minimizedef compute_percentile(values, threshold): count = sum(x <= threshold for x in values) percentage = 100. * count / len(values) # Improve precision of the percentile return minimize(lambda x: abs(np.percentile(values, x[0]) - threshold), percentage, bounds=[[0,100]], method='SLSQP', tol=10e-9).x[0]if __name__ == __main__ : demo_values = [np.random.normal(0.05, 0.02) for _ in range(60000)] print compute_percentile(demo_values, 0.065)
_unix.11261
Using mount.cifs on openSUSE 11.3, I'm getting very slow performance on a gigabit network, usually around 4-5MB/s. The following mount command has yielded me the best performance so far:mount.cifs //server/share /mnt/share -o user=aduser,domain=ADDOMAIN,uid=aduser,nogrp,nobrlWindows 7 on the same network gets almost full gig.What else can I try to make it faster?
mount.cifs is slow
performance;samba
null
_cs.56554
Summing Triples problem is strongly $NP$-complete as shown by McDiarmid.Summing Triples problem:Input: list of 3N distinct positive integersQuestion: Is there a partition of the list into N triples $(a_i, b_i, c_i)$ such that $a_i + b_i= c_i$ for each triple $i$?The condition that all numbers must be distinct makes the problem interesting and McDiarmid calls it a surprisingly troublesome . If the input is a multiset of positive integers, What is the complexity of Summing Triples? Does it remain NP-complete?May be I overlooked an easy reduction from the original problem.
What is the time complexity of Summing Triples with duplicates?
complexity theory;np complete
null
_unix.332559
Was reading man page of resolv.conf and meet sortlist.What is the use of it?Man page shows only list of network\IP addresses after sortlist keyword, not the sorting criterion. How that addresses map to sorting? Searched material about this question, did not found answer, though.
What is the use of sortlist option in /etc/resolv.conf?
dns;resolv.conf
sortlist is used to move matching IP addresses in DNS responses to the front of the result list with the intention that applications will use them preferentially. It's a bit obsolete though. Nowadays we have better a standard for that, in the form of RFC 3484 (see section 6).RFC 3484 is much better than the sortlist hack better because:It supports IPv6 [better].It takes source address selection into account.It's not specific to DNS (it's hooked into the libc name service, a layer above).It's a standard.RFC 3484 style destination address selection is configured in /etc/gai.conf.
_unix.264929
I have a text file containing below:title1 A1title3 A3title4 A4title5 A5 title1 B1title2 B2title5 B5 title1 C1title2 C2title4 C4title5 C5 title1 D1title2 D2title3 D3 I would like to have an output like below: title1 title2 title3 title4 title5 A1 A3 A4 A5 B1 B2 B5 C1 C2 C4 C5 D1 D2 D3 Could you please let me know how can I write a piece of code using AWK?Thanks in advance!
Transposing rows into columns in absence of few rows using AWK
awk
null
_scicomp.14645
I am trying to write an algebraic multi-grid solver (in c++). At a given level I determine which nodes are c-points and which nodes are f-points (where the total number of c and f points equals the matrix dimension on that level). Therefore I need two arrays: one array to hold the indices of the c-points, and one array to hold the indices of the f-points. The problem is I do not know how many c-points (or f-points) there will be before hand and so I don't know how large to make these arrays. One option is to just make both arrays to have size the same as the number of rows in the matrix that way ensuring no overflow. This is what I am doing right now, but this entails significant extra storage wasted. I could also essentially run my function that determines the c-points and f-points twice, where the first time I just record the final sizes, but this is obviously a lot of extra work. Does anyone know what is the best strategy for dealing with this? There does not seem to be any way of determining the final number of c-points without actually computing them one after another.
How to determine the number of c points in algebraic multi grid
linear algebra;c++;multigrid
Maybe you could make one array that's sized for the total number of points, then fill it with coarse points from the front and fine points from the back. They'll meet up somewhere in the middle (but not overlap).
_softwareengineering.80390
For some reason I got thinking the other day about DBAs and what they do. This thread goes some way to answer this question, but then I looked up the leading jobs site in my area out of curiosity, and it seems like there are more Oracle DBA jobs around than many other technology specialties. Even relatively common-sounding ones, such as Java Developer or Network Administrator.Here's the thing: I've been in this industry for ten years, worked in several jobs (a couple in fairly large corporate shops too), and I've never actually seen a real live DBA. There was usually a self-taught database guru around who was the goto guy for database issues (otherwise employed as a developer like the rest of us), but I've never seen anyone in an official DBA role, anywhere, ever.So, where are all the DBAs? I'm guessing that since all the places I've worked so far were relatively application-oriented, I've just never experienced a very hardcore DB-heavy environment. At the same time, at least one of the jobs I've had seemed like a pretty extreme data-centred operation (real time market/trading systems, huge databases), and even here the only database people were these developers who were database gurus on the side. No official DBA roles.Is it really just a case of me never having been in the kind of environment where DBAs are needed? If so, what kind of environment is that? Is this phenomenon perhaps to do with data centres being separate/outsourced operations these days, so most application level programmers just don't see them anymore?Note: I am basically trying to understand where the separation between developers who know databases well and actual DBAs is. It seems like a lot of dev roles require some pretty hardcore database knowledge these days (and that most development teams - even in quite DB-heavy environments - get by without an official DBA on staff). ie Please don't close or move to dba.SE.
Where are all the DBAs?
database;dba
A DBA is not a SQL developer. A DBA is an administrator. He/She installs, configures, backs-up, restores, grant privilges, control security, does physical tuning, migration, manage vendor app DBs (SAS, PeopleSoft) etc of a database. All medium-large enterprise (banks, insurance, retail etc) with valuable data in DB will have a DBA whether in-house or outsourced. And no a developer is not suitable for a DBA; the roles, responsibility and even work hours can be different.A database Developer is an SQL expert who is a part of the application development team. It is he/she who develops the logical data model (tables, views, indexes etc) and all SQL code (Stored Procs, dynamic SQL) including optimisation. This person may be an exclusive SQL developer (as I have in my team) or a shared SQl/OtherPorgrammingLanguage developer. Most importantly this person would have no access to production DBs and all changes would actually be performed by the DBA using change scripts or other tools. The DBA in turn should NOT question the SP code or Table schema as that is owned by the application ( I am talking about apps that own the DB and all data goes into the DB via the app).
_codereview.33774
I am constructing a selector on every radio button click. Since I am using the table repeatedly on every radio click, I cached it like:var $t1 = $(#tableone);but inside the radio check event, I need to retrieve the selector to construct a string.Approach 1:$radio.click(function () { var temp = $t1.selector + . + $(this).attr(mobnum);Note: If I do not $t1.selector, it comes as [object][Object] which I do not want, so I have to use $t1.selector.Since I am using $t1.selector to construct temp every time radio is clicked, is there still a benefit caching the table at the beginning?Approach 2:$radio.click(function () {var temp = $(#tableone) + . + $(this).attr(mobnum);Which one's better?
Selector on every radio button click
javascript;jquery;comparative review
I don't think your approach 2 will do what you want. So I the first one would be better.It looks to me though that you are building another selector. Probably to find the child element. So I would recommend something like this:var $c = $t1.find(. + $(this).attr(mobnum)).This returns the child element. This way you are already selecting only out of the children of $t1. Which would be more efficient, in theory.
_codereview.45444
I have written the following C code for calculating the Shannon Entropy of a distribution of 8-bit ints. But obviously this is very inefficient for small arrays and won't work with say 32-bit integers, because that would require literally gigabytes of memory. I am not very experienced in C and don't know what would be the best approach here. If it would simplify things, I could use C++ or Objective-C...Also, please tell me about any other issues with the code you may find :-)double entropyOfDistribution(uint8_t *x, size_t length){ double entropy = 0.0; //Counting number of occurrences of a number (using buckets) double *probabilityOfX = calloc(sizeof(double), 256); for (int i = 0; i < length; i++) probabilityOfX[x[i]] += 1.0; //Calculating the probabilities for (int i = 0; i < 256; i++) probabilityOfX[x[i]] /= length; //Calculating the sum of p(x)*lg(p(x)) for all X double sum = 0.0; for (int i = 0; i < 256; i++) if (probabilityOfX[i] > 0.0) sum += probabilityOfX[i] * log2(probabilityOfX[i]); entropy = -1.0 * sum; free(probabilityOfX); return entropy;}btw, this is the formula I implemented: $$ H(x) = -\sum_{x} p(x) \log(p(x))$$
Counting occurrences of values in C Array (Shannon Entropy)
c;beginner
Firstly, you know the size of the number of buckets you want to use here, so there is no reason to use dynamic allocation (specifically, double *probabilityOfX = calloc(sizeof(double), 256);). This could simply be:double probabilityOfX[256];memset(&probabilityOfX, 0.0, 256);You don't need to free this memory at the end then, either, reducing the possibility for memory leaks.Of course, this is fine for small values (like what can fit in a uint8_t), however, using a uint32_t (or larger), this will pre-allocate a large array which could potentially be very sparse. In this case, what you actually want is a dictionary data structure (like a hashmap). Since C doesn't have anything like this inbuilt, I'm going to switch over to C++ so we can use std::unordered_map and some other nice things like std::vector (instead of raw uintx_t pointers):double entropyOfDistribution(const std::vector<uint32_t>& vec){ std::unordered_map<uint32_t, unsigned> counts; // Store the number of counts for(uint32_t value : vec) { ++counts[value]; } double sum = 0.0; // Note the cast as otherwise we'll be doing integer // division and hence rounding to an int - // thanks @syb0rg for pointing that out. const double num_samples = static_cast<double>(vec.size()); for(auto it = counts.begin(); it != counts.end(); ++it) { double probability = it->second / num_samples; sum += probability * log2(probability); } return -1.0 * sum;}
_codereview.37542
There is a pattern that keeps coming up in my ruby code and I'm somewhat ambivalent about it. It's somewhere between a Hash and a Struct. BasicallyI used method_missing to return/set values in the Hash unless I want to override a specific value with some logic or flatten out the complex underlying structure in the JSON. It's very flexible and quickly allows code changes, but it also hides much of the structure of the object.In effect, the structure is in the data ( JSON file ) and not in the code.Is this an effective Pattern or just asking for trouble down the road? class AttributeKeeper def initialize @attributes = Hash.new end def import // Special import methods usually from JSON end def export // Export to JSON with maybe some data verification along the way. end def special_value= (value ) // Perform data check on special value @attributes[special_value] = value end def checked_value // Return value if passes checks. end def method_missing(meth, *args, &block) smeth = meth.to_s trim = smeth.chomp('=') #Handle setter methods. unless ( smeth == trim ) @attributes[trim] = args[0] else @attributes[smeth] end end def responds_to?(meth) smeth = meth.to_s if( @attributes[smeth] or smeth[-1,1] == '=') true else super end endend
Ruby Dynamic Struct - Pattern or AntiPattern?
ruby;design patterns
Useful to create mock, small scripts, remote api mapping... the github ruby api Octokit.rb is using this kind of pattern.Don't use this for huge (1000+) collection of objects with intensive call on them. The method_missing, symbol conversion will compromise your performance, generating a memory bloat and a lot of garbage collection,the Hashie isn't optimized as ActiveRecord::Base (method_missing triggering a define_method) so method call resolution has a always higher cost.Another aspect is that you tend to put your code at the wrong place (UtilityClass#full_name) instead of the actual class (user.full_name).
_unix.284744
I'm trying to figure out best way to control network settings in best way possible in real time.My current plan is this:Start ip -s -d -o monitor with systemd and write its output to file generated with mkfifo or write tiny script which outputs to tcp socket 127.0.0.1:<some port>Write shell script which reads the file/socket and generate systemd network config files on the fly if there are changes and of course use other commands to read additional data for systemd configuration depending of the changeThis way you can use ip <cmd> command to change network settings in real time and also you can write systemd config files by hand and restarting networkd and then again both ip and systemd's network settings stays in sync after boot.Then the question: or is there even better way?For example is there commands like:systemd-networkd --add-vlan 123 --name lansystemd-networkd --attach-vlan lan --device interface0systemd-networkd --monitor --script /etc/network_changes_script.sh
Systemd and controlling network settings
scripting;systemd;network interface;systemd networkd
null
_unix.381044
When I enter who command in the shell, i got this:root tty1 2017-04-01 12:21langxiaowei pts/2 2017-07-21 18:05So, for the safe, I want to kill the root user. Then I enter the comamnd in the shell:sudo pkill -kill -t tty1After, I enter who command again, I sure the root user is gone! But, a few seconds later, I lost connection from the machine. The host is not alive. The host restarted.I saw the last -x output, it's below:runlevel (to lvl 2) 3.13.0-24-generi Fri Jul 21 18:10 - 00:45 (06:35) reboot system boot 3.13.0-24-generi Fri Jul 21 18:10 - 00:45 (06:35) shutdown system down 3.13.0-24-generi Fri Jul 21 18:06 - 18:10 (00:03) langxiao pts/2 10.15.1.15 Fri Jul 21 18:05 - down (00:00) The syslog output is :Jul 21 18:06:39 ubuntu kernel: [9611571.765277] init: mountall-shell main process (6462) killed by KILL signalJul 21 18:06:40 ubuntu kernel: [9611571.879372] init: tty1 main process (1221) killed by HUP signalJul 21 18:06:40 ubuntu kernel: [9611571.879387] init: tty1 main process ended, respawningThe Linux Version is : Ubuntu 14.04 LTS \n \lThe kernel is : Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/LinuxI seemly ps -ef|grep tty1, saw /sbin/sulogin, perhaps there has relations. As I knew the comamnd pkill -kill -t tty1 is safe, can not cause reboot host. But why here reboot?I connected the host from remote on the secureCRT.PS:On Host B, I alse do pkill -kill -t tty1, there is no reboot, and the syslog is :Jul 21 18:04:34 ubuntu kernel: [32147390.433895] init: tty1 main process (997) killed by KILL signalJul 21 18:04:34 ubuntu kernel: [32147390.433917] init: tty1 main process ended, respawning
When I killed tty1 root user on ubuntu14.04the system reboot. Why?
ubuntu;tty;kill;reboot
null
_unix.171399
How would you grep for a line containing only 5 or 6 numbers? Something like this. case 1 (has leading space) 10 2 12 1 13case 2 (no leading space) 1 2 3 4 5 6I thought something like this would work. grep -E '[0-9]{5}'
Grep for a line containing only 5 or 6 numbers
grep
null
_unix.14127
In Mac OS X, if I don't touch it for a while, it will lock the screen and one must use password to unlock it, but this kind of log in is not recorded by last command. I want to know if anybody tried to break into my MacBook when I am not in front of it. Is there any way I can log such attempts?
How to know when and which user logged into the system under Mac OS X? Last is not enough!
osx;login;logs;last
If you suspect that someone has correctly guessed your password and got in, you can check this via the Console. To access Console press +space and type 'console' in the Spotlight box that appears. Click return.Click on 'Diagnostic and Usage Messages' on the left panel. At the time of the correct login attempt you see something like this:Note: 'screen locked, user typed correct password'.Now if someone tried, yet failed, you'd see something like this under system.log (also accessible via Console):I hope that's of some assistance to you.
_softwareengineering.188480
I want to fork on Github the TestNG java testing framework (Apache 2 license) so I can add/change some minor things to suit my needs.It's unlikely that all of my changes would be approved in the main project or that other people would use my fork. This would in no way be a competition to the main project.Now, in terms of naming, I want to change the artifact name (testng-mycompany) or the version (6.8.mycompany) so there's no confusion with the official version in my maven repository. Would this be considered poor etiquette? If yes, what is the best approach to distinguish your fork?
What is the etiquette of renaming an open source fork?
open source;github;etiquette;forking
null
_unix.182605
I have a strange problem with our cluster solution on Linux. We have the following set-up in our environment. Each of these servers hosts our enterprise application.Server1Server2Server3 Server1 fails over to Server2, Server2 fails over to Server3 and Server3 fails over to Server1 (Round Robin). The cluster is set-up using the RHEL clustering solution. When the fail over happens, the application mount points are moved to the other(Host) server, but the /home/sftpuser/.ssh directories are still in the original physical servers. The same user is on all the 3 Servers and hence we cannot overwrite the /home/sftpuser/.ssh directory on the Host server with the contents from the Guest Server. How can we pull files using sftp from the failed over server? Can we create a new user with his home directory in the application related mount points?
Linux Cluster - SFTP between failed over Servers
linux;sftp;cluster
I spoke to our sysadmin and adding the public keys corresponding to the Virtual IPs of the guest Servers in the authorized_keys files of all the servers did the trick. This enables the application to talk to the guest server irrespective of where they are physically running.
_unix.324132
This is partly a straight question and partly an attempt to gain more understanding about how QNAP network servers work.My office uses a local network drive installed with (according to /proc/version) a Linux 3.2.26 QNAP build. While trying to sort out a number of mishaps while our sysadmins were away, I learned that QNAP uses Samba/SMB.When I was initially trying to find the device with avahi-discover to connect to it (I'm running Ubuntu 16.04), it showed up under Microsoft Windows Network (as well as _qdiscover._tcp and a few others). I'm not sure if that means that QNAP is running a Windows VM that's confusing Avahi, or if it's just offering up connection options to as many OSes as possible and the Windows one is just what Avahi happened to pick up on.Is there a Linux command for determining this sort of thing? Or am I misunderstanding how this all works? I'm not a proper sysadmin but the two in our office are primarily Windows users, so having an understanding of the system is handy when I have to untangle something unusual between my machine and the network drive.
How to list QNAP virtual machines from an SSH command line?
ubuntu;networking;windows;samba;smb
null
_unix.92599
I ran df, and the output appears almost instantly:(FS Size Used Avail Use%)/dev/sda1 145G 8.4G 130G 7%sda1 is an ext4 partition.Without summing the size of all files, how can df give me the space information almost instantly?
How does my partition (ext4) know its size of used/free space?
linux;filesystems;ext4
Like traditional Unix File Systems, ext2, ext3 and ext4 have a segment of metadata called a superblock, which contains information about the configuration of the file system. The primary superblock is stored at a fixed offset from the start of the partition, and since the information it contains is so important, backup copies of the superblock are stored throughout the file system.The information the superblock contains includes the total number of inodes and blocks in the filesystem and how many are free. This information can be used to calculate the used and available space of the file system efficiently.
_unix.388328
Now sudoers supports the subfolder /etc/sudoers.d where we can set personalized rules there. I want use it and avoid changing the main /etc/sudoers file. So, in a file into /etc/sudoers.d/99_adjusts I want to unset the main user specification rule :ALL ALL=(ALL) ALLI am trying to avoid commenting it out at /etc/sudoers.I would want something which revokes this rule set before: !ALL ALL=(ALL) ALLBut the above unfortunately does not work;! looking at the man pages I can't figure out if there is some trick to do that.
How unset a rule in sudoers?
linux;sudo
AFAIK, it is not possible to remove sudo rules in a sudo config file. You should remove the main config file /etc/sudoers and write your rules only in /etc/sudoers.d/*. Using both is source of confusion.
_unix.265810
I have created an open-ssl private key which I would like to use to connect to my server through ssh. The openssl key was generated during certificate creation and I have to use this key on putty. The problem is that puttygen only allows openssh type keys to be converted to putty keys. How do I convert my open-ssl private key to openssh private key so I can convert it to putty key? The length of the private key is 2048 bits.
How to convert open-ssl created private key to openssh private key?
ssh;openssl;openssh;conversion;key authentication
null
_unix.100704
What's the difference between executing multiple commands with && and ;?Examples:echo Hi\! && echo How are you?andecho Hi\!; echo How are you?
Difference between executing multiple commands with && and ;
bash;shell
In the shell, && and ; are similar in that they both can be used to terminate commands. The difference is && is also a conditional operator. With ; the following command is always executed, but with && the later command is only executed if the first succeeds.false; echo yes # prints yestrue; echo yes # prints yesfalse && echo yes # does not echotrue && echo yes # prints yesNewlines are interchangeable with ; when terminating commands.
_unix.97302
Is there any standard that covers the portability of running a command after variable assignment on the same line?APPLE=cider echo hiHow portable is something like that? Where will it work and where won't it? Also: my shell scripts start with #!/bin/sh if that makes any difference.
Is it shell portable to run a command on the same line after variable assignment?
shell;posix
As long as you're using a POSIX compliant shell, yes.From the POSIX definition of shell command language: (relevant points in bold)A simple command is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control operator.When a given simple command is required to be executed (that is, when any conditional construct such as an AND-OR list or a case statement has not bypassed the simple command), the following expansions, assignments, and redirections shall all be performed from the beginning of the command text to the end:The words that are recognized as variable assignments or redirections according to Shell Grammar Rules are saved for processing in steps 3 and 4.The words that are not variable assignments or redirections shall be expanded. If any fields remain following their expansion, the first field shall be considered the command name and remaining fields are the arguments for the command.Redirections shall be performed as described in Redirection.Each variable assignment shall be expanded for tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal prior to assigning the value.In the preceding list, the order of steps 3 and 4 may be reversed for the processing of special built-in utilities; see Special Built-In Utilities.If no command name results, variable assignments shall affect the current execution environment. Otherwise, the variable assignments shall be exported for the execution environment of the command and shall not affect the current execution environment (except for special built-ins).Also, yes #!/bin/sh matters. From the POSIX definition of sh:The sh utility is a command language interpreter that shall execute commands read from a command line string, the standard input, or a specified file. The application shall ensure that the commands to be executed are expressed in the language described in Shell Command Language.So basically it says that sh must follow the rules we covered above.So as long as you're on a POSIX compliant OS, you're good.
_webapps.14809
What HTML code do I need to include on my webpages if I want visitors to share the URL or links to their friends on a social network like Facebook or a web service like Tumblr?I want the text to read something like:Share with Facebook or TumblrIs there a web app or service that I can use that will include the popular options instead of having to know which service or social network I want to offer a share link to?
Quick way to share my webpage via links through Facebook or Tumblr
facebook;sharing;tumblr;social networks
null
_webapps.25592
I'd like to view the revision history of a Google Docs document using more flexible tools like Git, and possibly migrate some content from Google Docs into a Git project.Google Docs has an API with access to the revision history, so this should be possible, for any of the variety of export formats it supports. I note, though, that there have been some API problems with revision history that mean that the list of contributors to each revision may not be complete, though they're considering fixing that:Sometimes there are more than one editor (for a particular revision). Yet, the API always gives me one editor per revision.Is there any code or advice on doing this available? Export to a different version control system like bzr, Mercurial, SVN or CVS would also be of interest.This is related to the Stack Overflow question Version Control with Google Docs Best Practices?, which was closed as off-topic there.
Import Google Docs document revision history into a Git repository?
google drive
Lars Kellog-Stedman created a great little python app called gitdriver which I found on this answer at StackOverflow. It does what you're looking for. It authenticates to Google with OAuth and pulls down all the revisions of a document, committing them to a git repository.With this, you could fetch a versioned copy of your Google Doc and then work with it using traditional git tools.
_cogsci.17872
I recently finished reading Habits of a happy brain, which discusses the role of oxytocin, serotonin, endorphin, dopamine, and cortisol in seeking behavior.The book argues that we evolved to direct ourselves towards things that would promote our survival, and each of these hormones has a role to play in either strengthening certain behaviors, or encouraging us to move on from certain behaviors - one of the ways this is done is Dopamine/Serotonin disappointment (I don't recall if it was also relevant for oxytocin), which lessens the reward - and seems to have evolved because it encouraged us to move on and try to do even better.But the book makes no mention of passion*, or how it fits in into all these discoveries.Specifically, I wonder, how is passion possible in light of these disappointments? I'd imagine passion involves a significant feeling of reward. Is there another hormone involved, one that's less... disappointing?And how does passion develop into what it is? I am a big believer in the claim (which also appears in the book) that we evolved to seek ways to survive, and that what makes us happy (or sad, or stressed) is perceived by us as helpful (or detrimental) to our survival. How does one connect something to the need for survival in such a way that gives him so much energy and continuously rewards him for doing it?And, being practical as always,How can I get me some of them passion?(Don't worry, it's for a good cause)*Please note that I am specifically talking about passion towards a thing/hobby, as opposed to towards a partner. I don't know how much overlap there is, but I wouldn't go there before I delve into the (surely extensive) body of research into love.
What causes passion, psychologically and chemically, and how does it last?
emotion;motivation;dopamine;reward;serotonin
null
_unix.343548
I'm running some third-party Perl script written such that it requires an output file for the output flag, -o. Unfortunately, the script appears to require an actual file, that is, users must create an empty file filename.txt with 0 bytes and then input this empty file on the script command line perl script1.pl -o filename.txtQuestion: How would I create an empty file within a bash script? If one simply tries perl script1.pl -o filename.txt, the script gives an error that the file doesn't exist.
How do I create a new empty file in a bash script?
bash;shell script;shell;files
Use touch command. touch filename.txt.
_reverseengineering.3792
I have a mipsel executable (DvdPlayer from a RTD1283 firmware). I know that IDA is able to identify many functions. Then, I would like to generate a .sig file with signatures of these functions for use with other executable DVDPlayer (from other firmwares).Would it be possible to convert the executable in a library ?
Generate a sig file from ELF executable
ida;firmware;mips
null
_cs.75008
What is the asymptotic behaviour, in notation, of the smallest function that for any $n_1$ and $n_2$ satisfies the following:$$t(n_1+n_2)t(n_1)+t(n_2)+c\log_2(1+n_2)$$where $n_1n_21$ and $t(1)=1$I tried to see what happens if $n_1 = n_2$:$$t(2n)t(n)+t(n)+c\log_2(1+n)$$$$t(n)2t(n/2)+c\log_2(1+n/2)$$Also if $n_2=1$:$$t(n+1)t(n)+t(1)+c\log_2(2)$$$$t(n)t(n-1)+1+c$$But I am not sure where to go next, or if this is a correct approach.
Asymptotics of a recurrence defined with two variables
asymptotics
The function $t$ is given by $t(n) = 1$ and for $n>1$,$$t(n) = \min_{1 \leq k \leq n/2} t(n-k) + t(k) + c\log_2(1+k).$$You can prove by induction that$$t(n) = n + c(n-1).$$This holds when $n=1$. For the inductive step,$$\begin{align*}t(n-k) + t(k) + c\log_2(1+k) &= [n-k + c(n-k-1)] + [k + c(k-1)] + c\log_2(1+k) \\ &= n + c(n-2) + c\log_2 (1+k) \\ &\geq n+c(n-2)+c \\ &= n + c(n-1).\end{align*}$$
_bioinformatics.2361
I have data, obtained from a single metagenomic DNA sample, that consists of two MiSeq FASTQ files (R1 and R2) that I merged using PEAR.Now I want to estimate the abundances of the bacteria taxa to generate a figure like this one:Figure from: Panosyan, Hovik, and NilsKre Birkeland. Microbial diversity in an Armenian geothermal spring assessed by molecular and culturebased methods. Journal of basic microbiology 54.11 (2014): 1240-1250.The problem is that there wasn't a step of amplification of the 16S region as the goal of the sequencing was to discover new genes. I've already isolated 16S reads from my sample using SortMeRNA, but it seems like softwares that do OTU picking, taxonomic assignment and diversity analyses (such as mothur and QIIME) require that all the reads come from the same region of the 16S gene.Is there a way of using these 16S reads that I've filtered using SortMeRNA in a diversity analysis using mothur/QIIME?
Microbial diversity analysis using whole-genome metagenomic data
metagenome;taxonomy
null
_unix.230822
I keep several Linux distros on a USB stick and manage them by simply writing grub.cfg entries for each distro. The other distros I keep on the stick boot and run just fine, but I (and others, it seems) started having problems with Debian Jessie (8.x). Debian Netinst will boot to the debian-installer curses interface, but then tries to search for the correct debian iso file, even when the iso path is given in the kernel line in grub.cfg.I've been partially successful trying to boot debian-8.2.0-amd64-i386-netinst.iso from a USB stick. I first setup my USB stick using the USB multiboot instructions found on the ArchWiki.Here's a simplified file and folder structure of the USB stick, followed by the relevant grub.cfg entries.USBROOT/ ----boot/ ----grub/ ----grub.cfg ----(other grub paraphernalia) ----iso/ ----debian/ ----debian-8.2.0-amd64-i386-netinst.iso ----initrd.gz (special initrd)While there is an initramfs within the iso, it won't allow debian to boot properly for reasons I don't really understand; it is explained briefly in the two links I've given so far.Now my grub.cfg entries. I know this is an i386/amd64 multiarch iso, but I will just focus on the 64 bit part for simplicity. If we can figure out the 64 bit part, I should be able to easily make another entry for i386:probe -u $root --set=rootuuidset imgdevpath=/dev/disk/by-uuid/$rootuuidmenuentry 'Debian 8.2 Multiarch' { set isoname='debian-8.2.0-amd64-i386-netinst.iso' set isopath='/boot/iso/debian' set isofile=${isopath}/${isoname} set initrdfile=${isopath}/initrd.gz loopback loop $isofile linux (loop)/install.amd/vmlinuz iso-scan/ask_second_pass=true iso-scan/filename=${imgdevpath}/${isofile} config quiet initrd ${initrdfile}/initrd.gz}As an aside: changing the initrd line toinitrd ${initrdfile}makes grub (I think) throw an error. Grub pauses for a few moments, then Debian tries to boot and immediately has a kernel panic--as expected, because it can't find an initramfs. However, this doesn't happen when I fully write out the path as shown in the block code example. Why would it throw an error when I specify the path with set variables, and not when just writing out the full path by hand? But my main question is:What kernel boot parameters must I supply so that no search is performed and the iso is located at the path I specify. The installer does eventually find the correct iso by searching, but why did it have to search?I am almost certain it has everything to do with the linux line:linux (loop)/install.amd/vmlinuz iso-scan/ask_second_pass=true iso-scan/filename=${imgdevpath}/${isofile} config quietI've tried at least 20 variations on the theme, such as changing:iso-scan/filename=${isofile}findiso=${imgdevpath}/${isofile}findiso=${isofile}EDIT: I fixed the initrd problem: I had single quotes when defining $initrdfile. The findiso/iso-scan/whatever problem still remains.
How do you write a grub.cfg menuentry for Debian Netinst (8.2 as of writing) to boot via USB?
linux;debian;boot;grub;debian installer
null
_unix.150946
I'm starting with VirtualBox and Linux on a Windows machine. I can log in to Linux using the Virtual Box command line but I want to do something pretty easy: log in from an external (not virtualbox) command line to Linux using ssh. I've created a user hsander to do so: ssh [email protected] but: I get the message: Connection timed outTo do so I looked for my Linux ipaddress using: /sbin/ifconfig -a I get the following:Normally the IP is shown next to inet addr:.... but I think 10.0.2.15 is a pretty rare IP isn't?So what am I doing wrong?I've been searching on Google but yet no solutions...
Logging in to VirtualBox via SSH
networking
That IP is likely inside a NAT block which VirtualBox has set up. You need to either bridge or forward if you want to access the machine's ports from outside; you can do both from the virtual machine settings panel.
_unix.25216
I'd like to see the absolute size in bytes of each file that has been compressed into single zip file. Having read the zip man page, I'm not sure that that utility can do it. This is on Mac OS X.Something like:$zip list myarchive.zipfile1.jpg 100 bytes compressed 3000 bytes uncompressedfile2.jpg 130 bytes compressed 3440 bytes uncompressed
Is there a command to list the compressed file sizes for files within a .zip file?
files;compression;zip;size
You can use the unzip utility with the -v flag:unzip -v files.zipArchive: files.zip Length Method Size Cmpr Date Time CRC-32 Name-------- ------ ------- ---- ---------- ----- -------- ---- 0 Stored 0 0% 11-23-2011 15:02 00000000 file1 0 Stored 0 0% 11-23-2011 15:02 00000000 file2-------- ------- --- ------- 0 0 0% 2 filesNote: The file sizes here are 0 because I made test files of zero length.
_unix.323024
I have some source file suppose mydata.csv and my target table.I want to validate the record count whether it's same between the source file and the target table .The target table is in hive.I have gone through this LinkI want something like if [ eval target_count_command -eq count_from_csv ]then echo File loaded fineelseLOad Againfi
Check the count of records from the source file and the loaded target
shell script;text processing;csv
The easiest way to count records would be wc -l. If you have a variable with the number of CSV lines that should be referenced as $count_from_csv (with the quotes). You shouldn't need to use eval in this case; instead you'll want to run the command to count the target number of rows using $(target_count_command).
_unix.145444
I have a program Vuze that is written in Java, which I use to download very large files, and I'm having a problem with it. I need to increase the amount of memory it uses. I've followed the directions for the application but it doesn't change the real memory usage. I would think this would then be because Java (JVM) is not set to support the amount of memory I set in the application.I both get errors about files missing and low memory.How can I increase the memory used by my Java Virtual Machine?My Java is Oracle. My system is Fedora 20 X86_64 KDE.
How to increase the memory used by Java in linux?
fedora;memory;java;application;out of memory
I found the solution to my problem here.The workaround: I increased the memory used to 1024M with these instructions.I set the Maximum files opened for read/write to a 101.I ran the application from the command line with this command:sudo bash -c 'ulimit -n 8192'; sudo -u username ./azureus
_unix.120973
I have a very old (c. 2001) computer and the most recent version of Ubuntu that it can run is 11.4. I am thinking of replacing Ubuntu with Centos 6.5 but am not sure if the hardware can handle it. I am therefore trying to install Centos 6.4 on a virtual machine using VMWare Player 3.1.6. I user VMWare Player to install CentOS-6.5-i386 from an ISO. It appears to run successfully and I get a Centos login dialogue. However, when I click on the login dialogue (or do control-G), the cursor disappears. I tried reinstalling Centos and found that the same thing happens during the installation so I suspect the problem lies with VMWare Player rather than with Centos 6.5. The keyboard also appears to have no effect when the cursor is captured.
Captured cursor invisible with Centos 6.4 running on VMWare Player 3.1.6 on Ubuntu 11.4
vmware;centos
null
_unix.179570
I'm running a CentOS 7 server.So I've installed Two Factor Authentication with Google Authenticator a while back and all was well.However I can't access my server at the moment over SSH.PuTTY and WinSCP don't ask for the Verification Code anymore.How can I fix this? I've already tried rebooting the server which didn't help.My server is self hosted btw so I can access it offline.
Putty not asking for Two Factor Authentication Code
ssh;centos;authentication;putty
null
_unix.180777
I am relatively new to Linux.I was trying to rebuild MDM display manager for Linux mint from urlhttps://github.com/linuxmint/mdm. In the documentation it is said that you should use./autogen.sh --enable-ipv6=yes --with-prefetch If I do that and I do a make I will get this errormdm-daemon-config.c:1818:4: error: format not a string literal and no format arguments [-Werror=format-security]gchar *s = g_strdup_printf (C_(N_(MDM ^Then I read somewhere that ubuntu is treating this as error. I tried with ./autogen.sh --enable-ipv6=yes --with-prefetch CFLAGS=-Wno-format-securityAnd I got rid of that warning but I got another error:mdm-daemon-config.c:2003:1: error: no previous prototype for mdm_daemon_load_config_file [-Werror=missing-prototypes] mdm_daemon_load_config_file (MdmConfig **load_config) ^I tried then with ./autogen.sh --enable-ipv6=yes --with-prefetch CFLAGS=-Wno-format-security -Wno-missing-prototypesbut that didn't help either. When I do a make I see that gcc is using (among other things just copied the interesting part)-Wno-missing-prototypes -Wall -Wstrict-prototypes -Wnested-externs -Werror=missing-prototypes so it is using both -Wno-missing-prototypes and -Werror=missing-prototypes which is probably what is causing it to malfunction.
How to change CFLAGS for autogen.sh
linux mint;make;gcc;mdm
null
_webmaster.700
Where does google webmaster tools get all it's data from? Is it paired with google analytics etc or is it purely crawlers and searches it display?
What is the source of google webmaster tools' data?
google search console
It's pulled directly from crawls and searches and may contain different information compared to google analytics. You can read more information in the Google Webmaster Tools FAQ
_softwareengineering.116031
Assumptions:Minimalist ASP.NET MVC 3 application for sending emails where the view represents the contents of an email.Over 500+ email types. I would NOT like to have 500+ actions in my controller corresponding to each email type.Email types are stored in an enum named MailType, so we could have:MailType.ThankYouForYourPurchase, MailType.OrderShipped, etc.The view name is the same as the mailType name:MailType.OrderShipped would have a corresponding view: OrderShipped.cshtmlSome views would directly use an Entity while others would use a ViewModel.So, given that I have 500+ email types, what is the best way/pattern to organize my application?Here is what I was thinking,Controller: public class MailController : Controller { public ActionResult ViewEmail(MailType mailType, int customerId) { string viewName = mailType.ToString(); var model = _mailRepository.GetViewModel(mailType, customerId); return View(viewName, model); } public ActionResult SendEmail(MailType mailType, int customerId) { ... } }MailRepository Class: public class MailRepository { private readonly CustomerRepository _customerRepository; private readonly OrderRepository _orderRepository; //pretend we're using dependency injection public MailRepository() { _customerRepository = new CustomerRepository(); _orderRepository = new OrderRepository(); } public object GetViewModel(MailType mailType, int customerId) { switch (mailType) { case MailType.OrderShipped: return OrderShipped(customerId); case MailType.ThankYouForYourPurchase: return ThankYouForYourPurchase(customerId); } return _customerRepository.Get(customerId); } public Order OrderShipped(int customerId) { //Possibly 30 lines to build up the model... return _orderRepository.GetByCustomerId(customerId); } public Customer ThankYouForYourPurchase(int customerId) { return _customerRepository.Get(customerId); } }But then this would lead to my MailRepository class becoming extremely large unless I somehow broke it up...
How do you organize an ASP.NET MVC 3 application with potentially hundreds of views but with only a few entry points?
design patterns;asp.net mvc;code organization
To avoid any one class getting too big you need to be mapping mail types to classes rather than method names - pick a naming convention like MailControllers.OrderShippedController and load the class with reflection.I'd also note that your MailRepository seems to be behaving more like a controller - not a major issue, but something that could become confusing later.
_cstheory.12762
In self-organizing maps(SOM) algorithm described here it is said about the weights of nodes and data items. If using this algorithm for sine function approximation given a few points are the nodes - points and weights - coordinates?
Self-organizing maps algorithm(Kohonen networks)
ai.artificial intel;data mining
null
_webapps.20868
Is there a way I can hide comments by default on SoundCloud?I saw the plugin for Chrome but I don't always use Chrome. Is there a better solution than that?
Hide Comments by Default on SoundCloud
soundcloud
Updated 1-26-15Here's a tampermonkey/greasemonkey script that disables comments in Soundcloud new and classic view:// ==UserScript==// @name SoundCloud - Hide comments// @description Hides comments on tracks// @include http*://soundcloud.com/*// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js// ==/UserScript==$(<style type='text/css'>+ .waveformComments{ display:none !important;} + .commentBubble__wrapper{ display:none !important;} + .commentPopover{ display:none !important;} + .waveform__layer.waveform__scene canvas:nth-child(2){ opacity:0 !important;} + </style>).appendTo(head);
_codereview.146304
I have a list of objects where one of the properties on the object class is an enum.The program below simply loops through each item in the list, checks an int value, then checks the enum value for that item, then adds the item to another list when the condition is met.I am using if-else statements, I attempted to use a switch statement but it doesn't seem possible to place 2 constants on a single case.I'd like to know if there's a better / more elegant way to do this or is what I've done sufficient in this scenario?Program Code// User inputs number from 1 - 5 int SelectedOppType = Int32.Parse(Console.ReadLine());foreach (Opportunities Opp in OpportunitiesList){ if (SelectedOppType == 1 && Opp.OpportunityStatusID == OpportunityStatus.Active) // Opp.OpportunityStatusID == OpportunityStatus.Draft { FilterdOppsList.Add(Opp); } else if (SelectedOppType == 2 && Opp.OpportunityStatusID == OpportunityStatus.Draft) { FilterdOppsList.Add(Opp); } else if (SelectedOppType == 3 && Opp.OpportunityStatusID == OpportunityStatus.Closed) { FilterdOppsList.Add(Opp); } else if (SelectedOppType == 4 && (Opp.OpportunityStatusID == OpportunityStatus.Active || Opp.OpportunityStatusID == OpportunityStatus.Draft)) { FilterdOppsList.Add(Opp); } else if (SelectedOppType == 5) { FilterdOppsList.Add(Opp); }}foreach (var OppItem in FilterdOppsList){ Console.WriteLine(OppItem.OppText);}Console.ReadLine();
Filtering a list by comparing enums against a user choice
c#;enum
Shortening ifsYou add everything to the same list so you can concatenate all conditions and use only one if with a helper variable:foreach (Opportunities Opp in OpportunitiesList){ var canAdd = (SelectedOppType == 1 && Opp.OpportunityStatusID == OpportunityStatus.Active) || (SelectedOppType == 2 && Opp.OpportunityStatusID == OpportunityStatus.Draft) || (SelectedOppType == 3 && Opp.OpportunityStatusID == OpportunityStatus.Closed) || (SelectedOppType == 4 && (Opp.OpportunityStatusID == OpportunityStatus.Active || Opp.OpportunityStatusID == OpportunityStatus.Draft)) || (SelectedOppType == 5); if (canAdd) { FilterdOppsList.Add(Opp); }}Other improvementsMagic numbersYou should create an enum for the SelectedOppType and cast the int given by the user to it.Example:enum OppType{ OppType1 = 1, OppType2 = 2, OppType3 = 3, OppType4 = 4, OppType5 = 5,}var selectedOppType = (OppType)Int32.Parse(Console.ReadLine());I know the names OppTypeX are ugly but I don't know what the numbers mean, this is why we dislike them. They have no meaning.Next, the logic can be extracted as an easier to maintain dictionary. Now that all values are enums we can easily build such a dictionary that I find by far is better then a switch nested in a loop. Besides, you can reuse the dictionary to display the options in other places (if you make it a filed or a property of some class).var allowedOppTypeStatuses = new Dictionary<OppType, IEnumerable<OpportunityStatus>>{ [OppType.OppType1] = new[] { OpportunityStatus.Active }, [OppType.OppType2] = new[] { OpportunityStatus.Draft }, [OppType.OppType3] = new[] { OpportunityStatus.Closed }, [OppType.OppType4] = new[] { OpportunityStatus.Active, OpportunityStatus.Draft }, [OppType.OppType5] = Enumerable.Empty<OpportunityStatus>(),};foreach (Opportunities opp in OpportunitiesList){ var canAdd = allowedOppTypeStatuses[selectedOppType].Any(x => x == opp.OpportunityStatusID) || !allowedOppTypeStatuses[selectedOppType].Any(); if (canAdd) { FilterdOppsList.Add(opp); }}Minor issuesWe use camelCase for local variables so SelectedOppType should be selectedOppTypeOpportunities - this doesn't look like a good name for a type, there seems to be more wrong with your code (unless it's an enum with Flags attribute).
_softwareengineering.341563
I'm building a native app which currently has zero backend infrastructure.With services like Firebase's Authentication, database and notifications means that all interactions are handled client-side within an Ionic app and consumed via Firebase javascript API.I would like to start sending triggered emails and communications. Both manually triggered by other user interactions, and on regular intervals (daily/weekly summaries). I feel slightly nervous about depending solely on client-side to process these message, especially as this wouldn't scale nicely at all.I'm familiar with writing API's and Services in .Net so I'd love to write something using the Azure message queue with something like Mandrill or Sendgrid. However it feels like there may be a far simpler solution. Perhaps Node.Js?Open to ideas and suggestions
Message queues and triggered comms within a native app
c#;cloud computing;message queue;azure;native
null
_cs.57180
Couldn't find much online on how an interactive system is different from a time-sharing system, or the different traits of both.My understanding of a time-sharing system is many people at terminals being able to use the system at the same time, and the CPU's aim is to maximise response time not CPU time (unlike a multiprogrammed batch system). The switches between jobs are very frequent, and users get immediate responses, when for example submitting interrupts via keyboard inputs. There is very little CPU idle time, duplication of software etc, but it is less reliable, there might be lower security and integrity, and potentially bad data communication. An example would be a chat messaging client or system.
Key differences between interactive and time sharing operating systems?
operating systems
Time sharing is a system of multi-tasking designed to allow multiple users to use a single machine at the same time.A time sharing operating system is one that supports multi-tasking and multi-user.In a time-sharing system the user typically interacts with the operating system through a secondary machine called a terminal. In an interactive operating system there is typically only one user on the system that has full control over the system.Because of the environment in which time-sharing machines are used (large cooperations and banks) security and separation between users is a prime concern. Interactive computing originates from the hobby and personal computing revolution. Because there is only a single user security was initially not a concern. From these starting points the lines have blurred.First single user systems gained multi-tasking and then multi-user concepts were copied over from time-sharing systems into the interactive OS'es. Meanwhile the security and performance of time sharing systems have also improved.
_softwareengineering.55662
I am developing high volume processing systems. Like mathematical models that calculate various parameters based on millions of records, calculated derived fields over milions of records, process huge files having transactions etc...I am well aware of unit testing methodologies and if my code is in C# I have no problem in unit testing it. Problem is I often have code in T-SQL, C# code that is a SQL stored assembly, and SSIS workflow with a good amount of logic (and outcomes etc) or some SAS process.What is the approach YOu use when developing such systems. I usually develop several tests as Stored procedures in a designed schema(TEST) and then automatically run them overnight and check out the results. But this is only for T-SQL. And Continous integration IS hard. But the problem is with testing SSIS packages. How do You test it? What is Your preferred approach for stubbing data into tables (especially if You need a lot data initialization). I have some approach derived over the years but maybe I am just not reading enough articles.So Banking, Telecom, Risk developers out there. How do You test your mission critical apps that process milions of records at end day, month end etc? What frameworks do You use? How do You validate that Your ssis package is Correct (as You develop it)/ How do You achieve continous integration in such an environment (Personally I never got there)? I hope this is not to open-ended question. How do You test Your map-reduce jobs for example (i do not use hadoop but this is quite similar). lukeHope that this is not too open ended
How can Agile methodologies be adapted to High Volume processing system development?
code quality;unit testing;performance;agile
null
_scicomp.26718
I'm trying to solve\begin{equation}\left\{\begin{split}\frac{\partial u}{\partial t}+(u\cdot\nabla)u-\nu\Delta u+\frac1\rho\nabla p&=f\;\;\;\text{in }\Lambda\\u&=0\;\;\;\text{on }\partial\Lambda\\\nabla\cdot u&=0\;\;\;\text{in }\Lambda\end{split}\right.\tag1\end{equation}on $\Lambda=(0,a)\times(0,b)$. Let\begin{equation}\begin{split}\mathfrak a(u,v)&:=\sum_{i=1}^d\langle\nabla u_i,\nabla v_i\rangle_{L^2}\\\mathfrak b(u,q)&:=-\langle\nabla\cdot u,q\rangle_{L^2}\\\mathfrak c(u,v,w)&:=\langle(u\cdot\nabla)v,\cdot w\rangle_{L^2}\end{split}\end{equation}for $u,v\in V:=H_0^1(\Lambda,\mathbb R^2)$ and $q\in\Pi:=\left\{p\in L^2(\Lambda):\int p=0\right\}$. Now, let\begin{equation}\begin{split}\tilde{\mathfrak a}(u,v)&:=\langle u,v\rangle_{L^2}+\Delta t\nu\mathfrak a(u,v)+\Delta t\mathfrak c(u^0,u,v)\\\tilde{\mathfrak b}(v,q)&:=\frac{\Delta t}\rho\mathfrak b(v,q)\end{split}\end{equation}for $u,v\in V$ and $q\in\Pi$. $u^0$ is the approximate solution of the previous time step and $\Delta t$ is the elappsed time. I've chosen a Taylor-Hood pair for the finite element discretization. Now, I'm left with a system $$\left(\begin{matrix}A&B^T\\B&0\end{matrix}\right)\left(\begin{matrix}u\\p\end{matrix}\right)=\left(\begin{matrix}f\\0\end{matrix}\right)\tag2$$ where\begin{equation}\begin{split}a_{ij}&=\tilde{\mathfrak a}(\phi_i,\phi_l)\\b_{ij}&=\tilde{\mathfrak b}(\phi_j,\psi_i)\end{split}\end{equation}and $(\phi_i)$ and $(\psi_i)$ are bases of the finite dimensional subspaces of $V$ and $\Pi$, respectively.My idea was to solve\begin{equation}\left\{\begin{split}BA^{-1}B^Tp&=BA^{-1}f\\Au&=f-B^Tp\;.\end{split}\right.\tag3\end{equation}However, I've got several problems with $(3)$:I'm trying to solve the linear equations using the GMRES method. As a first step, the right-hand side of the first equation, $BA^{-1}f$, has to be computed. I've assembled $A$ and $B$; hence I'm trying to find a solution $Ax=f$ (using the GMRES method) and then compute $Bx$. However, the GMRES method for $Ax=f$ converges extremely slowly (most probably due to the undesirable eigenvalue distribution of $A$). Can we accelerate the convergence by a preconditioner? If so, which one should I use?The same question applies to the invocation of the GMRES method for $BA^{-1}B^Tp=BA^{-1}f$. Which preconditioner can I use here?
Preconditioner for the GMRES method in the Uzawa algorithm
finite element;fluid dynamics;iterative method;preconditioning;gmres
Please check this paper by Benzi et al. They address this issue and give corresponding references on p. 45.Shortcut: for the Stokes problem $A = \text{diag}(A_{11},A_{11},\dots,A_{11})$ is just a collection of discrete Laplace operators, so it is natural to approximate their inverses using multigrid. However, things get much more complicated for Oseen type problems as in your case (especially if convection is high, $\nu \ll 1$); Uzawa converges rather slowly in this case. They give references to papers which propose preconditioning techniques for Uzawa. Beyond Uzawa: it may be useful to look at different solving techniques, e.g. block preconditioners such as PCD preconditioner by Kay et al. or AL preconditioner by Benzi and Olshanskii. A nice overview is given by Rehman et al. A recent step of deal.II tutorial implements AL approach (yet they use a direct solver for $A$ for simplicity of implementation).
_unix.120928
I am a new server admin. I just setup fail2ban on an ubuntu 12.04 VPS. I used this tutorial. Then I tried to login to the system via ssh from a friend's machine. It is showing operation timed out. It seems like this means fail2ban is working -- but I want to double check to be certain. Is this what it looks like on the client side when fail2ban has blocked your IP? Your SSH login times out because fail2ban/iptables does not allow it to initiate on the server side? $ ssh -p# user@IPuser@IP's password: Permission denied, please try again.user@IP's password: Permission denied, please try again.user@IP's password: ^C$ ssh -p# user@IPssh: connect to host IP port #: Operation timed out$ ssh -p# user@IPssh: connect to host IP port #: Operation timed out
Is this what it looks like in the terminal on the client side when you are blocked out via fail2ban?
security;iptables;fail2ban
If you take a look at this tutorial it states you'll see a timeout which is consistent with what you're seeing, titled: Fail2ban - Rackspace Knowledge Center.excerptsLet's test fail2ban to make sure it behaves the way we want it to. We'll do that by failing a few ssh logins.We'll use two machines: The server we want to protect and another machine to act as the attacker.Attacking machine's IP: 123.45.67.89The server's IP: 98.76.54.32To run the test, simply get on the attacking machine and try to ssh to your server five times. For example: $ ssh [email protected] the sixth try (assuming you have ssh's maxretry set to 5) your connection should time out if you try to ssh in again.NOTE: This last sentence is what you're seeing!Also you can setup fail2ban to send an email similar to this:If you have fail2ban set to send you email check to see if you got a message like this one: From fail2ban@ITSecurity Thu Jul 16 04:59:24 2009 Subject: [Fail2Ban] ssh: banned 123.45.67.89 Hi, The ip 123.45.67.89 has just been banned by Fail2Ban after 5 attempts against ssh. Here are more information about 123.45.67.89: {whois info} Lines containing IP:123.45.67.89 in /var/log/auth.log Jul 16 04:59:16 example.com sshd[10390]: Failed password for root from 123.45.67.89 port 46023 ssh2 Jul 16 04:59:18 example.com sshd[10390]: Failed password for root from 123.45.67.89 port 46023 ssh2 Jul 16 04:59:20 example.com sshd[10390]: Failed password for root from 123.45.67.89 port 46023 ssh2 Jul 16 04:59:21 example.comsshd[10394]: reverse mapping checking getaddrinfo for 123.45.67.89.example.com [123.45.67.89] failed - POSSIBLE BREAK-IN ATTEMPT! Jul 16 04:59:22 example.com sshd[10394]: Failed password for root from 123.45.67.89 port 46024 ssh2 Regards, Fail2BanProbably the best indication though that fail2ban worked was the existence of a new iptables rule that's now blocking the attacking IP address.For example:iptables -L Chain fail2ban-ssh (1 references)target prot opt source destinationDROP all -- 208-78-96-200.realinfosec.com anywhere
_datascience.17604
I have been reading about Generative Adversarial Networks (GANs) and was wondering if it would make sense to train a generator function only to use it for creating more training data.In a scenario where I don't have enough training data to build a robust classifier, can I use this limited data to train a generator that'll produce samples good enough to improve the accuracy of my discriminator (classifier)?
GANs to augment training data
neural network;dataset;accuracy;training;gan
Yes and no depending on how you define good enough samples.You will likely end up with a chicken and egg problem: you want to use the GAN to generate training data, but the GAN doesn't have enough training data itself to generate convincing enough samples.Other techniques exist for data synthesis of training images. For example: adding noise, flipping axis, change luminosity, change color, random cropping, random distorsion.
_unix.357999
I'm using KDE Plasma on ubuntu and I have aproblem with skype. Whenever someone messages me, the panel opens up and won't close until I read the message. Please take a look at these gifs:In the first gif, you see, how the panels opens up, after I get a message, but the panel does not close.In the second gif, you see, how I have to click on skype and to read the message, to close the panel.How can I disable this behaviour? I don't want the panel to show up, everytime someone messages me. And I don't want to read the message, to close the panel.Any suggestions? Please tell me, if you need more informations.Plasma version: $ plasmashell --versionplasmashell 5.8.5EDIT: New skype version: Problem remains:
KDE Plasma: Skype messages opens up panel and won't close until clicked
skype;plasma;plasma5
null