id
stringlengths 5
27
| question
stringlengths 19
69.9k
| title
stringlengths 1
150
| tags
stringlengths 1
118
| accepted_answer
stringlengths 4
29.9k
⌀ |
---|---|---|---|---|
_cs.33735 | What is the name for this variant of genetic algorithm. I'm sure I have read about this in Wikipedia, but now I could not find it:There in no thing as sequential population. The phenotypes lives and dies just like people. The death comes after random period of time. During life phenotypes can have children. The better phenotype is (fitness function) the bigger is chance to have (more) children. The better phenotype is the better can be it's candidate form wife or husband. Yes, phenotypes have sex (man or woman). | The name for this genetic algorithm variant | terminology;genetic algorithms;evolutionary computing | I think you mean a genetic algoithm with a steady state population model. |
_unix.121496 | I am using Debian Wheezy with wdm and LXDE. I would like to have my user to be logged into LXDE automatically after computer start. I know this is possible with other display managers, such as gdm.Is there some way to configure this in wdm? If not in wdm, is there some workaround to do it with some script? | WDM: autologin after boot | x11;lxde;display manager | This article looks like it will do exactly what you're looking forhttp://www.raspberrypi-spy.co.uk/2012/06/auto-login-auto-load-lxde/ |
_webapps.27269 | In Gmail, whenever I send an email I want to get a copy of the message that I sent in my inbox, 100% of the time. How can I do this? | Get sent emails copy in inbox | gmail | I have not found a way to add the inbox label to all outgoing messages. But you can use multiple inboxes to get sent mail to the top of the windowGo to settings/Labs and select Multiple inboxesSave ChangesYou should now see a Multiple inboxes tab in settings.GMail will let you specify a search query. In the first box enter is:Sent Mail without the quotes.Set the maximum page size to a larger number. It didn't complain about using 50, but I don't know if there is a maximum value.Optional: Set Extra panels positioning to Above the inbox. This will put the Sent Mail label above the main inbox.Save changesThere may be a couple of second lag the first time you go back to the main page, becuse it has to execute the new query.It does the job with a couple of issues: Each inbox has its own < and > button to move through the listEach inbox has its own view all button which jumps you to the labelThe gear button is only on the tool bar above the main inbox section. |
_unix.288491 | I need to remove unnecessary data from multiple output filespart of each file looks like this# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:18697:4431_2:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# 0 hits found# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:26276:5181_1:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# Fields: subject title, query acc., subject acc., evalue, q. start, q. end, s. start, s. end# 1 hits foundFJ712717_(modified) Trypanosoma brucei brucei from mouse 18S ribosomal RNA gene, partial sequence; internal transcribed spacer 1, complete sequence; and 5.8S ribosomal RNA gene, partial sequence M03117:99:000000000-ALL7G:1:1101:26276:5181_1:N:0:196 FJ712717_(modified) 1.42e-137 1 271 53 323# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:26276:5181_2:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# Fields: subject title, query acc., subject acc., evalue, q. start, q. end, s. start, s. end# 1 hits foundFJ712717_(modified) Trypanosoma brucei brucei from mouse 18S ribosomal RNA gene, partial sequence; internal transcribed spacer 1, complete sequence; and 5.8S ribosomal RNA gene, partial sequence M03117:99:000000000-ALL7G:1:1101:26276:5181_2:N:0:196 FJ712717_(modified) 1.06e-87 1 197 436 236# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:10339:5290_1:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# 0 hits found# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:10339:5290_2:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# 0 hits foundThe first 4 lines represent one output result# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:7647:16266_2:N:0:215# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# 0 hits foundI need to remove all output results with 0 hitsi.e all the 4 lines(shown above)I have noted that with a result of: 1 hits found, there are 2 extra lines added. The 6th line doesnt start with the # symbol.How can I use thegrep -Bcommand to do this? or any other....please helpMy expected output is a file with only 1 hits found result. as below# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:26276:5181_1:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# Fields: subject title, query acc., subject acc., evalue, q. start, q. end, s. start, s. end# 1 hits foundFJ712717_(modified) Trypanosoma brucei brucei from mouse 18S ribosomal RNA gene, partial sequence; internal transcribed spacer 1, complete sequence; and 5.8S ribosomal RNA gene, partial sequence M03117:99:000000000-ALL7G:1:1101:26276:5181_1:N:0:196 FJ712717_(modified) 1.42e-137 1 271 53 323# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:26276:5181_2:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# Fields: subject title, query acc., subject acc., evalue, q. start, q. end, s. start, s. end# 1 hits foundFJ712717_(modified) Trypanosoma brucei brucei from mouse 18S ribosomal RNA gene, partial sequence; internal transcribed spacer 1, complete sequence; and 5.8S ribosomal RNA gene, partial sequence M03117:99:000000000-ALL7G:1:1101:26276:5181_2:N:0:196 FJ712717_(modified) 1.06e-87 1 197 436 236# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:11481:5777_1:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# Fields: subject title, query acc., subject acc., evalue, q. start, q. end, s. start, s. end# 1 hits foundJN673389_(modified) Trypanosoma congolense isolate TS07210 18S ribosomal RNA gene, partial sequence; internal transcribed spacer 1, 5.8S ribosomal RNA gene, and internal transcribed spacer 2, complete sequence; and 28S ribosomal RNA gene, partial sequence M03117:99:000000000-ALL7G:1:1101:11481:5777_1:N:0:196 JN673389_(modified) 2.04e-105 1 231 23 253# BLASTN 2.3.0+# Query: M03117:99:000000000-ALL7G:1:1101:11481:5777_2:N:0:196# Database: /home/alex/blast/db/tryps_ITS/tryps_ITS_db# Fields: subject title, query acc., subject acc., evalue, q. start, q. end, s. start, s. end# 1 hits foundTCU22315_(modified) Trypanosoma congolense IL1180 18S, 5.8S, 28S-LS1, srRNA1, complete sequence, and 28S-LS2 ribosomal RNA, partial sequence M03117:99:000000000-ALL7G:1:1101:11481:5777_2:N:0:196 TCU22315_(modified) 1.40e-75 1 156 1176 1021Thanks in advance. | uniquely remove unwanted lines in multiple files | text processing;scripting;grep | You can use tac to reverse the lines of file and delete 3 lines before matching pattern including line which contains the matching pattern using sed, like this:tac filename | sed '/0 hits/I,+3 d' | tacand if you want to edit the file in-place you can use -i option in sed command like,tac filename | sed -i '/0 hits/I,+3 d' filename | tac |
_unix.324784 | This comes from how to apply patch in a debian package? . Now after building the packages, I have no idea whether the packages got built correctly or not. I did see this in the parent directory - [shirish@debian] - [~/games] - [5870][$] cat dpkg_1.18.15+nmu1_amd64.changesFormat: 1.8Date: Mon, 21 Nov 2016 01:04:02 +0530Source: dpkgBinary: dpkg libdpkg-dev dpkg-dev libdpkg-perl dselectArchitecture: source amd64 allVersion: 1.18.15+nmu1Distribution: UNRELEASEDUrgency: mediumMaintainer: Dpkg Developers <[email protected]>Changed-By: shirish <shirish@debian>Description: dpkg - Debian package management system dpkg-dev - Debian package development tools dselect - Debian package management front-end libdpkg-dev - Debian package management static library libdpkg-perl - Dpkg perl modulesChanges: dpkg (1.18.15+nmu1) UNRELEASED; urgency=medium . * Non-maintainer upload. * Apply d-m-h fix from #844701Checksums-Sha1: 8e50f097f70d621071e1e22384c1d68da7693929 1169 dpkg_1.18.15+nmu1.dsc 16aa8483b0ce8d9eb1f0daebca6da84578226966 4617028 dpkg_1.18.15+nmu1.tar.xz 3f3eae9de5bb31e178a4acb32654e68410902bda 1238392 dpkg-dbgsym_1.18.15+nmu1_amd64.deb 3877d627c7c70bd98f16ee0b71d80c69667a6885 1581332 dpkg-dev_1.18.15+nmu1_all.deb b678906567a0c8ba089a5eb109855eba608f60e7 2067816 dpkg_1.18.15+nmu1_amd64.deb 6130872887cd4eeba0b0cc0d0c7354322709dfe7 280736 dselect-dbgsym_1.18.15+nmu1_amd64.deb 58eb460ab48e1c802ee7ae439dc0295424ef7742 1270868 dselect_1.18.15+nmu1_amd64.deb 41e17c39ced6f55b9e72d042255a7a9b647b2e8e 1040980 libdpkg-dev_1.18.15+nmu1_amd64.deb a38005cde488603a7ee5de9ce7bc307c79277bb9 1242182 libdpkg-perl_1.18.15+nmu1_all.debChecksums-Sha256: 2c8cf8ab1256814aa7115009a4620da913b27935351872335cd429ae4e7a9c70 1169 dpkg_1.18.15+nmu1.dsc 47390a1ca4a296852ef3c25c0bdc82217e49738438882a980e8da28dca0d809e 4617028 dpkg_1.18.15+nmu1.tar.xz 4a47a968b5dd4b1e87c99e5de9e3fd31b610ebb1891989de3a72ef08afb3405b 1238392 dpkg-dbgsym_1.18.15+nmu1_amd64.deb a05ae6dcefd5bc9affe355c8dd4106b42f795678fa4de31bc063a9784fc845ab 1581332 dpkg-dev_1.18.15+nmu1_all.deb b9682da9975541f385b47cf1148028deea4a48a51156293589b124c6f706d7b7 2067816 dpkg_1.18.15+nmu1_amd64.deb d75479bb9005788d96e839ae8b2dde56701993ac6421df1f5aaf79634f008a48 280736 dselect-dbgsym_1.18.15+nmu1_amd64.deb 8b317f45808d408485c566b9748522d63d556bcec7525dcaa442a9720073dd27 1270868 dselect_1.18.15+nmu1_amd64.deb e45e67c3ab034ed3d1bf9f268daba92ee3cc406c3b75ef2bd0354ec79dc30d7f 1040980 libdpkg-dev_1.18.15+nmu1_amd64.deb d75ff545c612a7eb5f4563bb3619cd33ea4d4baff6cade9452e94bb1e7b7a412 1242182 libdpkg-perl_1.18.15+nmu1_all.debFiles: faab0ae6b71c8216a634cbef6759d122 1169 admin required dpkg_1.18.15+nmu1.dsc 69eeaa680e11f291860217a9536e93dc 4617028 admin required dpkg_1.18.15+nmu1.tar.xz 91961eae15e20a3bf2ad614cf42ee4ab 1238392 debug extra dpkg-dbgsym_1.18.15+nmu1_amd64.deb aa361b4cde6020393c75a601c51f54e6 1581332 utils optional dpkg-dev_1.18.15+nmu1_all.deb 325a9629e03781c027f884a17ada0550 2067816 admin required dpkg_1.18.15+nmu1_amd64.deb 75dbcd90ada67522d79206b65519865e 280736 debug extra dselect-dbgsym_1.18.15+nmu1_amd64.deb e490b38b2b132c26670635628e302941 1270868 admin optional dselect_1.18.15+nmu1_amd64.deb 0d206c14b1ffd5cb6b09608e9774b3bf 1040980 libdevel optional libdpkg-dev_1.18.15+nmu1_amd64.deb e22e289a709d36d2186da60e07b68225 1242182 perl optional libdpkg-perl_1.18.15+nmu1_all.debI also saw a build-tree in the same directory and from the time-stamps the build-tree must have generated during the last step only . $dpkg-buildpackage -us -ucNow the checksums that are provided, these should be canonical (meaning same). At least from what little I understand that is the claim of reproducible builds. . I want that me and the maintainer should be able to check the integrity of the packages built . I looked at the manpage of dpkg-buildpackage and tried searching for 'reproducible' keyword but didn't find it there. | Building a .deb package reproducibly | debian;dpkg;binary | The maintainer has only asked you to check whether the supplied patch fixes things. If dpkg with the patch allows you to install libconfig-model-perl without the errors you were getting before, that would suggest that the patch fixes the issue. If it doesn't, the patch also includes more verbose output which should help pinpoint the real issue. That's all that's needed there's no need to worry about reproducible builds.Since you have a .changes file, your build completed successfully; and since dpkg includes an extensive test suite, you can be confident that it built correctly.In any case, building a package reproducibly currently requires a modified toolchain, and reproducible builds answer a very specific question: given an identical build environment, can I build a package identically to some reference?. It's unlikely that the maintainer and you have an identical build environment.The checksums in the .changes file aren't canonical in a reproducible sense. They're present for two reasons:to verify that a package uploaded to the archive was uploaded correctly;to verify that a package uploaded to the archive matches what was signed by the uploader (this is part of the chain of integrity of Debian packages).Successive rebuilds of the same source are currently expected to result in different checksums. |
_softwareengineering.345205 | Electron BrowserWindow does not let you show the address bar, so the best users get is this:https://i.imgur.com/OFAZrJ6.pngFor all they know, I could've ripped the stylesheet and created a form for them to enter their username and password in so that I could access their account myself.I can have them open the developer tools if they'd like to confirm that the OAuth page is genuine--by confirming the domain within developer tools--but outside of that I can't figure out how to give them a way to check.Any thoughts on methods of verifying the authentication of OAuth in Electron? | Verifying the authenticity of OAuth within Electron | oauth | null |
_softwareengineering.280462 | I am trying to come up with an algorithm for getting items for a news feed from several sources.There are multiple lists of data: S1, S2, ... Sn. Each of these lists has a certain known amount of items, Q1, Q2, ... Qn. I need to show these items with pagination, with a certain amount from each list per page, P1, P2, ... Pn, with total amount of items per page T = sum(P). I get items from lists using offset and limit (in reality, they are SQL tables). Obviously, at some point i shall run out of items of a particular type, in which case i need to fill the blanks with items from other lists to get exactly T items for each page except the last one which can have less than T items.Here's a concrete example for N=2, Q1=27, Q2=95, P1=10, P2=20, T=10+20=30:==========================================================================| Page | From S1 | S1 offset | S1 limit | From S2 | S2 offset | S2 limit |==========================================================================| 1 | 10 | 0 | 10 | 20 | 0 | 20 || 2 | 10 | 10 | 10 | 20 | 20 | 20 || 3 | 7 | 20 | (7) | 23 | 40 | 23 || 4 | 0 | 0 | (0) | 30 | 63 | 30 || 5 | 0 | 0 | (0) | 2 | 93 | (2) |==========================================================================The numbers in parenthesis are not really important, because i can live with asking the SQL table for more entries than it has.Ideally, i'm looking for an algorithm that can give me offsets and limits for a given page. Any ideas? | Combining items from several lists with pagination | algorithms | null |
_unix.258448 | When I type ps -ef , there are lots of special kernel thread processes showing.I am not interested in kernel threads; I am only interested in user process/thread.Is there a way that I can hide the kernel threads? | Is there any way to hide kernel threads from ps command results? | linux kernel;ps;proc;utilities | ps output can be filtered in may ways. To see your processes, you could filter by the user/uid. relevant man page below -- U userlist Select by effective user ID (EUID) or name. This selects the processes whose effective user name or ID is in userlist. The effective user ID describes the user whose file access permissions are used by the process (see geteuid(2)). Identical to -u and --user. -U userlist Select by real user ID (RUID) or name. It selects the processes whose real user name or ID is in the userlist list. The real user ID identifies the user who created the process, see getuid(2). -u userlist Select by effective user ID (EUID) or name. This selects the processes whose effective user name or ID is in userlist. The effective user ID describes the user whose file access permissions are used by the process (see geteuid(2)). Identical to U and --user.To identify kernel vs user threads, it may depend on the kernel version. On my ubuntu machine (3.5.0-30-generic), I can exclude kernel threads by excluding children of kthreadd (pid =2). The pid of kthreadd may differ on 2.6 kernels - however, you could just use the relevant pid. As an example, to get a list of all processes that dont have ppid =2, I do (for options to feed to -o, check the man page)-- ps -o pid,ppid,comm,flags,%cpu,sz,%mem --ppid 2 -NYou could also filter these using grep or awk. The other way (not using ps) to identify kernel threads is to check whether /proc//maps or /proc/cmdline is empty - both are empty for kernel threads. You'll need root privileges to do this. |
_unix.31252 | I am on Linux (Ubuntu) and I am would like to exclude certain directories (like .hg) when I am doing afind | less I tried the following to exclude the .hg directory from listing, but does not seem to work.find -type d \( ! -iname \.hg \)find -type d \( ! -name \.hg \)find -type d \( ! -iname .hg \)How do I exclude .directory in a find command | find exclude directory | find | On the research for a similar find solution I discovered the helpful explanation on How to use '-prune' option of 'find' in sh? by Laurence Gonsalves.You could use something like:find . \( -type d -name .hg -prune \) -o \( -type f -name foo -print \)or (without the name)find . \( -type d -name .hg -prune \) -o \( -type f -print \)The (escaped) parentheses \( and \) group the tests (type and name) and corresponding actions (prune and print, respectively) together left and right of the OR (-o).Since -o has lower precedence than juxtaposition, you can omit the parentheses if you like. Many find implementations also let you skip the final -print.find . -type d -name .hg -prune -o -type f -name foo -print |
_cs.70693 | Randal Bryant developed an exponential size lower bound for any BDD encoding the middle bit output of the multiplication function, regardless of variable permutation.But at the same time the multiplication function is decidable in logarithmic space. Of course related to P versus NP, the lower bounds complexity of its inverse function is currently unknown. Having an efficient BDD encoding for multiplication also provides a mechanism for efficient factoring, so I understand that this would seem implausible.However, if a function belongs to L (such as multiplication or so I think), it most certainly belongs to L/Poly which is (to my understanding) the class of polynomial sized BDDs.From what I can discern, Bryant's proof relies on communication complexity rather than crypto-hardness assumptions or building upon mainstream conjecture. So what's going on here that seems a blatant contradiction in known lower bounds?For some related background see this post:https://cstheory.stackexchange.com/questions/3462/most-significant-bit-of-integer-multiplication-and-binary-decision-diagrams | Multiplication function BDD size lower bounds | complexity theory;bdd | I think the resolution to the paradox comes from looking more carefully what is meant when we say that multiplication can be performed in logarithmic space, and looking more carefully at what we mean by a BDD.Suppose we want to multiply two $n$-bit numbers $a,b$, and suppose the two numbers $a,b$ are stored in read-only memory. Then we can calculate any desired bit of the product using only $O(\lg n)$ additional bits of space. However, this fundamentally requires us to have (read-only) access to the numbers being multiplied.(Take a look at the formula in Wikipedia for $r_i$: $r_i$ depends on $a$, $b$, and $c_{i-1}$. The carry $c_{i-1}$ needs only $O(\lg n)$ bits of space to store. However, just storing the carry alone is not enough. We also need to have the numbers $a,b$ stored, and that requires $\Theta(n)$ bits of storage.)In short, multiplying two numbers takes $\Theta(n)$ bits (read-only) for the numbers being multiplied and $\Theta(\lg n)$ bits (read-write) of additional storage. This does prove that multiplication is in $L$. However, it doesn't prove that there is a polynomial-size BDD for multiplication.First, let's understand what we mean by BDD. There are many types of BDD, but the most relevant one here is the notion of a ROBDD (read-once binary decision diagram). A ROBDD is allowed to read each bit of the input only once. Normally, BDD means a ROBDD: for a reference, see, e.g., the Wikipedia article on BDDs, which writes In popular usage, the term BDD almost always refers to Reduced Ordered Binary Decision Diagram (ROBDD. Moreover, the lower bound for the size of a BDD for multiplication is actually a lower bound on the size of a ROBDD for multiplication. Therefore, in this answer I'll assume BDD means ROBDD.Now, here's why the above algorithm doesn't prove there is a polynomial-size (RO)BDD for multiplication. Given an algorithm with space complexity $s$ and time complexity $t$, you can construct a BDD with something like $2^s \times t$ nodes (but here $s$ must include all input bits that might be read more than once, as well as all additional storage). This means that the number of nodes in a BDD could be as much as exponential in $s$. In the case of multiplication, we have $s = \Theta(n+\lg n) = \Theta(n)$, so from the existence of the multiplication algorithm above, all we can conclude is that the size of the BDD could be (at most) exponential in $n$. This isn't enough to show that there exists a polynomial-size BDD.What about L vs L/poly vs BDDs? I don't think it's true that just because a problem is in L/poly, that means it has a polynomial-size BDD.Roughly speaking (ignoring uniformity vs non-uniformity), a problem is in L or L/poly if there is an algorithm that has read-only access to the inputs and uses only $O(\lg n)$ additional bits of (read-write) storage. If we also knew that this algorithm reads each bit of its input only once, then that would imply that there is a polynomial-size (RO)BDD for the problem. But if the algorithm scans back and forth over the input bits, reading them many times, then I don't think there necessarily exists a polynomial-sized (RO)BDD for the problem. At least, I don't know of any result that implies that. I could be missing something.I know Wikipedia says that L/poly is a complexity class that captures the complexity of problems with polynomially sized BDDs. I am not sure that is exactly correct. |
_cstheory.1037 | For a given algorithm (eg reverse the items in this list) and a given type of Turing machine (eg the 3-state 2-symbol busy beaver reduced to 5-tuples) - is there a single simplest way that this algorithm can be represented?(This thread on LTU seems to suggest there are differences of opinion about what representing an algorithm on the Turing machine boils down to.) | What does it mean that there are differing views on how computations are represented on the Turing Machine? | lambda calculus;turing machines | It is not the algorithms that are represented in different ways, but input and output. Depending on how the input is encoded, a given problem might be hard or easy. To take a trivial example, consider the following encoding of Turing machines:A turing machine $T$ is represented by a number of the form $2 n + b$ where $n$ such that the binary digit expansion of $n$ gives a description of $T$'s program (encoded in a reasonable way). The number $b$ is $1$ if $T$ halts when run on empty input and $0$ otherwise.With this encoding of Turing machines the halting problem becomes very easily computable. Given a description of Turing machine, just look at the lowest bit to determine whether the machine stops.The moral of the story is that encoding of data is meaningless until we also specify what sort of structure we are trying to encode, i.e., which operations on data are supposed to be computable. (In the case of Turing machines it is known that the relevant operations are those of the s-m-n and u-t-m theorems, which fail for the silly encoding above.)In case we worry about computational complexity we also need to require that the data are suitably compressed, for example, if the input to an algorithm is a number $n$, it should be written with input of size $O(\log n)$, otherwise we can artificially boost the efficiency of the algorithm by writing down input in a very inefficient way.If we work with the usual Turing machines then all reasonable ways of representing data will be equivalent (even polynomial-time convertible). But with very small Turing machines one might be forced to represent inputs in very strange ways because the machine will lack the power to recode its input in whatever form is needed. Under such circumstances people might disagree what is a reasonable way of encoding input. For example, may the input be repeated twice (suppose the machine lacks the ability to go backwards but it needs to read the input twice to do its job)? May the input be repeated infinitely many times? If we impose no restrictions on how the input is presented to the machine, then the input itself might already contain the answer that the machine is supposedly computing (witness the example of the Halting problem above). Sometimes it is hard to tell whether a given representation is hiding extra information. An infamous example of this was the solution to the Wolfram 2,3 Turing machine research prize where the input tape had to contain an infinite repeating pattern in order for the machine to work correctly. I suggest you look at the archives of the Foundations of mathematics mailing list for a detailed discussion about the 2,3 prize and about how even minor changes in input representations can cause big jumps in the computational power of a machine. The relevant threads are:Wolfram 2,3 Turing Machine PrizeSmallest universal machineDefinition of universal Turing machineSimple Turing machines, Universality, Encodings, etc. |
_webapps.103793 | I have a registration form that has been successfully submitted for a case in CommCare as well as several other forms that have been submitted against that case. If I archive the registration form will that action affect the other data already submitted and synced against this case? How will archiving this form affect that case's data? | Does archiving a registration form in CommCare affect the the other forms submitted to that case? | commcare | null |
_unix.172285 | Suppose User A and User B have disk quotas of 1 GB. Also suppose User B creates a 900 MB file with permission 0666.This allows User A to access that file temporarily (for some project, etc.).Notice this allows User A to write to the file as well.If User A creates a hard link to that file, and User B then deletes the file, has User A essentially exploited the quota system by stealing 900 MB of storage from User B?Assume User B never reports this to the admin, and the admin never finds out.Also assume User B never suspects a thing about User A. In other words, assume User B will not look at User A's directory and corresponding files.If similar question has been asked/answered before, I apologize for not being able to find them. | Hard Linking Other Users' Files | permissions;hard link | This is one of the ugly corner cases of the Unix permission model. Granting write access to a file permits hard-linking it. If user A has write permission to the directory containing the file, they can move it to a directory where user B has no access. User B then can't access the file anymore, but it still counts against user B for quota purposes.Some older Unix systems had a worse hole: a user could call chown to grant one of their file to another user; if they'd made the file world-writable before, they could keep using that file but the file would count against the other user's quota. This is one reason modern systems reserve chown to root.There is no purely technical solution. It's up to user B to notice that their disk usage (du ~) doesn't match their quota usage and complain to the system administartor, who'll investigate and castigate user A. |
_opensource.4698 | If I contribute code to a project that is under the GPL (or similar), can I still use my code (without any other parts that were contributed by other people) in a closed-source app? If yes, can I also allow others to use my code without publishing the source code? | Do I still own code I donated to GPL project? | gpl;contributor;ownership | It depends. Did you sign a Contributors License Agreement? These agreements usually clarify if the contributor keeps their copyright and just licenses the code to the project or if the contributor transfers copyright. In the first case, the contributor is usually still free to do whatever they like with the code because they still own it (except for revoking the license, of course). In the latter case, the project now owns the copyright and can usually deny the original author to use it. Projects often prefer the latter variant, not because they want to screw their contributors but because it allows them to change the license terms later without having to ask every single contributor to agree.Without a CLA? It appears to me that the general consensus among the open source community seems to be that no license transfer took place and the original author still owns their copyright. Contributors license their work to the open source project under an open source license (inbound = outbound). But should the situation go to court it's kind of a word-against-word situation if a copyright transfer took place or not. I am not a lawyer, so I can't tell how a court would rule under what circumstances in your jurisdiction. It might be important though if you did your work for free (as implied by donated) or received compensation. In the latter case it might get interpreted as work-for-hire which often includes automatic copyright transfer. |
_codereview.46357 | When the app is run on an iPhone or simulator, tapping the screen spawns a dog class and displays an image of the dog.I'd like comments, issues, whatever. Is this a decent first Objective-C project, and can others learn from it?The code is meant to demonstrate Objective-C, Cocoa and UIKit. Here's a link to the full project.Primary files in the project:ProtocolsGKLiving.h//// GKLiving.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>#pragma mark - Defines#pragma mark - The Living protocol of the GK namespace@protocol GKLiving <NSObject>#pragma mark - Mandatory methods#pragma mark - Optional methods@[email protected]//// GKAnimalia.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>#import GKLiving.h#pragma mark - Defines#pragma mark - The Animalia protocol of the GK namespace@protocol GKAnimalia <GKLiving>#pragma mark - Mandatory methods + (NSString *)stringRepresentationOfBreed;#pragma mark - Optional methods@[email protected]//// GKCanidae.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>#pragma mark - Defines#define GKCANIDAE_UNKNOWN_BREED @Mutt#pragma mark - The Canidae protocol of the GK namespace@protocol GKCanidae <GKAnimalia>#pragma mark - Mandatory methods // Note that the + makes this a class-level method (it is // not an instance method). + (NSString *)says;#pragma mark - Optional methods@optional@endDog ClassesGKDog.h//// GKDog.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>// Protocols#import GKAnimalia.h#import GKCanidae.h#pragma mark - Defines#define GKDOG_PRIVATE_THOUGHTS @I love you#define GKDOG_SOUND @Arf#define GKDOG_PLACEHOLDER_PATH \ [[NSBundle mainBundle] pathForResource:@how-to-draw-a-dog-4 ofType:@jpg]#pragma mark - The Dog class of the GK namespace// 1. No namespaces in Objective-C, so class prefixes are used instead.// The NS prefix (for NextStep, I assume) is pretty common.// 2. This class conforms to the GKCanidae protocol.// For a truer take on protocol naming conventions, see this article:// http://stackoverflow.com/questions/7483813/protocol-naming-in-objective-c//@interface GKDog : NSObject <GKCanidae>#pragma mark - Properties with getters/setters @property (strong, nonatomic) NSString *name; @property (strong, nonatomic) NSString *breed; @property (assign, nonatomic) NSInteger age; // A cute picture of the dog @property (strong, nonatomic) NSString *pictureUrlString;#pragma mark - Instance methods - (void)becomeMutt;@endGKYorkshireTerrier.h//// GKYorkshireTerrier.h// SampleApp//#import GKDog.h#pragma mark - Defines#define GKYORKSHIRETERRIER_BREED @Yorkie#define GKYORKSHIRETERRIER_PICTURE_URL @http://www.acuteaday.com/blog/wp-content/uploads/2010/12/yorkie-puppy-091210.jpg#pragma mark - The YorkshireTerrier class of the GK namespace@interface GKYorkshireTerrier : [email protected]//// GKYorkshireTerrier.m// SampleApp//#import GKYorkshireTerrier.h@implementation GKYorkshireTerrier#pragma mark - Class methods from GKAnimalia+ (NSString *)stringRepresentationOfBreed{ return GKYORKSHIRETERRIER_BREED;}#pragma mark - Initializers- (instancetype)init{ self = [super init]; if (self) { self.breed = [GKYorkshireTerrier stringRepresentationOfBreed]; self.pictureUrlString = GKYORKSHIRETERRIER_PICTURE_URL; } return self;}- (instancetype)initWithName:(NSString *)name{ self = [self init]; if (self) { self.name = name; } return self;}- (instancetype)initWithName:(NSString *)name andAge:(NSInteger)age{ self = [self initWithName:name]; if (self) { self.age = age; } return self;}@endMain Dog SpawningGKDogSpawner.h//// GKDogSpawner.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>#pragma mark - Defines#define GKDOGSPAWNER_IMAGE_MIN_X 0.0f#define GKDOGSPAWNER_IMAGE_MAX_X ([UIScreen mainScreen].bounds.size.width - GKDOGSPAWNER_IMAGE_WIDTH)#define GKDOGSPAWNER_IMAGE_MIN_Y 0.0f#define GKDOGSPAWNER_IMAGE_MAX_Y ([UIScreen mainScreen].bounds.size.height - GKDOGSPAWNER_IMAGE_HEIGHT)#define GKDOGSPAWNER_IMAGE_WIDTH 64.0f#define GKDOGSPAWNER_IMAGE_HEIGHT 64.0f#pragma mark - The DogSpawner class of the GK namespace@interface GKDogSpawner : NSObject#pragma mark - Instance methods - (void)spawnDogWithClassNamed:(NSString *)className onView:(UIView *)targetView;@endGKDogSpawner.m//// GKDogSpawner.m// SampleApp//#import GKDogSpawner.h#import GKDog.h#import GKYorkshireTerrier.h#import GKRandomNumber.h// AFNetworking// https://github.com/AFNetworking/AFNetworking#import UIImageView+AFNetworking.h@implementation GKDogSpawner#pragma mark - Instance methods- (void)spawnDogWithClassNamed:(NSString *)className onView:(UIView *)targetView{ // Create a dog instance of the specified class Class dogMetaClass = NSClassFromString(className); GKDog *newDog = [[dogMetaClass alloc] init]; // Just for fun... if ([newDog isKindOfClass:[GKYorkshireTerrier class]]) { NSLog(@Whoa, you spawned a %@! They typically say %@ regularly., [newDog breed], [dogMetaClass says]); } // Create a UIImage from the placeholder's local path UIImage *placeholderImage = [UIImage imageWithContentsOfFile:GKDOG_PLACEHOLDER_PATH]; // Create an NSURL object from the picture's URL string NSURL *pictureUrl = [NSURL URLWithString:[newDog pictureUrlString]]; // -- Create a UIImageView and populate its image from the picture URL. // -- While it's loading, the placeholder will be shown. // -- The -setImageWithURL:placeholderImage: method is from the UIImageView+AFNetworking // category on UIImageView; it provides plugin functionality that is not native to the base // UIImageView class. CGFloat x = [GKRandomNumber floatFrom:GKDOGSPAWNER_IMAGE_MIN_X to:GKDOGSPAWNER_IMAGE_MAX_X]; CGFloat y = [GKRandomNumber floatFrom:GKDOGSPAWNER_IMAGE_MIN_Y to:GKDOGSPAWNER_IMAGE_MAX_Y]; CGRect dogImageFrame = CGRectMake(x, y, GKDOGSPAWNER_IMAGE_WIDTH, GKDOGSPAWNER_IMAGE_HEIGHT); UIImageView *dogImageView = [[UIImageView alloc] initWithFrame:dogImageFrame]; [dogImageView setImageWithURL:pictureUrl placeholderImage:placeholderImage]; // Add the dog image view as a child of the target view. This will make the image visible. [targetView addSubview:dogImageView];}@endGesture RecognizersGKTapHandler.h//// GKTapHandler.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>#pragma mark - Defines#pragma mark - The TapHandler class of the GK namespace@interface GKTapHandler : NSObject <UIGestureRecognizerDelegate>#pragma mark - Instance methods // Use IBAction to link methods to the Storyboard - (IBAction)handleTouch:(id)sender;@endGKTapHandler.m//// GKTapHandler.m// SampleApp//#import GKTapHandler.h#import GKDogSpawner.h#import GKRandomNumber.h@implementation GKTapHandler#pragma mark - Instance variables{ GKDogSpawner *_dogSpawner; NSArray *_dogTypes;}#pragma mark - Initializers- (instancetype)init{ self = [super init]; if (self) { // Initialize the dog spawner self->_dogSpawner = [[GKDogSpawner alloc] init]; // Initialize and populate the dog types. Note the nil guard value. self->_dogTypes = [NSArray arrayWithObjects: @GKLhasaApso, @GKYorkshireTerrier, nil]; } return self;}#pragma mark - Instance methods- (IBAction)handleTouch:(id)sender{ NSUInteger totalDogTypes = self->_dogTypes.count; NSUInteger randomDogTypeIndex = [GKRandomNumber unsignedIntFrom:0 to:totalDogTypes]; NSString *dogType = [self->_dogTypes objectAtIndex:randomDogTypeIndex]; id applicationDelegate = [[UIApplication sharedApplication] delegate]; UIView *targetView = [applicationDelegate window].rootViewController.view; [self->_dogSpawner spawnDogWithClassNamed:dogType onView:targetView];}@endUtility ClassesGKRandomNumber.h//// GKRandomNumber.h// SampleApp//// Cocoa foundation classes#import <Foundation/Foundation.h>#pragma mark - Defines#pragma mark - The RandomNumber class of the GK namespace@interface GKRandomNumber : NSObject#pragma mark - Class methods + (NSUInteger)unsignedIntFrom:(NSUInteger)min to:(NSUInteger)max; + (float)floatFrom:(NSUInteger)min to:(NSUInteger)max;@endGKRandomNumber.m//// GKRandomNumber.m// SampleApp//#import GKRandomNumber.h// Required for arc4random_uniform#include <stdlib.h>@implementation GKRandomNumber#pragma mark - Class methods+ (NSUInteger)unsignedIntFrom:(NSUInteger)min to:(NSUInteger)max{ NSUInteger range = max - min; u_int32_t generatedInteger = arc4random_uniform((u_int32_t)range); NSUInteger result = generatedInteger + min; return result;}+ (float)floatFrom:(NSUInteger)min to:(NSUInteger)max{ return (float)[self unsignedIntFrom:min to:max];}@endView ControllersGKViewController.h//// GKViewController.h// SampleApp//// Main library for the iOS user interface#import <UIKit/UIKit.h>#pragma mark - Defines#pragma mark - The ViewController class of the GK namespace@interface GKViewController : UIViewController // Use IBOutlet to link properties to the Storyboard @property (weak, nonatomic) IBOutlet UITapGestureRecognizer *tapRecognizer;@end | Spawning a Dog class | objective c;ios;cocoa | Because this question is so, so large, I won't get into all the specifics of everything I see. I will point out some things, and provide some examples from one file or another, and as you work through my answer, you should work through your project to find all the other instances of an example I point out.I will start with a simple answer to the topic question:Is this a decent first Objective-C project, and can others learn from it?Simply, yes. I haven't built and compiled and tried running this, but I assume you have. Certainly anyone whose Objective-C knowledge is below that of this project would be able to learn from it. And it's fairly well organized, clean, etc, so I'll pass it as decent as well.But in the first few paragraphs, you talk about wanting for a project to serve as an example of Objective-C standard practice. A perfectly fine want--but let's be clear, this project isn't that.Also, while I did say that someone could learn from this project, I think the audience of people who would take the time to learn from this is fairly narrow. At least in my personal experience as a programmer, I learn best when adding small chunks of knowledge at a time. To me, learning programming is like having a rubber band ball. It's really hard to get that ball started. But once you do, all you have to do to keep it going is snap one more rubber band on here and there.Your project is, in my opinion, a bit too complex for Objective-C and iOS beginners and covers far too much ground. And the project contains some problems that if a more advanced Objective-C user learned as the way to do it, he wouldn't have benefited all that much.So, now that that's out of the way, I'll start at the top, and work my way down.It is likely that this answer my be broken into multiple answers or will receive future edits. Basically, treat this as an answer in progress, as there's quite a few things here I want to address, and I won't be able to address it all in one sitting--you didn't write this whole project in one sitting, did you?First of all, some of the problems that are consistent throughout the entirety of the project:EDIT: As a note here, I'm pointing to sections of your code you've marked off with a #pragma mark. I wanted to come back and edit in some clarity. The #pragma mark themselves are for the most part okay. These are basically just comments with some special features, and using #pragma marks to mark off sections is great. I'm mostly discussing the content in each of these sections.#pragma mark - Namespace ...// 1. No namespaces in Objective-C, so class prefixes are used instead.// The NS prefix (for NextStep, I assume) is pretty common.Correct and correct. NS does stand for NextStep. In iOS development, most of the Foundation classes you'll use are prefixed with NS or UI. You'll run into some other common ones too like CG, AF, etc.But more importantly, you're correct about the fact that there are no namespaces in Objective-C. As such, a project hoping to serve as the standard practice for Objective-C shouldn't have a #pragma mark - Namespace in every single header file in its project. True Objective-C projects should have this no where. Best case scenario, you might see it in an Objective-C++ project.It is perfectly fine for a programmer coming from a non-Objective-C background to do something like this if it helps the organization of the project because he's used to thinking of it in some other way, but it's definitely not standard practice.#pragma mark - DefinesYou've included this line in most of the files. The fact of the matter is, you shouldn't be using #define so often that it's a regularly occurring section in your code. Certainly, you shouldn't be using #define simply for constant values. That's what the const keyword is for. And if you need to declare a constant value in a .h file so it can be seen by multiple files, well, that's what the extern keyword is for.So for example this:#define GKDOGSPAWNER_IMAGE_MIN_X 0.0fShould be replaced with this:extern CGFloat const DKDOGSPAWNER_IMAGE_MIN_X;in the .h, and then define it in the .m of the same file:CGFloat const DKDOGSPAWNER_IMAGE_MIN_X = 0.0f;Applying this thinking to all of your defines eliminates all but 3 of the #defines.The last three could also potentially be eliminated via functions. For example:#define GKDOGSPAWNER_IMAGE_MAX_X ([UIScreen mainScreen].bounds.size.width - GKDOGSPAWNER_IMAGE_WIDTH)could be replaced with:CGFloat GKDOGSPAWNER_IMAGE_MAX_X();in the .h, then define the function in the .m:CGFloat GKDOGSPAWNER_IMAGE_MAX_X() { return ([UIScreen mainScreen].bounds.size.width - GKDOGSPAWNER_IMAGE_WIDTH);}In this case though, the #define doesn't bother me as much. These points on #define aren't really even Objective-C specific. They can apply across all of the C-Based languages that support preprocessor statements (though the syntax may vary slightly from language to language).#pragma mark - Mandatory methods#pragma mark - Optional methodsIt is fine to have these #pragma marks in, particularly in large protocols or just large files. But having these marks does not excuse not marking the methods with code that actually makes methods required or optional.This is something that doesn't really translate unless you're in an IDE, but a #pragma mark and other codes show up in different colors. In my current Xcode theme, all precompiler code (which includes #pragma mark) shows up as brown. Things like @protocol, @required, @optional, and @end show up as pink. So if I were to load up your code in Xcode, a quick glance at your protocols would show me the keyword @required never shows up. It'd be a bit confusing. Now, all methods in a protocol are by default @required (unless marked @optional), but if we're going to talk about standard practice, I am certainly of the opinion that a section of @required methods should be explicitly marked with the @required keyword. It is my personal habit to individually mark every method in a protocol so there is no mistaking the intent of any of the protocol methods. This may be a bit overboard for a standard practice, but I certainly think the @required keyword belongs, for clarity.GKRandomNumber.h / GKRandomNumber.mThere are a few problems I have with this class.First, it's not really a class, is it? No one should ever instantiate an object of this class, and yet they could. There are two fixes. Fix one is to use preprocessor statements to prevent instantiation and subclassing. I don't really like this fix, but it is a possibility. Preventing instantiation looks like this in the .h file:+ (id)alloc __attribute__((unavailable(GKRandomNumber cannot be instantiated)));- (id)init __attribute__((unavailable(GKRandomNumber cannot be instantiated)));But this is a little silly. Especially when the two methods in this class are so simple. We don't need a class because we don't need Objective-C style methods. We can simply use C-style functions:NSUInteger randomUnsignedInt(NSUInteger min, NSUInteger max);My second big problem with these files is that the method names don't say random in them--they should. The name of the file or class isn't enough. Consider NSArray or NSString, for example. Look at all their methods. If you're using an NSArray, you know you're dealing with an NSArray, but Apple says this isn't enough, and as such, all the methods look like this:arrayarrayWithArray:arrayWithContentsOfFile:arrayWithContentsOfURL:arrayWithObject:arrayWithObjects:arrayWithObjects:count:My third big problem with this pair of files is that you have a method for grabbing an integer in a range... but require only unsigned integers. If I want to assure a positive number, I can just assure my minimum number is greater than zero, right? Why are we dealing only with unsigned integers?Fourth, your method has no way of dealing with when the value sent for max is larger than the value sent for min. Given we're dealing with UNSIGNED INTEGERS, this will be a big, big problem. If you try to find a random number between 10 and 5, you won't get 6, 7, 8, or 9. When you find the range (5-10) using unsigned ints, you'll get underflow, and it will wrap around to some number about 5 less than whatever the max for NSUInteger is (which will depend on system). So your range will be almost the entire spectrum of unsigned ints. When you add your min back (10, not 5), you will definitely be outside the range of 5 to 10. The answer to this problem is to do things the way Apple has done. Rather than taking a starting point and an ending point, you take a starting point and a range.Fifth, you're doing a lot of unhelpful and misleading castings. The float version of your random number method doesn't really return a random float... it returns a random NSUInteger cast as a float. And your NSUInteger doesn't really return a random NSUInteger in the given range... it returns a u_int32_t cast as an NSUInteger.u_int32_t is a typedef from C that is a 32-bit integer, no matter the operating system.NSInteger is a typedef from Objective-C. On 32-bit systems it's a 32-bit integer. On 64-bit systems, it's a 64-bit integer.float is a floating point number and not an integer.Again, I'm not super familiar with arc4random_uniform, and using u_int32_t may be a limitation of this function. But if that's the case, then your Objective-C method should reflect this. If you're using a u_int32_t range and getting the result from the random function as a u_int32_t, then the method should take u_int32_t arguments and return a u_int32_t value. If the end user of this method needs to cast it as something else, then let them, but if the internals of the method do all the actual work in some particular data type, you should probably use that data type as the return type and the argument type.And this logic applies to the float version of the method. To me, a method that says it returns a random float is a method that will return more than just an integer cast to a float. If I want a random whole number to use as an argument to some method that expects a floating point number, then I need to use a method to generate a random int and cast it to a float myself or generate a random float and come up with some method for zeroing out the decimals. Either way, I shouldn't be mislead by a method that claims to return a float and only returns integers cast as floats. |
_softwareengineering.134050 | I'm working on a view model for a view that presents a dialog with export options. The user selects options then clicks Export. When the view model completes the Export, the calling view model receives notification.I'm curious which is the better practice for implementing the notification: a traditional event or an Action callback that gets passed in when the dialog is opened.Traditional Eventpublic class ExportDialogViewModel : ViewModelBase{ private readonly ICommand _exportCommand; private readonly ICommand _cancelCommand; public event EventHandler Finished; public ICommand ExportCommand { get { return _exportCommand; } } public ICommand CancelCommand { get { return _cancelCommand; } } public ExportDialogViewModel() { _exportCommand = new RelayCommand(Export); _cancelCommand = new RelayCommand(Cancel); } public void Initialize() { //set the initial conditions } public void Export() { //perform export OnFinished(); } public void Cancel() { OnFinished(); } private void OnFinished() { if (Finished != null) Finished(this, EventArgs.Empty); }}Callbackpublic class ExportDialogViewModel2 : ViewModelBase{ private readonly ICommand _exportCommand; private readonly ICommand _cancelCommand; private Action _callback; public ICommand ExportCommand { get { return _exportCommand; } } public ICommand CancelCommand { get { return _cancelCommand; } } public ExportDialogViewModel2() { _exportCommand = new RelayCommand(Export); _cancelCommand = new RelayCommand(Cancel); } public void Initialize(Action callback) { _callback = callback; //set the initial conditions } public void Export() { //perform export _callback(); } public void Cancel() { _callback(); }}My initial thoughts are that the traditional event is a little more flexible: it allows more than one subscriber to be notified, and it also allows zero subscribers to be notified. The callback, on the other hand, enforces a particular way of interacting with the dialog--the callback must be passed in during initialization. The callback is also simpler to implement and use, though perhaps less familiar than events.Which of the two notification patterns do you recommend and why? | Which notification pattern is preferable? | c#;wpf;mvvm;event programming | null |
_webmaster.53757 | Does Google+ support authorship for brand pages (e.g. not a personal Google+ profile).It is unclear on the context. E.g. here it says you need a recognizable profile photo of a face:https://plus.google.com/authorshipBut on the examples they have ZDNet logo:https://support.google.com/webmasters/answer/1408986?expand=option2What would be the authorship markup for Google+ pages as page urls differ from profile urls? | Google+ and authorship of brand pages | google plus;google plus pages | This subject has a great deal of misinformation surrounding it, partly due to the rather vague documentation by Google.There are very many articles about using Google+ authorship for business, but amazingly none of them have this critical piece of information.After having searched extensively for the answer to this myself for quite some time, and experimenting with the Google Structured Data Testing Tool, I have concluded that you cannot link a Google+ business page to authorship.Most articles that give examples of how to link your Google+ page for business marketing (i.e. not the Google+ business page!) use URL examples that are not business URLs.Of course, this is one of those under-the-bonnet things that could change with no notice or announcement by Google in the near future. |
_cs.33756 | I am looking up the meaning of reduction in complexity theory:On Wikipedia it says: reduction is an algorithm for transforming one problem into another problemOn the Princeton's notes on NP-Completeness, it says: reduction is whereby given all x $\in $ language L1, for instance f(x) $\in$ L2, apply decision algorithm to f(x), then L1 $<=$ L2Can someone make clear how a language (which is just a bunch of numbers) relates to a problem? If they are used interchangeably, can someone show how does I can conceptualize a language as a problem?Thanks | How does language relate to problem in complexity theory? | complexity theory | A (decision) problem is a predicate on strings (that is, a property of strings) that can be either TRUE or FALSE; the problem is to decide whether a string satisfies the predicate (that is, has the property). We represent this predicate as the set of TRUE strings (that is, strings satisfying the property). A language is a set of strings. Thus the denotations of problem and language are the same they are both sets of strings and they can be used interchangeably. But semantically we use problem when our set of strings comes from a predicate, and language in other cases.Here is an example. The NP-complete problem CLIQUE is the set of all pairs $(G,k)$ such that $G$ is a graph that has a $k$-clique. As stated, this is not really a set of strings, but rather a set of pairs $(G,k)$. But when we say the set of all pairs $(G,k)$ we really have some encoding in mind. For example, we can encode a graph $G$ as a list of edges, where the vertices are indexed by numbers, in the format $((i_1,j_1),\ldots,(i_\ell,j_\ell))$. For example, the following is an encoding of a triangle $((1,2),(1,3),(2,3))$. Under this encoding, the language CLIQUE contains the string $(((1,2),(1,3),(2,3)),3)$ but not the string $(((1,2),(1,3),(2,3)),4)$ nor the string $()()($, for example. Another issue that comes up when we talk about strings is: strings over what alphabet. In this case, our strings are over the alphabet $(),0123456789$; but since everything can be encoded in binary, we typically imagine such binary encoding of our strings.CLIQUE is a predicate on pairs $(G,k)$ that holds if $G$ is a graph containing a $k$-clique. It is also a property of pairs $(G,k)$, that of $G$ having a $k$-clique. The corresponding language (which we identify with the CLIQUE problem) consists of all strings encoding (in a fixed way) pairs of graphs $(G,k)$ such that $G$ has a $k$-clique. The corresponding decision problem (which we identify with the language of all accepted instances) is to decide, given a pair $(G,k)$, whether $G$ contains a $k$-clique. |
_unix.229188 | How can I keep long strings from truncating in terminal? For example if I runjournalctl -xnThere's a lot of text that I cannot read. I am open to using other programs/tools. | journalctl: how to prevent text from truncating in terminal | terminal;systemd | From the journalctl manpage: The output is paged through less by default, and long lines are truncated to screen width. The hidden part can be viewed by using the left-arrow and right-arrow keys. Paging can be disabled; see the --no-pager option and the Environment section below.If you don't want to constantly be using the left and right arrow keys, simply pipe it directly to less:$ journalctl -xn | lessThis will wrap lines that are too long for your terminal (the default behavior of less, which journalctl overrides).Or, of course, if you don't mind possibly having to use your terminal's scrollback, you could use no pager at all:$ journalctl -xn --no-pager |
_webapps.89991 | Is there a way to randomly distribute leads using Google Forms?A lead enters their information and it's logged in a Google Sheet. The goal is to randomly distribute the leads to other sheets, ideally from the master sheet.If there isn't a way to allocate directly from the Google Form submission, is there a way to distribute row data from the master sheet to other sheets? | Is there a way randomly distribute Google Form lead submissions | google spreadsheets;google forms | null |
_unix.365020 | I downloaded the Ubuntu from gnome, gnome-ubuntu. I have a laptop and I'm new to Linux. The problem I have is that when connecting a USB mouses it stops working almost immediately. I read that it could be configurations with respect to USB auto-suspend but nothing has worked for me.I have changed the configuration of both laptop-mode and manually entering the devices. I tried changing the probe seconds from 2 seconds to 10. It does not save the Configuration I do not know what else to do,. The version is 16.Edit: Output of dmesg:[ 799.770548] usb 2-1.2: new low-speed USB device number 8 using ehci-pci[ 799.883505] usb 2-1.2: New USB device found, idVendor=15d9, idProduct=0a4c[ 799.883511] usb 2-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0[ 799.883514] usb 2-1.2: Product: USB OPTICAL MOUSE[ 799.886727] input: USB OPTICAL MOUSE as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/0003:15D9:0A4C.0004/input/input16[ 799.947049] hid-generic 0003:15D9:0A4C.0004: input,hidraw0: USB HID v1.11 Mouse [ USB OPTICAL MOUSE] on usb-0000:00:1d.0-1.2/input0[ 800.700267] usb 2-1.2: input irq status -75 received[ 800.708256] usb 2-1.2: input irq status -75 received[ 800.740257] usb 2-1.2: input irq status -75 received[ 800.748257] usb 2-1.2: input irq status -75 received[ 800.772257] usb 2-1.2: input irq status -75 received[ 800.788248] usb 2-1.2: input irq status -75 received[ 800.876258] usb 2-1.2: input irq status -75 received[ 800.916259] usb 2-1.2: input irq status -75 received[ 800.940295] usb 2-1.2: input irq status -75 received[ 800.956267] usb 2-1.2: input irq status -75 received[ 800.988261] usb 2-1.2: input irq status -75 received[ 801.020261] usb 2-1.2: input irq status -75 received[ 801.028260] usb 2-1.2: input irq status -75 received[ 801.068254] usb 2-1.2: input irq status -75 received[ 801.100289] usb 2-1.2: input irq status -75 received[ 801.108253] usb 2-1.2: input irq status -75 received[ 801.116262] usb 2-1.2: input irq status -75 received[ 801.212270] usb 2-1.2: input irq status -75 received[ 801.357815] usb 2-1.2: input irq status -75 received[ 801.524285] usb 2-1.2: input irq status -75 received[ 803.348302] usb 2-1.2: input irq status -75 received[ 803.388292] usb 2-1.2: input irq status -75 received | Mouse goes off after 2 seconds on linux | linux;ubuntu;gnome | null |
_unix.40548 | I have a PHP script running on my LAMP server that requires certain files in order to produce HTML content. The script is publicly accessible (i.e. http://example.com/script.php) but the files required by the script must secured. I could probably place the files in any directory other than /var/www and they would be relatively safe, but I'm trying to learn the Linux filesystem and I'd like to use the most appropriate place (according to FHS). Any help would be great. | Where to securely place files needed by PHP in Linux filesystem (according to FHS) | php;apache httpd;fhs | In /var/www, create a folder public_html and reconfigure that as your root directory for Apache. Files in /var/www can be included, but not accessed directly. |
_unix.195853 | I have a Node.js script that requires ssh-agent to be running 24/7 on my Ubuntu server. I installed keychain and put eval 'keychain --eval id_rsa into my ~/.bash_profile, but that only runs when I ssh into the machine.Is there a way to have the ssh-agent run 24/7 using keychain?EDIT: If there is a way to have the ssh-agent run only at certain times of the day (e.g. 4pm-7pm), that would be better. But 24/7 would be fine too. | Run ssh-agent 24/7 using keychain? | ubuntu;ssh;ssh agent;node.js | null |
_softwareengineering.96399 | Does anybody have suggestions on creating a flowchart representation of a REST-style webinterface? In the interest of supplying thorough documentation to co-developers, I've been toying around in dia modeling the interface for modifying and generating a product resource:This particular system begins to act differently with user authentication/resource counts, so before I make modifications, I'm looking for some clarification:Complexity: how would you simplify the overall structure to make this easier to read?Display Symbol: is this appropriate for representing a page?Manual Operation Symbol: is this appropriate for representing a user action like a button click?Any other suggestions would be greatly appreciated.My apologies for the re-post. The main stackexchange site suggested this question was better presented on programmers. | Documenting a REST interface with a flowchart | documentation;rest;flowchart | I feel Message Sequence Chart/Sequence diagram is better suited for documenting RESTful API interaction. What you have is a state diagram, while RESTful API by definition is stateless. |
_vi.13220 | TLDR: How can I open a file from the list of recent files without going to the end of the list to get to the prompt for file number?In order to open recent files, I do :bro ol and then when I see the file that I want to open, I have to press Space to get to the bottom of the list and to see the prompt for entering the file number. I was wondering if there is a faster way; possibly being able to get the prompt for file number on the first page of recent files, rather than pressing space until I get to the end of the page.bonus question:What does :ol do? Does it just list the recent files and a file cannot be opened from the list? | Opening recent files issue | vimrc;gvim;filesystem;multiple files;file operations | null |
_unix.75683 | I know how to kill the last process with kill $!However I would like to kill the last−1 process, i.e. not the last one, but the one before the last one.I tried kill $$(($! -1))but that didn't work. | How to kill the (last - 1) PID with bash | bash;process;kill | null |
_scicomp.1172 | We have Maui and Torque on our lab's UNIX cluster. Right now, all jobs are served by FIFO. We'd like to implement a more fair policy, but I have not successfully implemented it. The online documentation was not quite clear, and nothing that I've tried to implement has had any effect (I've altered the config file, then restarted Maui). Any suggestions? | Implementing a fair scheduling policy on Maui/Torque | pbs | null |
_webmaster.38020 | I have read the Google page event documentation, but I am not sure I understand it correctly. I am new to Google analytics, and I have two questions:Once I have google analytics enabled for my site (i.e. I have inserted the tracking code in my pages etc), do I need to set anything else up (at the Google end - i.e. in my Google analytics account)It is not clear to me how the event data particularly, relating to how the data can be aggregated and analyzed.For instance, if I want to track an event under category category for click action action, I will use the following code snippet:<a href=some-uri.htm onclick=_gaq.push(['_trackEvent', 'category', 'action', 'label']);>Do Something</a>For the sake of simplicity, lets say I am interested in monitoring click events in my header and footer, and I want to find which pages the header and or footer is clicked most often.How would I set things up so that I can analyze the header/footer clicks aggregated at the page level? | Google page events monitoring and analysis | google analytics | null |
_webapps.109108 | When others try to send mail to me the message comes:The address rpmroaddurgotsavcommittee in the To field was not recognized. Please make sure that all addresses are properly formed. | When others try to send mail to me they can't | gmail | null |
_unix.178294 | In most POSIX compliant shell like bash. ksh, dash, mksh, pdksh, when variable assignment occur, field splitting and filename expansion (and brace expansion if the shell supports) are not performed in RHS of assignment:$ IFS=/$ a=1/2# Field splitting and filename expansion turned off here$ b=$a$ IFS=$ printf '%s\n' $b1/2Some shell's documentation (bash, ksh) mentioned about this, but POSIX documentation didn't.I can see this behavior in most POSIX compliant shell, so I wonder is it portable since when POSIX documentation does not specify it? | Is field splitting and filename expansion turn off in RHS of variable assignment portable? | shell;posix | Depends on where you look at. From Chapter 2, Section 9.1:Each variable assignment shall be expanded for tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal prior to assigning the value.I would assume that this list is exhaustive, and since field splitting is not mentioned, the lack of field splitting is POSIX-specified. |
_cs.57678 | I'm trying to prove that $BPP^{BPP}=BPP$.$BPP\subseteq BPP^{BPP}$ is obvious. I'm struggling with $BPP^{BPP}\subseteq BPP$..Can anyone help? | Proving that $BPP^{BPP}=BPP$ | complexity theory;probabilistic algorithms;oracle machines | null |
_webmaster.86574 | I'm trying to structure my site to serve different areas of content, sort of like this one. I'm wondering how they make it so subdirectories have their own default pages, for example:http://webmasters.stackexchange.com/questions/ask (the URL of the ask page).It looks like a default page to me since it doesn't end in a file extension, but I don't know how that works. I'm running on an IIS server hosted on GoDaddy and I'm using the ASP.NET Web Pages (SPA) model if that makes a difference.And if they're not default pages, why do they appear without file extensions? | Can the subdirectories on a server have their own default pages? | web development;website design;subdirectory | null |
_webapps.49299 | I was just searching my Google Drive account for a document containing the word 'internet' and the top hit was a screenshot i took of instructions of how to configure the DNS settings to use for a proxy VPN service - which is littered with the word 'internet'The file is named Screen Shot 2013-06-23 at 21.29.53.png and its a png so there is no static text in there (although it is a screen shot if text).Does Google Drive OCR images to check for the text inside of them to make them available in search, or is this just a lucky coincidence ? | Does Google Drive OCR images for the search internal function in Google Drive? | google drive;ocr | null |
_unix.204614 | I want to exclude the file ./test/main.cpp from my search.Here's what I'm seeing:$ grep -r pattern --exclude=./test/main.cpp./test/main.cpp:pattern./lib/main.cpp:pattern./src/main.cpp:patternI know it is possible to get the output that I want by using multiple commands in a pipes-and-filters arrangement, but is there some quoting/escaping that will make grep understand what I want natively? | Run `grep` excluding a file in a specific path | command line;grep | grep can't do this for file in one certain directory if you have more files with the same name in different directories, use find instead:find . -type f \! -path './test/main.cpp' -exec grep pattern {} \+ |
_webmaster.81611 | Can you use Google Keyword Tool to find out key words that get searched?I have looked into Google AdWord and Keyword Tool. All I could find was a way to pay a certain amount everyday for my website to be found easier when people googled certain keywords.I simply want to see how often certain words are searched and in what areas. | Can you use Google Keyword Tool to find out key words that get searched? | search | null |
_cs.71192 | What are the problems that are in co-NP but not in NP?i.e, those problems where incorrect strings can be deterministically verified in polynomial time but the correct strings can't be. | co-NP but not NP problems | p vs np;co np | co-NP is the set of complements of problems that are in NP. So co-NP contains problems such as non-3-colourability, Boolean unsatisfiability and so on.Most complexity theorists believe that NP$\,\neq\,$co-NP and one consequence of this is that the complement of any NP-complete problem would be in co-NP but not in NP.Wikipedia has more information on co-NP. |
_codereview.79330 | I'm visiting some code that I wrote for one of my finals projects and wanted to know whether there were a more optimal, more elegant way to do this so it does not look so hard-coded.The problem was that I needed to calculate the Determinant of a matrix, and, at the time (some of it was rushed) I did not know of a better way, using loops or re-usable code that could make the code a little better. Here is the code:namespace Determinant { template<int X> float determinant(std::vector<Vector> &data) { float deter = 0.0; if(X == 2) { float a = data[0][0]; float b = data[1][0]; float c = data[1][1]; deter = (a + c) * (a + c) -4 * (a*c-b*b); }else if(X == 3) { float determinant1 = (data[1][1] * data[2][2]) - (data[2][1] * data[1][2]); float determinant2 = (data[1][0] * data[2][2]) - (data[2][0] * data[1][2]); float determinant3 = (data[1][0] * data[2][1]) - (data[2][0] * data[1][1]); deter = (data[0][0] * determinant1) - (data[0][1] * determinant2) + (data[0][2] * determinant3); } return deter; }}As you can see the Determinant is very hard-coded which is probably not the right way -- But are there any other alternatives that isn't hard-coded? I want to start to use a design pattern, as I feel one would be useful here but can't seem to figure out which one. | Determinant of a matrix | c++;matrix;library | You don't really need a design pattern for determinants, just a better algorithm. Generally one of the easiest (and fastest) ways of calculating a matrix determinant is by using what is known as LU-Decomposition. This factors a matrix into two matrices, a lower triangular and an upper triangular matrix. From these, the determinant can simply be calculated as the product of diagonal elements.Note that you have to be careful when calculating determinants of large matrices; for a 100x100 matrix, it can easily overflow the maximum size of a float (or double). For this reason it's often better to calculate a log-determinant.On to the actual code you've presented:data should be passed by const& since it isn't (and shouldn't be) modified:float determinant(const std::vector<Vector>& data)Using a template int parameter to choose between determinant sizes is really odd, and is potentially easily misused. What if I use Determinant::determinant<2>(...) on a 3x3 matrix? It'll give me the wrong answer. You should generally try to make your code easy to use and hard to misuse. In this case, that means calculating the determinant size based on the row/column size of the passed parameter. Better yet would be creating a matrix class to encapsulate all of this information.These days, it generally doesn't make a lot of sense to use float over double unless you really need the speed (and even then, it is often no faster, and can sometimes even be slower on modern hardware). Stick to using double by default. |
_unix.274234 | I have two Linux work stations:Workstation A at homeWorkstation B at workThe workstations are linked to the internet and they don't belong to the same network.How can I sync a folder Test between Workstation A and B, Although, they don't belong to the same network:I tried:rsync -avu -e ssh /Test/ [email protected]:/Path/to/Test This command keep output an error message No route to hostHow can I solve this problem? | Syncing two folders between two Linux workstations (Two different networks) | command line | null |
_cs.1371 | I'm really struggling with this property:Let $X,Y$ be coherence spaces and $f: Cl(X) \rightarrow Cl(Y)$ be a monotone function. $f$ is continuous if and only if $f(\bigcup_{x\in D} x)=\bigcup_{x \in D}f(x)$, for all $D \subseteq Cl(X)$ such that $D$ is a directed set.Directed set is defined thus: $D \subseteq $ POSET$ $ is a directed set iff $ \forall x, x' \in D$ $ \exists z \in D $ such $ x \subseteq z$ and $x' \subseteq z$. $Cl(X) $stands for cliques of X: $\{x \subseteq |X| \mid a,b \in x \Rightarrow a$ coherent $b \}$.Many books give that as a definition of Scott-continuous functions, but unluckly not my teacher. He gave us this definition of continuous:$f : Cl(X) \rightarrow Cl(Y)$ is continuous iff it is monotone and $\forall x \in Cl(X), \forall b \in f(x), \exists x_0 \subseteq_{fin} x, b \in f(x_0)$, where monotone is defined as: $f$ is monotone iff $a \subseteq b \Rightarrow f(a) \subseteq f(b)$This is the proposed proof I have, but I can't understand the last equation.Proof of $f$ continuous implies $f(\bigcup D)=\bigcup f(D)$:Let $b \in f(\bigcup D)$. By the definition of continuity, $\exists x_0 \subset_{fin} x \mid b \in f(x_0)$. Note that $x_0$ is the union of $\{ x_i \mid x_i \in D\}$.If $D$ is direct then: $\exists z \in D \mid x_i \subseteq z$ then $x_0 \subseteq z$. By the definition of monotony, $f(x_0)\subseteq f(z)$ so $b \in f(z)$ (???) $\subseteq \bigcup f(D)$. And even that is true we should show that $\bigcup f(D) = f(\bigcup D)$, not just $\subseteq$.The proof of the other implication is even worse so I can't write it here... Can you explain to me how the proof can work? | Scott-continuous functions: an alternative definition | terminology;programming languages;semantics | null |
_webmaster.60940 | My company has build a webshop (for jewels and watches in case that matters). We got contacted by another site, a shop-in-shop.The shop-in-shop site does the following: Collects feeds from different shops and present those products (1) You can browse those products per category, similar products sorted together When you click a product, you get a 'preview', a fancybox-like div with img and a price (2) When you click buy they redirect the user to the productpage of the webshop offering it(1) I don't know how they decide to show which product if multiple shops offer the save, asume all shops provide unique products(2) It's not an iframe, so it's not a subpage or something (in case of duplicate content)I'm worried this might backfire, but a.t.m. I can't really think of something that will effect negatively, and the increase in backlinks and pagevisits is positive. | Will another site (a shop in shop) that shows our inventory then directs users to us to complete the purchase hurt our SEO? | seo;webshop | null |
_unix.283899 | The file command (Debian Jessie) in does not recognize some Perl modules.For example: /usr/share/perl5/XML/SAX.pm (from libxml-sax-perl) gives:$ file /usr/share/perl5/XML/SAX.pm/usr/share/perl5/XML/SAX.pm: C++ source, ASCII textThe module starts with:# $Id$package XML::SAX;use strict;use vars qw($VERSION @ISA @EXPORT_OK);When I remove the first two line, file sees it as a Perl module:$ file tttt: Perl5 module source, ASCII textStill, other modules starting with comment, such as /usr/lib/i386-linux-gnu/perl/5.20.2/Encode.pm are correctly identified.Is this a bug?And where do I find the uncompiled mime data for /usr/share/file/magic.mgc? | file command does not recognize perl module | file command | null |
_unix.288821 | I just got a new laptop with a killer wireless-ac 1535. After installing linux mint 17.3 I cannot use the wifi.I found some information about this here:athk10 linux mint killer wireless ac 1535 installationand here:http://www.killernetworking.com/support/knowledge-base/17-linuxHowever I am having trouble getting the backports to build, I get the following error:make[5]: `conf' is up to date.boolean symbol HWMON tested for 'm'? test forced to 'n'boolean symbol HWMON tested for 'm'? test forced to 'n'## configuration written to .config#Building backport-include/backport/autoconf.h ... done. CC [M] /home/moagstar/Desktop/backports-4.3-1/compat/main.o CC [M] /home/moagstar/Desktop/backports-4.3-1/compat/backport-3.14.o CC [M] /home/moagstar/Desktop/backports-4.3-1/compat/backport-3.15.o CC [M] /home/moagstar/Desktop/backports-4.3-1/compat/backport-3.17.o CC [M] /home/moagstar/Desktop/backports-4.3-1/compat/backport-3.18.oIn file included from include/linux/if_vlan.h:15:0, from /home/moagstar/Desktop/backports-4.3-1/backport-include/linux/if_vlan.h:3, from /home/moagstar/Desktop/backports-4.3-1/compat/backport-3.18.c:11:/home/moagstar/Desktop/backports-4.3-1/backport-include/linux/netdevice.h:85:8: error: redefinition of struct pcpu_sw_netstats struct pcpu_sw_netstats { ^In file included from /home/moagstar/Desktop/backports-4.3-1/backport-include/linux/netdevice.h:3:0, from include/linux/if_vlan.h:15, from /home/moagstar/Desktop/backports-4.3-1/backport-include/linux/if_vlan.h:3, from /home/moagstar/Desktop/backports-4.3-1/compat/backport-3.18.c:11:include/linux/netdevice.h:1706:8: note: originally defined here struct pcpu_sw_netstats { ^make[6]: *** [/home/moagstar/Desktop/backports-4.3-1/compat/backport-3.18.o] Error 1make[5]: *** [/home/moagstar/Desktop/backports-4.3-1/compat] Error 2make[4]: *** [_module_/home/moagstar/Desktop/backports-4.3-1] Error 2make[3]: *** [modules] Error 2make[2]: *** [modules] Error 2make[1]: *** [modules] Error 2make: *** [default] Error 2Does anyone have any clue why this error might be occuring? | backports error while trying to get killer wireless-ac 1535 working in linux mint 17.3 | backports | null |
_webapps.93405 | Say for instance I want the user to input into 4 fields the meters they will dig up in different areas. On the form itself I would like to have a number at the bottom displaying the sum of 3 of said fields.Is this possible? If it is, how do I go about getting it done? | How do I add a field in Google Forms to show the sum of multiple fields (that are numbers) | google spreadsheets;google forms | Google Forms doesn't include calculated fields. One alternative is to create a web app by using Google Apps Scripts. |
_cstheory.5680 | The post is related to:https://mathoverflow.net/questions/59631/lovasz-theta-function-and-independence-number-of-product-of-simple-odd-cyclesHow far away is the Lovasz bound from the zero-error capacity of regular graphs? Are there any examples where the Lovasz bound is known to be not equal to the zero-error capacity of a regular graph? (This was answered below by Oleksandr Bondarenko.)In particular is any strict inequality known for odd cycles of sides greater than or equal to $7$?UpdateWhat improvement is needed in spectral theory to improve the Lovasz theta function so that the gap between Shannon capacity and Lovasz Theta for the cases for which a gap exists could be lowered? (Note I am concerned only from spectral perspective) | Lovasz theta function and regular graphs (odd cycles in particular) - connections to spectral theory | graph theory;it.information theory | null |
_cs.2989 | Consider the context free grammar:$\qquad \begin{align} \mathrm{bill} &\to \mathrm{items}\ \mathrm{total}\ \mathrm{vat} \\ \mathrm{items} &\to \mathrm{item} \mid \mathrm{item}\ \mathrm{items} \\ \mathrm{item} &\to name\ \mathrm{price} \mid name\ \mathrm{quantity}\ \mathrm{price} \\ \mathrm{quantity} &\to integer \\ \mathrm{price} &\to integer \\ \mathrm{total} &\to integer \mid TOTAL\ \mathrm{price} \\ \mathrm{vat} &\to VAT\ \mathrm{price} \end{align}$How do I factor the grammar?This was asked in a past exam, and I don't know how to get started.Also, if you have any links that could help me understand this more it would be much appreciated! | Factor a grammar | formal languages;formal grammars;context free | null |
_webmaster.90809 | I have a typical Wordpress site, with a typical Search page set up which uses the typical GET format <form id=searchform action=http://example.com method=get> <input id=s type=text name=s placeholder=Search Again> </form>For users' convenience, I'd like to have the following url redirect to the search page:http://example.com/search?search-termRedirect to:http://example.com/search/search-termHow do I do this? I need this to work even if the user enters no search parameter. In other words, if the user enters:http://example.com/search/...the displayed URL should remainhttp://example.com/search/Not the typicalhttp://example.com/?s=...even though the page is still redirecting to the Wordpress search template.Hope that made sense.UPDATE: The closest I've been able to get is this:<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # redirect /search/param to /?s=param RewriteCond %{QUERY_STRING} (.*) RewriteRule ^search/?$ /?s=%1 [R=302,L] #standard wordpress stuff RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]</IfModule> | How do I redirect /search/ to /?s= | htaccess;redirects;mod rewrite | In order to match against the query string (everything after the first ?) you need to use a RewriteCond directive and check against the QUERY_STRING server variable. The RewriteRule pattern only matches against the URL-path.So, try something like the following in .htaccess, before any WordPress rewrites:RewriteCond %{QUERY_STRING} (.*)RewriteRule ^search/?$ /?s=%1 [R=302,L]If the user requests /search?[something] then they are redirected. Where [something] is entirely optional.This is a temporary (302) redirect, change to a permanent (301) when you are sure it's working OK.UPDATE: Instead of using the query string to pass the search term (ie. /search?search-term, use the URL-path instead (ie. /search/search-term). And keep the original URL in the browser (ie. don't externally redirect to /?s=) then try something like the following instead:RewriteRule ^search(/(.*))? index.php?s=$2 [L](This replaces both the directives above.)This allows you to specify either /search, /search/ or /search/search-term and the URL stays in the browsers address bar. |
_cs.32244 | Given the following (arbitrary language, although I think it is close to Algol 60) program:program main; // A main parent level var i : integer; // A 'global' variable (* Note that all parameters are passed by value here *) function f1 (j : integer) : integer; // A Child function begin { f1 } i := i + 3; f1 := 2 * j - i; end; { f1 } function f2 (k : integer) : integer; // Another Child function, same level as f1 var i : integer; // Here, there is a variable that is declared begin { f2 } // but no value assigned i := k / 2; f2 := f1(i) + f1(k); end; { f2 }begin { main } // Running/Calling/Executing the code i := 8; i := i + f2(i); writeln(i);end. { main }How would you trace the values of variables throughout the program when it is interpreted using Dynamic scoping of free variables, when the arguments appearing in expressions are evaluated left to right, and when they are evaluated right to left, so that the user can watch what happensI have created a JS plnkr for Static Scoping with Left to Right evaluation and another for Static Scoping with Right to Left evaluation.Feel free to adapt these answers (if possible) for Dynamic Scoping, with L->R and R->L evaluation.I chose plnkrs because I knew I could get the Static/lexical side using JS, but am unsure of how to make it happen dynamically or in another interactive environment (preferably not one I have to install).I learn a bit slower on some problems like this where the values are asked of the output, but don't show the value states throughout the program, and trying to get a better understanding, especially in an example I can play around with interactively, as the book examples are really bad. In the code above, it also gets challenging, because it appears that the variable i in line 2 is allocated, but would be undefined. But that may be my imperative/functional brain making it more complicated than it is... | Interactive example of Dynamic scoping and evaluation order of expressions | programming languages;programming paradigms;variable binding | null |
_codereview.86093 | The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following:Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.My answer is this: import Data.List(sort) sumSquareLargest :: (Ord n, Floating n) => n -> n -> n -> n sumSquareLargest x y z = b ** 2 + c ** 2 where [a, b, c] = sort[x, y, z]Am I doing unnecessary work here? How could I improve this answer, even if only stylistically-speaking? | SICP Exercise 1.3: Sum of squares of two largest numbers out of three, Haskell Version | haskell;homework;sicp | If you don't need a value, don't bind it, use a wildcard instead.[a, b, c] = sort [x, y, z] # and btw, add a space after the function namebecomes[_, b, c] = sort [x, y, z]Perhaps its just personal preference (I don't use much Haskell myself), but I usually see the where clause in the next line, with an extra tab, like:sumSquareLargest x y z = b ** 2 + c ** 2 where [_, b, c] = sort [x, y, z]Moreover, the b and c values are not obvious at first glance, and you need to read the second line before the first. In these cases, a let expression can be a more nice alternative:sumSquareLargest x y z = let [_, b, c] = sort [x, y, z] in b ** 2 + c ** 2This is a very small function, but consider having more meaningful names for your bindings:sumSquareLargest x y z = let [_, medium, maxim] = sort [x, y, z] in medium ** 2 + maxim ** 2Also, consider writing some unit tests in a library like QuickCheck. |
_unix.119381 | I am an absolute newbie to the *ix ,so if my question is dumb please bear with me.I am writing a script where I am trying to export some variable , and after exporting my variable when I am printing, it is printing an extra line after it.Here I am reading from a csv file containing two columns.This script is present in file script.sh and I am executing that file ./script.sh#!/bin/bashwhile IFS=, read f1 f2do echo Source IP : $f1 #it is printing without extra line echo Destination IP : $f2 #it is printing without extra line export sourceIP=$f1 export destIP=$f2 ssh -t -t sjain@$f1 <<ENDSSH #Start copying 33KB File echo Destination IP Address: $destIP # here it is printing an extra line after destIP startTime=$(($(date '+%s%N')/1000000)) scp KB_33.txt sjain@$destIP:/home/sjain endTime=$(($(date '+%s%N')/1000000)) printf 'Elapsed time in copying 33KB file: %s\n' $((endTime-startTime)) #Write the stats to the file echo $sourceIP','$destIP',33KB,'$((endTime-startTime)) >> report.txt exit ENDSSHdone < ipaddress.csvbecause of the above problem when I am executing scp KB_33.txt sjain@$destIP:/home/sjainit is breaking the command into 2 parts , like thisscp KB_33.txt sjain@$X.X.X.X:/home/sjainAnd when I am directly hardcoding the value instead of destIP , it is working fine.How can I fix this?Input CSV file Data10.0.0.1,10.0.0.2 | Remove extra line break from a variable | linux;command | When you split the contents of your CSV file you're splitting on commas, ,. This can be problematic because the second IP address in that file likely has a trailing newline character after it.The easiest method to resolve this would be to simply chomp that character off the end of the $destIP variable like so:export sourceIP=$f1export destIP=$(echo $f2 | tr -d '\n') |
_cs.75594 | I want to know the difference between Bandwidth and propagation speed. How are they associated with each other i.e. the impact on bandwidth if propagation speed varies or the impact on speed if bandwidth varies. I have gone through this difference between propagation speed and bandwidth in digital communication still I am unable to understand it very clearly. Could it be possible to explain with some other example like may be with water pipes etc. | Difference between Bandwidth and Propagation Speed in computer networks? | computer networks | null |
_webapps.104687 | I'm trying to use Trello for support system administration.I have a software company and I want to load my tasks in Trello, but I need a simple option that lets me select from what customer an issue originates. This is so in the future I can filter issues by customer and see the history.Is there a way to do this in Trello? | Can I indicate from which customer a Trello task is for? | trello | null |
_unix.330673 | Let say user choose 5 (antall).I want then to print 5+6+7+8+4 (for instans).In my script i get this print:5+6+7+8+4**+**How to get rid of the last +??(I have tried echo + in a for loop, but havent manage to get i right)My script:plusse () {while true; dorandom=0summit=0read -p Hvor mange tall vil du plusse>> antallecho Hva er? for (( i=1; i<=$antall; i++ )); dorandom=$(( RANDOM % 10 ))summit=$(( summit + $random ))echo -n $random echo -n +doneechoread -p Svaret mitt er>> svarrecho $summit if [[ $svarr == $summit ]]; then echo Gratulerer! $svarr er riktig svar! read -p Vil du fortsette?>> fortsette case $fortsette in ja|j|JA|Ja|y|Yes) continue ;; nei|n|Nei|n|N) break 1 ;; *) exit 1 ;; esac else echo Beklager, $svarr er feil. Riktig svar er $summit read -p Vil du fortsette?>> fortsette case $fortsette in ja|j|JA|Ja|y|Yes) continue ;; nei|n|Nei|n|N) break 1 ;; *) exit 1 ;; esac fidone} | Different number of strings (for loops | bash;shell script | null |
_scicomp.25204 | I've the following Matlab code:r = symrcm(A(2:end, 2:end)); prcm = [1 r + 1]; spy(A(prcm, prcm));where A should be sparse connectivity matrix.I understood what it does:Finds a permutation vector r of the submatrix of A A(2:end, 2:end) (produced by the reverse Cuthill-McKee algorithm)Creates a vector prcm which is basically a vector with a $1$ in the first position and all other elements of r increased by $1$. This prcm vector applied to A as A(prcm, prcm) logically means that we're going to permutate all rows and columns of A according to the reverse Cuthill-McKee algorithm except the first row and the first column. So the resulting matrix would look something like this:Ignore the specific numbers that you see in the plot.QuestionWhy would one want such a permutation of the rows and columns of a matrix?From what I've been reading and I've observed applying, for example, the guassian elimination to this matrix would produce a disastrous fill-in after trying to remove all entries of the first row (Check chapter 5.7 from A first course in numerical methods by Ascher and Greif). So, who wrote this code definitely didn't want to find a permutation of $A$ to apply the guassian elimination... | Find a permutation matrix (using the Matlab's function $symrcm$) of a matrix $A(2:end, 2:end)$ | matlab;sparse;vector;banded matrix | null |
_datascience.18695 | I am trying to understand the training phase of the tutorial Using Keras and Deep Deterministic Policy Gradient to play TORCS (mirror, code) by Ben Lau published on October 11, 2016.The tutorial says:Then the actor policy is updated using the sampled policy gradient: $$\nabla_\theta J = \frac{\partial Q^{\theta}(s,a)}{\partial a}\frac{\partial \mu(s|\theta)}{\partial \theta}$$which in the code corresponds to: actor.train(states, grads).In the actor.train() method, I fail to see where $\frac{\partial Q^{\theta}(s,a)}{\partial a}$ gets multiplied by $\frac{\partial \mu(s|\theta)}{\partial \theta}$.I did read:self.params_grad = tf.gradients(self.model.output, self.weights, -self.action_gradient)where self.action_gradient corresponds to $\frac{\partial Q^{\theta}(s,a)}{\partial a}$, and tf.gradients(self.model.output, self.weights) corresponds to $\frac{\partial \mu(s|\theta)}{\partial \theta}$, but I see no multiplication.Where does $\frac{\partial Q^{\theta}(s,a)}{\partial a}$ get multiplied by $\frac{\partial \mu(s|\theta)}{\partial \theta}$? | Understanding the training phase of the tutorial Using Keras and Deep Deterministic Policy Gradient to play TORCS tutorial | neural network;deep learning;tensorflow;reinforcement learning;training | null |
_cs.73815 | I need to prove that $n^2$ is not $o(n^2+10^{10}n)$. I thought of the limit test: $$\lim_{n \to \infty} \frac{n^2}{n^2+10^{10}n} = 1 \Rightarrow n^2 = \Theta(n^2+10^{10}n)$$However I'm not sure if the result of the test rules out the possibility of $o(n^2+10^{10}n)$. | How to prove that $n^2$ is not $o(n^2+10^{10}n)$? | asymptotics;landau notation | One definition $f(n)=o(g(n))$ is that $\lim_{n\to\infty} f(n)/g(n)=0$. If this is the definition you're using, then showing that the limit is $1$ already shows that $f(n)\neq o(g(n))$.The other definition is that, for every $c>0$, there is an $n_0$ such that $f(n)\leq cg(n)$ for all $n\geq n_0$. The fact that $\lim_{n\to\infty} f(n)/g(n)=1$ means that, for all $\varepsilon>0$, there is some $n_0$ such that $f(n)/g(n)>1-\varepsilon$ for all $n\geq n_0$ (this is part of the definition of limit). So, for all $\varepsilon>0$, we have $f(n)>(1-\varepsilon)g(n)$ for all large enough $n$. This means that, in particular, we do not have $f(n)\leq cg(n)$ for $c=1-\epsilon$, so $f(n)\neq o(g(n))$ by the alternative definition. |
_softwareengineering.102689 | One of the things I struggle with is not using Hungarian notation. I don't want to have to go to the variable definition just to see what type it is. When a project gets extensive, it's nice to be able to look at a variable prefixed by 'bool' and know that it's looking for true/false instead of a 0/1 value.I also do a lot of work in SQL Server. I prefix my stored procedures with 'sp' and my tables with 'tbl', not to mention all of my variables in the database respectively.I see everywhere that nobody really wants to use Hungarian notation, to the point where they avoid it. My question is, what is the benefit of not using Hungarian notation, and why does the majority of developers avoid it like the plague? | What is the benefit of not using Hungarian notation? | coding style;coding standards;naming | Because its orginal intention (see http://www.joelonsoftware.com/articles/Wrong.html and http://fplanque.net/Blog/devblog/2005/05/11/hungarian_notation_on_steroids) has been misunderstood and it has been (ab)used to help people remember what type a variable is when the language they use is not statically typed. In any statically typed language you do not need the added ballast of prefixes to tell you what type a variable is. In many untyped script languages it can help, but it has often been abused to the point of becoming totally unwieldy. Unfortunately, instead of going back to the original intent of Hungarian notation, people have just made it into one of those evil things you should avoid.Hungarian notation in short was intended to prefix variables with some semantics. For example if you have screen coordinates (left, top, right, bottom), you would prefix variables with absolute screen positions with abs and variables with positions relative to a window with rel. That way it would be obvious to any reader when you passed a relative coordinate to a method requiring absolute positions.update (in response to comment by delnan)IMHO the abused version is avoided like the plague becauseit complicates naming. When (ab)using Hungarian notation there will always be discussions on how specific the prefixes need to be. For example: listboxXYZ or MyParticularFlavourListBoxXYZ.it makes variable names longer without aiding the understanding of what the variable is for.it sort of defeats the object of the exercise when in order to avoid long prefixes these get shortened to abbreviations and you need a dictionary to know what each abbreviation means. Is a ui an unsigned integer? an unreferenced counted interface? something to do with user interfaces? And those things can get long. I have seen prefixes of more than 15 seemingly random characters that are supposed to convey the exact type of the var but really only mystify.it gets out of date fast. When you change the type of a variable people invariably ( lol ) forget to update the prefix to reflect the change, or deliberately don't update it because that would trigger code changes everywhere the var is used...it complicates talking about code because as @g . said: Variable names with Hungarian notation are typically difficult-to-pronounce alphabet soup. This inhibits readability and discussing code, because you can't 'say' any of the names.... plenty more that I can't recall at the moment. Maybe because I have had the pleasure of not having to deal with the abused Hungarian notation for a long while... |
_unix.185 | I run a software raid array for my backups, but my data has outgrown capacity. considering I have a full 2.4TB array with 5*600GB drives and also have 5*2TB drives I would like to swap in.What would be the nicest way to upgrade the array?I thought of faulting 1 drive at a time and swapping in a new drive and rebuilding, but I am not sure if at the end of the process I will be able to resize the arrayThoughts? | In place upgrade of a software raid 5 array | linux;raid;software raid | Assuming this is linux, this is doable and pretty easy actually. It is covered on the software raid wiki but the basic steps are:Fail and remove drive.Replace with a larger drive.Partition the drive so the partitions are the same size or larger than the ones in the existing software raid partition.Add the partitions to software RAID and wait for it to sync.Repeat above steps until all drives have been replaced.mdadm --grow /dev/mdX --size=max to resize the mdadm device.resize2fs /dev/mdX to resize the file system assuming you have ext3.You can grow the mdadm device and the file system while the server is live too. If your drives are hot swappable you can do everything without downtime. |
_cs.23953 | I'm trying to reduce an optimization problem to a decision problem, more specifically, consider the Max-Cut problem in its decision version:Given $(G=(V,E),k)$ as input, where $G$ is an undirected weighted graph (all weights are positive integers, formally: $w: E\rightarrow \mathbb{N}$ is the weight function) and $k\in\mathbb{N}$, one should decide whether there exist a cut $(V_1,V_2)$, s.t its weight is at least $k$, meaning $k\leq \sum _{u\in V_1, v\in V_2}w(u,v)$.The optimization version is simply finding the maximum weighted cut.What I'm trying to achieve is, given an algorithm $A$ that can solve the decision problem, I want to describe an algorithm that can find the maximum cut in $G$.So, first of all, this is what I had in mind: Find the weight of the maximum cut in $G$ (this can be done with a simple for loop that starts with 1 and stops at $m$, where $m=\sum _{e\in E}w(e)$ while in each iteration the algorithm queries $A$), define $k$ to be the weight of the maximum cut.Initialize new set $S\leftarrow \phi$For $e\in E$ do:Omit edge $e=(u,v)$ from $G$, to create new graph $G_e$.If $A(G_e,k)=0$ (both ends of $e$ are at the same set), $S\leftarrow S\cup \left \{ u,v \right \}$else if $A(G_e,k)=1$ then...(?)This is where I'm stuck, I'm not sure how can I tell which end of $e$ should be in $S$...In fact, I'm not even sure if this is the right way to do it.Any help and thoughts will be appreciated. | Reducing optimization problem to decision problem | reductions | Given the formulation of your decision problem, first of all notice that you can do binary search to find the max-cut weight $k$, rather than linear search. Secondly, when you test each edge, you get that either the two end points are in the same set, or the two end points are in different sets. Let $S$ be a set on one side of the cut, and let $x_u,x_v$ be boolean indicator variables for whether $u,v$ are in $S$. Then if edge $(u,v)$ crosses the cut, you want $(x_u,x_v) = (1,0)$ or $(0,1)$, and otherwise you want $(x_u,x_v) = (0, 0)$ or $(1,1)$. You can formulate this as a 2-sat problem and solve it in linear time (linear in the number of edges) to determine membership in set $S$. For example, if $(x_u,x_v) = (0, 0)$ or $(1,1)$ then you would add the two clauses $(x_u \vee \neg x_v) \wedge (\neg x_u \vee x_v)$ to your 2-sat formula. |
_cs.77528 | how can i prove the following statement :1- $L_1\subseteq\Sigma^*$ is CFL and $L_2\subseteq\Sigma^*$ is regular Language, then $L_1$\ $L_2$ is CFL .so i want to know what is the method to prove it ?I'm not sure, but can i use a PDA and DFA or something else ?so i tried the following :$L_2$ is regular and thus is $\overline{\rm L_2}$ also regular.$L_1 \cap \overline{\rm L_2}$ is CFL $\iff$ $L_1 \cap \overline{\rm L_2}$ is recognized by a PDA.$M1=(Z_1,\Sigma,\Gamma,\delta_1,z_{01},$#$,E_1)$ is a PDA for $L_1$$M_2=(Z_1,\Sigma,\delta_2,z_{02},E_2)$ is a DFA for $\overline{\rm L_2}$$M^{'}$=($Z_1$x$Z_2$,$\Sigma,\Gamma,\delta^{''},(z_{01},z_{02}),$#$,E_1$x$E_2)$, so that $M^{'}$=$M_1\cap M_2$but how should i define $\delta{'' ?}$Many Thanks | CFL Intersection with Regular Language prove | formal languages;context free;closure properties | null |
_cs.64955 | As programmers, we are always trying to find the most efficient space and time complexity solutions to algorithms. Is it forseeable in the future that we have languages or techniques such as AI/machine learning to automatically find such optimum solutions to any generic algorithm? | Using AI / Machine learning to find the most time and space efficient solutions to an algorithm | algorithms;algorithm analysis;optimization;machine learning;artificial intelligence | No.With all the hype about AI/Machine learning, sometimes people forget that there are known limitations to computers, which can be proven, so it doesn't matter how fast your computer is, how sophisticated is your neural net, you just cant do it.I'll try to address your specific question. First, you have to define exactly what is the task that you expect your AI algorithm to solve. Suppose your input is a description of the problem, given in the form of an encoding of a Turing machine $\langle M\rangle$ which solves it, or as a valid code in your favorite programming language. Now, say we want to output an equivalent program, with optimal (asymptotic) time complexity. The decision version corresponding to your problem is, given a program in your language, decide if there exists an equivalent program with better (asymptotic) time complexity.This is not possible for any computer, or in more technical terms, this language is undecidable. We can reduce the halting problem to the above in the following way:Given a pair $(\langle M \rangle,w)$, Let $M_w$ be the machine which, given input $x$, runs $M$ on $w$ for $|x|$ steps. If $M$ halted then $M_w$ accepts iff $x$ is a palindrome. If $M$ didn't halt within $|x|$ steps, $M_w$ rejects. We can build $M_w$ such that $M_w$ runs in $O(n^2)$ time.If $M$ halts on $w$ after $n$ steps, then $L(M_w)=\left\{x \big| |x|\ge n \land \text{x is a palindrome}\right\}$, otherwise $L(M_w)=\emptyset$. Since we know that checking whether a string is a palindrome requires $\Omega(n^2)$ time on a single tape Turing machine, then if $M$ halts on $w$, $M_w$ decides $L(M_w)$ with optimal time complexity. Otherwise it doesn't (the empty language can be decided in constant time, just output no without even reading the input). This means that $M$ halts on $w$ iff $M_w$ has optimal time complexity.This shows that for general programs, this task is hopeless. Perhaps, for a specific subset of programs, you can decide optimality, and this doesn't necessarily mean using some fancy AI algorithm, see Program optimization. |
_unix.281350 | i have a text file which its size is 23.5 Mb. i want to reduce file size under 20 Mb. how can i do that?the file type is: plain text document (text/plain).this file have ~40000 line and ~500 column.this is part of file:TRINITY_DN100014_c0_g1 GO:0003674 GO:0003824 GO:0003964 GO:0005488 GO:0016740 GO:0016772 GO:0016779 GO:0034061 GO:0043167 GO:0043169 GO:0046872TRINITY_DN100015_c0_g1 GO:0000166 GO:0000943 GO:0001882 GO:0001883 GO:0003674 GO:0003676 GO:0003677 GO:0003723 GO:0003824 GO:0003887 GO:0003964 GO:0004175 GO:0004190 GO:0004518 GO:0004519 GO:0004521 GO:0004523 GO:0004540 GO:0005488 GO:0005524 GO:0005575 GO:0005634 GO:0005737 GO:0006139 GO:0006259 GO:0006260 GO:0006278 GO:0006310 GO:0006725 GO:0006807 GO:0008150 GO:0008152 GO:0008233 GO:0008270 GO:0009058 GO:0009059 GO:0009987 GO:0015074 GO:0016032 GO:0016070 GO:0016740 GO:0016772 GO:0016779 GO:0016787 GO:0016788 GO:0016891 GO:0016893 GO:0017076 GO:0018130 GO:0019076 GO:0019438 GO:0030554 GO:0032196 GO:0032197 GO:0032549 GO:0032550 GO:0032553 GO:0032555 GO:0032559 GO:0034061 GO:0034641 GO:0034645 GO:0034654 GO:0035639 GO:0036094 GO:0043167 GO:0043168 GO:0043169 GO:0043170 GO:0043226 GO:0043227 GO:0043229 GO:0043231 GO:0044237 GO:0044238 GO:0044249 GO:0044260 GO:0044271 GO:0044403 GO:0044419 GO:0044422 GO:0044424 GO:0044428 GO:0044446 GO:0044464 GO:0044699 GO:0044763 GO:0044764 GO:0046483 GO:0046872 GO:0046914 GO:0051704 GO:0070001 GO:0070011 GO:0071704 GO:0071897 GO:0090304 GO:0090305 GO:0090501 GO:0097159 GO:0097367 GO:1901265 GO:1901360 GO:1901362 GO:1901363 GO:1901576TRINITY_DN100018_c0_g1 GO:0005575 GO:0005737 GO:0044424 GO:0044464TRINITY_DN100019_c0_g1 GO:0003674 GO:0003676 GO:0003723 GO:0005488 GO:0005575 GO:0005681 GO:0006139 GO:0006396 GO:0006397 GO:0006725 GO:0006807 GO:0008150 GO:0008152 GO:0008380 GO:0009987 GO:0016070 GO:0016071 GO:0030529 GO:0032991 GO:0034641 GO:0043170 GO:0044237 GO:0044238 GO:0044260 GO:0044422 GO:0044424 GO:0044428 GO:0044446 GO:0044464 GO:0046483 GO:0071704 GO:0090304 GO:0097159 GO:1901360 GO:1901363TRINITY_DN100021_c0_g1 GO:0000166 GO:0000902 GO:0000904 GO:0001882 GO:0001883 GO:0003674 GO:0003774 GO:0003777 GO:0003824 GO:0005488 GO:0005524 GO:0005575 GO:0005795 GO:0005871 GO:0005874 GO:0005875 GO:0005886 GO:0006928 GO:0007017 GO:0007018 GO:0008150 GO:0009653 GO:0009987 GO:0010090 GO:0016020 GO:0016043 GO:0016462 GO:0016787 GO:0016817 GO:0016818 GO:0016887 GO:0017076 GO:0017111 GO:0030554 GO:0032502 GO:0032549 GO:0032550 GO:0032553 GO:0032555 GO:0032559 GO:0032989 GO:0032991 GO:0035639 GO:0036094 GO:0043167 GO:0043168 GO:0043234 GO:0044422 GO:0044424 GO:0044430 GO:0044431 GO:0044444 GO:0044446 GO:0044464 GO:0044699 GO:0044763 GO:0044767 GO:0048869 GO:0071840 GO:0097159 GO:0097367 GO:1901265 GO:1901363i changed the file type to csv , html and java by saving as in LiberofficeClac but the new file was bigger than the first. | File size limits | files | null |
_cs.19263 | Algorithms for the finding of an MST in a graph can be applied for both maximum and minimum spanning trees.It is well known, however, that the finding of a max-cut in a graph is an NP-hard problem while the min-cut problem can be easily solved in polynomial time.Why aren't the two equivalent? What is the restriction that Im missing here? Thanks! | Reduction from max-cut to min-cut | complexity theory;graph theory;np complete | Some intuition involves the notion of a convex function. You can look up the formal definition, or consider the quintessential example of a convex function, namely $x^2$. Minimizing a convex function is easy, since there is a unique minimum, and moreover if you start anywhere and keep going done, you will eventually reach the minimum. Maximizing a convex function is a different thing. Suppose for example that you want to maximize $x^2$ under the constraint $x \in [\alpha,\beta]$. In order to do that, you need to compute the function at both endpoints $\alpha,\beta$ and choose the maximum. Now imagine that you function is multivariate and has lots of inputs. Minimizing is still easy - there is a unique minimum that can be reached by descent - but maximizing is problematic, since there are many potential maxima.MAX-CUT and MIN-CUT are related to the cut function, which gets as input a cut, and outputs the number of edges cut. This is a set function rather than a function on $\mathbb{R}^n$, but it has the property of submodularity, which is a form of convexity for set functions. Indeed, in general one can minimize submodular functions, but maximizing them is NP-hard. |
_hardwarecs.6484 | Due to budget constraints I constantly find myself several years behind current technology, when it comes to my PC hardware and operating systems. I do, however, make it a point to learn exactly what hardware is required to accomplish a given set of tasks.Unfortunately, matching system specifications to a given task is often a game. I can't tell you how many times I've been told that I CAN'T accomplish things I regularly do with ease on one of my systems. Often people will speak authoritatively about the absolute need for hardware that is WAY over qualified, and equally over priced for my needs.With this background I am asking for direct experience with the task I've outlined, to find out what critical specs and PC hardware (CPU type, clock speed, FSB speeds, number of cores, OS, Video card specs) I will need to accomplish one simple thing: Be able to live stream videos, play DVDs, and play various downloaded video/movie files, while driving my TV to its full 1920 x 1080 resolution, and at a reasonable frame rate ( which I assume should be at least 30fps). In addition to the actual specs, it will be a helpful addition to know HOW LONG AGO such specs became pretty common. I.e., if what I need became common place in 2010, that is a helpful reference point. I probably will want a windows box, if only because I've been intimately acquainted with most MS OS's for many years. I'm also looking for used equipment, because I doubt these tasks really require the latest, greatest machine. Again... not looking for brand recommendations, but the system specifications needed to easilly perform the task. Note: I have edited both the title and content of this post several times now both for brevity and clarity. For that reason, many comments no longer apply. Also, as the comment thread has already gotten too long, I ask that any further comments or answers at this point be limited to addressing the info I'm seeking. | minimum PC hardware specification to reproduce 1080i at 30 fps | pc;cpu;video adapters | null |
_unix.185384 | When I use the su command in OS X's Terminal say, to quickly switch to an administrator account to mount a drive using diskutil the style of the command prompt changes. Before using su, the Terminal's Darwin bash prompt displays my computer's name as dictated by the part of $HOSTNAME which precedes the part of that text string which reads .local, a colon, the current working directory, a space, the current user's name, and, finally, a dollar sign. After running su, all that's displayed is bash-3.2$. Is there a command that I could run to revert this without undoing my use of su? | Maintaining the Current Style of the Command Prompt After Using 'su?' | osx;prompt;su | Run su -l $USERNAME via Terminal to log in as another user without losing your current prompt style. |
_unix.33661 | No matter how big font I set for titlebar, the height of the titlebar is not changed at all. I don't see any editbox where I could enter the desired height of titlebar.So far, I only found workaround, that you should edit window's button (close, maximize, and so on) from current theme. However this is tiresome, because if you decide, that the new height is not OK, and it should be 1 px bigger, you have to rescale the buttons (whole set) again.I am looking for something theme independent, and straightforward. | How to make titlebars in XFCE bigger? | windows;xfce;window title | null |
_unix.208992 | I am trying to start supervisor service supervisor start, as root, but it gives meenv: /etc/init.d/supervisor: No such file or directory Yet, I can clearly see that file exists:[root@master vagrant]# ls -l /etc/init.d/ total 256-rwxr-xr-x. 1 root root 2062 Oct 17 2014 atd -rwxr-xr-x. 1 root root 3378 Jun 22 2012 auditd -rwxr-xr-x. 1 root root 2826 Nov 23 2013 crond -rw-r--r--. 1 root root 18586 Oct 10 2013 functions -rwxr-xr-x. 1 root root 5866 Oct 10 2013 halt -rwxr-xr-x. 1 root root 10804 Nov 23 2013 ip6tables -rwxr-xr-x. 1 root root 10688 Nov 23 2013 iptables -rwxr-xr-x. 1 root root 652 Oct 10 2013 killall -r-xr-xr-x. 1 root root 2134 Nov 23 2013 lvm2-lvmetad -r-xr-xr-x. 1 root root 2665 Nov 23 2013 lvm2-monitor -rwxr-xr-x. 1 root root 2989 Oct 10 2013 netconsole -rwxr-xr-x. 1 root root 5428 Oct 10 2013 netfs -rwxr-xr-x. 1 root root 6334 Oct 10 2013 network -rwxr-xr-x. 1 root root 6364 Nov 22 2013 nfs -rwxr-xr-x. 1 root root 3526 Nov 22 2013 nfslock -rwxr-xr-x. 1 root root 3852 Dec 3 2011 postfix -rwxr-xr-x. 1 root root 5383 Mar 30 08:29 postgresql -rwxr-xr-x. 1 root root 1513 Sep 17 2013 rdisc -rwxr-xr-x. 1 root root 1822 Nov 22 2013 restorecond -rwxr-xr-x. 1 root root 2073 Feb 22 2013 rpcbind -rwxr-xr-x. 1 root root 2518 Nov 22 2013 rpcgssd -rwxr-xr-x. 1 root root 2305 Nov 22 2013 rpcidmapd -rwxr-xr-x. 1 root root 2464 Nov 22 2013 rpcsvcgssd -rwxr-xr-x. 1 root root 2011 Aug 15 2013 rsyslog -rwxr-xr-x. 1 root root 3085 May 11 21:07 salt-master -rwxr-xr-x. 1 root root 3332 May 11 21:07 salt-minion -rwxr-xr-x. 1 root root 1698 Nov 22 2013 sandbox -rwxr-xr-x. 1 root root 2056 Feb 27 15:57 saslauthd -rwxr-xr-x. 1 root root 647 Oct 10 2013 single -rwxr-xr-x. 1 root root 4534 Nov 22 2013 sshd-rwxr-xr-x. 1 root root 1345 Jun 11 10:20 supervisor -rwxr-xr-x. 1 root root 2294 Nov 22 2013 udev-post -rwxr-xr-x. 1 root root 15634 Mar 7 2014 vboxadd -rwxr-xr-x. 1 root root 5378 Mar 7 2014 vboxadd-service -rwxr-xr-x. 1 root root 20887 Mar 7 2014 vboxadd-x11And it contains some script, as expected.What am I doing wrong? | Supervisor: no such file or directory even though it is there | shell script;executable;supervisord | It's not complaining about the /etc/init.d/supervisor file itself, but most likely about the file it wants to execute as - usually the shell that appears on the shebang line in that file. It's a somewhat misleading error that I've seen many times before. |
_webmaster.22624 | I am really curious about how to prevent comment spam in a forum using a honey pot trap for spam bots. What if CSS and javascript is turned off in a browser?Do you see any other disadvantages in the honey pot trap?What do you think every honey pot trap should have?Do you know any other anti-spam alternative, that does not disturb the users experience. | Prevent spam using Honey Pots | security;spam;spam prevention;honeypots | null |
_unix.111771 | I have a log file that has lines that look like this:blah blah blah Photo for (702049679 - blah blah blahNow I know I could get all the lines like that from the file by doing:grep Photo for logFileBut how can I take those lines and get a comma seperated list of each number after the parenthesis in a single output line (these are going to be pasted into an SQL query)?The numbers in question will be the first occurrence of a string of numeric characters 9 or more digits long. Ideally it could be matched using that criteria, or the criteria of the first number occurring after the Photo for ( text. | Awk/grep/sed get comma separated list of numbers from lines of text | command line;sed;grep;awk | A regex this complicated is better handled with Perl, e.g.grep Photo for logFile | perl -pe 's/.*Photo for ((\d+).*/\1/' | tr '\n' ','If Perl is out of the question:grep Photo for logFile | awk '{sub(/.*Photo for \(/,,$0);sub(/[ ].*/,);print $0}' | tr '\n' ',' |
_webmaster.5672 | I've looked at what I consider the big three (I could be wrong about that)Microsoft Cloud AzureAmazon Simple Web ServicesGodaddy Virtual Server SpaceI'm not a server expert, I like hosting a site on godaddy because I don't have to think about the hosting part but I want to manage multiple sites without having to buy a hosting account each time. | Cloud Hosting Options, what are the differences? | cloud hosting | I believe Godaddy's Virtual Server Space is a VPS service, not a cloud computing platform. I also don't think Amazon offers such a thing as Simple Web Services. They do offer Amazon Web Services, which is a whole host of cloud services, including Amazon S3 (Simple Storage Service) and Amazon SQS (Simple Queue Service) and Amazon SNS (Simple Notification Service), but you're probably looking for Amazon EC2 (Elastic Compute Cloud). And Google App Engine is another popular cloud service, which is far more widely used than Godaddy's Virtual Server Space.The differences are mainly going to be pricing, architecture, and how the service is managed and integrated. Google App Engine is Java- and Python-based. So if you use PHP, then you won't be able to use App Engine. Azure is Windows-based, however it uses FastCGI so it can use almost any programming language. Amazon EC2 is much more like a VPS service in that you're managing individual virtualized servers. So you can pick what OS and software to load onto it. Also, because of this, EC2 applications will be much more portable than applications that have been designed specifically for App Engine or Azure.Additionally, each cloud platform has their own unique feature set. AWS offers a few cloud storage options separate from EC2. Google App Engine comes with DataStore, which is based on BigTable, and Azure comes with its own set of storage services. Naturally, AWS services are easier to integrate with one another. Likewise, App Engine (for Business) can be closely integrated with Google Apps.Lastly, you should know that pretty much all web hosts allow you to manage multiple sites on a single account. DreamHost, for instance, lets you manage an unlimited number of domains and subdomains on even their most basic hosting plan. So that's not a unique feature of Godaddy. You don't need to think about hosting with any decent web host. Though with better web hosts you do have a lot more control and freedom over customization than you get with Godaddy. |
_unix.159742 | How can I have some of the options to a unix command come from a file? That is the file does not contain all the options -- other options are specified elsewhere.For example I have the filelsoptions.txt with the following content:-F -GNow I would like to execute ls -a <and all options specified in the file lsoptons.txt>ie, I want to execute ls -a -F -G.That is, specify some of the options, but other options are read from a file.Note:This is obviously a cooked up example. My real use case is that my shell script needs some parameters that were provided in a TeX file. So, instead of having the user duplicate the information in multiple places, I will have the TeX write the desired options into a file so that the shell script can also have access to them. One option would be to have the TeX generate the entire script, but would much easier if I could just read the options from a file. | Options to a command specified in a file | shell;options | For the trivial example listed above,ls -a $(cat lsoptions.txt) |
_cstheory.31054 | In my computer science education, I increasingly notice that most discrete problems are NP-complete (at least), whereas optimizing continuous problems is almost always easily achievable, usually through gradient techniques. Are there exceptions to this? | Is it a rule that discrete problems are NP-hard and continuous problems are not? | cc.complexity theory;co.combinatorics;optimization | An example that I love is the problem where, given distinct $a_1, a_2, \ldots, a_n \in \mathbb{N}$, decide if: $$\int_{-\pi}^{\pi} \cos(a_1 z) \cos(a_2 z) \ldots \cos(a_n z) \, dz \ne 0$$This at first seems like a continuous problem to evaluate this integral, however it is easy to show that this integral is not zero iff there exists a balanced partition of the set $\{a_1, \ldots, a_n\}$, so this integral problem is actually NP-complete.Of course, I encourage playing around with some numerical tools to convince yourself that most (if not all) numerical tricks to evaluate this integral are doomed to failure once $n$ gets large enough. |
_datascience.16494 | I have a dataset of web browsing histories for users visiting a particular website over a period of time (say the last 90 days). Each user has a unique ID and several records showing when he/she visited a particular page on the website.It looks like follow:UserID,Timestamp,PathU_1,2017-01-24 12:05:43,/sport/rugby/article_titleU_1,2017-01-24 12:06:56,/sport/football/article_titleU_1,2017-01-24 15:26:12,/finance/local/article_title......I do not have access to the content of the articles, I just know the path to the article.My goal is to build a classifier to predict if a user will take an action or not. So I need to extract features from each user data.Suppose that I have ground-truth information associated with each user, indicating when a user did the action.My first guess is to aggregate all the records of each user and extract frequency features (hashing TF) from each level of the path.So for demonstration, a particular user might visit the /sport category 5 times (first level category), and the /sport/football category 3 times (second level category), and the /sport/rugby 2 times (second level category).So for each user I will have a feature vector representing the frequency of the first level categories, and another one for the second level categories and so on.I can now train a classifier for each feature vector and do a late fusion of the results, or I can concatenate (early fusion) the different features and train a single classifier.I can also extract the terms from the article titles and build a TFIDF feature.What I am trying now is to extract the features from the N days proceeding taking the actions for the positive samples, and randomly select N consequent days from negative users.What are the possible other features that I can extract, and is there any better ML techniques to use in order to model and learn the user web browsing behaviour? | Feature extraction from web browsing history of one website | classification;feature extraction | What you describe uses the data that the paths can offer. You can easily generate features from the data and time. For instance, given the date, you can generate a categorical variable denoting the weekday (Monday, Tuesday, etc..). Given the timestamp, you can generate binary variables to partition the day in four or more partitions: is_morning, is_afternoon etc.. Somebody may only read in the morning or at night, and the aim of these features is to capture this. Further, you can get the interactions between weekdays and day partitions. Such features may help to distinguish users that in the Sunday mornings read about sports while Monday mornings they are at work and read financial news. Be careful of the overfitting though. Note that trees have been shown to capture such complex interactions; given them explicitly is beneficial though. |
_codereview.16007 | I have been developing a capitalizer in Python. This is actually a script that an end user will type at their terminal/command prompt. I have made this script to:Taking the first argument as a file name and process it.Don't process words that have 3 or less alphabet.Here's some code:#!/usr/bin/env python#-*- coding:utf-8 -*-from os import linesepfrom string import punctuationfrom sys import argvscript, givenfile = argvwith open(givenfile) as file: # List to store the capitalised lines. lines = [] for line in file: # Split words by spaces. words = line.split() for i, word in enumerate(words): if len(word.strip(punctuation)) > 3: # Capitalise and replace words longer than 3 letters (counts # without punctuation). if word != word.upper(): words[i] = word.capitalize() # Join the capitalised words with spaces. lines.append(' '.join(words)) # Join the capitalised lines by the line separator. capitalised = linesep.join(lines)print(capitalised)A lot more features still have to be added but this script does the stuff it is made for. What I want (from you):I want this script to be emerge as a command line utility. So,How can I make this a better command line utility?Could I have written in a better way?Can this script be faster?Are there any flaws?Other than GitHub, how can I make it available to the world (so that it is easier to install for end users)? because GitHub is for developers.Please also post links to make my script and me even more mature. | Command-line utility to capitalize long words in a file | python;performance;strings;file | How can you make this a better command-line utility?Along with using argparse (which is a great suggestion), I would suggest adding options for reading files from stdin, and maybe an option to write to somewhere other than stdout (to a file, for example).Could it be written better / can it be faster?Of course! There's always room for improvement. The biggest performance issue I can see here is that you append the output to the lines list, then output at the very end. The downside to this is that you must hold the entire output in memory before you return. If the file is large, it will be slow due to all the allocation/garbage-collection, and in extreme cases you could run out of memory!Instead of appending to lines and joining at the end, I'd suggest you replace this line:lines.append(' '.join(words))withprint ' '.join(words) # probably needs replaced with something that preserves whitespace.Then delete all lines that refer to lines:lines = [] and capitalised = linesep.join(lines) and print(capitalised)With this, and allowing for input from stdin, you could use it in unix pipelines, like so: cat somefile | capitalizer | grep 'Foo' (or something like that), and you'll see output immediately (as opposed to when the entire file is processed).Is there an easier way for end-users to install this?Yes, kind-of... as long as your users are not afraid of the command-line (which I assume, since this is a command-line program), you can publish this to PyPi, then it can be installed with tools like PIP and easy_install.Here's a simple tutorial for getting started with PyPiWhen setup properly, installation can be a simple as:easy_install capitalizer or pip install capitalizerFinally, discovery is a bit better than just github, as users can find your app with tools like the PyPi website, and crate.io. |
_softwareengineering.298564 | Programmers all seem to agree that readability of code is far more important than short-syntaxed one-liners which work, but require a senior developer to interpret with any degree of accuracy - but that seems to be exactly the way regular expressions where designed. Was there a reason for this?We all aggree that selfDocumentingMethodName() is far better than e() -- Why should that not apply to regular expressions?It seems to me that rather than designing a syntax of one-line logic with no structural organization:var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})(0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;And this isn't even strict parsing of a URL!Instead, we could make a some pipeline structure organized and readable, for a basic example:string.regex .isRange('A-Z' || 'a-z') .followedBy('/r');What advantage does the extremely terse syntax of a regular expression offer other than the shortest possible operation and logic syntax? Ultimately, is there a specific technical reason for the poor readability of regular expression syntax design? | Is there a specific reason for the poor readability of regular expression syntax design? | readability;regular expressions | There is one big reason why regular expressions were designed as terse as they are: they were designed to be used as commands to a code editor, not as a language to code in. More precisely, ed was one of the first programs to use regular expressions, and from there regular expressions started their conquest for world domination. For instance, the ed command g/<regular expression>/p soon inspired a separate program called grep, which is still in use today. Because of their power, they subsequently were standardized and used in a variety of tools like sed and vimBut enough for the trivia. So why would this origin favor a terse grammar? Because you don't type an editor command to read it even one more time. It suffices that you can remember how to put it together, and that you can do the stuff with it that you want to do. However, every character you have to type slows down your progress editing your file. The regular expression syntax was designed to write relatively complex searches in a throw-away fashion, and that is precisely what gives people headaches who use them as code to parse some input to a program. |
_codereview.69909 | This was largely an exercise in making my code more Pythonic, especially in catching errors and doing things the right way. I opted to make the PageNotFound exception part of the class so that users could simply from ratebeer import RateBeer and not have to worry about anything else.If you prefer, the code is on Github.from bs4 import BeautifulSoupimport requestsimport reimport exceptionsclass RateBeer(): Makes getting information about beers and breweries from RateBeer.com as easy as: >>> summit_epa = RateBeer().beer(summit extra pale ale) A utility for searching RateBeer.com, finding information about beers, breweries, and reviews. The nature of web scraping means that this package is offered in perpetual beta. Requires BeautifulSoup, Requests, and lxml. See https://github.com/alilja/ratebeer for the full README. class PageNotFound(Exception): pass def __init__(self): self.BASE_URL = http://www.ratebeer.com def _search(self, query): # this feels bad to me # but if it fits, i sits payload = {BeerName: query} r = requests.post(self.BASE_URL+/findbeer.asp, data = payload) return BeautifulSoup(r.text, lxml) def _parse(self, soup): s_results = soup.find_all('table',{'class':'results'}) output = {breweries:[],beers:[]} beer_location = 0 # find brewery information if any(brewers in s for s in soup.find_all(h1)): s_breweries = s_results[0].find_all('tr') beer_location = 1 for row in s_breweries: location = row.find('td',{'align':'right'}) output['breweries'].append({ name:row.a.contents, url:row.a.get('href'), id:re.search(/(?P<id>\d*)/,row.a.get('href')).group('id'), location:location.text.strip(), }) # find beer information if any(beers in s for s in soup.find_all(h1)) or not soup.find_all(text=0 beers): s_beer_trs = iter(s_results[beer_location].find_all('tr')) next(s_beer_trs) for row in s_beer_trs: link = row.find('td','results').a align_right = row.find_all(td,{'align':'right'}) output['beers'].append({ name:link.text, url:link.get('href'), id:re.search(/(?P<id>\d*)/,link.get('href')).group('id'), rating:align_right[-2].text.strip(), num_ratings:align_right[-1].text, }) return output def search(self, query): return self._parse(self._search(query)) def beer(self, url): r = requests.get(self.BASE_URL+url, allow_redirects=True) soup = BeautifulSoup(r.text,lxml) output = {} # check for 404s try: s_contents_rows = soup.find('div',id='container').find('table').find_all('tr') except AttributeError: raise RateBeer.PageNotFound(url) # ratebeer pages don't actually 404, they just send you to this weird beer reference # page but the url doesn't actually change, it just seems like it's all getting done # server side -- so we have to look for the contents h1 to see if we're looking at the # beer reference or not if beer reference in s_contents_rows[0].find_all('td')[1].h1.contents: raise RateBeer.PageNotFound(url) info = s_contents_rows[1].tr.find_all('td') additional_info = s_contents_rows[1].find_all('td')[1].div.small abbr = additional_info.find_all([abbr,a]) big = additional_info.find_all(big) if additional_info.find(text=re.compile(SEASONAL)): del big[2] for location, label in enumerate(abbr): key = None if RATINGS in label.text: key = num_ratings if CALORIES in label.text: key = calories if ABV in label.text: key = abv if SEASONAL in label.text: key = season if IBU in label.text: key = ibu if key is not None: output[key] = big[location].text output.update({'name':s_contents_rows[0].find_all('td')[1].h1.text, 'overall_rating':info[0].find_all('span', attrs={'itemprop':'average'})[0].text, 'style_rating':info[0].find_all('div')[2].div.span.text, 'brewery': info[1].a.text, 'brewery_url':info[1].a.get('href'), 'style':info[1].div.find_all('a')[1].text, }) return output def reviews(self, url, pages=1,start_page=1,review_order=most recent): assert pages > 0, ``pages`` must be greater than 0 assert start_page > 0, ``start_page`` must be greater than 0 review_order = review_order.lower() url_codes = { most recent:1, top raters:2, highest score:3 } url_flag = url_codes.get(review_order) if not url_flag: raise ValueError, Invalid ``review_order``. output = [] for page_number in range(start_page,start_page+pages): complete_url = {0}{1}{2}/{3}/.format(self.BASE_URL, url, url_flag, page_number) r = requests.get(complete_url, allow_redirects=True) soup = BeautifulSoup(r.text, lxml) content = soup.find('div',id='container').find('table').find_all('tr')[5] [x.extract() for x in content.find_all('table')] # strip ad section review_tuples = zip(*[iter(content.find_all('div'))] * 4) # basically magic for review in review_tuples: detail_tuples = zip(*[iter(review[0].find_all([big,small]))] * 2) details = dict([( label.text.lower().strip().encode(ascii,ignore), rating.text, ) for (label, rating) in detail_tuples]) details.update({'text':review[3].text}) output.append(details) return output def brewery(self, url, include_beers=True): r = requests.get(self.BASE_URL+url, allow_redirects=True) soup = BeautifulSoup(r.text, lxml) try: s_contents = soup.find('div',id='container').find('table').find_all('tr')[0].find_all('td') except AttributeError: raise RateBeer.PageNotFound(url) output = { 'name':s_contents[8].h1.text, 'type':re.search(Type: +(?P<type>[^ ]+),s_contents[8].find_all('span','beerfoot')[1].text).group('type'), 'street':s_contents[0].find('span',attrs={'itemprop':'streetAddress'}).text, 'city':s_contents[0].find('span',attrs={'itemprop':'addressLocality'}).text, 'state':s_contents[0].find('span',attrs={'itemprop':'addressRegion'}).text, 'country':s_contents[0].find('span',attrs={'itemprop':'addressCountry'}).text, 'postal_code':s_contents[0].find('span',attrs={'itemprop':'postalCode'}).text, } if include_beers: output.update({'beers':[]}) s_beer_trs = iter(s_contents[8].find('table','maintable nohover').find_all('tr')) next(s_beer_trs) for row in s_beer_trs: beer = { 'name':row.a.text, 'url':row.a.get('href'), 'id':re.search(/(?P<id>\d*)/,row.a.get('href')).group('id'), 'rating':row.find_all('td')[4].text.strip(), 'num_ratings':row.find_all('td')[6].text.strip(), } output['beers'].append(beer) return output | RateBeer.com scraper | python;error handling;library;web scraping;beautifulsoup | I ran pylint on your code, which came up with 98 warnings - this is not good! I have split this down into each warning class, ordered by number of occurrences.Note that if you particularly disagree with any specific warning, you can use comments to disable them, e.g.:# pylint: disable=too-many-localsThis at least makes it clear that you've considered and dismissed the issue.bad-whitespace [30 counts]The style guide lays out the rules for whitespace, you should have:One space after commas (e.g. in tuples, lists, definitions and calls);One space after colons (e.g. in dictionaries); andNo spaces around = in calls/definitions.Not only do you not follow this, you are inconsistent. Also, lining up e.g.if RATINGS in label.text: key = num_ratingsif CALORIES in label.text: key = calorieswith whitespace is not Pythonic (we will come back to this line later...)line-too-long [24 counts]Lines should be at most 79 characters long (72 for docstrings). One is 119 characters long!bad-continuation [13 counts]When continuing statements across multiple lines, you should eitheracceptable = ('start on the first line' and 'continue at the same indent') # close paren on same lineoralso_acceptable = ( 'start on the next line' and ' use a single level of indent') # closing paren on next line, here# ) or herePick one of the three, and be consistent.missing-docstring [8 counts]Although you have a docstring for the class (albeit not correctly formatted), none of its methods are documented. I would put your overall explanation as a module docstring, then have an addition docstring for at least every public method. I like the Google style, but there are others.multiple-statements [6 counts]To return, as promised, to:if RATINGS in label.text: key = num_ratingsThat line contains two statements, and should therefore be on two lines:if RATINGS in label.text: key = num_ratingsNote that you could use a dictionary to simplify this, for example:KEYWORDS = {'RATINGS': 'num_ratings', ...}for keyword in KEYWORDS: if keyword in label.text: key = KEYWORDS[keyword] breakinvalid-name [5 counts]A few methods use r as a variable name - something more meaningful might be helpful (pylint generally requires at least three characters).Also, BASE_URL should be a class attribute.trailing-whitespace [3 counts]There should be no tabs/spaces on blank lines or at the end of a line. You can generally set up IDEs to remove this automatically (or when you ask them to - e.g. Format > Strip trailing whitespace in IDLE). If you have the option, turning on display of whitespace helps you see what's going on.anomalous-backslash-in-string [3 counts]You have a few regular expressions that use backslashes (e.g. for digits \d) - these should be made raw strings r'...'.unused-import [1 count]You never use exceptionstoo-many-locals [1 count]There are 20 local variables in RateBeer.beer, suggesting it should be split into more, smaller methods (pylint sets the limit at 15).old-style-class [1 count]RateBeer should inherit from object to make it a new-style class:class RateBeer(object):old-raise-syntax [1 count]You mostly raise correctly, but:if not url_flag: raise ValueError, Invalid ``review_order``.Again, one statement per line, and use the new syntax:if not url_flag: raise ValueError(Invalid ``review_order``.)no-self-use [1 count]RateBeer._parse doesn't actually use any instance attributes, and could therefore be a standalone function or @staticmethod.expression-not-assigned [1 count]This line:[x.extract() for x in content.find_all('table')] creates a list that never gets assigned. If you're just doing this for the side-effects, make that clear with e.g.:_ = [x.extract() for x in content.find_all('table')] Additionally, the import statements should be:import re # standard library firstfrom bs4 import BeautifulSoup #then third-partyimport requests |
_webmaster.65162 | I have an online store with categories that have a tree structure (meaning they can be nested inside other categories) and products inside these categories.What is the best way to structure the URLs of the product pages?Some ideas I have thought are:example.com/<root-category-name>/<child-category-name>/<product-name>example.com/<root-category-name>/<product-name>example.com/<child-category-name>/<product-name>example.com/p/<product-name>Now a little info about each of these names.The names of the root categories are the most important keywords. These I want to target. Eg. bath-furniture. I suppose I want to have much URLs with this segment since it contains the most important keyword.The names of the nested categories could be important but not in all the cases. In some cases they are some random-given names like Aphrodite Series which is not something a user would search for.The names of products could repeat the root categories keywords (which would be redundant) or could be random names (which is more correct imho). eg. bath-furniture-nova-350XL vs nova-350XL.I want the most correct and good for SEO design. | Structuring URLs of an online shop for SEO | seo;url;google search | null |
_unix.166413 | I am setting up a DNS(Bind) server and by default the /etc/named.conf has the following entries:zone . IN { type hint; file named.root;};zone localdomain. IN { type master; file localdomain.zone; allow-update { none; };};zone localhost. IN { type master; file localhost.zone; allow-update { none; };};zone 255.in-addr.arpa. IN { type master; file named.broadcast; allow-update { none; };};zone 0.in-addr.arpa. IN { type master; file named.zero; allow-update { none; };};When I tried to start named, it fails because these 5 files (named.root, named.zero, named.broadcast, localhost.zone and localdomain.zone) does not exist anywhere on this server. So I removed these entries and named started fine and its running. DNS is working as expected. I did a bit of research and came to know that these files are used for resolving localhost domains. I checked couple of other DNS server and saw that these files basically has A and NS records pointed to the localhost. My questions are:Is it okay if I keep running this DNS on our production environment without these files? What are the side-effects?I have named.ca in the server, but no named.root. I checked another DNS server (where both these files exist) and saw that they have the same contents (records pointed to root nameservers. Am I okay with having only named.ca since it has the root nameserver entries? Is named.root a deprecated version of named.ca ?I have no forwarders set up in named.conf, but external domains are all resolving fine. Should I still need some kind of forwarders? Some of our other older DNS server has the forwarder set up that points to rackspace where we have our servers. | Need of built-in zone files in named.conf | rhel;bind;named | First of all, if your distribution supplied or installed a default named.conf file that references those zone files, they should definitely exist on your system. Maybe you should reinstall the package? (or did you install from source?)If your DNS server is authoritative only(You are talking about resolving external domains so I don't think this is the case.)You absolutely don't need the placeholder zones localhost, localdomain, 0.in-addr.arpa, and 255.in-addr.arpa. They will never get queried.I'm not sure about the root hints zone. I wonder if BIND might not still use it even in an authoritavive only configuration. I would err on the side of leaving it in.If your DNS server has recursion enabledYou really need the root hints zone. BIND has built-in defaults, which is why it's still working for you even without it, but the root hints information does change from time to time, and the built-in hints can get out of date. Even though it's very unlikely that the root hints change so much that there is no longer any overlap between the built-in hints and the current root server locations and your server starts failing, you should still have a root hints file and keep it up to date on a (very) occasional basis.As for the other placeholder zones, nothing will go wrong if you don't have them, but it means that if your server gets garbage queries for names under these domains, it will forward them to the Internet whereas with the placeholder zones it could have produced negative answers much more quickly.root hints filenameRegarding your second question about the root hints filename, it doesn't matter whether you call the file named.root or named.ca or anything else, just as long as you reference it in named.conf using the correct filename. The root hints do not change very often, which is why you noticed another server has an identical copy.As explained above, you should use the root hints file rather than relying on the compiled-in defaults.ForwardersYou can configure forwarders if you want. It will keep a small amount of traffic off the root servers and directly it to your upstream servers instead, but this isn't a big deal for a handful of servers. The efforts of configuring forwarders, keeping them up to date, and the risk of having your server fail if the forwarders fail is usually not worth it. If you are managing hundreds or thousands of servers, or if your are creating a default configuration for use on end-user systems then I would definitely consider it. |
_webapps.37642 | I have a Google spreadsheet where each sheet is a student group, say, Group1, Group2, Group3 etc. Each sheet is organized identically.I would like to summarize some information from all sheets into a final one. Since cell A1 of each sheet has the student group name, I'd like to code something like:**Group name** =Group1!A1 =Group2!A1 =Group3!A1 ...Is it possible to code/script this with Google Docs? I have the impression that yes it is, but I cannot find the way to code it (being pretty useless with spreadsheets, all apologies). | Selecting a sequence of sheets in Google Docs / Spreadsheets | google spreadsheets | Update based on OP's feedbackWhat might help you then is =INDIRECTFor example: =INDIRECT(Sheet & ROW() & !A1)What this formula does is uses the current sheet's own row to help define what information is being pulled. In this case, starting with cell A1, the formula will be evaluated as =INDIRECT(Sheet1!A1)What =INDIRECT does is allows you to use text strings to define reference ranges when pulling data, thus you can use & to concatenate a string and insert an automated way of iterating through the various sheet numbers. To get the summarized data in A1 of all sheets, just drag the formula in the summary sheet all the way down the column to have the formula auto-fill each of the following roles. Here's a screenshot:What's happening in my example is that on Sheet1 I have Status in cell A1. Looking at my formula in columnC, you'll notice that =INDIRECT is pulling that value from A1. The following entries is from autofilling (click and drag) the formula down to other rows, making =INDIRECT concatenate different Sheet #s based on the row().OLD ANSWER Which does not use =INDIRECTWithout knowing more about the format of your specific Groups' sheets, you have it almost correct in your example.If you rename sheets in your document to a custom name, you need to reference them using quotes. If you add single quotes around the sheet name, you've got it:Group name ='Group1'!A1 ='Group2'!A1 ='Group3'!A1 ...You can also add summary information in a sheet, like:Groups Total Sum=sum('Group1'!B1:B13)That will give you the sum of values in Sheet Group1, column B, rows 1 - 13.Note: if you're ever confused as to how to reference a value from another sheet, you can always just:Go to the summary sheetSelect the cell you'd like to editHit = to start a formula and thenClick to another sheet/cell and see how the formula bar autofills the information. |
_scicomp.20439 | I am looking for a way to simulate behavioral economic models to illustrate the effects of changing parameters. I am familiar with statistical analysis (especially R), but I only have few programming skills beyond R. I think that if there is a way to achieve my goal (I'm not really sure if it is possible at all!) that Octave should be a good choice.Usually such a model defines some kind of game with actions, strategies and payoffs for every player. Then these actions get evaluated and normally an equilibrium between the players actions/strategies is determined.One of my desired models is Rabin's idea of Fairness Equilibria. Pages 1286ff can give a short idea of how Rabin defines the game and determines the equilibrium. LINKMy goal is to have a function that depicts that model and enables me to illustrate the effects of different assumptions and situations within the frame of the specific model.So my question is: Is it possible at all? Is Octave suitable or should I choose another language/environment?Thanks in advance for any sort of advice!EDIT:I try to sketch the model:Starting point is a two player normal form game (Prisoner's Dilemma) with the strategy sets $S_1, S_2$ for every player from which they choose their actions. The payoff function for each player is defined as $\pi_i = S_1 \times S_2$. So player $i$ chooses action $a_i \in S_i$. Now player $j$ has a believe about $i$'s strategy $b_i \in S_i$ and player $i$ has a belief about player $j$'s belief about $i$'s strategy $c_i \in S_i$. So the feasible payoffs for $i$ depending on his beliefs are in the set $\Pi(b_j) = \{(\pi_i(a_i,b_j),\pi_j(b_j,a_i)) | a_i \in S_i\}$That's the framework.The routine now has to determine$\pi_j^h(b_j)$ as the highest payoff for $j$ depending on $i$'s belief that is Pareto efficient in $\Pi(b_j)$$\pi_j^l(b_j)$ as the lowest payoff for $j$ depending on $i$'s belief that is Pareto efficient in $\Pi(b_j)$$\pi_j^{min}(b_j)$ as the worst possible payoff for $j$ depending on $i$'s beliefthe reference point for $j$: $\pi_j^e(b_j) = \frac{\pi_j^h(b_j) + \pi_j^l(b_j)}{2}$the kindness of $i$ towards $j$: $\kappa_i(a_i,b_j)=\frac{\pi_j(b_j,a_i) - \pi_j^e(b_j)}{\pi_j^h(b_j) - \pi_j^{min}(b_j)}$believed kindness of $j$ towards $i$: $\bar\kappa_j(b_j,c_i)=\frac{\pi_i(c_i,b_j) - \pi_i^e(c_i)}{\pi_i^h(c_i) - \pi_i^{min}(c_i)}$Then the Expected Utility is defined as: $U_i(a_i,b_j,c_i) = \pi(a_i,b_j) + \bar\kappa_j(b_j,c_i) \cdot [1+\kappa_i(a_i,b_j)]$Now, to be a Fairness Equilibrium, a pair of strategies $(a_1^*,a_2^*)$ has to fulfill following conditions:$a_i^* \in \text{argmax}_{a_i \in S_i} U_i(a_i,b_j,c_i)$$c_i = b_j = a_i^*$So my goal is to get a routine that determines these Fairness Equilibria when a certain game is given. | Software to simulate behavioral economic models? | simulation;octave | null |
_webmaster.69222 | I'm used to using Google Analytics and Hitwise to get demographic info (particularly age) of a websites' users. Neither of these track users under 18. I know it's unlikely for a range of reasons, but are there any tools that do? Even to get a sense of the overall proportion of users who may be under 18 would be useful.Failing that, what techniques would you recommend for getting a rough guide to the trajectory of child visitor numbers? I'm currently looking at upstream traffic in Hitwise, and tracking % of of users who've also visited key sites aimed at children. Vague I know, but better than nothing.Ideally, I'd introduce user accounts, mailing list signup or another method of data capture to collect this info first hand, but before I do that... | How to track demographic info of child (under 18 years old) website users? | google analytics;demographics | I am not aware of any mainstream tracking platforms that will track minors. The only few solutions I could think of are:1) Make users sign up for something and ask for their age. Something Like a user profile.2) Do surveys on your site that ask that question. You can do a standard survey or you can do something like pop-up lightboxes with a question.Be aware that there are A LOT of laws that prevent you from gathering info on minors. Laws such as Childrens Privacy Policy (COPPA) - http://www.ftc.gov/enforcement/rules/rulemaking-regulatory-reform-proceedings/childrens-online-privacy-protection-rule |
_unix.59754 | I want to make the programs compiled by Codeblocks, run the shell program 'Terminator'.So I went into Environment Settings > Terminal to launch console programs, the default value is xterm -T $TITLE -e so I replaced it with /usr/bin/terminator -T $TITLE -e but when I compile the program doesn't run... How can I do it? | Making CodeBlocks work with Terminator? | ubuntu;ide;compiler | null |
_softwareengineering.130416 | I develop personal projects on two machines without use of a shared server or a network connection between the two.Do any common version control systems reliably support use of portable storage (such as a USB flash device) as the shared repository? | Version Control based on portable storage? | version control | Use a DVCS such as Git or Mercurial.Distributed version control systems do not have a shared central server.With a DVCS, every copy of a repository holds the complete history - everything. This means, that when used on a USB key any changes you make are make to the repository on the USB key and when moved between computers will hold this history. |
_cs.13930 | This is a Google interview question. I got it from a website.You have two arrays source and target, containing two permutations of the numbers [0..n-1]. You would like to rearrange source so that it equals to target. The only allowed operations is swap a number with 0. Find the minimum number of swaps?e.g. {1,0,2,3} -> {1,3,2,0} swap 0 with 3. one swap is enough.My attempt on problem: If we consider arrays as strings we could use edit distance to convert source to target if other edit distance operations like insert,delete,replace etc are allowed but here only allowed operation is swapping. | Rearrange an array using swap with 0 | algorithms;sorting;permutations | Without loss of generality you can assume that the target array is $0,1,...,n-1$: you can relabel the target array as 0,1,2,...,n-1 (and relabel the corresponding numbers in the source array, too). The allowed operation becomes swap a number with x (where x is not necessarily 0) and the target array is 0,1,2,...,n-1.You can build a directed graph with $n$ nodes and an edge from node $n_i$ to node $n_j$ if $n_i = j$, i.e. the target position of $n_i$ is $j$ (skip nodes that are already in the correct position). The resulting graph contains one or more distinct cycles.You can arrange the cycle containing the zero following the arcs in the reverse direction, then jump to another cycle and arrange it; the entry point doesn't matter.In the example of the figure above the swap number is zero and the target permutation is $0,1,...6$; after completing the first cycle (blue one) you must enter the second cycle (red one) in order to complete it; if $(n_i \rightarrow n_j)$ is a directed arc of the second cycle, then it must modified in $(n_i \rightarrow 0 \rightarrow n_j)$. The entry point is irrelevant (the number of swaps needed to arrange the second cycle doesn't change). You can also interpret the swaps on a cycle like a shift of its numbers.The procedure always ends with the sorted array (after arranging a cycle, its numbers are never moved again). If there are $m$ cycles and the $i$-th cycle has $p_i>1$ numbers that needs to be arranged and cycle 1 contains the number used for the swaps, the total number of swaps is $(p_1-1)+(p_2+1)+...+(p_m+1)$. If the number used for the swaps is already in place the number of swaps is $(p_1+1)+(p_2+1)+...+(p_m+1)$. To prove that the number of swaps used is optimal, you can observe that every number of each cycle must be moved (requires a swap), and there is no way to move a number of a cycle without moving the zero on that cycle. |
_webmaster.74575 | You know, there are tons of sites on the internet which check the value of sites, showing traffic details about sites, seo score checker sites, whois checker sites etc..Also, some of them are 4-5-6 PR; big sites, for example:www.websitestatz.com/info/example.comwww.websitevalues.net/example.com.htmlAre these links are toxic or not? Should we write them to our disavow file?Or how can I check if a URL is toxic or not? | Are website review links toxic such that they should be disavowed? | seo;google;backlinks;disavow links | No. These and others are not toxic sites. Google knows these kinds of sites very well and discount their links to your site. Often, these links will add a small value to your overall profile, but are considered very low quality none-the-less.Be careful not to disavow links unless you know that they are toxic. It is a bad practice to disavow links as a rule. Only disavow links as a last resort and only if the links are causing damage to your PR in a significant way. |
_codereview.71718 | I'm currently working on the library BigPicture.js with live demo here.There surely are lots of little improvements possible in the main .js file (< 300 lines of code), here are some little questions :Is it common to use something like :(function() { // code here} ) ();to launch the code and to be able that return; will work ? Or are there more common schemes ?Should I place this at the end of the <body> in the mail .html file or in the <head> part? Should I launch this code on something like DOMContentLoaded ?When zooming to much (using the zoom feature I provide with mousewheel or double-click or PGUP/DOWN etc.) with Chrome (for example when a single letter uses full browser height, i.e. the text is really big), then panning (with CLICK+DRAG ) is really slow. It is not true at all on Firefox, not on IE. What could be the reason (and solution) for this slowness with Chrome only?Are there some other obvious improvements? I taught myself JavaScript (but with help of SO questions/answers of course), so there are surely some bad coding habits in my code, right?Code for panning (a little bit shortened, see the project's page for real code) dragging = false; bpContainer.onmousedown = function(e) { dragging = true; previous_mouse = {x: e.pageX, y: e.pageY}; } window.onmouseup = function() { dragging = false; } bpContainer.ondragstart = function(e) { e.preventDefault(); } bpContainer.onmousemove = function(e) { if (dragging) { bp.style.transitionDuration = 0s; bp.x += e.pageX - previous_mouse.x; bp.y += e.pageY - previous_mouse.y; bp.style.left = bp.x + 'px'; bp.style.top = bp.y + 'px'; current.x -= (e.pageX - previous_mouse.x) * current.zoom; current.y -= (e.pageY - previous_mouse.y) * current.zoom; previous_mouse = {x: e.pageX, y: e.pageY}; } } | Improving the BigPicture | javascript;library | null |
_webmaster.78404 | My WordPress blog is completely cloned. That clone site is updating in real time with my blog. I am surprised that someone can actually do that. What should I do to stop harmful impact in my search engine ranking? Is there any way to tell Google not to index that site? | Someone has cloned my WordPress blog, how do I prevent it from hurting SEO? | wordpress;scraper sites | null |
_unix.75786 | Normally dot files are not included for wildcard expansion:% echo *Applications Desktop Documents Downloads Library Movies Music Pictures Public binIf I explicitly ask for dot files, I get them:% echo * .*Applications Desktop Documents Downloads Library Movies Music Pictures Public bin . .. .CFUserTextEncoding .DS_Store .Trash .adobe .bash_history .cups .gitconfig .gnupg .history .lesshst .netbeans .scanview.cfg .sqlite_history .ssh .swt .systemmodeler .tcshrc .viminfoHowever I also get . and ... I don't want those, for example if I'm passing to du -s where I want the size of every item in the directory. Is there some pattern that gives me just what's in the current directory, and everything in the current directory without . and ..?I use tcsh.(With regard to the This question may already have an answer here: note above: no this question doesn't have an answer there, since that answer only works for bash.) | How do I specify arguments to return all dot files, but not . and ..? | shell;tcsh;csh;dot files | With tcsh 6.17.01 and above:set globdotdu -s -- *With older ones:du -s -- * .[^.]* ..?*(interestingly, that works better than its POSIX counterpart (* .[!.]* ..?*) because in tcsh (and in zsh in csh emulation (cshnullglob option)), contrary to POSIX shells, those pattern that don't match any file get expanded to nothing instead of themselves)With standard find:find . ! -name . -prune -exec du -s {} +Note that GNU du has a -d option to limit the depth at which dir disk usage are reported:du -ad1 |
_unix.296926 | I am facing an issue in my project.We support an App which is hosted on a unix server.Partners try to access the same from many regions. Now some users in an region say R are complaining about slowness and we have reason to believe that it might be due to a network issue which is at their end.What are some commands I can run in their system in their terminal through which I can prove to them that it is an network issue at their end? Also some commands which can prove to them that other web applications in the past few minutes have also taken a lot of time from their systems?I am very new to UNIX.Thanks in advance. | Network slowness | networking;command line;lag | Inherent limitationsThe issue could be variable (e.g. congested link to ISP or congestion within ISP). It could also be horrible (firewall or even anti-virus doing deep packet inspection); the tools below might not show any problem at all. They're worth having, but there is a limit to how much you can achieve just typing commands into a terminal.2 tests you should knowUse ping to measure round-trip latency to servers over ICMP/IP. You can also traceroute or tracepath to your server, and check how much round-trip latency there is to the first few hops. You're mainly trying to check for symptoms of bufferbloat, so be aware that only happens when the link is fully used! (latency under load measure).You can check available web download bandwidth (single-stream) just using wget or curl --remote-name to download a file. If you're uninspired I suggest downloading a Linux :-). Find the download link and use copy link location from the right-click menu. You probably don't have to let the download run to completion because it'll show the current download rate - use Control+C to cancel it. You could test a mirror in the same region as your server (this is potentially significant). I guess if you're considering the terminal, it's good to know wget exists. Personally I'd prefer to use http://testmy.net/mirror.That's basically it, from the information you've given. There's a caveat with one of the results from ping, which I've highlighted below.ping is excellent for initial testing. traceroute is an expert tool. I only suggest traceroute as a way to try and illustrate bufferbloat, if that's what ping seems to show... it may actually be better to use ping on the routers you see in traceroute.Low download rates as a direct cause can easily be over-estimated. Webapps don't need to serve much data to respond to user requests unless there are uncached images. E.g. unix.stackexchange.com is 75K and takes 0.2s to download at 4Mb/s. But it's easy to run a test, and provides a little data point to fit into the puzzle.How much packet (ping) loss is too much?Any noticeable packet loss rate can limit download rate, and particularly over trans-continental distances.Unfortunately the effect of loss on short transactions is a bit more complicated than that. It looks like a single loss probably won't cause more than 100% increase for transfers around ~20Kb. Unless the first packet from the server (or client) is dropped, in which case it won't recover until a full receive time out - 3 seconds.There's an issue/caveat when measuring loss, in that it could be affected by packet size. When measuring loss with ping, you should notice that it uses small packets by default. This is similar to the first packets from client and server (SYN / SYN-ACK respectively). Putting this together, if you see 5% loss when running ping $SERVER without options, you wouldn't expect a perfect experience using that web app. (I.e. out of 20 user actions, expect 1 of them to take 3 seconds before anything happens at all. It won't be mitigated by persistent connections given common web server configurations)You can check statistics for full-size packets e.g. ping -s 1400 on unix. In principle there could be yet more factors (prioritization at the router aka QoS) and what you specifically want are TCP retransmit details from the specific application, gathered from the kernel or a packet trace.Note that from an endpoint, it's very difficult to distinguish whether a link is congested, v.s. whether the link is physically unreliable. Packet loss is how routers tell TCP to slow down; more congested links will have more packet loss. I think the best you could expect is to identify (prove) a link with high packet loss, and ask someone with access for investigation or monitoring. |
_codereview.169044 | I have a simple task of creating a simple lotto game to practice python. I had some troubles with return of functions so i dropped few because of not understanding the scopes maybe.In my next version i want to try to make it fully in functions, and in the next version i want to do it in OOP principles.By posting this code I would like to hear maybe some suggestions where my logic was wrong and some PEP comments.Game rulesEach player is given 15 numbers, in increasing order. This is why i use sorted() on the lists of player and computer. Also there is a common list with numbers in it from 1 to 90.A random number is picked and removed from this list and printed to players. The player who has this number in his card crosses it out or skips its turn. This continues until either player or computer crosses out all his numbers, or for some strange reason they are out of numbers :) I think in other parts of the world it is also called BINGO but I might be wrong.import randomnumber_pool = list(range(1, 91))computer_card = random.sample(number_pool, 15)computer_card_sorted = sorted(computer_card)player_card = random.sample(number_pool, 15)player_card_sorted = sorted(player_card)def display_cards(): print(Computer card:\n) print(computer_card_sorted) print(====================================) print(Player card:\n) print(player_card_sorted)def lotto_choice(): choice = random.choice(number_pool) number_pool.remove(choice) return choicedef the_game(): while number_pool: choice = lotto_choice() print(The random lotto is: + str(choice)) display_cards() cross_number = input(Do you want to cross out a number) cross_number.lower() if cross_number == y: if choice in player_card_sorted: player_card_sorted.remove(choice) elif choice in computer_card_sorted: computer_card_sorted.remove(choice) if cross_number == n: if choice in computer_card_sorted: computer_card_sorted.remove(choice) else: continue else: if len(player_card_sorted) == 0: print(Congratulations Player ! You won) elif len(computer_card_sorted) == 0: print(The computer have won, too bad !) else: print(It is a tie you both ran out of numbers, very straange !)the_game() | A simple lotto game in Python | python;beginner;python 3.x;random | For your current purposes, the biggest problem is that you are relying on global variables exclusively. This makes it a lot tougher to understand, maintain, and debug your code. This question actually has some great answers that discuss why this can cause real problems in code:https://softwareengineering.stackexchange.com/questions/148108/why-is-global-state-so-evilAs a specific example, this bit of code had me confused for a few minutes:while number_pool:Because number_pool wasn't used anywhere in your while loop, and so I had no idea why this wasn't just an infinite loop. I eventually realized that it is getting modified inside the lotto_choice method which is called within the while loop. This is pretty much exactly why you don't want to use global state: if any bit of code can modify any variable anywhere, you can quickly lose track of who modifies what and when it happens, and bugs can creep in very quickly. You also will have your own trouble if you come back to the code after a while and find that you no longer remember exactly what gets modified by what functions.So, always make sure and keep input into functions and output out of functions clear. In the case of lotto_choice you could easily do something like this:def lotto_choice( number_pool ): choice = random.choice(number_pool) number_pool.remove(choice) return ( choice, number_pool )Then you would call it like this inside your while loop:( choice, number_pool ) = lotto_choice( number_pool )Now you can easily see where number_pool gets modified. Since you are just now getting started, now is the time to establish good habits. So take the time and understand how variable scope works and (especially in a learning exercise like this) make sure not to use any global state. My biggest suggestion is to fix that and then post a new code review question with your updated code.Also, small change. You want to only execute your game if called in the 'main' context, like this:if __name__ == '__main__': the_game() |
_softwareengineering.85177 | I currently use one controller per action. One of the problemssort ofI encountered is when naming the methods of these controllers, which only have one.Should I use a generic method name like get() or should I encapsulate all my controllers into one and name its methods after the action they do, e.g. indexAction(), userListAction()? | Naming controllers and their methods | php;mvc;naming | I like the Ruby on Rails RESTful routes convention: each controller represents a resource (a noun), and there are 7 conventional actions:Note that resources don't have to map directly to models/database tables - for e.g. password reset, you may create a password_reset resource to request a new password, and update it to set the new password, even though behind the scenes, it only modifies your user model. |
_unix.126071 | If we install the Red Hat System then can we compile the other distros of linux on the Red Hat server system? If so, please provide me the tutorials and links. | Do I compile Ubuntu Source code on Red Hat System? | linux;ubuntu;rhel;compiling | First If by that you mean creating a custom Ubuntu or other distros yes you can and this action is not entirely distro-specific (i.e in your case Redhat).For that you could use two diffrerent approaches. Either use automation tools such as linuxcoe and other different tools or go native and start by LFS (Linux From Scratch). Either way you have three things to consider:Your kernel Your GUIYou distribution system Build your own distroFor the third option you could use other distros tools also (or write your own)Or you meant to compile codes for other platforms which is something else and has more to do with your make and build environment and coding skills (writing config files for example). you code do it in Jail env. or Virtual machine if you like.Or perhaps you meant to access other distros inside a running RedHat.In this case what you should consider the most is the arch of the Host and target system.This could be done by chrooting. Consider that you have the live image of some distro in /mnt/distro.first you should mount your /proc , /dev and /sys Then chroot to /mnt/distro.mount -t proc proc /mnt/distro/procmount --rbind /sys /mnt/distro/sysmount --rbind /dev /mnt/distro/devThen for chrooting part you need to specify your environment completely to avoid problems in future.chroot /mnt/distro /bin/env -i TERM=$TERM /bin/bash Note: It is the base idea and the path and env would be different in your case |
_scicomp.20933 | How to find $C$ such that $CC^T = AA^T + BB^T$, $A$ and $B$ are known.$A = \left(\begin{matrix}X\\Y\end{matrix}\right)$, $B = \left(\begin{matrix}0\\cY\end{matrix}\right)$, $c$ is a constant.To clarify. Cholesky decomposition can give the solution. I was wondering is there any closed form solution? | How to find closed form $C$ such that $CC^T = AA^T + BB^T$ | matrix | null |
_codereview.116563 | I am doing a lot of stuff with JavaScript and jQuery lately, but am not heading for clean code too much, as I am usually writing userscripts or small applications for myself.Recently, a community I am part of announced that it will change their supported BB-Codes, as the tabmenu BB-Code had a possible safety issue. By now, hundreds of posts have been done with tabmenus and a lot of users were complaining that editing all these posts will take forever.As I am a guy who likes to automate as much stuff as possible, I took the task and developed a small application that changes posts with the tabmenu BB-Code into a format that is supported by the forum.Here are two examples of what the application does:Original BB-Code:[tabmenu][tab=Tab1]Tab1 Text[tab=Tab2]Tab2 Text[/tabmenu]Note: tabmenu has a closing tag, tab does not and will contain all text until the next tab or until the closing [/tabmenu].Result:[h]Tab1[/h]Tab1 Text[h]Tab2[/h]Tab2 Texth turn into headlines, just as in HTML and force a linebreak.As the tabmenu does not only support tabs, but also subtabs, here is the second example:Original BB-Code:[tabmenu][tab=Tab1][subtab=Subtab11]Subtab11 Text[subtab=Subtab12]Subtab12 Text[tab=Tab2][subtab=Subtab21]Subtab21 Text[/tabmenu]Note: If you have subtabs in you tabmenu, you can't write text into tab areas. Apart from that subtabs behave like tabs when getting their content.Result:[h]Tab1[/h][spoiler=Subtab11]Subtab11 Text[/spoiler][spoiler=Subtab12]Subtab12 Text[/spoiler][h]Tab2[/h][spoiler=Subtab21]Subtab21 Text[/spoiler]tabs are still being replaced with h. The behavior for subtabs is a bit different though. Here my application is taking the title from the subtab, turning it into a spoiler-Tag (not comparable with the spoiler-codes of Stack Exchange, the spoiler-BB-Code is more like an accordion) and placing the content of the subtab between the opening spoiler-Tag and the closing one.$(function () { $('#buttonGenerate').on('click', function () { // The format of titles can be like this: [tab=Title], [tab=Title] & [tab='Title'] // the user can choose the format with this checkbox var bbFormat = $('input[name=bbCodeFormat]:checked').val(); var titleTemplate; var regexTab; var regexSubTab; switch (bbFormat) { // Depending on which format was chosen, different regex patterns are used case '1': // Format: [tab=Title], allows certain special chars in the title regexTab = /\[tab=((\w|[ ,.\-;:_#'+*!$%&/()=?^])*)\]/g; regexSubTab = /\[subtab=((\w|[ ,.\-;:_#'+*!$%&/()=?^])*)\]((.|\s)+?((?=\[subtab)|(?=\[\/tabmenu)|(?=\[tab)))/g; titleTemplate = '###'; break; // Format: [tab=Title] allows any special chars in the title case '2': regexTab = /\[tab=((.| )*)\]/g; regexSubTab = /\[subtab=((.| )*)\]((.|\s)+?((?=\[subtab)|(?=\[\/tabmenu)|(?=\[tab)))/g; titleTemplate = '###'; break; // Format: [tab='Title'] allows any special chars in the title case '3': regexTab = /\[tab='((.| )*)'\]/g; regexSubTab = /\[subtab='((.| )*)'\]((.|\s)+?((?=\[subtab)|(?=\[\/tabmenu)|(?=\[tab)))/g; titleTemplate = '###'; break; } // Gather original BB-Code from textarea var input = $('#inputArea').val(); // Replace the tabmenu BB-Code via Regex input = input.replace(regexSubTab, '[spoiler=' + titleTemplate.replace('###', '$1') + ']$3[/spoiler]'); input = input.replace(regexTab, '[h]$1[/h]'); input = input.replace('[tabmenu]', '').replace('[/tabmenu]', ''); $('#outputArea').val(input.trim()); });}); | JavaScript BB-Code transformation | javascript;performance;jquery | Your code is good, but it could be improved:Using an enumIf you use an enum, you can avoid Magic Numbers in your switch statement: switch (bbFormat) { // Depending on which format was chosen, different regex patterns are used case '1':Whereas, doing:var BB_FORMAT_TYPES = { NoQuotes: 1, DoubleQuotes: 2, SingleQuotes: 3};with:switch (bbFormat) { case BB_FORMAT_TYPES.NoQuotes: break; case BB_FORMAT_TYPES.SingleQuotes: break; case BB_FORMAT_TYPES.DoubleQuotes: break;}However, using an enum is usually suited more for when the contents of each have different execution styles. In your case, it'd be better to move the code to an object, and have a single execution path referencing said object. var object = { 1: { regexTab: /\[tab=((\w|[ ,.\-;:_#'+*!$%&/()=?^])*)\]/g, regexSubTab: /\[subtab=((\w|[ ,.\-;:_#'+*!$%&/()=?^])*)\]((.|\s)+?((?=\[subtab)|(?=\[\/tabmenu)|(?=\[tab)))/g, titleTemplate: '###' }, 2: { regexTab: /\[tab=((.| )*)\]/g, regexSubTab: /\[subtab=((.| )*)\]((.|\s)+?((?=\[subtab)|(?=\[\/tabmenu)|(?=\[tab)))/g, titleTemplate: '###' }, 3: { regexTab: /\[tab='((.| )*)'\]/g, regexSubTab: /\[subtab='((.| )*)'\]((.|\s)+?((?=\[subtab)|(?=\[\/tabmenu)|(?=\[tab)))/g, titleTemplate: '###' } };Chaining:Instead of having the replace on each line, try using chaining: input = input.replace(regexSubTab, '[spoiler=' + titleTemplate.replace('###', '$1') + ']$3[/spoiler]'); .replace(regexTab, '[h]$1[/h]'); .replace('[tabmenu]', '') .replace('[/tabmenu]', '');that way you can avoid looking up and writing to the input variable each time. |
_codereview.152637 | I have the following function that takes out the rotation values from a css string and returns them as an array.var extractRotationValues = function(code) { var getAllIndexes = function(arr, val) { var indexes = [], i = -1; //To understand the second parameter of indexOf function //have a look at this : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf while ((i = arr.indexOf(val, i + 1)) != -1) { indexes.push(i); } return indexes; }; var indexes = []; var closingIndexes = getAllIndexes(code, )) var values = []; var rindexes = []; rindexes.push(code.indexOf(X(), code.indexOf(Y(), code.indexOf(Z()); //No value for rotateX was found so consider it 0 if (rindexes[0] == -1) values.unshift(0); else { //We have a value for rotateX //Where does rotateX start from => rindexes[0] //Where does it end? =>closingIndexes[0] var value = code.substr(rindexes[0], closingIndexes[0]).split(()[1].split(deg))[0]; values.push(value) } //No value for rotateY if (rindexes[1] == -1) values.splice(1, 0, 0); else { //We have a value for rotateY //Where does rotateY start from => rindexes[1] //Where does it end? =>closingIndexes[1] values.push(code.substr(rindexes[1], closingIndexes[1]).split(()[1].split(deg))[0]) } //No value for rotateZ if (rindexes[2] == -1) values.splice(2, 0, 0); else { //We have a value for rotateZ //Where does rotateZ start from => rindexes[2] //Where does it end? =>closingIndexes[2] var zvalue = code.substr(rindexes[2], closingIndexes[2]).split(()[1].split(deg))[0] values.push(zvalue); } return values;};console.log(extractRotationValues(rotateX(90deg) rotateY(87deg) rotateZ(22deg)))I was wondering.Is there anything that can be done in a better way here or something to improve? | Extract rotation values from css string Javascript | javascript;css | First: A little regexp will do ya just as well, I'd imagine. Something like:function extractRotationValues(string) { var values = {x: 0, y: 0, z: 0}; string.replace(/\brotate([XYZ])\s*\(\s*([+-]?[\d.]+)\s*deg\s*\)/g, function (_, axis, value) { values[axis.toLowerCase()] = parseFloat(value); }); return values;}Note that this does a couple of things differently:parses the string values into Number valuesreturns an object with x, y, and z properties rather than an array (just because I feel that that's more useful - it can be made to return an array, though)Basically it looks for rotate[name of axis]([a number]deg) (while skipping over possible whitespace - the \s* stuff - that might be in the string) and captures the axis name and number. Despite the use of replace nothing's actually replaced (or rather we don't care about replacing things). It's just that String.replace takes a function as its 2nd argument, which gets passed the matched/captured substrings, which sort of turns replace into a scan-like function.Anyway, that's what I'd do. Not saying it's bulletproof (spent a minute writing it, and robustly matching a number can be more complicated), but it's certainly less code.Your code works too, of course, though the lower-level approach of finding indices and slicing and dicing strings is less elegant in my eyes. But it's a valid approach nonetheless.There are however a few things I want to comment on:I'd encourage you to always use strict equals (=== and !==). Just because it's a good habit to get into.closingIndexes is a nice descriptive name by itself, but it gets confusing when you also have rindexes where you've abbreviated, and just plain indexes (which isn't actually used). I'd give all of them equally descriptive names, instead of having one that's descriptive, one that's slightly cryptic, and one that's generic. (I also tend to favor indices for the plural form, but indexes is correct English too.)Why are default zero values inserted into the array in a different way than extracted/found values? The found values you just insert with push, which makes a lot of sense. But when you want to insert 0 for x, y, or z, you use unshift or splice? Why not use push in all cases, as that's the simplest?I'd rather have a branch that determines the value to insert, and a common push(value) call after that, than branch the array-insertion itself, because in both cases you want to append some value. The branching should be about what to insert, because how and where to insert it is always the same.Incidentally, if you find a value, you insert it as a string. If you don't find one, you insert zero as a number. Don't mix types like that; keep it consistent. If you'd used null or undefined instead of zero to denote no value, that'd be fine, but here you're essentially making up a rotation that's not present in the CSS string, so it's not no value, it's fallback value. And thus it should be the same type as a non-fallback value and vice-versa.Your code can stumble on malformed CSS. E.g. rotateX(42deg rotateY(23deg) (note the missing closing parenthesis) won't be parsed right. It'll find 42deg rotateY as the value for x-axis rotation, which you might say is better than nothing. However, the CSS was malformed, so technically speaking there is no x-axis rotation; nothing would actually be better.Most importantly: Why write 3 separate if-else blocks when all that changes in them is an index? That's what loops are for. Write a regular for loop, or call forEach on rindexes, e.g.:rindexes.forEach(function (rindex, i) { var value = 0; if(rindex !== -1) { value = code.substr(rindex, closingIndexes[i]).split(()[1].split(deg))[0]; } values.push(value);}); |
_webapps.6267 | Is there a way to clear the list of recently watched movies on Netflix? | How can I clear my Netflix recently watched movies list? | netflix | There is no way to do this currently.I was trying to find an official statement about it, which I'm pretty sure exists since I remember reading about it a while ago, but it seems that the Netflix help has changed and it's hard to find what you are looking for.A simple search reveals a bunch of threads asking for this same feature. |
_codereview.174025 | Problem is to calculate median of numbers. My idea is :Fill array of integer with numbers using Arraymake() function copy the address into a pointer created in main() functionpass that array to Median() function and calculate that median Code: #include <stdio.h> #include <stdlib.h> int* Arraymake(size_t);//Function for creating array of numbers. void Median(size_t ,int* );//Function for calculate the median. int main(int argc, char **argv) { size_t count;//Size of the list of numbers. puts(Size of the list:); scanf(%Iu,&count); int *ArResult=Arraymake(count);//Result of the first function Median(count,ArResult); free(ArResult); return 0; } int* Arraymake(size_t ln) //ln~lenght { int* Array=(int*) malloc(ln*sizeof(int)); int number ,i; //numbers filling the array puts(Please input numbers.\n); for(i=0;i<(ln);i++) { scanf(%i, &number); Array[i]=number; } return Array; } void Median(size_t ln,int* Array) { float median; if((ln)%2==0) { median= (Array[(ln)/2]+Array[(ln/2 )-1] )/2; printf(%f,median); } else { median= Array[((ln-1)/2)]; printf(%f,median); }}I want to find a way to optimize my variables and make my code more self-documented? How can I improve my code? | Median of numbers stored in array | c;statistics | 1. Arraymake:Change the name to MakeArray as it makes more sense or name it MakeArrayFromInput to make it more descriptive to what it actually doesName the parameter length, as in : int* MakeArray(size_t length) - this is descriptive and you don't have to put the comment explaining what it doesName local variables in camelCase, so array instead of ArrayMatter of preference but consider declaring array as int *array instead of int* array - you won't forget that the variable itself is a pointer and you have to declare additional pointers in the same statement with *s - int *array, *anotherPointer;int number ,i; //numbers filling the array - comment is redundant and you don't have to declare i here, you can do it in the for - speaking of which:for(i=0;i<(ln);i++) can become for(int i = 0; i < length; i++) - parentheses over ln are redundant, you should use better spacing to make it more readable.2. Median:The same story with the parameter and naming, also pass the array first, then the length : void Median(int *array, size_t length)You don't have to declare the median variable before the ifParentheses in the if are redundant : if(length % 2 == 0)The calculation of the median in the case of an even number of elements is flawed - you do an integer division as both operands of / are ints - you'd have to make at least one of them a float e.g. like this median= (Array[(ln)/2]+Array[(ln/2 )-1] )/2.0; - see the 2.0 - this is a double literal, a floating-point number, not an intYou can shorten the calculation a bit by changing array[(length - 1) / 2]; to array[length / 2]; in the case of an odd number - the integer division will truncate the result into what you needThe function should do one thing - you're calculating the median and printing it in the same function. Consider making the function Median return the value of the median and print it somewhere elseThe function then should look more or less like this : float Median(int *array, size_t length){ if(length % 2 == 0) { float median = (array[length / 2] + array[length / 2 - 1]) / 2.0; return median; } else { float median = array[length / 2]; return median; //or just simply return array[length / 2]; }}Something more complex, the function can be greatly simplified by using the ternary operator ?: :float Median(int *array, size_t length){ return length % 2 == 0 ? (array[length / 2] + array[length / 2 - 1]) / 2.0 : array[length / 2];}However, this is just trivia and you should aim to make your code as readable as possible3. mainI think that all of the comments are redundant here, everything is self-documentingNaming : ArResult should be something descriptive and simple - the most simple way would be to name it just array Spacing in function parameters e.g.scanf(%Iu, &count); instead of scanf(%Iu,&count);4. General adviceWork on the spacing - try to put spaces between operands and operators as in if(length % 2 == 0), in places like for loops : for(int i = 0; i < length; i++) and in function parameters : scanf(%Iu, &count);Put comments before the thing they're describing, not at the end of the line - this way if you want to make it a multi-line comment you won't have problems and it's more readable that way e.g.like this://Function for creating array of numbers.int* MakeArray(size_t);//Function for calculating the median.int Median(int*, size_t);This is just an example - I think the function names are descriptive enough not to put comments there, they will clutter the view :int* MakeArray(size_t);int Median(int*, size_t);EDITWhat I didn't initially remember is that to calculate the median, you have to use a sorted array. You should probably do that separatelyint *array = MakeArray(count);qsort(array, count, sizeof(int), compare)float result = Median(count, array);The qsort is a function from stdlib.h. You have to also declare a function compare to use in it e.g.int compare(const void* a, const void* b){ int int_a = *((int*) a); int int_b = *((int*) b); if(int_a == int_b) return 0; else if (int_a < int_b) return -1; else return 1;}This is taken from https://stackoverflow.com/a/3893967/7931009 |
_webapps.37484 | In the iPad YouTube application there is a list of most viewed videos for the last week and for today.Is it possible to get the same list on the YouTube web interface? | Popular for the last week and today on youtube | youtube | Most viewed today and Charts. That should be all you need to know. |
_cs.39745 | https://cstheory.stackexchange.com/a/3627/32204Could someone explain to me why this reasoning is false. I don't understand it! To me this sounds plausible! | Subexponential algorithm for Np-complete problems | complexity theory;np complete;np | null |
_unix.370994 | I use echo xxx > /dev/ttySxxx to send command to tty. When I do this first time, I must set baut rate. After once, I needn't. So, where does the kernel keep the serial port config? | Where does the kernel keep the serial port config? | serial port | null |
_unix.204183 | I created a nice PS1 for bash with http://bashrcgenerator.com/, but something seems to go wrong. The terminal emulator shows me some random, characters which means that PS1 probably has a syntax error. The weird thing is that it will work after I edit it (with nano). If I add a space, remove it, save it, and run bash, it works fine. But when I log out and log in agai,n it's buggy and weird again. This is my .bashrc:## ~/.bashrc## If not running interactively, don't do anything[[ $- != *i* ]] && returnalias ls='ls --color=auto'#PS1='[\u@\h \W]\$ 'PS1=\[$(tput sgr0)\]\033[38;5;15m\033[38;5;14m\u\[$(tput sgr0)\]\033[38;5;15m\033[38;5;15m \[$(tput sgr0)\]\033[38;5;15m\033[38;5;10m\w\[$(tput sgr0)\]\033[38;5;15m\033[38;5;15m \\[$(tput sgr0)\]\033[38;5;15m\033[38;5;14m\\$\[$(tput sgr0)\]\033[38;5;15m\033[38;5;15m \[$(tput sgr0)\] | Bashrc PS1 error | bash;prompt;bashrc | I recommend just manually creating the prompt yourself. All you have to do is set up a few variables, and then your code for setting the prompt becomes readable. In my bashrc file, I have this:#Set variables for foreground colorsfgRed=$(tput setaf 1) ; fgGreen=$(tput setaf 2) ; fgBlue=$(tput setaf 4)fgMagenta=$(tput setaf 5) ; fgYellow=$(tput setaf 3) ; fgCyan=$(tput setaf 6)fgWhite=$(tput setaf 7) ; fgBlack=$(tput setaf 0)#Set variables for background colorsbgRed=$(tput setab 1) ; bgGreen=$(tput setab 2) ; bgBlue=$(tput setab 4)bgMagenta=$(tput setab 5) ; bgYellow=$(tput setab 3) ; bgCyan=$(tput setab 6)bgWhite=$(tput setab 7) ; bgBlack=$(tput setab 0)#Set variables for font weight and text decorationB=$(tput bold) ; U=$(tput smul) ; C=$(tput sgr0)#NOTE: ${C} clears the current formattingPS1=${B}${fgCyan}\u${C}@\h(bash): ${fgGreen}\w${C} > I'll bet you can tell at a quick glance what my prompt looks like. And that's the point; no fancy WYSIWYG editors are required.The reason I use tput is that it's supposed to be more portable. And as an added bonus, using tput makes it so that when you type echo $PS1 at the command prompt, it'll show you a formatted/colorized version of PS1.This doesn't exactly answer why yours isn't working. But if you set up your prompt like this, you will definitely be able to get rid of that pesky error. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.