id
stringlengths
5
27
question
stringlengths
19
69.9k
title
stringlengths
1
150
tags
stringlengths
1
118
accepted_answer
stringlengths
4
29.9k
_webapps.4196
I have a small ecommerce store, and we would like to offer a deal of the day, however our platform (http://smallbusiness.yahoo.com/) doesn't seem to offer anything like that. Is there a service that will plugin to our yahoo store, or any other ecommerce platform for that matter. Requirements:a. Allow us to post a Deal of the dayb. Provide inventory tracking, or limited number of salesc. They need to have some sort of url rewrite/customization so it can look/feel like our own store.
Is there an web application that will power a Woot like site for eCommerce business?
webapp rec;ecommerce
null
_datascience.22611
I am a relative beginner to machine learning and I am trying to train a neural network to play Yahtzee. Those who play Yahtzee will know that after you are done your turn, you must choose a section to place your score in. These are planned to be the outputs of my neural network, but at certain states of the game, some of the outputs will be invalid choices, as they would be illegal Yahtzee moves. What should I do to ensure that the invalid output is never chosen?
How to deal with invalid outputs from a neural network
neural network
null
_unix.205478
Today I need to check which lines of my files containing trailing whitespace. And I figured out a solution:grep -Enr --color \s+$ ./This works well except for those lines containing non-Unix newline characters.These newline characters will be considering valid match for \s.How to exclude them in OSX grep?
How to grep whitespace exclude new-line character?
grep
Assuming that you mean you don't want to match \r, you could just specify that you're after a tab or a space and nothing else:grep -P '[\t ]$' file Since you're on OSX, your grep won't have -P, so you could instead try:grep -E $'\t'| $ file Alternatively, you can use the POSIX character class:grep '[[:blank:]]$' fileAs explained in man wctype, the [[:blank:]] character class realizes the isblank(3) classification function and, as explained in man isblank, that is: isblank() checks for a blank character; that is, a space or a tab.Finally, you could also use another tool instead: sed -n '/[\t ]$/p' file perl -ne 'print if /[\t ]$/' file
_webapps.43788
I want to measure my power consumption. So once in a month I note my meter reading.So I got the following data:2012-12-01| 893.8| | |312013-01-05| 977.2|34|2.45|312013-02-01|1052.2|26|2.88|282013-03-06|1165.3|35|3.23|312013-04-07|1263.6|31|3.17|302013-05-03|1335.9|26|2.78|31Where...Date of readingkWhdays in between readingsdelta since last readingnumber of days of reading month.So I would like to compute the average over a month. Any Ideas how to do that?
Compute average over month when measurement is irregular
google spreadsheets
null
_cs.59847
PreliminaryAfter doing some searches of similar questions posted here and elsewhere, i feel like this is the right place to inquire about, now let's get through some boring main notations...A MiniMax tree is an arborescence structure generated by an AI role-playing game to simulate the opponent turns giving notes/scores to each of, and so each turn taken by the player itself, in order that a maximal value is chosen as the actual perfect step against the minimum value which represents the best step taken by the opponent.in the image above A is the player, B is the opponent, C4 is the best tack chosen using MiniMax.First thing which would cross your mind, when chosing B1=3, B2=5, is it necessay to visit all child-nodes of B3?, of course the computer wouldnt act stupid if you code it to not be stupid, then it will stop at C8 then breaks the process, why? well that is called Alpha-Beta pruning, it cuts the C9 subtree and all its successors within the subtree B3 because it wont searcg any lower value than 2 when it does consider the maximum for A which must be forcibly bigger than 5. The all process is illustrated below for wiki-joint model.After thinking a while, I have deduced the presence of a system of mathematical inequalities that allows finding a structure of positive number labeled tree-leafs forming a tree that generates a maximal number of branch-pruning.Look here in this example in french, let us assign this data-configuration to terminal leafs $\{6,7,1000,4,2000,3000\}$ , 4 nodes (3 leafs in two subtrees) of this tree arent visited because: $\begin{eqnarray} \left\{ \begin{aligned} 7\;>\;6\ \ (1\ branch\ =\ 1\ leaf)\\ 4\;<\;6\ (1\ node\ =\ 2\ leafs)\\ \end{aligned} \right.\end{eqnarray}$So as remarked that the inequality changes direction as long as we mount to higher levels of the tree.from that base, maximizing branch pruning can be achieved by assigning alternatively bigger than smaller values for specific ranges of leafs, regarding a symbolic binary tree as follow : | ---------------------- -------------- --------------- ---------- ---------- ---------- ------------ | | | | | | | | x0 x1 x2 x3 x4 x5 x7 x8As a beginning rule, opting for the maximum from the tree summit underlies the nature of values selected from the base, which is the maximum in this case, this gives a system of inequalities helping us to exclude maximum number of leafs from being visited.$\begin{eqnarray} \left\{ \begin{aligned}x_2\;>\;max(x_0,x_1)\ \ (1\ branch\ =\ 1\ leaf)\\ max(x_4,x_5)\;<\;max(x_0,x_1)\ (1\ node\ =\ 2\ leafs)\\ ...\end{aligned} \right.\end{eqnarray}$Number of leafs we excluded is $1+2$ , generalized to $(1+2^1)+(1+2^2)+....$ for binary trees defined in an infinite range of positive integers ]0,$\infty$[ (with duplication).The QuestionConsider that tree is also parsed counter-clockwise, and we want to maximize the unvisited leafs when we parse a n-ary tree both directions as an intersection of two unvisited sets , is there a way to figure out a general system of inequalities for that ? a closed form for the maximum in terms of $n$ the level of this tree ? a O(N) algorithm working along this ground to output a data-set of corresponding leafs?Right firstmost example of a trenary tree there was 3 cuts (1 of them is potential) at C5, C9 which results in 3 unvisited leafs (C5,C6,C9)Parsing same tree right-to-left results in 1 cut (C2) which means 2 unvisited leafs, the overall (intersection) is 0 (all nodes are visited)My progress:After diving quite deep into this tree, I could calculate the minimal number of survivng leafs from one of either both directions as:$U(0) = n $$U(1) = n+n-1$$U(k) = U(k-1)+(n-1)U(k-2)$Where : n is the degree of this complete and balanced graph, k is the depth.an illustration with a trenary graph, and system of inequality where the formula is bounded by:Number of visited leafs here:$U(0) = 3 $$U(1) = 3+1+1$$U(k) = U(k-1)+(2)U(k-2)$Considering both directions now, for graph degrees > 2, the minimal of surviving leafs are $2U(k)$ where they cant be intersected for trenary graphs or bigger, that means the unvisited leafs are $n^k-2U(k)$, I am still wondering what is the overall system of inequalities which generates these special configurations of integer leaf-labels.
Maximizing pruned branches in an alpha-beta tree
algorithms;optimization;artificial intelligence;trees
null
_codereview.42030
I wrote the following simple Perl script to read lines from stdin that are the output from a psql call that returns lines of the form key1 | key2 | long text field and create a separate output file for each line, whose name is key1_key2_NNN.txt, where NNN is just a counter to ensure unique file names.my $count = 0;while (<>) { if (/(.*)\|(.*)\|(.*)/) { $count++; my $outname = $1_$2_$count.txt; my $text = $3; $outname =~ s/\s+//g; my $outfile = new IO::File(> $outname); $outfile->print($text); }}This does the trick, but there are 2 things I'm not thrilled aboutI'd like to be able to do the $count++ inline while putting the incremented number into the string, but I'm not sure how to not just get 0++ plugged in (i.e. how to make it know that the ++ is a command and not part of the literal string).I don't like that I have to save $3 to another variable, but if I don't, it gets cleared out before I need it.Anyhow, any suggestions on making this a bit more slick?
Parsing psql output into multiple files
parsing;perl
I don't know if this is the complete script, but the absence of use strict; use warnings is pretty noticeable. Always use these as a basic safety net, no matter how small or simple your program.Your usage of the regex /(.*)\|(.*)\|(.*)/ can be improved in some ways:Don't use a regex to extract the data. Instead: my @cols = split /[|]/, $_, 3;. This really is the correct way to go, the following points however deal with normal regex usage.Some guides recommend putting special characters into a character class [|] instead of escaping them \|. It's my experience that this makes complicated regexes easier to read.Immediately after matching, assign the values of the captures to permanent variables. Otherwise, they could be modified by a subroutine you call the next match can clear those values. Note also that ways exist to booby trap such an innocent-looking operation like incrementing an integer to clear the last match.So we either write code such as:if (/(.*)[|](.*)[|](.*)/) { my @fields = ($1, $2, $3); ...}or we don't use the capture variables at all, and use the regex in list context instead:if (my @fields = /(.*)[|](.*)[|](.*)/) { ... }Technically, this isn't absolutely equivalent (e.g. in case you aren't using any captures, or if some captures are conditional, or ), but it's far better style.If course, you'd assign to a list of names rather than an array:my ($name_a, $name_b, $text) = ...The substitution s/\s+//g might be considered slightly silly, as it's equivalent to s/\s//g. The former variant has the advantage of less substitution operations, so it might actually be preferable. But why are you sanitizing the $outname rather than the parts of which it's made up? Note that you can apply a substitution to multiple variables like s/\s+//g for $x, $y;If you don't want to remove all space in those strings (remember that most filesystems can deal with spaces in filenames all right) but only at the start or beginning of the string, you might want to split with a different separator instead:split /\s*[|]\s*/, ...The expression $1_$2_$count.txt does not contain a bug, but this is accidental. For example, $foo_$bar is equivalent to $foo_ . $bar underscores can be part of variable names, but variables can't start with numbers, so the problem isn't visible here (variable names can consist solely of numbers, and all such variables are reserved for capture groups).As a fix, use curly braces to delimit the variable names: ${1}_${2}_$count.txt, or use sprintf:sprintf '%s_%s_%d.txt', $1, $2, $countThe line my $outfile = new IO::File(> $outname); is a big no-no for two reasons:Don't use the indirect object notation method $object @arglist. Instead use $object->method(@arglist). The former variant may look nicer, but is often ambiguous, has rather confusing precedence, and widely considered to be a syntactic mistake.If you need help to get rid of that habit, you may enjoy the no indirect pragma.What you're doing is basically open my $outfile, > $outname. Use the three-argument form of open:open my $outfile, >, $outnameor in the object-oriented wrapper: IO::File->new($outname, '>').The next problem here is that you aren't doing any error handling! Check the return value of the constructor to assert that you could actually open the file. Well, calling a method on an undefined value will die, but checking manually allows you to output a sensible error message.The $outfile->print($text) would usually be written print { $outfile } $text. For one thing, the object-oriented interface to file handles is used very rarely. You can use the normal interface directly. Also, you are unnecessarily stringifying the $text. If it isn't already a string, that will be managed by print. Note that explicit stringification creates a copy of that value, something which you would usually (but not always) want to avoid.Then, you are using print, not say. This means (together with the fact that in a regex, . does not match newlines), that you won't end your output to the file with a newline. This is probably an oversight.Another aspect that just came to my mind is that your input file could contain slashes, allowing a filename like /you/were/pwned/_key2_1234.txt to be created (assuming the path already exists). Let's put in a bit of validation.The script now looks like:use strict;use warnings;use autodie; # easier than explicit, manual error handlinguse feature qw/say/; # say is like print, but appends newlinemy $count = 0;while (my $line = <>) { chomp $line; my ($name_a, $name_b, $text) = split /[|]/, $line, 3 or next; for ($name_a, $name_b) { s/\s+//g; die qq(The first two columns in $line may not contain slashes) if m[/]; } my $filename = sprintf '%s_%s_%d.txt', $name_a, $name_b, ++$count; open my $fh, >, $filename; say { $fh } $text;}How did this solve your problems?Use sprintf to format a string with a variable you want to increment at the same timeAssigning captures to variables is a best practice, and should always be done.As 200_success mentioned, it is rather suspect that you are using a command-line tool to interface with a database. Perl has the excellent DBI modules which provides a common frontend for various SQL databases. The docs have some simple examples which should get you rapidly started. Using such a module is safer (less escaping levels) and faster (no extra process, no tempfiles, prepared statements, ). Have fun exploring all the great DBI features!
_unix.335995
I've googled to see if Spotify is available for Fedora 25 and it is. What I to know is whether Fedora's version is the same as the official latest version released for Ubuntu? Is it maintained?
Is the latest version of Spotify linux version available on Fedora 25?
fedora;software installation
Currenlty, latest version in PPA provided by Spotify is 1:1.0.44.100.ga60c0ce1-29 (2016-12-15).The Spotify client I am running on my Fedora 25 (from negativo17.org) is $ rpm -q spotify-clientspotify-client-1.0-5.fc25.x86_64therefore the release does not look like the last one, but investigating the changelog:$ rpm -q --changelog spotify-client | head* Wed Dec 21 2016 Simone Caronni <[email protected]> - 1:1.0-5- Update to 1.0.45.186.g3b5036d6.you can notice the version is even newer (1.0.45.186.g3b5036d6, 2016-12-21) than the one in Ubuntu.
_unix.143764
Whenever I ping on my personal computer, nothing gets displayed other than a single statement.Upon stopping execution, I see that several packets were transmitted in the statistics. On top of all this, I'm getting a rather absurd packet loss.What can I do to make ping react in a sane manner?I am running Centos 6.5 64bit.Below is an example output when I try ping google.com:[root@Virus os]# ping google.comPING google.com (74.125.230.160) 56(84) bytes of data.^C--- google.com ping statistics ---5 packets transmitted, 0 received, 100% packet loss, time 4274msifconfig -a:[root@Virus os]# ifconfig -aeth0 Link encap:Ethernet HWaddr B4:B5:2F:29:FE:D7 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:108 errors:0 dropped:0 overruns:0 frame:0 TX packets:108 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:9081 (8.8 KiB) TX bytes:9081 (8.8 KiB)wlan0 Link encap:Ethernet HWaddr 84:4B:F5:14:9B:58 inet addr:172.20.40.55 Bcast:172.20.255.255 Mask:255.255.0.0 inet6 addr: fe80::864b:f5ff:fe14:9b58/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:56944 errors:0 dropped:0 overruns:0 frame:0 TX packets:40200 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:55308863 (52.7 MiB) TX bytes:6291284 (5.9 MiB)iptables -L:[root@Virus www]# iptables -LChain INPUT (policy ACCEPT)target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)target prot opt source destination netstat -nr:[root@Virus www]# netstat -nrKernel IP routing tableDestination Gateway Genmask Flags MSS Window irtt Iface172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlan00.0.0.0 172.20.4.254 0.0.0.0 UG 0 0 0 wlan0
Ping command results in packet loss
networking;centos;ping
null
_unix.381255
I have a fresh install of Raspbian on a raspberry pi 3. It boots fine, and I am able to perform any function that I can think of with one exception: any attempt to install or remove a package results in the error Files list file for package 'qdbus' is missing final newline. Indeed the file at /var/lib/dpkg/info/qdbus.list is full of garbage. What I tried so far:Adding a newline to the file. $sudo apt-get clean - did nothing. Delete qdbus.list - a different file is indicated as corrupted, I got as far as deleting about 25 files before things like ssh stopped working and I had to re-install the OS. Reinstall the OS from a fresh, hash-checked download of the latest version$sudo dpkg --configure -a - did nothing.Any help would be appreciated.
Files list file for package 'qdbus' is missing final newline (Raspbian)
apt;raspbian;dpkg
I have encountered same problem. And I solved this by downgrading raspbian jessie.http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-06-23/Remove your current version probably raspbian-2017-07-05/ and downgrade to raspbian-2017-06-23/. It will require a lot more time to update and upgrade packages but works fine for me.
_webapps.97324
I'm wondering is there a way to filter YouTube videos from the band that I don't want to see? I know how to exclude channel, YouTube is giving option for that, but is there a way to exclude whole music from one band on YouTube?
Is there a way to exclude YouTube videos from specific band?
youtube;youtube playlist;youtube watch later
null
_scicomp.21529
I have:1) The dark image with few groups of high-brightness pixels and some amount of noise around it.2) Number of clusters.Example:1) 2) 2 clustersAnd i need find centers of bright pixel groups.Centers, in that case, should be placed like this:Question: Which clustering alghoritm is suitable for this task?
Clustering pixel clots
clustering
If the number of clusters is known (like here)You may use Lloyd's clustering [1]The idea is as follows:it optimizes a set of cluster centers $p_i$:Initialize the p_i's with an initial guess, or randomlyFor each iteration: Compute the cluster associated with each p_i, (the cluster is the set of points nearer to p_i than to the other p_j's) Move each p_i to the weighted centroid of its clusterFor an image, the iteration can be implented as follows, computing the mass m_i and the centroid g_i of each cluster:For each i m_i = 0 g_i = (0,0)For each pixel (x,y) of the image let i denote the index of the center p_i nearest to (x,y) m_i = m_i + pixel_intensity(x,y) g_i = g_i + pixel_intensity(x,y) * (x,y)For each i p_i = (1/m_i)*g_iSince the number of clusters is small, you can find the nearest p_i using a simple loop. If you have a higher number of sites, you may either use a kd-tree, or compute the Voronoi diagram of the sites and iterate on the pixels of each Voronoi cell.I used this algorithm to cluster the colors of a rubics cube acquired by a lego color sensor, and it works reasonably well while being very easy to implement [3]If the number of clusters is unknownthen the problem is much more difficult.You may use mean shift clustering [2], that will apply a filter-like operation to the image, and make the modes appear. It acts like the inverse of a smoothing filter. [1] https://en.wikipedia.org/wiki/Lloyd%27s_algorithm[2] https://en.wikipedia.org/wiki/Mean_shift[3] http://alice.loria.fr/WIKI/index.php/Graphite/Lego
_unix.46474
I want to disable VSync (it's called Sync to VBlank in nvidia-settings) for my nvidia graphics card. But the configuration only takes effect if I start the nvidia-settings tool. After rebooting the system VSync is enabled again and I have to start the program again.I tried exporting the xorg.conf and putting it in /etc/X11/ but with no success.So my question is how can I make changes in the nvidia-settings tool persistent?
How to make changes in nvidia-settings tool persistent
arch linux;configuration;graphics;nvidia
Looking into the readme indeed helps sometimes :)This behaviour is intentional to give different users the chance to have their own settings.In short the nvidia-settings config file is stored in ~/.nvidia-settings-rc and can be executed by calling nvidia-settings --load-config-only at startup.For more details, here's the relevant part of the readme:4) Loading Settings AutomaticallyThe NVIDIA X driver does not preserve values set with nvidia-settings between runs of the X server (or even between logging in and logging out of X, with xdm, gdm, or kdm). This is intentional, because different users may have different preferences, thus these settings are stored on a per user basis in a configuration file stored in the users home directory.The configuration file is named ~/.nvidia-settings-rc. You can specify a different configuration file name with the --config commandline option.After you have run nvidia-settings once and have generated a configuration file, you can then run:nvidia-settings --load-config-onlyat any time in the future to upload these settings to the X server again. For example, you might place the above command in your ~/.xinitrc file so that your settings are applied automatically when you log in to X.Your .xinitrc file, which controls what X applications should be started when you log into X (or startx), might look something like this:nvidia-settings --load-config-only & xterm & evilwmor:nvidia-settings --load-config-only & gnome-sessionIf you do not already have an ~/.xinitrc file, then chances are that xinit is using a system-wide xinitrc file. This system wide file is typically here:/etc/X11/xinit/xinitrcTo use it, but also have nvidia-settings upload your settings, you could create an ~/.xinitrc with the contents:nvidia-settings --load-config-only & . /etc/X11/xinit/xinitrcSystem administrators may choose to place the nvidia-settings load command directly in the system xinitrc script.Please see the xinit(1) manpage for further details of configuring your ~/.xinitrc file.
_unix.318401
Is there a way to actually execute results from a shell command, instead of using them as arguments to another command?For instance, I'd like to run '--version' on all executables in a folder, something like:ls /usr/bin/ | --versionI've found a way using find/exec:find /usr/ -name valgrind -exec {} --version \;But I'd like to do it with ls. I've search for over 45 minutes and can't find any help.
Execute stdout results
command line;exec
Try doing this :printf '%s\n' /usr/bin/* | while IFS= read -r cmd; do $cmd --version; done
_softwareengineering.229733
I've currently got a browser talking via an API to the server. API is scare quoted because the API really wouldn't support another user interface very well, because it consists of every call our UI happens to need, in the form it happens to need it, and nothing else. Which could be fine. However, we are starting to have calls along the lines of GetUserSummaryData, GetUserHisFriendsAndHisPurchases, GetUserAndHisPurchases, etc. Note that on the server a more reasonable fine-grained API is written, (and the current API calls just cause the server to wire those together) it's just that what is exposed to the UI matches exactly what it needs at that particular moment.The justification for the current approach is that going from I need those 6 things at the moment to I need to make 6 calls and put the data together has to happen somewhere, and if you do it on the server then the browser can make 1 course-grained call, vs. the alternative of either making 6 calls and taking a (significant) performance hit, or else figuring out some system of batching the 6 calls (including dealing with the issue of dependencies, possibly by having the call batching mechanism smart enough to say the 3rd parameter of call 2 should be this part of the JSON response object from call 1 and having the server understand that).Doing things on the server as we are does make it pretty much impossible to write another UI without making more customized views on the server to support it. But we have no reasonable current expectation that someone without access to the server would want to write another UI.Is continuing to make really customized views on the server as the only API the right approach, and if not what would be better?
Coarse-grained views on server vs fine-grained views assembled on client vs fine-grained views with batching
api design
null
_unix.375192
I need to check out DHCP lease time on OpenSUSE Leap 42.2, I tried these, but they didn't help:~> less /etc/dhclient.conf~> sudo less /var/lib/dhcp/dhclient.leases# ls -a /var/lib/NetworkManager/~> sudo ifconfig -aHow can I do that?I run the following command as suggested by @MariusMatutiae:linux-box:/var/log # grep -nriIl dhcYaST2/mkinitrd.logYaST2/macro_inst_initial.ycpYaST2/y2logzypp/historyaudit/audit.logpk_backend_zypp-1pk_backend_zyppzypper.logboot.logThen I do the following for each output file, but I couldn't find the lease time provided by DHCP.linux-box:/var/log # grep -E dhc YaST2/y2log
How to check out DHCP lease time on OpenSUSE provided by DHCP server
opensuse;dhcp
null
_unix.345190
I'm connecting to my Raspberry Pi using SSH as user mike. I use touch to create a file in a directory whose owner pi / users. Both mike and pi are in group users. The newly created file has owner pi / users. I would think it would be mike / users.$ ls -l ..total 4drwxrwxr-x 1 pi users 4096 Feb 12 15:03 parent_dir$ touch z$ ls -l z -rwxrwxr-x 1 pi users 0 Feb 12 15:03 zIs this expected behavior? Why isn't the owner mike / users?
Touch Creates File with Different Owner
permissions
null
_unix.388232
I'm using Linux+QT for my OS system.And here is what I'm facing the problem.My Lan IP address is 172.16.120.17 and my wifi IP address is 172.16.120.20.So I think they are in the same network segment.Then I going to ping the address by using eth0.And it works perfectly.But When I ping it with wlan0 like below command.ping -I wlan0 xxx.xxx.xxx.xxxI can't ping the address.After some testing, I find out that if I close down eth0 then wifi ping out as expect.(I'm doing with below command)ifconfig eth0 downIf wifi and lan are in the different network segment then wifi and lan both can ping out as expect.Why will this happened and how to fix it?Or this is the normal phenomenon?Thanks in Advanced!
How to work both wifi and Lan in the same network segment?
linux;wifi;lan
null
_unix.254444
I'm having a really weird problem after installing a new Blu-Ray/DVD drive last night into a SATA 3 port on my desktop. My installed Linux distribution (Ubuntu 12.04/elementary Luna/kernel 3.7.5) won't boot. It seems to hang after the modeset. I can get to recovery mode with the following kernel options: nomodeset recovery. A Fedora 23 MATE Live CD/DVD seems to hang right after finishing the initial bootup loading screen. I can get booted into a Clonezilla Live CD, but I can't get into either my installed Linux or a new Fedora.In the Clonezilla kernel log, I see that ata8.0 fails to initialize, saying that an IDENTIFY PACKET FAILED or something along those lines. This makes me think that either there's something wrong with the SATA port, the SATA cable, or the Blu-Ray/DVD reader device. Windows 7 on the same machine boots just fine and I can play DVDs in the device without issue. How can I debug what's actually going wrong so that I can fix it (perhaps with a kernel boot parameter)?
Installed Blu-Ray/DVD drive over SATA 3 link, no longer able to boot
linux;sata;blu ray
Answer found here:In my case, the motherboard is ASRock Z77 Extreme4 with the same ASMedia ASM1061 chip for two SATA3 ports. I had a DVD drive in one of them and got the error. Switched the DVD drive to a SATA port handled by the Z77 chip and everything works.Unfortunately, things that we often take for granted like SATA and USB don't always work as reliably as we think that they do.In my case, my motherboard has two different sets of SATA ports, one run by one type of SATA firmware, the other run by a different type of SATA firmware. Switching the drive from one set of ports to the other fixed my problem.On a related note, manufacturers of motherboards should really just choose the best chipset for the job and use that everywhere.
_unix.368761
I want to record down all write/change query except SELECT, I hope following script online but it doesn't contain timestamp, source and destination IP address, anyone have a better solution for this? tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e ' while(<>) { chomp; next if /^[^ ]+[ ]*$/; if(/^(UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) { if (defined $q) { print $q\n; } $q=$_; } else { $_ =~ s/^[ \t]+//; $q.= $_; }}'
tcpdump mysql query with timestamp, source and destination IP
perl;mysql;tcpdump
null
_opensource.5544
From Octave's FAQ, Code written using Octave's native plug-in interface (also known as a .oct file) necessarily links with Octave internals and is considered a derivative work of Octave and therefore must be released under terms that are compatible with the GPL....A program that embeds the Octave interpreter (e.g., by calling the octave_main function), or that calls functions from Octave's libraries (e.g., liboctinterp, liboctave, or libcruft) is considered a derivative work of Octave and therefore must be released under terms that are compatible with the GPL.Here, 'terms that are compatible with the GPL' appears repeatedly.At first, I thought that it can be any license in the list of GPL-compatible licenses.However, the part of ... is considered a derivative work of Octave and therefore must be released under terms that are compatible with the GPL confuses me.As far as I know, derivative work of GPLed one should follow GPL itself, not compatible one.What are 'terms that are compatible with the GPL'?
What does 'terms that are compatible with the GPL' mean?
licensing;gpl;license compatibility
This advice from the Octave project is in line with the GNU project's own FAQ:You have a GPL'ed program that I'd like to link with my code to build a proprietary program. Does the fact that I link with your program mean I have to GPL my program?Not exactly. It means you must release your program under a license compatible with the GPL (more precisely, compatible with one or more GPL versions accepted by all the rest of the code in the combination that you link). The combination itself is then available under those GPL versions.This FAQ item directly applies to your case, but doesn't fully answer your question by itself, so I'll explain further.The GPL imposes a particular set of requirements on the distribution of derivative works. Importantly, a few of those requirements include:downstream derivatives must, as a whole, be licensed under the GPLthe licensing terms of downstream derivatives may not impose any additional requirements beyond what is required by the GPLSo, your own creative work may be licensed under any terms that do not cause issue when they are upgraded to the terms of the GPL as part of the combined work (original GPL work + your work) that you distribute. In other words, you may license your work with terms that are a subset of the GPL terms.Visually, we can show how the terms of your work (left) combine with the GPL terms of the original work (middle) to create the combined terms (right):In the case where your works is licensed under a subset of GPL terms, there is no issue complying with the requirement that the combined work be licensed under GPL terms. Your work's terms are GPL-compatible. In the second case, where your work is licensed under terms that are not a subset of GPL terms, some rogue term(s) will exist in conflict with the GPL's requirement that the combined work be licensed under the GPL, which cannot include any additional non-GPL terms.
_webmaster.87537
I have added Schema Aggregate Rating Reviews to my site and I can confirm that Google's Rich Snippet Testing Tool has no issues with my code. After waiting some time Google has enabled review stars on all pages apart from the home page.Using Google's Site Search Command: site:http://www.example.com reveals:Question:How do I enable rich snippets on the homepage so Google displays review stars using Schema Aggregate Rating?
Homepage Rich Snippet Star Ratings not showing in Google SERP
google search;rich snippets;schema.org;homepage
Google Search doesnt seem to support Rich Snippets for homepages.This is currently not documented, but confirmed by the Google employee @methode (on SO):We (Google) don't accept rich snippets for homepages; rich snippet annotations should be placed on leaf pages.
_unix.370089
I am installing a program following instructionsWhat you need for a manual installation is the subdirectory MaTiSSe-vx.x.x under the release directory (chose the version x.x.x you want). Just copy this subdirectory and make a link to the wrapper script MaTiSSe.py where your environment can find it. I don't know how to make it with command line.
Make a link to the file so that enviroment can find it
software installation;symlink
I would interpret the instructions as create a link to the wrapper script in a place where it would be accessible through your $PATH.If your path contains something like/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/binI would create the link in, e.g., /usr/local/bin:ln -s /some/path/MaTiSSe-vx.x.x/wrapper-script /usr/local/bin/matisseAlternatively, just add the MaTiSSe-vx.x.x directory to your path in ~/.bash_profile or ~/.bashrc:PATH=$PATH:/some/path/MaTiSSe-vx.x.xand then use the name of the wrapper script on the command line.
_hardwarecs.2670
I am looking for a security camera that I can use to view what's going on in my apartment, without having to use a third party website/app. I am currently using one that requires me to connect to a website based in China, and I don't really trust the parent company not to snoop.
Security camera that doesn't use a third party
video camera;home security
null
_unix.362234
Booting on my Ubuntu 17.04 fails, and I want to debug it.The booting fails randomly and I believe it is due to a race condition.Can I ask systemd not to parallelized any tasks, so I can see if this causes the boot to fail predictably?
systemd: serialize boot
systemd;parallelism
null
_softwareengineering.185152
Context:I recently had to deal with a class file generated by XSD.exe. It was 3500 lines long with ridiculously-verbose class / variable names (think someRidiculouslyLongPrefixThenMaybeOneThingUniqueAtTheEnd - difficult to compare at a glance with someRidiculouslyLongPrefixThenMaybeOneOtherThingChanged) and annotations all over the place. Bottom line is it took me ages to work out what the heck was going on. I read it and thought I would never put my name next to something so... Un-clean.Question:1) Is it bad practice to mess with generated code (i.e. clean it).2) Would it be better practice to write a mapper to map the generated classes to my own nice, clean classes (which I could then get to work with, quite happily)?EDIT:Thanks for all the comments. If I was actually going to do anything interesting with it (i.e. if there were domain objects which were anything but transport objects) then I think I'd map them to 'cleaner' classes, which I'd have to do anyway to get any kind of functionality out of them. In this case the classes are effectively DTOs so perhaps it makes sense that the naming matches the corresponding elements. As stated, I don't need to touch it - just to call accessors / mutators before passing the data down to another layer for processing.For now, I think I'll leave them well alone.
Cleaning Up Generated Code: Refactor or Map?
refactoring;clean code
The danger with refactoring generated code to clearn and tidy it is that if it is regenerated again by the tool by yourself or another developer then the changes would be lost.Your team could get yourselves in a position where you would be generating the code in another file and copying it into the cleaned version and refactoring to apply changes which just takes time and resource. (I've been there with the original version of Entity Framework.)If you cannot live with the names generated, either change the source it generates from or do as you suggest in #2.
_unix.73945
I want to implement mutual authentication (two - way ) with apache web server.References : 1.Failed to sign CSR with the CA root key 2.Firefox error message when adding client certificate signed by CAafter many steps :Configuring Apache 2.0 SSL to accept https by editing ssl.conf .Creating a Certificate Authority using OpenSSL & importing it to the web browser [link]Creating a Web Server Certificate & sign it by CA & put it as apache certificate.[link]Creating a Client Certificate & sign it by CA & export it as PKCS#12 format [link]& import it to web browser I now have an access with https to the server but for all users . I want just the authorized users who I gave them a signed certificate by CA to access to web pages on my server . I needed to edit ssl.conf in /etc/httpd/conf.d/ssl.conffollowing this tutorial , I did this to ssl.conf :SSLVerifyClient requireSSLVerifyDepth 2Update#1 :and of course I had set the certificate to the signed one by CA :# Server Certificate:#SSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateFile /var/www/sslConf/server.crt# Server Private Key:#SSLCertificateKeyFile /etc/pki/tls/private/localhost.keySSLCertificateKeyFile /var/www/sslConf/server.keyand as a result I got this message and after pressing ok this message (in firefox). what's the mistake I had committed ?
Configuring Apache to Require a Client Certificate
authentication;apache httpd;certificates
Look into the Apache logs to see what is wrong. It looks like apache isn't able to verify the client certificate.Do you have the SSLCACertificateFile directive set correctly? This is necessarry, apache cannot verify certificate otherwise.
_cstheory.36247
In many textbooks the Chomsky-Schtzenberger enumeration theorem is stated as that the characteristic formal power series of a language is $\mathbb N$-algebraic, if the grammar is unambigious. In some other books the formulation is given, that the structure describing function $$f_L(x)=\sum_{n \in \mathbb N}l_nx^n$$ is algebraic over $\mathbb Q$ iff the grammar is unambigious, where $l_n = \vert \Sigma^n \cap L \vert$.I understand that by replacing every terminal by the same terminal in the system of equations associated with a grammar $G$ it is possible, to obtain the structure describing function, but I couldn't find a proof anywhere,(and don't know how I could construct one) that then the (analytical) power series $f_L(x)$ is not transcendental.
Chomsky Schtzenberger enumeration theorem
algebra;grammars
There is a proof in the book of Kuich & Salomaa, Semirings, Automata, Languages and another one in the paper of Panholzer, Grbner Bases and the Defining Polynomial of a Context-free Grammar Generating Function, J. of Automata, Languages and Combinatorics 10 (2005), 7997. I wish there were a simple and clear proof of the result.
_unix.118586
How is it ensured that Linux software-RAID superblock(for example version 1.2) can be created at 4KiB from the beginning of the drive? According to manual of mdadm it is. I mean isn't there a hazard that this area on the disk is already occupied for example by the GRUB2 stage 1.5?In addition, if software-RAID is created using partitions for examplelike this:mdadm --create --verbose --level=1 --metadata=1.2 --chunk=64 --raid-devices=2 /dev/md0 /dev/sdb1 /dev/sdc1..then how should one ensure that for example MBR/GPT is mirrored or bootloader data is mirrored which both are located outside of partitions?
Linux software-RAID and bootloader
mdadm;software raid
null
_unix.217440
I am trying to monitor a remote, embedded host that is writing output to a file: /var/log/myapp.logThis host may lose power for hours. The app may be killed and restarted.On my local machine, I want to capture the myapp.log contents in real-time as it gets updated.The basic script I have does this:ssh user@remote_host_ip 'tail -f /var/log/myapp.log' | tee -a ~/logs/myapp.logThis works for the simple case where the remote host is already up and can be SSH'd into. I would like something that will continuously try to SSH into the remote host over and over until it succeeds, and then run the tail -f ... command and capture the output locally. I want to avoid having to rerun this program if the remote host loses power.From what I have searched so far, it is sounding like I may want to use some combination of autossh and screen.I tried playing with the rscreen script included with autossh but have not had much luck. Here is the modified script, which takes another argument for the command to run on the remote host. I called the modified script rscreen_myapp:#!/bin/sh## MODIFIED (not working) sample script to use autossh to open up a remote screen# session, or reconnect to an existing one.## $Id: rscreen,v 1.4 2002/05/07 17:54:13 harding Exp $autossh -M 20004 -t $1 screen -e^Zz -D -R -X $2But when I run: ./rscreen_myapp remoteuser@remotehost tail -f /var/log/myapp.log, I get:Agent pid 28990Identity added: /home/localuser/.ssh/id_rsa (/home/localuser/.ssh/id_rsa)No screen session found.Connection to 10.10.3.9 closed.I am struggling with screen and admittedly confused by it... What am I doing wrong? Am I not using the -X argument properly? Or do I need to do something else altogether? Do I need to somehow make use of the screenlog.n files? (I would rather avoid the .n unique identifier and prefer just having myapp.log on the local machine.)Ultimately, this script/program would run automatically and in the background on my local machine. So as long as the local machine is on, it will try to capture/mirror the log from the remote machine whenever possible and indefinitely.
How to capture tail -f output from remote host indefinitely
ssh;logs;gnu screen;monitoring
null
_softwareengineering.243229
Among computer scientists and programmers, there's the common habit of naming people in the context of security protocols e.g. Alice, Bob or Eve. Descriptions of more elaborate attack vector sometimes refer to Charlie (as does this XKCD strip), but is there a convention for additional participants?
Naming in Security Protocols: Alice, Bob and Eve
security;naming;culture
Alice and Bob were the first two described in Applied Cryptography. These are two people communicating and used a placeholder names. Keeping with a convention makes it easier for people to remember what role they play in communication.Beyond Alice and Bob, the first letter of the name typically implies the role of the individual in the communication.C is sometimes a third person, but other times C is a Cracker.D is often a fourth person in communication.E can either be a fifth person, but often E has Evil intent. Eve in particular is an Eavedropper.F is a sixth person... and so on.M becomes a Malicious attacker (as opposed to Eve, who just wants to eavesdrop).O is an Opponent, similar to M, but not necessarily malicious.P needs to have something Proven and V needs to have something Verified.S is for Sybil which is a book about the treatment of a woman named Sybil Dorsett who had dissociative identity disorder. In the context of security names, Sybil is a particular type of attacker who uses many identities often in combination with a system that uses reputation.T is Trusted.W can either be a Warden who guards Alice and Bob or a Whistleblower with insider information.Further reading:Alice and Bob (Wikipedia)Metasyntatic variable (Wikipedia)Placeholder name (computing specific) (Wikipedia)
_codereview.115784
I'm using a method to make initialize the attributes of my objects, and this method is called from both constructor.What it does is, if no correct currency has been passed, choose by default.I'm just wondering if what I've done below is correct in terms of design.class Prix{ double valeur; string monnaie; public Prix(double valeur, string monnaie) { if (monnaie.Equals() || monnaie.Equals($)) { this.valeur = valeur; this.monnaie = monnaie; } else { defaultConstr(valeur); } } public Prix(double valeur) { defaultConstr(valeur); } private void defaultConstr(double valeur) { this.valeur = valeur; this.monnaie = ; }}
Constructors for a class to represent a price in or $
c#;constructor
You can invoke constructor overloads from each other as such:public Prix(double valeur, string monnaie)callspublic Prix(double valeur)by:public Prix(double valeur, string monnaie) : this(valeur)Therefore,You can simplify the exact same behaviour at least in terms of the final state as follows:class Prix{ double valeur; string monnaie = ; public Prix(double valeur, string monnaie) : this(valeur) { if (monnaie.Equals() || monnaie.Equals($)) { this.monnaie = monnaie; } } public Prix(double valeur) { this.valeur = valeur; }}EDIT 1:You also don't have to check and assign moannie if it is passed in as euro because it already has the value euro:class Prix{ double valeur; string monnaie = ; public Prix(double valeur, string monnaie) : this(valeur) { if (monnaie.Equals($)) { this.monnaie = monnaie; } } public Prix(double valeur) { this.valeur = valeur; }}
_webapps.39952
How can I move videos from one channel to another without re-uploading them?we are 5 friend and have 5 video channels in YouTube and after 6 years we detect some videos for another channel that should move them to another channels and total videos more than 1000 videos and videos must be move more that 100 ....Are there any tools (online) for managing YouTube channels in such a fashion?
Moving videos from a YouTube channel to another one without re-uploading them
youtube;file management
null
_softwareengineering.328187
I am trying test driven development for the first time (test first development, actually). I wrote down my specifications, then alternated writing tests, then code, writing the code to pass the latest test and not break prior tests. My code is doing input validation on a user-supplied file path:Does the path exist and is it a file?Is the file in a specific format?Does the file contain a specific field?Does the file have a feature where the field is set to a given value?This led me to write functions that return True/False for each condition, and tests for inputs leading to True and False outputs. However, there is some duplication between the functions (loading the file, etc.) and I could write a more streamlined function that combines all the checking. This is important in my case because the files can be large.Where I'm having issues:Do I also refactor the tests?If I have a single larger function that outputs True/False based on the sub-checks, how can I still test for the individual specific conditions?Should I instead raise Exceptions, and check that the correct exceptions are raised?
Modifying the tests and refactoring duplicate code in test driven development
unit testing;refactoring;tdd;exceptions
null
_softwareengineering.196361
I'm writing a program to automatically make the draw for a competition. There are four objects: Debate Judge School Team Each Debate has two teams and a judge. Each team participates in three debates. With this, there are the following rules: 1) A team cannot face someone from their same school 2) A team cannot face another team from the same other school (As in if they play a team from a school once, they cannot play again against someone from that school) 3) A judge cannot come from the same school as a team they are judging.So how would I create a draw? A draw looks like a table (I just need the data, but when you write it it looks like this) with a column for judges and then three other columns for each round of debates (the three debates each team participates in).Right now I'm basically choosing a random team, finding an opposing team that hasn't played the school of the first team before and doesn't come from the same school and then finding a judge from neither of those schools. Then I do the same thing until I have all the debates. The problem is the program sometimes gets into ruts where there is no other team/judge that fits. A human would then shift things around and try to find a way to move other judges around to figure it out, but how can I do that with a program. If I run the program again it figures it out just because it's random which teams it chooses for what. Basically, I'm wondering what the best solution is to the problem?
Best way to create draw with limitation
java;design;design patterns
I think you're close. The trick is to start with the first team ('first' can be defined any way you want, including random) and make a list of all the available other teams, in some order. Pair up the first team with the first of the available other teams. Now look make a list of the available judges (again in some order), and pick the first available judge.Repeat the above for the next set. At some point you won't have any second team to pick, or you'll be out of judges. At that point you need to backtrack - unwind one of your previous decisions and move on to the next.For example, when you select team A, your choices are (B and C). You select B and move on. Later you discover that B was an unfortunate choice, so you revisit that choice and select C instead.The idea is called Depth First Search. It's a lot easier than the Wikipedia page makes it out to be.I'd handle your challenge by assigning each team a random number then use that number for sorting them whenever I'm looking for the next available team or judge. That way you'd get your random pairings and a way to backtrack and unwind. (The goal is to correctly select the correct teams and judges in such an order that you get all the pairings you need, subject to the contest rules constraints).The only time you use Random() is when you're setting up the data. The algorithm shouldn't use it.
_computergraphics.5521
As a pet project, I'm trying to build a small app that visualizes 4D polytopes. I want to use the Wythoff Construction method, where the shape is generated kaleidoscopically by the interaction of 4 mirrors using a single movable generator vertex. I know how to create a reflection matrix from a hypersurface normal, what I am looking for is an simple way to generate all possible matrices generated by the interreflections of the set of mirrors.The brute force method would be something like:1: Create the initial set of mirrors and their matrices2: Reflect each matrix in each of the other mirrors, add to temp list3: Remove duplicates from temp list4: Add temp list to master list and remove duplicates5: Reflect each matrix in temp list through each mirror except its generating mirror and add to new temp list6: Repeat from step 3 with new temp list, continue until no non-duplicates foundThis method will work but will involve a huge amount of redundant computation generating, checking, and discarding duplicates, especially in symmetry groups like the 120-cell / 600-cell which contain thousands of permutations. Does anybody know of a more elegant method of creating the full set?
Finding all possible reflection matrices for a given Wythoff construction
algorithm;matrices;reflection;4d
null
_unix.207900
I use EduBOSS Linux 3.0. Since installation I still not update my OS. But I want to solve some Audio, Video and Graphics problems. To solve that problems I want update my BOSS Linux. sudo apt-get updateHit http://packages.bosslinux.in anokha Release.gpgHit http://packages.bosslinux.in eduboss-3.0 Release.gpgHit http://packages.bosslinux.in anokha Release Hit http://packages.bosslinux.in eduboss-3.0 Release Hit http://packages.bosslinux.in anokha/main Sources Hit http://packages.bosslinux.in anokha/contrib Sources Ign http://ppa.launchpad.net anokha Release.gpg Hit http://packages.bosslinux.in anokha/non-free SourcesHit http://packages.bosslinux.in anokha/main i386 Packages Hit http://packages.bosslinux.in anokha/contrib i386 Packages Hit http://packages.bosslinux.in anokha/non-free i386 Packages Ign http://ppa.launchpad.net anokha Release Hit http://packages.bosslinux.in eduboss-3.0/main Sources Hit http://packages.bosslinux.in eduboss-3.0/main i386 PackagesIgn http://packages.bosslinux.in anokha/contrib Translation-sa_IN Ign http://packages.bosslinux.in anokha/contrib Translation-sa Ign http://packages.bosslinux.in anokha/contrib Translation-enIgn http://packages.bosslinux.in anokha/main Translation-sa_IN Ign http://packages.bosslinux.in anokha/main Translation-sa Ign http://packages.bosslinux.in anokha/main Translation-enIgn http://packages.bosslinux.in anokha/non-free Translation-sa_INIgn http://packages.bosslinux.in anokha/non-free Translation-sa Ign http://packages.bosslinux.in anokha/non-free Translation-en Ign http://packages.bosslinux.in eduboss-3.0/main Translation-sa_IN Ign http://packages.bosslinux.in eduboss-3.0/main Translation-sa Ign http://packages.bosslinux.in eduboss-3.0/main Translation-en Err http://ppa.launchpad.net anokha/main Sources 404 Not FoundHit http://dl.google.com stable Release.gpg Hit http://dl.google.com stable ReleaseErr http://ppa.launchpad.net anokha/main i386 Packages 404 Not FoundHit http://dl.google.com stable/main i386 PackagesIgn http://ppa.launchpad.net anokha/main Translation-sa_INIgn http://ppa.launchpad.net anokha/main Translation-saIgn http://ppa.launchpad.net anokha/main Translation-enIgn http://dl.google.com stable/main Translation-sa_INIgn http://dl.google.com stable/main Translation-saIgn http://dl.google.com stable/main Translation-enW: Failed to fetch http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu/dists/anokha/main/source/Sources 404 Not FoundW: Failed to fetch http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu/dists/anokha/main/binary-i386/Packages 404 Not FoundE: Some index files failed to download. They have been ignored, or old ones used instead.How can I update BOSS Linux by terminal only?
How can I update or upgrade BOSS Linux by terminal?
debian;command line;terminal;upgrade;jboss
null
_unix.20216
Is it safe to interrupt (Ctrl-C) a long running xfs_fsr job?I'm attempting to defragment a very large XFS volume.
Is xfs_fsr safe to interrupt?
xfs
Like all filesystem manipulation tools, xfs_fsr takes care of leaving the filesystem in a consistent state, in case the machine crashes (due to a power failure, for example). Unless you're unlucky and encounter a bug, that is filesystem drivers are more complex than they look, especially as they are written for speed.If you interrupt xfs_fsr cleanly (with any of the usual signals SIGINT, SIGHUP, SIGTERM or SIGQUIT), it takes care to write where it left off in /var/tmp/.fsrlast (or the file indicated with the -f option). So you can safely interrupt it with Ctrl+C, and restart it again with the same options later to complete the job.
_webapps.107095
I don't know if there's any way to go about this but I've tried using =IMAGE() to show images of cells in a column that contain only hyperlinks of tracking numbers. I was hoping to make life easier for myself except this =IMAGE() makes the spreadsheet really cluttered. I was hoping to be able to similarly write something where you could roll your mouse over the hyperlink and have a temporary popup window show the hyperlink's contents; in this case, it would be the tracking number's contents shown. Is there any way to do this or is it impossible?
Google Sheets - Popup preview for Hyperlinks
google spreadsheets;google apps script
null
_unix.17810
Possible Duplicate:What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'? I was wondering what relations and differences are between computerterminal and virtual console/terminal?Quoted from WikipediaA computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system. Early terminals were inexpensive devices but very slow compared to punched cards or paper tape for input, but as the technology improved and video displays were introduced, terminals pushed these older forms of interaction from the industry. A related development was timesharing systems, which evolved in parallel and made up for any inefficiencies of the user's typing ability with the ability to support multiple users on the same machine, each at their own terminal.Quoted from wikipediaA virtual console (VC) also known as a virtual terminal (VT) is a conceptual combination of the keyboard and display for a computer user interface. It is a feature of some operating systems such as UnixWare, Linux, and BSD, in which the system console of the computer can be used to switch between multiple virtual consoles to access unrelated user interfaces. Virtual consoles date back at least to Xenix in the 1980s.I thought computer terminal to be the hardware device, and virtual console is part of OS. But after reading the articles, I now think they are the same thing as part of OS, and computer terminal cannot be independent of OS.From further discussion on the two articles, is it true that eitherof them can be divided into text terminal and graphical terminal?As I understand from the articles, Terminal emulator and virtual console/terminal are different. Virtual console is a broader concept, including both text terminal and graphical terminal. Terminal emulator is just someemulator of text terminal running under graphical terminal?
Computer terminal and virtual console
terminal;terminology
null
_unix.277977
My machine which OS is CentOS7 have to backup 50G data into MySQL. But, there is no space left on the device. But there are many spaces on /home. How can I make user that there are enough space for MySQL to store data. I think there is no space in /dev/mapper/centos-root, how can I move space to from /home to /.$ df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 50G 50G 20K 100% /devtmpfs 7.8G 0 7.8G 0% /devtmpfs 7.8G 84K 7.8G 1% /dev/shmtmpfs 7.8G 2.6G 5.2G 34% /runtmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/mapper/centos-home 500G 20G 480G 4% /home/dev/sda1 497M 241M 257M 49% /boottmpfs 1.6G 16K 1.6G 1% /run/user/42tmpfs 1.6G 0 1.6G 0% /run/user/0tmpfs 1.6G 4.0K 1.6G 1% /run/user/1000And g++ compile code failed.$ g++ test.cppCannot create temporary file in /tmp/: No space left on device[1] 6642 abort (core dumped) g++ test.cpp
No space left on device on CentOS7
centos;mysql;devices;block device;g++
null
_unix.218556
My hardware screen on my laptop turns white, when the console times out and blanks, upon idling.I would expect it to normally turn black or turn off the screen entirely.When clicking a button, the screen wakes up and presents the console as normal.There are no relevant BIOS settings.I am running Void Linux on an HP EliteBook 8530p laptop and I don't use a desktop environment, only console CLI, thus it's not a problem with X.Is it a setting that determines how the blanking works? Is it possible to change the behaviour of the blanking, so it turns off the screen until a key is pressed?If none of the above, can you point me in a direction where I can find out if it's a hardware error?
Console timeout blanks to white instead of black
linux;console;screensaver
null
_datascience.12673
Many have shown the effectiveness of using neural networks for modeling time series data, and described the transformations required and limitations of such an approach. R's forecast package even implements one approach to this in the nnetar function. Based on my reading, all of these approaches are for modeling a single outcome variable based on its past observations, but I'm having trouble finding a description of a neural-network-based approach that also incorporates independent predictor variables (a sort of ARIMAx analogue for neural networks). I've found references to Nonlinear autoregressive exogenous models (NARX), which seem like they should be what I'm looking for, but all the reading I've been able to find talks more about using this approach for multi-step-ahead prediction of a univariate series. Can anyone point me in the right direction on this? For bonus points, does anyone know of an implementation of what I'm looking for in R?
Neural Network Timeseries Modeling with Predictor Variables
r;neural network;time series
null
_unix.374442
BTRFS disk mounted like this: /dev/sdb /mnt/disk1 btrfs noexec,nofail,defaults,compress-force=lzo 0 0disk1 is shared via cifs with 640 permissions. I can't launch any application/script because permissions and noexec mount parameter but when I map this share in windows I can change permissions - right click on file -> preferences -> security tab and add executable permission and thats all right because I am the owner of changing file but I can't understand why from now I can launch exe file (windows app. will launch) on noexec btrfs filesystem ?Debian 9 with btrfs-progs 4.7
Debian filesystem permissions
permissions;filesystems;btrfs
The noexec flag only applies to the OS which is using that fstab entry to mount the relevant partition. Windows does not use fstab and indeed doesn't care about such flags.
_unix.296790
I'm configuring a VGA passthrough on Arch for a virtual Windows machine, and when I use lspci | grep Audio, I get two different devices with different PCI IDs. They look very similar, and I'm not sure which one to pass through. The output of the above command is this: 00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05). I don't know if it's arbitrary or if I have to pass a specific one through. Please help.
Not sure which audio device to pass through via OVMF
arch linux;audio;virtual machine;pci
null
_unix.266139
I'm running Ubuntu in virtual machine and what I've noticed is that the shortcuts to characters (like : ; ) are different than shortcuts used in windows. I'm guessing this has to do with OS (or is this just a VMWare thing?) so my question is if it's possible to remap them so I could be using the same shortcuts in Windows and Linux?
Different characters for some keyboard keys
keyboard layout
You most probably have set the wrong keyboard layout. See here to get started:https://askubuntu.com/questions/459617/keyboard-layout-isnt-kept-upon-reboothttps://askubuntu.com/questions/471849/change-keyboard-layout-permanently-in-xubuntu-14-04
_webapps.14603
Is there any way I can get all of the links associated with my j.mp account and arrange them so that the links with the most clicks are at the top?
Sort all my j.mp links by most clicked
url shortening;sorting
null
_unix.218539
I am trying to install a printer driver package (Canon Pixma MX437 cnijfilter-mx430series-3.70-1-deb) on my system running Debian 8.1 3.16.0-4-amd64 Jessie xfce. I get a dependency error that package libtiff4 is not installed:dpkg: dependency problems prevent configuration of cnijfilter-mx430series: cnijfilter-mx430series depends on libtiff4; however: Package libtiff4 is not installed.dpkg: error processing package cnijfilter-mx430series (--install): dependency problems - leaving unconfiguredErrors were encountered while processing: cnijfilter-mx430seriesWhere I can find this package?
Debian libtiff4
libraries;backports
null
_codereview.162958
I have an ASP.NET CORE API app and now I have an endpoint like:[HttpPost(receipt)][ValidateModel][SwaggerResponse(200, typeof(string))][SwaggerResponse(400, typeof(string))]public async Task<IActionResult> SendReceipt([FromBody] EmailDetails emailDetails){ try { var requestId = HttpContext.TraceIdentifier; var connectionId = HttpContext.Features.Get<IHttpConnectionFeature>().ConnectionId; await _emailSender.SendEmailAsync(emailDetails, requestId, connectionId); return Ok($The mail has been sent successfully.); } catch (Exception ex) { _logger.LogError(ex.Message); return BadRequest($Error sending email: {ex.Message}); }}While Model looks like:public class EmailDetails{ [Required] [EmailAddress(ErrorMessage = Invalid Email Address)] public string Email { get; set; } [Required] public string Subject { get; set; } [Required] public string Receipt { get; set; }}So for now as you can see I'm getting an image in Base64 encoded string and then I convert it to the image. Is it a good idea to get an image in that way? Maybe should I use some alternative solution?If you need any assistance, please let me know.
Send image between apps
c#;image;api;base64;asp.net core
null
_cs.13082
I'd like to reduce 3 colorability to SAT. I've stuffed up somewhere because I've shown it's equivalent to 2 SAT.Given some graph $G = (V,E)$ and three colors, red, blue, green. For every vertex $i$, let the boolean variable $i_r$ tell you whether the $i$-th vertex is red (or more precisely, that the $i$-th vertex is red when $i_r = 1$). Similarly, define $i_b$ and $i_g$.Suppose two vertices $i$ and $j$ were connected by an edge $e$. Consider the clause \begin{align} (\bar i_r \vee \bar j_r) \end{align} If we demand the clause is true, it means that the vertices cannot both be red at the same time. Now consider the bigger clause $\phi_e$ \begin{align} (\bar i_r \vee \bar j_r)\wedge(\bar i_b \vee \bar j_b)\wedge(\bar i_g \vee \bar j_g) \end{align} which, if true, demands that the vertices $i$ and $j$ aren't both the same color. By itself, this clause is in 2-SAT.For every edge $e \in E$, I now make a clause $\phi_e$ of the above form and put them all together using $\wedge$'s \begin{align} \phi = \wedge_{e \in E} \phi_e \end{align}Thus, for the entire graph, I've come up with a 2SAT formula which is equivalent to 3 coloring.This is obviously wrong, but I can't tell where I've screwed up.
3 Colorability reduction to SAT
complexity theory
With your modeling, setting $i$, $i_r$, $i_g$ and $i_b$ to false for all vertices yields a solution of the SAT problem and this is not a solution of the graph coloring problem.You need to add clauses to say that each vertex is blue or green or red, namely$(i_r\vee i_g\vee i_b)$.Then it becomes a 3-SAT problem.Note that if a vertex is assigned to more then one color, then we can take any of its colors and obtain a 3-coloring.
_webmaster.22870
I recently purchased a hosting plan from a provider.They gave me temporary url of accessing the hosting space, controlpanel, ftp details.Now when I deleted all the files from public_html and put up a index.html, then on clicking on the temporary url,everytime a files gets downloaded (with download name).What can be the issue?
New webserver offering HTML for download, not for browsing
web hosting
null
_opensource.958
I've noticed that the GNU GPL version 3 uses the word convey where version 2 used distriubte:GNU GPLv3:To convey a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.GNU GPLv2:To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.Is convey in GPLv3 the same thing as what GPLv2 means by distribute?
GPL v3 convey vs. GPL v2 distribute
licensing;gpl;terminology
The GPL FAQ states:Is convey in GPLv3 the same thing as what GPLv2 means by distribute?Yes, more or less. During the course of enforcing GPLv2, we learned that some jurisdictions used the word distribute in their own copyright laws, but gave it different meanings. We invented a new term to make our intent clear and avoid any problems that could be caused by these differences.So yes, they mean basically the same.
_codereview.94487
I was solving this question on a site that gives you a 1d array called gridgrid = ['top left', 'top middle', 'top right', 'middle left', 'center', 'middle right', 'bottom left', 'bottom middle', 'bottom right']and you're expected to write a method fire(x,y) that takes in two coordinates and gives you back where you hit the grid.For example:fire(0,0) # 'top left'fire(1,2) # 'bottom middle'Here is my solution, I used NumPy for it.import numpy as npdef fire(x,y):#the grid is preloaded as you can see in description oneDArray = np.array(grid) twoDArray = oneDArray.reshape(3,3) return twoDArray[y][x]I'm looking to get some feedback on the answer.
Converting a 1D Array of Strings to a 2D Array in Python
python;array;numpy
That works, but if your only goal is to implement fire(x, y), then NumPy is overkill.def fire(x, y): return grid[3 * y + x]
_ai.3632
I have created 22 different Convolutional neural networks that all test for the presence of unique objects in an image (each one of the classifiers is unique). Each sample in the test set has the output of a 22-long vector that looks something like this [0, 1, 1, 0, 0, 1, ..., 1], the binary nature of the vector representing the presence/absence of specific objects. I have implemented this already in keras and reach around 97% accuracy avg for the 22 models. Is there any specific ensemble methods that can allow me to combine all 22 classifiers?
Ensemble Learning using Convolutional Neural Networks
neural networks;machine learning;convolutional neural networks;classification;keras
null
_vi.8878
I'm not really sure how to describe what I'd like to do. Basically I'd like to use visual block mode to select a region of text and then paste it as a collection of lines rather than as a rectangle.a bc de fg hafter pressing gg0<c-v>Gy the rectangle a/c/e/g is in the default yank register (I forgot what it's called).If I then paste the rectangle p I get the following:aa bcc dee fgg hI'm wondering if it's possible to paste a rectangle / visual block selection on a group of lines by itself, as if it were an ordinary visual selection.acega bc de fg h
Paste visual block selection on its own lines
cut copy paste;visual block
Try this::put! :put: insert the contents of the specified register!: insert before the current line (the default is after): the unnamed register (check :help registers for details)You could do it from insert mode as well: Ctrl-r+
_cs.49421
What is the relation and difference between a programming model anda programming paradigm? (especially when talking about theprogramming model and the programming paradigm for a programminglanguage.)Wikipediatries to answer my question in 1:Programming paradigms can also be compared with programming models that are abstractions of computer systems. For example, the von Neumann model is a programming model used in traditional sequential computers. For parallel computing, there are many possible models typically reflecting different ways processors can be interconnected. The most common are based on shared memory, distributed memory with message passing, or a hybrid of the two.But I don't understand it:Is it incorrect that the quote in Wikipedia says the 'von Neumann model' is a programming model, because I understandthat the Von Neumann model is an architectural model fromhttps://en.wikipedia.org/wiki/Von_Neumann_architecture?Are the parallel programming models typically reflecting different ways processors can be interconnected? Or are parallelarchitectural models reflecting different ways processors can beinterconnected instead?In order to answer the question in 1, could you clarify what a programming model is? Is it correct that a programming model provided/implemented by aprogramming language or API library, and such implementation isn'tunique?From Rauber's Parallel Programming book, programming model isan abstraction above model of computation (i.e. computationalmodel) which is in turn above architectural model. I guess that aprogramming model isn't just used in parallel computing, but for aprogramming language, or API library.
Differences between programming model and programming paradigm?
terminology;programming languages;computation models;programming paradigms
null
_cstheory.4934
I have defined a finite state machine Q = {, S, s0, , F} where = {'[r]equest', '[o]ut', '[i]n', '[e]nd'} S = {'[R]eady', '[I]nitiating', '[W]aiting', 'Re[C]eived', 'Re[S]etting'} s0 = R, F = {R} = (q S and x ) q x q ------------------- R r I I o W W i C C e S S RHowever, I have a transition from W to S via a temporal event. How should I represent it?If I add an epsilon-move W Sit is not intuitive that it is a temporal event. possibly a timeout
A fsm with temporal events
fl.formal languages;automata theory
This was a comment first, but Suresh asked me to turn it into an answer:Maybe you want to take a look at timed automata. These are finite automata equipped with clocks; time can pass, clocks can be reset, transitions can be restricted to occur within a given time by clock guards etc. Here are some nice introductory slides: lsv.ens-cachan.fr/~bouyer/files/bouyer_chennai.pdf(This is actually the framework that Vor is using in his answer. His solution makes use of a clock that is reset and a guard for the epsilon transition.)
_unix.90225
At work, I'm facing security risk with the mail sender spoofing. I have a relay mail server which accepts mail relay from all server subnets.If an user in a normal server sends mail within command line:user@server$ echo mail_content | mail -r [email protected] -s Important [email protected] basically, this guy can pretent to be anyone when sending email, which could lead to really big troubleWhat I'm expecting is, even though running the above command, the recipient still get the mail with From: user@serverHow can I do it in Postfix?Edit: I forgot to add, the authentication method is Active Directory, not sure if it makes the configuration much complicated :)
How to config Postfix to prevent sender spoofing?
postfix
null
_webmaster.74358
My web-site automatically redirects everyone to Google when people try to search. This is done with the following nice and simple nginx code:set $goog http://www.google.com/search?q=site:ports.su+$arg_q;location = /search { return 307 $goog;}In Google Webmaster Tools, I see that I have a lot of hits to my web-site every single day; it's basically the same number of hits as visitors in total.Since Google may or may not redirect people to https (and then in case of such redirect the search string will be lost, and the site:example.com part will be unavailable for present/absent inspection), is there a way to know how many people find the site organically through Google, as opposed to finding Google through my site, only to then find the specific pages within site:example.com?(Going to https is not an option for me, since it's not backwards compatible with http and older https browsers.)
Is there a way to distinguish organic search referrers from users that perform a site: search on Google from my site?
google;google search console
null
_unix.74419
I have an ISO image in another system which I need to burn on my system. I can copy that image to my system using SCP and then do burning. But I would like to know, whether I can directly burn the remote data(image here) to the dvd? Both the systems have GNU/Linux.
Burn remote data on to a disc
linux;remote;iso;burning
null
_unix.134268
I have a directory with ownersip like user:group. I want to make on it something like sgid, but for user - all of new created files have a directory ownership. For example:drwxrwx--- 2 user group 4096 Jun 3 16:10 testAnd all created files in it have automaticly set following ownership on user:-rwxrw---- 1 user group1 0 Jun 3 16:11 file1-rwxrw---- 1 user group2 0 Jun 3 16:11 file2-rwxrw---- 1 user group3 0 Jun 3 16:11 file3It is possible to do this?
Solaris - Inheriting by files the user's ownership of directory
permissions;solaris;chown
null
_softwareengineering.204996
I have a behaviour that I'd like to use in different classes. Those classes are unrelated to each other (no inheritance). I'm using AS3, where multiple inheritance is not possible.I could use an interface but then I'd have to rewrite the same implementation every time, which is basically what I'm doing now (but without the interface).As en example I have many situations where I have an icon and a text label. In buttons, signs, etc. I'd like to centralise the alignment behaviour between the icon and the label.What is the best OOP pattern for that?
how to use the same behaviour in different classes
design patterns;object oriented
The Strategy pattern is what I would use for this (encapsulating an algorithm). How the alignment is done is something that can be configured at runtime. There are also lots of different ways of aligning elements so you encapsulate them behind an interface. The example below is one way you could use strategy pattern with your Aligner class.class Panel{ UIElement[] Children; IAligner Aligner; public SetAlignment(IAligner aligner) { this.Aligner = aligner; } public void Render() { Aligner.Align(Children) Display(Children) }}interface IAligner{ void Align(UIElement[] elements)}class LeftAligner : IAlignerclass RightAligner: IAlignerclass CenterAligner: IAligner
_unix.321856
I want to programmatically install MySQL to a Mac system running OS 10.11.6 El Capitan, so once the .dmg has been downloaded the script unpack it with the command:sudo hdiutil attach mysql-5.7.16-osx10.11-x86_64.dmgafter that the script runs:sudo installer -package /Volumes/mysql-5.7.16-osx10.11-x86_64/mysql-5.7.16-osx10.11-x86_64 .pkg -target /Here starts the installer, now when I install MySQL from the GUI I get a message-box telling me the temporary password for the root user (see attached picture)so, what I want is the script to read the temp root password and eventually set a predefined password for the root user:1) is possilbe to make bash shell read the temp password and store it into a variable?2) can the script reset the root password automatically?
Mac install MySQL from a shell script
shell script;software installation;osx;mysql
null
_unix.128911
I am running Firefox 27.0 and sometimes it shows strange symbols instead of icons. For example, instead of arrows up/down for up voting or down voting in a forum, it show some Japanese looking character.
Strange symbols instead of icons in Firefox
firefox
null
_codereview.26153
Just a little thing I made to load 20 random images from imgur. I looked at the way that imgur references images on its site, and I felt like I could probably generate a random string of letters and numbers that would, on occasion, produce a valid image URL. So I threw this together in PHP, because I am trying to learn PHP. It takes a while to get the 20 that it does, way longer for more. I would like to speed it up, and my current project in PHP is to learn more about classes etc, but I really have no idea where to start.I would love some feedback! I know this looks real amateur hour, but I am a real amateur, so go easy on me!BEWARE: not everything on imgur is worksafe, so if you decide to try this code out on your own server, the images returned are truly random with no filter, so no telling what you might see.<html><head> <title>Random imgur Loader</title> <style type='text/css'> #bg { position:fixed; top:-50%; left:-50%; width:200%; height:200%; z-index: -10; } #bg img { position:absolute; top:0; left:0; right:0; bottom:0; margin:auto; min-width:50%; min-height:50%; z-index: -10; opacity: 0.4; } #container { width: 760px; margin: 0 auto; } .imgcell { border: 1px solid black; } </style></head><body><div id='container' style='text-align: center;'><?php$gcode1=generateCode(5);$url3=http://i.imgur.com/.$gcode1..jpg;?><div id=bg> <img src=<?=$url3?> alt=></div><?php$pagepath=$_SERVER[PHP_SELF];if ($_GET['numimg']=='') { $numimg=20;} else { $numimg=$_GET['numimg'];}?><h1 style='font-family: verdana;'><?=$numimg?> random imgur images</h1><table border=0><tr><?phpfunction generateCode($length=6) { $source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; $code=''; for ($i=0; $i<$length; $i++) { $code .= $source[(rand() % strlen($source))]; }return $code;}$ii=1;while ($ii<=$numimg): $gcode=generateCode(5); $url=http://i.imgur.com/.$gcode..jpg; $url2=http://www.imgur.com/.$gcode; $headerfile=get_headers($url2, 1); $http_code=$headerfile[1]; $imgheader=get_headers($url, 1); $imgcode=$imgheader[Content-Type]; #echo $imgcode; if ($imgcode == 'image/gif') { $bcode='red'; } else { $bcode='gray'; } if($http_code!=HTTP/1.1 404 Not Found) { print(<td style='border: 2px solid $bcode' ><a target='_blank' href='$url2'><img title='$imgcode' width='160px' height='160px' src='$url'></a><td>); echo(str_repeat(' ',4096)); if ($ii % 5 == 0) { print(</tr><tr>); } flush(); $ii++; }endwhile;?></tr></table><?php print(<p><a href='$pagepath'>Get $numimg more!</a></p>);?></div> </body></html>
Random imgur image loader
php;beginner;html;random;image
Definitely separate your PHP from HTML as Alex suggested. You probably don't need to go the full MVC route for something so simple, but simply generating your PHP variables then outputing your HTML would make your code a lot more readable/manageable. I like your idea of generating a random string and checking it, but Flambino's right, it will never be reliable (by design) - also, imgur probably hates you ;) A simpler approach would be to consume imgur's RSS feed: http://feeds.feedburner.com/ImgurGallery?format=rssI was bored one morning, so I added something similar to the login page of one of my projects. It pulls one random image from lolcats' RSS feed and inserts it into the page. Here's the code that pulls the image:$feed = $this->get('feed_parser'); // This is just a SimplePie object$feed->set_feed_url('http://feeds.feedburner.com/lolcats/rss');$feed->init();$items = $feed->get_items();$item = $items[array_rand($items)]; // Gets one random image, but can modify for more$item = $item->get_content();$this->get('feed_parser') is just a fancy way of getting a SimplePie object from the PIMPLE container - you could just instantiate a SimplePie object yourself (if you want code you can't test). After running this code, $item would be a PHP array (or some collection class) containing the details of one image. In my case, I then exposed this as JSON and a REST API endpoint for use by JavaScript, but you could just as easily have PHP output the appropriate HTML.
_cs.52634
I have a similar question to that of Stable Marriage Problem.This is the criteria1) 1 Student must have 1 Teacher only.2) 1 Teacher ideally should have 3-4 Students.The spreadsheet is done using Google Apps Script (Javascript).How do I go about with the system calculation and giving teachers the system-generated result (3-4 Students) ?
Match students and teachers based on ranking
algorithms;bipartite matching;assignment problem
Your problem differs from stable marriage problem in a minor way. A teacher can have 4 students maximum. You will have to fix the maximum students allotted to teacher (you may not have 3-4, if you also prescribe minimum number of students then you might have to dig deeper).Now you can do two things, first, have four copies of each teacher and solve the stable marriage problem. Second solution is essentially like first but you keep a list of 4 engagements for each teacher.
_vi.4612
Is there a vimscript function that wraps text in a similar manner like gqgq does?For example, if I have the following string variable:let txt = 'One foo, two bars and three bazes went up the hill'I'd like to call something likelet indent = 4let textwith = 12let wrapped = wrap(txt, indent, textwidth)After the call, the value of wrapped should be One foo, two bars and three bazes went up the hillIs there something that does that?
Is there a vimscript function to wrap text
vimscript;wrapping
This function does what I needfu! TextWrap(text, width, indent) let l:line = '' let l:ret = '' for word in split(a:text) if len(l:line) + len(word) + 1 > a:width if len(l:ret) let l:ret .= \n endif let l:ret .= repeat(' ', a:indent) . l:line let l:line = '' endif if len (l:line) let l:line .= ' ' endif let l:line .= word endfor let l:ret .= \n . repeat(' ', a:indent) . l:line return l:retendfuThe function is then called, for example, like soecho TextWrap(one two three four five six seven eight nine ten, 8, 2)Which results in one two three four five six seven eight nine tenThe parameter indent specifies how many empty (space) characters there are in front of the first word. width specifies the maximum number of characters after indent characters. (for example five six or nine ten each constists of 8 characters).
_cs.33751
Suppose we have a degree $m$ multivariate polynomial $p(x_1, x_2, \ldots, x_m)$ in $n$ variables (by degree I mean the highest sum of powers of factors in any monomial term). Such a polynomial can have infinitely many rational zeros. Suppose we have landed at one of them, then what is an efficient way to escape from the zeros? Schwartz's theorem gives us that $p$ can be zero on an at most half of the integer points in any 2m x 2m x 2m x ... n-cube set of points such as the points with x,y,z,... in {0, 1, ..., d}, but this is computationally inefficient. Is there a better way to find a non-zero?In the actual problem I'm trying to solve, there are restrictions on the $x_i$'s. I'm hoping to find a criterion that I can satisfy within these restrictions, so the more, the merrier!
Finding a rational non-zero of a multivariate polynomial in polynomial time
complexity theory
null
_unix.136243
I have a user of name x in tty1 and y in tty2. x wants to write some message to y and vice-versa. When I typed write y tty2 in the tty1 terminal, it said:write:you have write permission turned offwrite:y has messages disabledI then tried to enable messages:$ mesgis n$ mesg yNow I can successfully write a message from x to y or vice-versa, but the first line of error continues to appear. I have tried logging out and back in again, but the symptom doesn't change. I also looked through the file /etc/default/devpts and saw that TTYMODE=620.
Problem in writing message from one terminal to another terminal
ubuntu;terminal;write
null
_softwareengineering.191524
I just came from an interview in which they asked me several questions about programming and problem solving. Regarding the programming questions, I asked them to let me Google so I can see the code (I quoted that logic is the thing to learn, not the language). At the end of the interview they told me that my skills very good but what would I do if Google has been blocked around our country(It can happen in Pakistan, Youtube is yet blocked). Is it really that a programmer should know the code too?
Is Googling every code a bad practice?
source code
null
_cstheory.14700
If a circuit ({AND OR NOT} circuit) with depth d computes the majority function, what's the best lower bound for majority function?I know the lower bound for parity function is $ 2^{\Omega (n^{1/d})} $
lower bound of majority function?
cc.complexity theory;lower bounds
null
_cs.48707
If $L$ is the set of strings $\langle M\rangle$ such that $M$ accepts all strings of even length and does not accept any strings of odd length.What will be $\overline L$ ?a) set of strings $\langle M\rangle$ such that $M$ accepts all strings of even length as well as any strings of odd length.b) set of strings $\langle M\rangle$ such that $M$ accepts all strings of odd length and does not accept any strings of even length.
Complement of a Language which is set of Turing Machine descriptions
formal languages;terminology;closure properties
Neither. A machine $M$ is not in $L$ if either it rejects some even-length string or it accepts some odd-length string (or both).
_softwareengineering.200552
I have seen the words Fetch and Select used seemingly interchangeably when naming data access layer methods (ex. Person.Select or Person.Fetch). Which one is correct? My instinct is that the point of the data access layer is to abstract data access and thus the term Fetch would be more of an abstraction perhaps than Select would be. But if one can imagine for a moment that SQL was not an existing technology, the term Select on its own might be appropriate.
Which is architecturally correct for Data Access Layer method names - Fetch or Select?
naming;methods;repository
According to the given comments, I'd also say that it's a matter of preference. When I have to cope with naming issues, I usually look for semantic differences of the words in a dictionary.fetch - go for and then bring back (someone or something) for someoneselect - carefully choose as being the best or most suitableThe word select has a notion of choosing between some elements. This is not the case in a Data Access Layer, because in a specific method you know which entity you want to access and thus, the selecting process rather takes place in the Database Layer itself.Therefore I'd prefer the word fetch in this case, because, according to the definition, you go for an entity's data and you want to bring it back (=forward it) to the next higher layer, maybe the business logics layer.
_codereview.52149
Next version of Adding a duplicate entry randomly into a list in haskell using random monadI wrote this trying to set up a Haskell testcase. The aim is to take a list and add a single duplicate from any place in the list to anywhere else in the list. I'm trying to learn to use the Random Monad properly so the main aims should be clear, simple, idiomatic and pure code. However any recommendations for improvement are appreciated. The code here has most of the improvements suggested by @Petr in the review of the previous version, howeverI'm still using lists rather than sequences because the code I plan to test uses listsI still have an infinite list function because I want to be able to use it easily from IO code where the number of strings to be generated isn't known in advance. I believe that since the Random Monad uses incremental state based on the State Monad, it should be okay to generate infinite lists with it.-- DataListDuplicator.hs by Michael De La Rue 2014-- licensed to StackExchange codereview under cc by-sa 3.0-- may be used under AGPLv3module DataListDuplicator where import Control.Monad.RandominfiniteDuplicateLists :: (MonadRandom m) => [a] -> m [[a]]infiniteDuplicateLists = mapM addRandomDuplicate . repeataddRandomDuplicate :: MonadRandom m => [a] -> m [a]addRandomDuplicate genlist = do frompos <- getRandomR (0 ,llen - 1) topos <- getRandomR (0 ,llen) let newlist = listEntryDuplicate frompos topos genlist return newlist where llen = length genlistlistEntryDuplicate from to list = start ++ [repeat] ++ end where repeat = list !! from (start, end) = splitAt to listHere's a little program which drives that:-- duplicate-to-list-randmonad.hs by Michael De La Rue 2014-- licensed to StackExchange codereview under cc by-sa 3.0-- may also be used under AGPLv3-- N.B. Trivial copying of code fragments does not normally require any license.import Data.Listimport Control.Monad.Randomimport DataListDuplicatormain :: IO ()main = do putStrLn $ list comparison ++ prettyList list g <- getStdGen let shuffled = evalRand (infiniteDuplicateLists list) g putStrLn $ lists after \n ++ intercalate \n ( map prettyList (take 5 shuffled)) where list = [a,b,c]prettyList :: (Show a) => [a] -> StringprettyList list = [ ++ intercalate , (map show list) ++ ]
v2 - Adding a duplicate entry randomly into a list in haskell using random monad
haskell;linked list;random;monads
null
_unix.369545
I am new to Mac related commands. I installed CentOS vagrant on virtual box through terminal. Is there any command that I can directly switch user to vagrant from terminal?
Vagrant in Mac Terminal
vagrant
null
_cs.54840
I have been following the book Introduction to Automata Theory, Languages, and Computation by John E. Hopcroft and Jeffery D. Ullman.I came across the following topic titled Bad Case for Subset Construction (2.3.6). I cannot follow the example given over there, about NFA N that can accept strings with 1 at the $n^{th}$ position, and that the DFA formed from that NFA thereafter will have no equivalent with fewer than $2^n$ states.They argue that The DFA $D$ must be able to remember last n symbols it has read. Since any of the $2^n$ subsets of the last n symbols could be 1, if D had fewer than $2^n$ states, then there would be some state $q$ such that $D$ can be in state $q$ after reading two different sequences of n bits, say $a_{1}a_{2}...a_{n}$, and $b_{1}b_2...b_n$.Here is an extract from the book itself:I have been trying to comprehend the proof, including this line and the subsequent paragraph that follows, but I have not been able to.Can someone please explain the approach ?
An NFA with no equivalent DFA with fewer than $2^n$ states: Example and Proof
automata;finite automata
null
_unix.115323
Emacs backup files start with .# but I can find those in my directory. I've try:find . -name '^\.#.*'orfind . -name '.*#.*'and they are not show up, and I have them. For instance if I create one just for test:touch '.#test'and if I try to find it using find command it not show up.
How to find Emacs backup files?
bash;find;emacs;backup
> touch .#test> find . -name '.#*'./.#testWorks! find uses shell globbing, not regular expressions. . does not need to be escaped in the former because it is not a special character, it is always literal. The glob equivalent of the regexp wildcard . is ?. Also, * is a wildcard in globbing, the regexp equivalent of which is .* (* being a quantifier and not a wildcard in regexps).
_softwareengineering.112589
IS MVVM getting any kind of traction outside the Microsoft community? Within Silverlight this is a non-issue, but for other technologies, like JavaScript it surely is: For instance Knockout.js is a great framework, but the 'rest of the world' seems to be on a Backbone path.My concern is that MVVM frameworks (like Knockout) are going to suffer a lack of network effect by being constrained to the Microsoft ecosystem, and thus fall behind compared to the rest.
Examples of MVVM adoption outside the Microsoft community?
web development;javascript;design patterns;mvvm
null
_scicomp.19319
I am using 8 ODEs in Matlab to simulate the effect of asymptomatic infections in the epidemiology of a vector borne disease. Searching the parameter space under certain settings produces negative numbers for the human population and the following warning in the command consol:Warning: Failure at t=3.562559e+03. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.275958e-12) at time t. > In ode45 at 308 In Mosquito_Framework_2_human_plots at 79Is there some setting I could put the solver on to get rid of the problem. The current solver is ode45 under 'RelTol', 1e-6 option.The following code produces the negative human population and warning message:function [t,Sh,Ah,Ih,Rh,Se,Sv,Iv] = Mosquito_Framework_2_human_plots(betaI,betaV,c,...theta,d,muh,p,muv,omega,epsilon,Sh0,Ah0,Ih0,Rh0,Sv0,Ev0,Iv0,MaxTime)% Sets up default parameters if necessary.if nargin ~= 18 disp('defaults') %displays message default to say simulation is using defaults if not %enouth argumants is given betaI = (0.3+1)/2*(0.1+0.75)/2; betaV = (0.3+1)/2*(0.5+1)/2; c=1; theta=8; d=0.25; muh=1/(60*365.0); p=0.9; muv=1/6; omega=1/11; epsilon=1/((8+12)/2); Sh0=(1e6)-1; Ah0=1; Ih0=0; Rh0=0; Sv0=9.5e6; Ev0=0; Iv0=0; MaxTime=10*(365);endgammaI=1/theta;gammaA=1/(d*theta);betaA=c*betaI;Nh0=Sh0+Ah0+Ih0+Rh0;Nv0=Sv0+Ev0+Iv0; Se0=Nv0*(muv/omega); % Checks all the parameters are valid if Sh0<=0 error('Initial level of susceptibles (%g) is less than or equal to zero',Sh0); endif Ah0+Ih0<=0 error('Initial level of infecteds (%g) is less than or equal to zero',Ah0+Ih0);endif betaA+betaI<=0 error('Transmission rate betaA+betaI (%g) is less than or equal to zero',betaA+beta);endif betaV<=0 error('Transmission rate betaV (%g) is less than or equal to zero',betaA+beta);endif gammaA+gammaI<=0 error('Recovery rate gammaA+gammaI (%g) is less than or equal to zero',gammaA+gammaI);endif muh<=0 error('Death and birth rate gamma (%g) is less than or equal to zero',muh);endif MaxTime<=0 error('Maximum run time (%g) is less than or equal to zero',MaxTime);endif Sh0+Ah0+Ih0>Nh0warning('Initial level of susceptibles+infecteds (%g+%g=%g) is greater than human population size (%g)'...,Sh0,Ah0,Ih0,Sh0+Ah0+Ih0,Nh0);endif Sv0+Ev0+Iv0>Nv0warning('Initial level of susceptibles+infecteds (%g+%g=%g) is greater than mosquito population size (%g)'...,Sv0,Ev0,Iv0,Sv0+Ev0+Iv0,Nv0);endSh=Sh0; Ah=Ah0; Ih=Ih0; Rh=Rh0; Se=Se0; Sv=Sv0; Ev=Ev0; Iv=Iv0;% The main iteration options = odeset('RelTol', 1e-6);[t, pop]=ode45(@Diff_Framework_1,[0 MaxTime],[Sh Ah Ih Rh Se Sv Ev Iv],options,... [betaA betaI betaV gammaA gammaI muh p muv omega epsilon]);Sh=pop(:,1); Ah=pop(:,2); Ih=pop(:,3); Rh=pop(:,4); Se=pop(:,5); Sv=pop(:,6); Ev=pop(:,7); Iv=pop(:,8);%plot the graphs with scaled coloursplot(t,Ah,'Color',[250/255,228/255,32/255],'LineWidth',1.4);hold on%hold on makes matlab plot to the same plot.plot(t,Ih,'-r','LineWidth',1)set(gca, 'FontSize', 14)xlabel('Time in Days','FontSize',18);ylabel('Human Population','FontSize',18);% ylim([0,1e5])name = strcat('Vector_dep_M2@_c=',num2str(c),'_d=',num2str(d),'_p=',num2str(p));Human_pop_plot_name = strcat('Human_pop_',name,'.fig');savefig(Human_pop_plot_name);hold off%hold off stops matlab ploting to the same plot.%Saves graph%creates string based around parameters used called dataset_name Both_pops_csv_names = strcat('Both_pops_',name,'.csv');Both_pops_csv = dataset({t,'Time_in_Days'},{Sh+Ah+Ih+Rh,'Total_Human_Population'},...{Sh,'Susceptibles_Humans'},{Ah,'Asymptomatic_Humans'},{Ih,'Symptomatic_Humans'},...{Rh,'Recovered_Humans'},{Se+Sv+Ev+Iv,'Total_Mosquito_Population'},...{Sv+Ev+Iv,'Total_Adult_Mosquito_Population'},{Se,'Pre_Adult_Mosquito_Population'},... {Sv,'Susceptible_Mosquito_Population'}, {Ev,'Incubating_Mosquito_Population'},... {Iv,'Infectious_Mosquito_Population'});%export(Both_pops_csv,'File',Both_pops_csv_names,'Delimiter',',')%creats csv file of outputs% Calculates the differential rates used in the integration.function dPop=Diff_Framework_1(t,pop, parameter)betaA=parameter(1); betaI=parameter(2); betaV=parameter(3); gammaA=parameter(4);... gammaI=parameter(5); muh=parameter(6); p=parameter(7); muv=parameter(8); ... omega=parameter(9); epsilon=parameter(10);Sh=pop(1); Ah=pop(2); Ih=pop(3); Rh=pop(4); Nh=Sh+Ah+Ih+Rh; ... Se=pop(5); Sv=pop(6); Ev=pop(7); Iv=pop(8); Nv=Sv+Ev+Iv; dPop=zeros(8,1);dPop(1)= muh*Nh - Sh/Nh*(betaV*Iv) - muh*Sh;dPop(2)= (1-p)*Sh/Nh*(betaV*Iv)-(gammaA+muh)*Ah;dPop(3)= p*Sh/Nh*(betaV*Iv) - (gammaI+muh)*Ih;dPop(4)= gammaA*Ah+gammaI*Ih - muh*Rh;dPop(5)= muv*Nv - omega*Se;dPop(6)= omega*Se - (Sv*betaA*Ah/Nh + Sv*betaI*Ih/Nh) - muv*Sv;dPop(7)= (Sv*betaA*Ah/Nh + Sv*betaI*Ih/Nh) - epsilon*Ev - muv*Ev;dPop(8)= epsilon*Ev - muv*Iv;
How do I stop negative numbers and error message: Failure at t=3.562559e+03. Unable to meet integration tolerances
matlab;ode
null
_unix.185802
I get the following error after doing sudo apt-get upgrade:Setting up php5-cli (5.5.9+dfsg-1ubuntu4.6) ...ucfr: Attempt from package php5-cli to take /etc/php5/cli/php.ini away from package php5-fpmucfr: Aborting.dpkg: error processing package php5-cli (--configure): subprocess installed post-installation script returned error exit status 4dpkg: dependency problems prevent configuration of php5-readline: php5-readline depends on php5-cli (= 5.5.9+dfsg-1ubuntu4.6); however: Package php5-cli is not configured yet.dpkg: error processing package php5-readline (--configure): dependency problems - leaving unconfiguredNo apport report written because the error message indicates its a followup error from a previous failure. dpkg: dependency problems prevent configuration of php-pear: php-pear depends on php5-cli; however: Package php5-cli is not configured yet.dpkg: error processing package php-pear (--configure): dependency problems - leaving unconfiguredNo apport report written because the error message indicates its a followup error from a previous failure. Setting up php5 (5.5.9+dfsg-1ubuntu4.6) ...Errors were encountered while processing: php5-cli php5-readline php-pearE: Sub-process /usr/bin/dpkg returned an error code (1)After that, I tried sudo apt-get install -f, sudo dpkg --configure -a and sudo apt-get install --reinstall php5, all of them with the same error. How can I fixed this?
Can't finish php5-cli update
ubuntu;apt;php5
To solve it, I had to remove the symlink in /etc/php5/cli/php.ini that points to ../fpm/php.ini.After that, all works as expected.I found the solution here.
_webmaster.17902
I'd like to include extra information that would give us a bump in location specific search?
How can I include location data in a page so that Google search results include a map?
seo;google
null
_softwareengineering.319597
I have built a server-side Java application of about 10k lines of code and on a code review a colleague made me notice that when developing a new business feature , I have to touch several files. My explanation is the following:In a well-layered architecture, delivering an additional business functionality might require small changes/additions to all the layers. For example in a classical three layer application which has a REST API/business logic/ data access layer, adding a new feature might require to touch these three layers.When developing a new feature you will easily get presented with the chance of refactoring existing code in order to keep the code in good quality(cyclomatic complexity, dependency tree length, etc) and DRY. Given that I have a test coverage between 70% and 80% I do that aggressively.Due to the small changes of point 2, I might have to slightly touch the tests for those featuresBecause I touch N layers, I will have to update each unit test for each layer + at least one integration testA different approach would obviously be to develop a more componentized application, where each business functionality is achieved through an independent module. Am I right in considering a layered architecture better, at least in containing the total cost of ownership and development of the application?
Layered architectures and modular software
design;layers
null
_softwareengineering.4391
I've programmed a bit of Haskell and Prolog as part of a couple of uni courses, but that's about it. And I've never seen it been used in industry (not that I've had much of working experience to begin with but I've never seen an ad where you are required to know them).So should we be using functional and/or logic programming languages more often? Are there any advantages or disadvantages for using or not using them?
Should we be using functional and/or logic programming languages more?
programming languages;functional programming
I believe in using the right tool for the job. Both imperative and functional languages have their place and there's no need to push for using one kind more than the other.For the advantages/disadvantages, I don't think I could beat Eric Lippert's answer to the Why hasn't functional programming taken over yet? SO question.
_cs.257
There's been a lot of hype about JIT compilers for languages like Java, Ruby, and Python. How are JIT compilers different from C/C++ compilers, and why are the compilers written for Java, Ruby or Python called JIT compilers, while C/C++ compilers are just called compilers?
How is a JIT compiler different from an ordinary compiler?
compilers
JIT compilers compiles the code on the fly, right before their execution or even when they are already executing. This way, the VM where the code is running can check for patterns in the code execution to allow optimizations that would be possible only with run-time information. Further, if the VM decide that the compiled version is not good enough for whatever reason (e.g, too many cache misses, or code frequently throwing a particular exception), it may decide to recompile it in a different way, leading to a much smarter compilation.On the other side, C and C++ compilers are traditionally not JIT. They compile in a single-shot only once on developer's machine and then an executable is produced.
_computergraphics.2275
In virtual reality, the motion-to-photon time is very important. Oculus says it has to be less than 20ms. Maybe 10~15ms is better.Some people try to introduce Frameless rendering technology into VR. I think it's good to reduce the latency. But I don't know how the display quality is. According to the paper: Adaptive Frameless Rendering and the video (https://www.youtube.com/watch?v=ycSpSSt-yVs), it seems not very good. But, in this paper Construction and Evaluation of an Ultra Low Latency Frameless Renderer for VR, the authors used FPGA instead of GPU to render and used Frameless Rendering to reduce the latency to 1ms. In my mind, FPGA is very hard to replace GPU in 3D rendering area. And, Frameless Rendering needs racing the beam, it is also very hard to program. What do you think? Is it realistic to use FPGA and frameless rendering?
Can Frameless rendering reduce latency? And, can FPGA do 3D rendering instead of GPU?
rendering;gpu;virtual reality
First of all, the frameless rendering technique is in the context of raytracing, not rasterization. It's not obvious how it could be made to work effectively with rasterization, given that the basic idea of it is to update an image by a combination of temporal reprojection plus firing rays specifically at areas where the algorithm thinks the image is undersampled.So this technique is, prima facie, not compatible with rasterization-based graphics applications. But if you're already doing raytracing for other reasons, this technique would be interesting to look at; it certainly appears to improve quality relative to an image raytraced from scratch each frame, with the same number of rays per second.Raytracing on a GPU is certainly possible; you don't need an FPGA for that. I've only skimmed the second paper, but my reading of it is that the main reason for the FPGA is to get a close coupling between the display scanout and the rendering activity: namely they race the beam and evaluate pixels just before they're about to be scanned out, thus obtaining low latency.The GPU equivalent of this is probably to split the image in thin horizontal strips, and kick off a compute dispatch to render each strip just before it starts to be scanned out. Today, this is difficult to accomplish as it requires either millisecond-precise scheduling that desktop OSes are not currently set up for, or it requires the GPU to be able to dispatch based on an interrupt from the scanout unit—a hardware feature that doesn't currently exist AFAIK (or if it does, it isn't exposed in any graphics APIs). Or you might be able to make it work with a long-running asynchronous compute dispatch, if you can find a way to stay in sync with scanout.So, there are obstacles, but they aren't insurmountable, and I think if there was sufficient interest in racing-the-beam-style rendering, then OS and GPU vendors could come up with a way to do it in the future. So I don't think an FPGA is required for this kind of technique to work. On the other hand, the fact that it's based on raytracing is a much bigger obstacle to using it in real-world apps and games.
_unix.58087
I mounted redhat dvd media and I named in redhat.iso. And when i mounted it and did lsit showed /media/RHEL-5.6 i386 DVD. What does this space mean between 5.6 and i386 and DVD. Because Im creating a DVD based Repository which i will use to Upgrade the Redhat linux.Im asking this because I have to assign this path in Baserul=file:///Absolute/Path to run yum upgradecommand which will upgrade redhat 5.5 to 5.6. And when assign it like this baseurl=file:////media/RHEL-5.6 i386 DVDit give me error that i can only use https, ftp or URL not df -h ResultsInstructions entered in dvd.repo[dvd.repo]name=dvd.repobaseurl=file:///media/RHEL_5.6\ i386\ DVD/SERVERenabled=1gpgcheck=0And when I omitted white space and wrote basurl like thisbaseurl=file:///media/RHEL_5.6\i386\DVD/Serverand saved it and then used the command YUM CLEAN ALL and after that YUM LIST ALL it smashed me with this message
What does White space mean when you mount ISO
rhel;repository
null
_codereview.134934
I created this code and it works fine, but I think it's ugly. Could you show me a better way to create a list of three different random numbers from 1 to 9?class Baseball_Engine(object): def __init__(self): self.count = 0 self.random_number_list = [0, 0, 0] while self.count < 3: random_number = random.randint(1, 9) self.random_number_list[self.count] = random_number if self.random_number_list[self.count - 1] != random_number and self.random_number_list[self.count - 2] != random_number: self.count += 1 print self.random_number_list
Python random number generator between 1 and 9
python;random
null
_unix.359494
Ok, here's a brain puzzle: how can I find out how many times a particular file has been opened (in any mode) by any / all processes currently running on a Linux machine? I.e. how many file descriptors, globally (or within a namespace / container, doesn't matter) are in use referencing a particular file / inode?One way of finding this out would probably be using lsof and counting how many times does the filename in question appears in its output. But that seems inelegant, and in any case, I'd need something like this programatically, in C.Edit: or maybe a similar but different question, which would also be helpful: is a particular file (a random file on the file system, so no attaching handlers and waiting for something to happen) opened at all, by any process (possibly excluding this one)?
Find out how many times a file has been opened?
filesystems;c;system calls;lsof
null
_webmaster.68899
I'm working as a bit of a webmaster for a guy that runs a network of backlinked websites to increase his PR for a couple of his eCommerce sites. I don't know much about them, I just know they generate content and funnel the link juice back to where it's needed. He is hell-bent on making SEO as good as possible on every one of the sites under his network. We have a VPS running about 10 of these sites on a single IP address and he has been struck with the somewhat logical assumption that if Google thought they all came from different servers, as opposed to one, their SEO and pagerank would be better. I'm however a little more skeptical of this idea, as I don't see why on earth Google would consider the content generated from the same server more valuable than content generated from different servers.In terms of SEO, would a network of sites that link to each other benefit from having different IP addresses? Or could they result in a penalty if they all used the same IP address?
Would a different IP address for each site in a network of sites help with SEO or prevent a penalty?
seo;google;pagerank;ip address
It is highly likely that Google reduces the linkjuice passed from one site to another if it is on the same IP address because Google makes the logical and reasonable assumption that the link isn't an unbiased link. Google uses links as 'votes' for how important a site is - the more links it gets from other sites the higher it's 'authority'. The more links you get from high authority sites the better. If you get links from sites that you own, i.e. they are on the same IP address, then that doesn't count like a full vote from a completely independent site.It isn't quite as simple as changing the IP address though. IP addresses are chunked up into blocks, and if you use a hosting provider they will normally have ownership over several blocks ('C' blocks, where the first three sets of numbers (octets) are the same), and even if you take out another server with a different IP address it is likely to be from the same C block, which again is another clue for Google that the two websites are controlled by the same person. Cue reduced linkjuice.Final point - Google is totally aware of these backlink schemes and have engineers that are cleverer than the webmasters trying to set them up; whilst this sort of thing worked ten years ago it is less and less successful now. Far more sustainable and value-adding is building a credible backlink profile by legitimately building good content that other independent and relevant sites want to link back to.A link wheel type thing where you create the spokes linking into the hub website is doomed to failure because the 'domain authority' of the spoke sites is going to be practically zero (because they don't have authoritative links into them). I've been responsible for the SEO for an eCommerce business that generates over $150M in revenue per year and I'd never dream of trying to set up this kind of backlink scheme.
_softwareengineering.347238
I have two engineers with very different development styles.Engineer A prefers a high degree of upfront planning and designing, considerations for all possible options with pros/cons mapped out. Engineer B prefers to find the quickest path to test. We are a skunkworks team and are responsible for testing a bunch of new ideas. So Engineer B seems to be taking the right path. On the other hand, the rationale from Engineer A is, if something works, we would have to toss much of what we've just done and build it right. So a go slow to go fast mentality.I am frantically trying to hire a technical leader for this team, but in the mean time I'm in charge and my lack of technical background is starting to show. Any advice, or even pointing me in the right direction would be helpful!
How should I weigh the cost of rapidly testing for customer signal versus proper upfront design?
team leader;leadership
null
_softwareengineering.135272
I was wondering whether it is possible to give any advice as the the maximum number of lines of code at which one should consider switching from say MATLAB to a more low level language?Is it even the case that at a certain point it makes more sense to manage a certain degree of complexity of a given program in a proper object oriented language rather then MATLAB? I should say I am a newbie in both MATLAB and Java, so I have no hidden agenda in this question even though I m aware of the heated discussions that people sometimes engage in over whether MATLAB is a proper programming language. I'm not experienced enough to even think about participating in such an exchange and I'm just looking for advice whether there is a cut off point where one really needs to go to a different language?Also I should add I understand the code may become longer when you move to lower level, however I was under the impression that object oriented programming makes it easier to manage the complexity of bigger programs. (Maybe lines of code was a bad choice as a proxy for complexity?) Is the choice of low vs. high level just one of performance? (which in the end you have to pay for with a bigger programming task at your hands for the low level language?)
Lines of Code vs. Optimal Language
java;matlab
null
_softwareengineering.154796
I know this sounds a lot like other questions which have already being asked, but it is actually slightly different. It seems to be generally considered that programmers are not good at performing the role of testing an application. For example: Joel on Software - Top Five (Wrong) Reasons You Don't Have Testers (emphasis mine) Don't even think of trying to tell college CS graduates that they can come work for you, but everyone has to do a stint in QA for a while before moving on to code. I've seen a lot of this. Programmers do not make good testers, and you'll lose a good programmer, who is a lot harder to replace.And in this question, one of the most popular answers says (again, my emphasis): Developers can be testers, but they shouldn't be testers. Developers tend to unintentionally/unconciously avoid to use the application in a way that might break it. That's because they wrote it and mostly test it in the way it should be used.So the question is are programmers bad at testing? What evidence or arguments are there to support this conclusion? Are programmers only bad at testing their own code? Is there any evidence to suggest that programmers are actually good at testing? What do I mean by testing? I do not mean unit testing or anything that is considered part of the methodology used by the software team to write software. I mean some kind of quality assurance method that is used after the code has been built and deployed to whatever that software team would call the test environment.
Are programmers bad testers?
testing;qa
null
_unix.370283
I have a script that runs several different psql statements. I'm trying to capture the error output from psql when password entered is incorrect.The password is entered in before the check (and when correct, the psql statements execute successfully)I've tried the following:pwcheck=`psql -q -U postgres -h $ip -d $database;`echo error message: $pwcheckWhen I enter an incorrect password to check it, the error messages are output but the variable is empty. psql: FATAL: password authentication failed for user postgresFATAL: password authentication failed for user postgreserror message:Ideally, I'd like to save the error message to a variable and not print my own error message/prompt and not display the psql errors at all.How can I store either of these error messages in a bash variable?
How to save psql error message output in bash variable?
bash;shell script;variable;postgresql;error handling
null
_unix.29587
Is there way to run Plasma/DeviceNotifier under another WM to KWin/KDE (e.g. Fluxbox).To be more specific, I have currently configured KDE, but I work remotely thorough SSH -Y + X-forwarding. So running plasma-desktop might run all other Plasmoids/Widgets. I'd like to run only one : DeviceNotifier. As I see it runs thought libs, no standalone executable there:~$ pacman -Ql | grep devicenotikdebase-workspace /usr/lib/kde4/plasma_applet_devicenotifier.sokdebase-workspace /usr/lib/kde4/plasma_engine_devicenotifications.sokdebase-workspace /usr/share/kde4/services/plasma-applet-devicenotifier.desktopkdebase-workspace /usr/share/kde4/services/plasma-dataengine-devicenotifications.desktopkdebindings-python /usr/share/sip/PyKDE4/solid/devicenotifier.sipkde-l10n-pl /usr/share/locale/pl/LC_MESSAGES/plasma_applet_devicenotifier.mokdelibs /usr/include/solid/devicenotifier.hSo... how to run it ?Update:Running plasma-desktop does not work.I run on my laptop:laptop$ xinit;laptop$ ssh -Y desktop;desktop$ fluxbox #X forwardingSo I run fluxbox on remote machine (Desktop).When I run in such situation plasma-desktop I end-up with whole screen messed up with all widgets I normally use on remote machine when I work on it locally.There are few problems there : (1) On desktop I have six times more screen space, (2) when I work remotely I do not need most of stuff I need when I work locally (3) I'm afraid of running another instance remotely of all those widgets and stuff, when it's already running on desktop.That's why I am asking about running only one widget.It can be plasma-desktop, but running only one widget, but not whole stuff I have setup and running on desktop locally.
Running Plasmoid under NOTKDE (e.g. Fluxbox) - Plasma/DeviceNotifier
kde;window manager;desktop;desktop environment;plasma
The name of the executable your looking for is called plasma-desktop. I would try it out first, and if your satisfied with the results, then set it to autostart. You are required to install a good chunk of the KDE dependencies to make it happen, but should not have a problem running just the plasmoids.I will say this, plasmoids are the best desktop widgets around. It becomes obvious once you compare the offerings of other available engines. Unfortunately they are not the easiest to write, and they are highly integrated with the KDE DE. You would get a much lighter environment running a light standalone widget engine. I suspect though, because of your specified applet, that alternative web widgets are not what you want. If you are having trouble with clean automounting, which can be an issue on clean install Flux/Black/OpenBox, good lightweight udisks/udev scripts are available from packages.Update: In response to new issues.It's possible to run single plasmoids, in their own window. You would need to use plasmoidviewer to run the Device Notifier. It's known for its use in developing widgets, and also considered fairly ugly. However it should work, if you only desire to run the one single widget.
_unix.323953
I have many directories with the names as followinggeom1 geom10 geom11 geom12 geom13 geom14 geom15 geom16 geom17 geom18 geom19 geom2 geom20 geom3 geom4 geom5 geom6 geom7 geom8 geom9I would like to rename them to be like this geom0000001 geom0000002 geom0000003 geom0000004 geom0000005 geom0000006 geom0000007 geom0000008 geom0000009 geom0000010 geom0000011 geom0000012 geom0000013 geom0000014 geom0000015 geom0000016 geom0000017 geom0000018 geom0000019 geom0000020I used the following scripta=1 for i in geom*/; do new=$(printf geom%07d $a) mv -- $i $new let a=a+1 donethe problem, it moves for examples geom10 to geom0000002 not to geom0000002 while geom2 to geom0000012 not to geom0000002what I want is to renames the directories with the same sequence but with the new format.
How to reformat the directories names?
shell script
null
_unix.210336
How can I manipulate field-based data from the commandline? For exampleHow can I print only lines whose Nth field is foo?How can I print only lines whose Nth field isn't foo?How can I print only lines whose Nth field matches foo?How can I change field N to foo?Is there a standard approach or toolset that facilitates manipulating field-based data on *nix systems?
How can I extract/change lines in a text file whose data are separated into fields?
text processing;sed;awk;perl
There are two basic approaches one can use when dealing with fields: i) use a tool that understands fields; ii) use a regular expression. Of the two, the former is usually both more robust and simpler.Many of the commonly available tools on *nix are either explicitly designed to deal with fields or have nifty tricks to facilitate it.1. Use a tool that understands fields1.1 awkThe classic tool here is awk. It will automatically split each input line into fields (the field separator is whitespace by default but can be changed using the -F flag) and the fields are then available to the awk script as $n where n is the field number. The 1st field is $1, the second $2 etc.Print lines whose 3rd field is foo.awk '$3==foo' fileChanging the delimiter to :awk -F: '$3==foo' fileThe default action of awk is to print. Therefore the commands above will print all lines whose 3rd field is foo. When using -F, you can set arbitrary field separators, and even use regular expressions.How can I print only lines whose 3rd field isn't foo?awk '$3!=foo' fileHow can I print only lines whose 3rd field matches foo?If you're just looking for fields that match a pattern (for example, foo matches foobar), use ~ instead of ==:awk '$3~/foo/' fileHow can I print only lines whose 3rd field doesn't match foo?awk '$3!~/foo/' fileHow can I change the 3rd field to foo?awk '$3=foo' file1.2 PerlAnother choice is perl one-liners. Like awk, Perl is a full-featured scripting language but can also be run as a commandline program taking a script as input. Its behavior is modified by commandline switches, the most relevant of which for this question are:-e : the script that perl should run;-n : read the input file line by line;-p : print each input line after applying the script given by -e;-l : remove trailing newlines from each input line and add a newline to each print call;-a : awk-mode, split each input line into the array @F;-F : the field separator for -a.An important difference with awk is that perl's -a switch splits files into an array. In Perl, arrays start at 0, not 1. This means that the 2nd field is actually $F[1] and not $F[2]. With all this in mind, the perl equivalents of the above are:Print lines whose 3rd field is foo.perl -ane 'print if $F[2] eq foo' fileChanging the delimiter to :perl -F: -ane 'print if $F[2] eq foo' fileUnlike awk, perl can't use regular expressions as field delimiters. They need to be a specific character or string.How can I print only lines whose 3rd field isn't foo?perl -ane 'print unless $F[2] eq foo' fileHow can I print only lines whose 3rd field matches foo?perl -ane 'print if $F[2]=~/foo/' fileHow can I print only lines whose 3rd field doesn't match foo?perl -lane 'print unless $F[2]=~/foo/' fileHow can I change the 3rd field to foo?This one is a bit more cumbersome in Perl. The usual approach is to change the value in the @F array and then print the array. With simple space-separated files, this is easy:perl -lane '$F[2]=foo; print @F' fileWith a different delimiter, you will need to join the array. Otherwise, it will be printed space-separated:perl -F: -lane '$F[2]=foo; print join :,@F' file2. Use regular expressionsThe idea here is to use a regular expression (regex for short) that defines the position of the target string in the line. For example, in a file whose fields are separated by :, we can find the 2nd field by matching everything up to the 1st : (the 1st field) and then looking for the second:^[^:]*:[^:]*:This regex means:^ : the beginning of the line;[^] : a negated character class. [^:] means anything but :;* : 0 or more of the previous pattern;: : a literal :;Taken together, this means that the first [^:]* is the first field and the second is the second field. Obviously, this is not very practical if you're looking for the 14th field but it can be useful for simpler things. So, how do we implement this to manipulate our data? There are various tools that can do this; in these examples I will use sed but you could do very similar things with awk, perl or python.How can I print only lines whose 2nd field is foo?sed -n '/^[^:]*:foo:/p' fileThe -n suppresses normal output and the /regex/p means print any lines that the regex matched.How can I print only lines whose 2nd field isn't foo?sed '/^[^:]*:foo:/d' fileThe logical inverse of the above. Here, the /regex/d means delete any lines that the regex matches.How can I print only lines whose 2nd field matches foo?sed -n '/^[^:]*:[^:]*foo/p' fileHow can I print only lines whose 2nd field doesn't match foo?sed '/^[^:]*:[^:]*foo/d' fileHow can I change the 2nd field to foo?sed 's/\([^:]*:\)[^:]*/\1foo/' file Or, since sed substitution can directly address a patterns occurrence by its repetition with a simple numeric flag:sed 's/[^:]*/foo/2' file
_unix.360869
I'm testing some custom kernels. But each time I rebuild the bzImage and copy it to /boot directory, it refuses to boot and stuck at initramfs.I recognised the problem as previously built kernel modules are not loading with the new kernel.disagrees about version of symbol module_layoutAs they're looking for the exactly same kernel version.I don't want to rebuild the modules each time.So is there any way to force the kernel not to check kernel version, like --force-varmagic and load them ?Also is there any way to disable this local version related issue while configuring the kernel ?UpdatesIn my kernel configuration CONFIG_MODVERSIONS is y and CONFIG_MODULE_FORCE_LOAD is also y .
Boot time kernel parameter to ignore module version check
linux;linux kernel;kernel modules
null
_reverseengineering.15579
I know that shl instruction is like mul operation, and shr is like div operation, and it's used for optimization. shl eax, n is the same as eax = (eax)*(2^n)Now I am reading about rol and ror assembly instructions and I got how it works, but I don't know what is the point of the rotation operation in general and when to use it?
What is the need of the Rotation Operation?
assembly;x86
null
_unix.198061
Background and Current SituationI inherited a CentOS 5.7 box running Mailman 2.1.9 housing a series of legacy mailing lists. I've been working on moving these lists to other services like Exchange mailing lists and have simply been aliasing the mailing list on the current mailman box to the new Exchange list which is a great short term fix for getting users to use the new lists.I'd ultimately like to phase out this box and remove it from production but for a few months at least I'd like to auto-reply to (but not forward) messages sent to the old lists and let clients know that the list is going to be phased out and ideally inform them of the new list address.The QuestionWhat would be the best way to take messages sent to [email protected] where the current alias in /etc/aliases looks like training: |/usr/lib/mailman/mail/mailman post trainingand reply to the sender with a message? I've read in a number of places that procmail or the vacation package are the best bets but I can't seem to find any guidance on how to adapt these solutions to large numbers of aliases where there aren't actual users behind the alias.One Caveat is that the lists aren't transitioning one for one (i.e. [email protected] isn't becoming [email protected]) so I can't simply do a blanket redirect or simply update the MX records to point to a new set of mail servers. Environment DetailsBelow are some details about the current box and installed packages:CentOS 5.7Mailman 2.1.9Procmail 3.22Sendmail 8.13.8Postfix 2.3.3
Auto-Reply to Messages Sent to Mailing List
email;sendmail;procmail
Your question is hazy on the details, and I have a bad feeling you are making the whole thing more complex than it needs to be (do you really need to rename the mailing lists? What is it about Exchange that makes it not worse?) but to attempt to answer your concrete question, you should be able to add a second destination to the alias which runs the responder, then passes the message to Mailman, or forwards to the new list address, or whatever. (Of course, if you just want to send the reply, you don't need the original destination any longer; but it is worth pointing out that this is a possibility.)training: |/usr/local/bin/autoreply training, |/usr/lib/mailman/mail/mailman post trainingwhere /usr/local/bin/autoreply might look something like#!/bin/sh######## WARNING: not properly investigatedvacation -a $1 -m /etc/vacation.msg -f /etc/vacation -e /etc/vacationI have not investigated whether it is possible or sensible to run vacation with these options, and it also depends on which user you are running this action as (sendmail?). You need to set things up so that the user who runs this script has write access to the resources the program is trying to use; maybe even create a separate user for this purpose. As a starting point, if you can run vacation -I with the above options as root and then change the owner of the files it creates to the user you want to use for this, you should be all set.Obviously, if you want to use Procmail instead of vacation, you can pretty much copy and paste the traditional recipe from man procmailex -- because it is made up from simple pieces, it might be easier to adapt to your circumstances if you can't get vacation to work reasonably in this setting.... Or look into something like http://www.brandonchecketts.com/archives/vacation-autoreply-message-with-virtual-users-and-postfix as a one-stop replacement for the regular vacation program. If your end goal is simply to shut down things ASAP, you might want to consider replacing Sendmail with Postfix just so you have a simpler and more secure system during the transition period, and then the virtual vacation responder instructions behind the link should be easy to just plug and play. (See also https://benjaminjchapman.wordpress.com/2012/07/31/creating-a-vacation-message-in-centos/ for a sort of middle ground.)
_softwareengineering.183807
I've written a recursive search algorithm to find the boundaries of a voxel data structure in order to render it more efficiently. I've looked around, and either it's such a simple and obvious technique that nobody's bothered to patent it, or it's novel and nobody's done it this way before.It's openly published on GitHub and protected under the GPL. I'd like to show it to others, to see if it can be improved, however...I fear that although I've written and published it, someone may attempt to patent the same idea.Am I safe, protected by the banners of open source software, or must I attempt to protect myself like the big guns and patent trolls do?It's my belief that software patents are evil, and that in order for the best software to be written, many eyes need to see it. I'm worried this may be a rather nave viewpoint on how software is written, though, and I'm curious as to what others think.
Can someone else patent my open-sourced algorithm?
licensing;algorithms;software patent
Disclaimer: I am not a lawyer. If you are concerned enough, seek professional legal advice.Assuming we are dealing with US law, it would be very difficult for someone to patent it now because the code on GitHub would be prior art. However, someone may have already filed a patent before you first published the work to GitHub. Make sure you keep any notes, source code or similar material if it significantly predates the GitHub work. I would not recommend looking for similar patents because they can be very difficult to read and, if you do find one and continue, your liability triples under US law.However, I would recommend searching for similar implementations outside patents as there may be existing prior art elsewhere. As someone whose professional work used to include reviewing patent applications and looking for prior art, if you do not find anything similar, I would guess you are not searching in the right places or using the correct terms.Also note that, even if someone else does patent it, they may not assert their right to prevent you using the invention. They would only do so if your use of the invention materially impacts their sales or otherwise made them more money than taking legal action against you.As mentioned above, seek professional advice if it concerns you.[Edit: Added the following.]Also remember that the GitHub code is only prior art for that exact implementation. There may be variations, alternatives or improvements, for example, so keeping notes or a diary for potentially patentable work is critical.
_datascience.9025
I've been writing a java library that I want to use to build Bayesian Belief Networks. I have classes that I use to build a Directed Graphpublic class Node{ private String label; private List<Node> adjacencyList = new ArrayList<Node>(); private Frequency<String> distribution = new Frequency<String>(); public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public List<Node> getAdjacencyList(){ return adjacencyList; } public void addNeighbour(Node neighbour){ adjacencyList.add(neighbour); } public void setDistribution(List<String> data){ for(String s:data){ distribution.addValue(s); } } public double getDistributionValue(String value){ return distribution.getPct(value); }} Graphpublic class DirectedGraph {Map<String,Node> graph = new HashMap<String,Node>();public void addVertex(String label){ Node vertex = new Node(); vertex.setLabel(label); graph.put(label, vertex);}public void addEdge(String here, String there){ Node nHere = graph.get(here); Node nThere = graph.get(there); nThere.addNeighbour(nHere); graph.put(there,nThere);}public List<Node> getNeighbors(String vertex){ return graph.get(vertex).getAdjacencyList();}public int degree(String vertex){ return graph.get(vertex).getAdjacencyList().size();}public boolean hasVertex(String vertex){ return graph.containsKey(vertex);}public boolean hasEdge(String here, String there){ Set<Node> nThere = new HashSet<Node>(graph.get(there).getAdjacencyList()); boolean thereConHere = nThere.contains(here); return (thereConHere);}}I have a class that I use to keep track of the probability distribution of a data setpublic class Frequency<T extends Comparable<T>> {private Multiset event = HashMultiset.create();private Multimap event2 = LinkedListMultimap.create();public void addValue(T data){ if(event2.containsKey(data) == false){ event2.put(data,data); } event.add(data);}public void clear(){ this.event = null; this.event2 = null; this.event = HashMultiset.create(); this.event2 = LinkedListMultimap.create();}public double getPct(T data){ int numberOfIndElements = event.count(data); int totalNumOfElements = event.size(); return (double) numberOfIndElements/totalNumOfElements;}public int getNum(T data){ int numberOfIndElements = event.count(data); return numberOfIndElements;}public int getSumFreq(){ return event.size();}public int getUniqueCount(){ return event.entrySet().size();}public String[] getKeys(){ Set<String> test = event2.keySet(); Object[] keys = test.toArray(); String[] keysAsStrings = new String[keys.length]; for(int i=0;i<keys.length;i++){ keysAsStrings[i] = (String) keys[i]; } return keysAsStrings;}}as well as another function that I can use to calculate conditional probabilitiespublic double conditionalProbability(List<String> interestedSet, List<String> reducingSet, String interestedClass, String reducingClass){ List<Integer> conditionalData = new LinkedList<Integer>(); double returnProb = 0; iFrequency.clear(); rFrequency.clear(); this.setInterestedFrequency(interestedSet); this.setReducingFrequency(reducingSet); for(int i = 0;i<reducingSet.size();i++){ if(reducingSet.get(i).equalsIgnoreCase(reducingClass)){ if(interestedSet.get(i).equalsIgnoreCase(interestedClass)){ conditionalData.add(i); } } } int numerator = conditionalData.size(); int denominator = this.rFrequency.getNum(reducingClass); if(denominator !=0){ returnProb = (double)numerator/denominator; } iFrequency.clear(); rFrequency.clear(); return returnProb;}However, I'm still not sure how to hook everything up in order to perform classification.I was reading over a paper entitled Comparing Bayesian Network Classifiers to try and get an understanding. Let's say that I am trying to predict a person's sex based on the attributes height, weight and shoe size. My understanding is that I would have Sex as my parent/classification node and height, weight and shoe size would by my child nodes.This is what I'm confused about. The various classification nodes only keep track of the probability distribution of their respective attributes, but I'd need the conditional probabilities in order to perform classification.I have an older version of Naive Bayes that I wrotepublic void naiveBayes(Data data,List<String> targetClass, BayesOption bayesOption,boolean headers){ //intialize variables int numOfClasses = data.getNumOfKeys();//.getHeaders().size(); String[] keyNames = data.getKeys();// data.getHeaders().toArray(); double conditionalProb = 1.0; double prob = 1.0; String[] rClass; String priorName; iFrequency.clear(); rFrequency.clear(); if(bayesOption.compareTo(BayesOption.TRAIN) == 0){ this.setInterestedFrequency(targetClass); this.targetClassKeys = Util.convertToStringArray(iFrequency.getKeys()); for(int i=0;i<this.targetClassKeys.length;i++){ priors.put(this.targetClassKeys[i],iFrequency.getPct(this.targetClassKeys[i])); } } //for each classification in the target class for(int i=0;i<this.targetClassKeys.length;i++){ //get all of the different classes for that variable for(int j=0;j<numOfClasses;j++){ String reducingKey = Util.convertToString(keyNames[j]); List<String> reducingClass = data.dataColumn(reducingKey,DataOption.GET,true);// new ArrayList(data.getData().get(reducingKey)); this.setReducingFrequency(reducingClass); Object[] reducingClassKeys = rFrequency.getKeys(); rClass = Util.convertToStringArray(reducingClassKeys); for(int k=0;k<reducingClassKeys.length;k++){ if(bayesOption.compareTo(BayesOption.TRAIN) == 0){ conditionalProb = conditionalProbability(targetClass, reducingClass, this.targetClassKeys[i], rClass[k]); priorName = this.targetClassKeys[i]+|+rClass[k]; priors.put(priorName,conditionalProb); } if(bayesOption.compareTo(BayesOption.PREDICT) == 0){ priorName = this.targetClassKeys[i]+|+rClass[k]; prob = prob * priors.get(priorName); } } rFrequency.clear(); } if(BayesOption.PREDICT.compareTo(bayesOption) == 0){ prob = prob * priors.get(this.targetClassKeys[i]); Pair<String,Double> pred = new Pair<String, Double>(this.targetClassKeys[i],prob); this.predictions.add(pred); } } this.iFrequency.clear(); this.rFrequency.clear();}So I generally understand how the math works, but I'm not quite sure how I'm supposed to get things to work with this specific architecture. How do I calculate the conditional probabilities?Can somebody explain this discrepancy to me please?
How do I perform Naive Bayes Classification with a Bayesian Belief Network?
machine learning;data mining;classification;statistics;predictive modeling
After reading some more papers, I realize that I misunderstood how the graphs work. The graphs are supposed to contain the conditional probabilities based on their parent(s). This clears up the doubts that I had before.For more information, see this book chapter.