id
stringlengths
5
27
question
stringlengths
19
69.9k
title
stringlengths
1
150
tags
stringlengths
1
118
accepted_answer
stringlengths
4
29.9k
_unix.277624
I need to have a PHP file execute whenever the httpd service starts or restarts. I found that Systemd has a configuration setting called **ExecStartPost, which looks perfect for what I need to do.I updated the /etc/systemd/system/multi-user.target.wants/httpd.service file to reflect the following:[Unit]Description=The Apache HTTP ServerAfter=network.target remote-fs.target nss-lookup.targetDocumentation=man:httpd(8)Documentation=man:apachectl(8)[Service]Type=notifyEnvironmentFile=/etc/sysconfig/httpdExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUNDExecStartPost=/bin/php /usr/sbin/php_testExecReload=/usr/sbin/httpd $OPTIONS -k gracefulExecStop=/bin/kill -WINCH ${MAINPID}# We want systemd to give httpd some time to finish gracefully, but still want# it to kill httpd after TimeoutStopSec if something went wrong during the# graceful stop. Normally, Systemd sends SIGTERM signal right after the# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give# httpd time to finish.KillSignal=SIGCONTPrivateTmp=true[Install]WantedBy=multi-user.targetThe content of /usr/sbin/php_test is:#!/bin/php<?phpecho Writing to /tmp/php-test.txt...\n;$myfile = fopen(/tmp/php-test.txt, w) or die(Unable to open file!);$txt = TEST! . date(F j, Y, g:i a) . PHP_EOL;fwrite($myfile, $txt);fclose($myfile);echo Done!!\n;?>Then I chmod 777 the php file and reloaded the daemon files via systemctl daemon-reload. But when I restart httpd, it doesn't create the /tmp/php-test.txt file that I was expecting to see. If I execute /bin/php /usr/sbin/php_test via the command line, it works perfectly fine.I found a separate StackOverflow thread stating that Systemd reads the .service files from bottom to top, so I moved the ExecStartPost line to right above the ExecStart line, reloaded the daemon files and restarted apache again, with no success...What am I doing wrong here?Thanks!Update 1I changed the httpd.service file to the following:[Unit]Description=The Apache HTTP ServerAfter=network.target remote-fs.target nss-lookup.targetDocumentation=man:httpd(8)Documentation=man:apachectl(8)[Service]Type=notifyEnvironmentFile=/etc/sysconfig/httpdExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUNDExecStartPost=/bin/bash -c /bin/php -f /tmp/php_testExecReload=/usr/sbin/httpd $OPTIONS -k gracefulExecStop=/bin/kill -WINCH ${MAINPID}# We want systemd to give httpd some time to finish gracefully, but still want# it to kill httpd after TimeoutStopSec if something went wrong during the# graceful stop. Normally, Systemd sends SIGTERM signal right after the# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give# httpd time to finish.KillSignal=SIGCONTPrivateTmp=true[Install]WantedBy=multi-user.targetAnd now I get an error (at least that's something to go on!). When I review the logs via journalctl -xe, I see the following:Apr 19 12:47:46 silo-stg-a01.cymedica.com systemd[1]: Starting The Apache HTTP Server...-- Subject: Unit httpd.service has begun start-up-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel---- Unit httpd.service has begun starting up.Apr 19 12:47:46 silo-stg-a01.cymedica.com bash[13268]: Could not open input file: /tmp/php_testApr 19 12:47:46 silo-stg-a01.cymedica.com systemd[1]: httpd.service: control process exited, code=exited status=1Apr 19 12:47:47 silo-stg-a01.cymedica.com systemd[1]: Failed to start The Apache HTTP Server.-- Subject: Unit httpd.service has failed-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel---- Unit httpd.service has failed.---- The result is failed.Apr 19 12:47:47 silo-stg-a01.cymedica.com systemd[1]: Unit httpd.service entered failed state.Apr 19 12:47:47 silo-stg-a01.cymedica.com systemd[1]: httpd.service failed.The error is Could not open input file: /tmp/php_test.. Not sure what that means yet though.And I'm aware that prefixing the command with a hyphen would let the process move on even if the PHP file fails to execute, but that's not what I'm trying to fix. I need the PHP script to execute properly.FYI, if you're wondering why I have it execute /bin/bash -c /bin/php -f /tmp/php_testand not just /bin/php -f /tmp/php_testI was just playing around with trying to have it execute the php script from a bash command. But if I change it to just /bin/php -f /tmp/php_test, I get the exact same error in journalctlUpdate 2I notice that if I replace the ExecStartPost line with the PHP command with just:ExecStartPost=/bin/logger ExecStartPost 1(which goes just after the ExecStart line), it logs ExecStartPost 1 to the logs just fine... So I think its related to how the php file itself is executed
Configuring Systemd to execute extra script after httpd start/restart using ExecStartPost setting not working
centos;systemd;init script;apache httpd
You have in your unit file:PrivateTmp=trueThis means systemd will create a separate namespace for the unit's /tmp and /var/tmp directories. Remove the line to use the usual /tmp.
_unix.374965
I am trying to compile the HDF-EOS5 augmentation tool. However, when I run:./configure --with-hdfeos5=/HDF-EOS5-path/I get the error:checking for inv_init in -lGctp... noconfigure: error: invalid Gctp in hdfeos5When I try to check the config.log files, I get:configure:3571: $? = 0configure:3580: result: yesconfigure:3608: checking for compress2 in -lzconfigure:3633: gcc -o conftest -g -O2 conftest.c -lz -lm >&5configure:3633: $? = 0configure:3642: result: yesconfigure:4325: checking for inv_init in -lGctpconfigure:4350: gcc -o conftest -g -O2 -I/home/midawn/ClimateResearch/hdfeos5//include -L/home/midawn/ClimateResearch/hdfeos5//lib conftest.c -lGctp -lz -lm >&5/usr/bin/ld: cannot find -lGctp collect2: error: ld returned 1 exit statusconfigure:4350: $? = 1configure: failed program was:| /* confdefs.h */| #define PACKAGE_NAME aug_eos5| #define PACKAGE_TARNAME aug_eos5| #define PACKAGE_VERSION 2.2| #define PACKAGE_STRING aug_eos5 2.2| #define PACKAGE_BUGREPORT [email protected]| #define PACKAGE_URL | #define PACKAGE aug_eos5| #define VERSION 2.2| #define HAVE_LIBM 1| #define HAVE_LIBZ 1| /* end confdefs.h. */| | /* Override any GCC internal prototype to avoid an error.| Use char because int might match the return type of a GCC| builtin and then its argument prototype would still apply. */| #ifdef __cplusplus| extern C| #endif| char inv_init ();| int| main ()| {| return inv_init ();| ;| return 0;| } configure:4359: result: noconfigure:4369: error: invalid Gctp in hdfeos5
Error with installation of HDF-EOS5 augmentation tool: Cannot find -lGtcp
gcc
null
_unix.17310
I use this command to fill out a form in Drupal 6 (create node):curl -b cookies.txt -d title=thetitle&menu%5Blink_title%5D=&menu%5Bparent%5D=primary-links%3A0&menu%5Bweight%5D=0&teaser_include=1&body=content+here&format=1&changed=&form_build_id=form-01fbf44be3dab1ea177d17544bce415c&form_token=f1af1b01946065a34e49fdbde8fcc64b&form_id=story_node_form&log=&comment=2&pathauto_perform_alias=1&field_pidio%5B0%5D%5Bembed%5D=&name=admin&date=&status=1&promote=1&op=Save http://localhost/subdo/node/add/storyIt works without any problem; no messages in the terminal and the node is created in Drupal as expected.After a while, I use that code again without any modification. But instead of posting a new node, the terminal shows the HTML code of the form. It looks like cURL isn't hitting the Save button.
submitting form with cURL sometimes works, sometimes doesn't
curl
null
_softwareengineering.215263
I have a design problem related to a public interface, the names of methods, and the understanding of my API and code.I have two classes like this:class A: ... function collision(self): .......class B: .... function _collision(self, another_object, l, r, t, b): ....The first class has one public method named collision, and the second has one private method called _collision. The two methods differs in argument type and number.As an example let's say that _collision checks if the object is colliding with another object with certain conditions l, r, t, b (collide on the left side, right side, etc) and returns true or false. The public collision method, on the other hand, resolves all the collisions of the object with other objects.The two methods have the same name because I think it's better to avoid overloading the design with different names for methods that do almost the same thing, but in distinct contexts and classes.Is this clear enough to the reader or I should change the method's name?
How bad is it to have two methods with the same name but different signatures in two classes?
design patterns;software;class design;design;class diagram
null
_cstheory.19405
The subgraph isomorphism problem problem is to determine given $G$ and $H$ whether $G$ is a subgraph of $H$.Let $G$ and $H$ be regular graphs with degree of $H$ greater than degree of $G$.Does the subgraph isomorphism problem remain NP-complete for the following case:$1.$ Girth of $G$ and $H$ are fixed, say $girth=3$ or a fixed $h$?How large should a fixed $k$-diameter $d_H$-regular graph $H$ be for it to have a fixed $k$-diameter $d_G$-regular subgraph $G$ of vertex count $n_G$ when both have the same girth?
On the subgraph isomorphism problem
graph theory;graph isomorphism
null
_cs.65099
I'm currently working through some regular expression questions and I've got a solution for one of the problems that I'm not certain is correct. The question has this preface.We only consider languages over the alphabet $\{0, 1, 2\}$. We also view words over this alphabet as ternary numbers. For the language below give either a regular expression that describes it or a proof that the language is not regular. Note that e.g. the set of integers $\{4, 7, 11\}$ (in decimal notation) becomes in this view the language $\{11, 21,102\}$.The question - The set of all words that contain more 1s than 2s.Would the regular expression (11)2 suffice for this?
The set of all words containing more 1's than 2s
formal languages;regular languages;regular expressions
No. The regular expression $(11)2$ describes the language $\{ 112 \}$, which is clearly not the language of all strings with this property.Hint: Can you really count character occurrences using the regular operators?
_webapps.42870
I am running out of storage in my gmail account. However, I have 5GB of free space on my Google Drive. Is there a way I can store some of my emails (not only their attachments, but the complete email) in my Google Drive?Another viable solution would be do add the storage that I have on my Google Drive to the one on my Gmail account. Is this possible?
Adding my free Google Drive storage to my Gmail storage
gmail;google drive;online storage
null
_unix.360279
During boot, my system displays this message.Loading, please wait... One or more specified logical volume(s) not found.Unable to find LVM volume vg_ssd/swapScanning for Btrfs filesystems[...]Then, it finishes booting.It's trying to mount a logical volume that used to exist, before I removed it. vg_ssd/swap is not in /etc/fstab anymore, so why is it trying to mount it?Edit: I found a file in my initial ramdisk with /dev/mapper/vg_ssd-swap in it. Regenerating initramfs doesn't make it go away.$ mkdir bootimg; cd bootimg$ zcat /boot/initrd.img-3.16.0-4-amd64 | cpio -i$ cat conf/conf.d/resumeRESUME=/dev/mapper/vg_ssd-swap
Boot process tries to mount nonexistent logical volume
debian;lvm
initrd is trying to check whether the computer is resuming from hibernate. Even though swap is not in /etc/fstab, it's still in the config file /etc/initramfs-tools/conf.d/resume.Edit that file, and comment out the only line. ChangeRESUME=/dev/mapper/vg_name-lv_nameto#RESUME=/dev/mapper/vg_name-lv_nameRegenerate initrd. Run:update-initramfs -uupdate-grubSee also: Debian error message: Unable to find LVM volume, but then boots successfully and https://askubuntu.com/questions/292878/how-to-set-swap-in-etc-initramfs-tools-conf-d-resume-if-i-have-two-swap-partito
_vi.7481
I am root on the machine, and have my .vimrc at /root/.vimrc. Vim ignores this, even though # echo $HOME/rootIf I do# vim -u /root/.vimrc some-file-to-editvim still ignores it. Setting export MYVIMRC=root/.vimrc has no effect.Vim sources my file without problems if I start vim and type :source /root/.vimrc.Note VIMINIT is unset.What could be preventing vim from sourcing my .vimrc when starting up?I'm happy to supply any other information that may be helpful, just let me know what.EDIT 1: excerpt from running vim -V filename:...finished sourcing $VIM/vimrcchdir(/root)fchdir() to previous dir sourcing $HOME/.vimrcSearching for filetype.vim in /root/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,/root/.vim/afterSearching for /root/.vim/filetype.vim...The full output is long, so this is just an excerpt to show the line that verifies sourcing of /root/.vimrc.EDIT 2: output from running :scriptnames after vim normally* 1: /usr/share/vim/vimrc 2: /usr/share/vim/vim74/debian.vim 3: /usr/share/vim/vim74/syntax/syntax.vim 4: /usr/share/vim/vim74/syntax/synload.vim 5: /usr/share/vim/vim74/syntax/syncolor.vim 6: /usr/share/vim/vim74/filetype.vim 7: ~/.vimrc 8: /usr/share/vim/vim74/indent.vim 9: /usr/share/vim/vim74/ftplugin.vim 10: /usr/share/vim/vim74/syntax/nosyntax.vim 11: /usr/share/vim/vim74/plugin/getscriptPlugin.vim 12: /usr/share/vim/vim74/plugin/gzip.vim 13: /usr/share/vim/vim74/plugin/matchparen.vim 14: /usr/share/vim/vim74/plugin/netrwPlugin.vim 15: /usr/share/vim/vim74/plugin/rrhelper.vim 16: /usr/share/vim/vim74/plugin/spellfile.vim 17: /usr/share/vim/vim74/plugin/tarPlugin.vim 18: /usr/share/vim/vim74/plugin/tohtml.vim 19: /usr/share/vim/vim74/plugin/vimballPlugin.vim 20: /usr/share/vim/vim74/plugin/zipPlugin.vim 21: /usr/share/vim/vim74/indent/python.vim 22: /usr/share/vim/vim74/ftplugin/python.vim 23: /usr/share/vim/vim74/syntax/python.vimAgain, seems to be sourcing /root/.vimrc (item 7). Soo... line 8 makes me suspicious: my problem is that the indent settings in my vimrc aren't reflected. Maybe they are being superceeded...EDIT 3: Placing my file in ~/.vim/after/...Moving my file to the following locations had no effect on the output of scriptnames:~/.vim/after/indent.vim~/.vim/after/indent.vim/myscript.vim~/.vim/after/indent/myscript.vim ~/.vim/after/syntax/myscript.vim~/.vim/after/indent/myscript.vim~/.vim/after/myscript.vimAnd, while moving my to ~/.vim/after/plugin/.vimrc did change the output of :scriptnames, causing my file to be sourced after item 20 (see above), it seems my indent settings are still getting overridden (probably by item 21).Use of the after directory doesn't work how I imagined (see my list of attempts). Only after/plugins/ seems to be considered.Is there a way to ensure that the file is sourced after everything?
Why won't vim source my vimrc?
vimrc;invocation
Here is what worked for me:First opening vim normally and doing :scriptnames showed that, in fact, my ~/.vimrc was sourced. Other scripts were just overridding my indent settings.Moving just the lines pertaining to indentation from my ~/.vimrc into a new file at ~/.vim/after/ftplugin/python.vim solved the problem. The filename is crucial, and it is only executed when reading python files. Alternatively put the file in ~/.vim/after/ftplugin/python/some-name.vim.
_webapps.76649
My primary email address is going to be invalid soon. So I want to change my email address for my Google account. However, it seems that I can't change my email address and I can't even add a new email address.This is what it looks like:
Change or add email address to Google account
google;email
null
_unix.223276
So ssh has the option HostKeyAlgorithms. Sample usage:ssh -o HostKeyAlgorithms ssh-rsa user@hostnameI'm trying to get the client to connect using the servers ecdsa key, but I can't find what the correct string is for that.What command can I use to get a list of the available HostKeyAlgorithms?
How do I list available host key algorithms for an SSH client?
ssh;openssh
from the ssh_config man page:HostKeyAlgorithms Specifies the protocol version 2 host key algorithms that the client wants to use in order of preference. The default for this option is: [email protected], [email protected], [email protected], [email protected],[email protected], [email protected],[email protected], ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521, ssh-rsa,ssh-dss If hostkeys are known for the destination host then this default is modified to prefer their algorithms.
_softwareengineering.232436
I am learning how to work with XMLHttpRequests. I know that request.setRequestHeader() is an important factor. I just don't understand why. It took me a while but I have at least found a list of Headers here and here, but I still don't understand what each one of them does, and what value goes with each. Is there a resource that gives an example and explains what they are for?
How to use specific Request Header
headers;http request;xmlhttprequest
A quick search found: http://code.tutsplus.com/tutorials/http-headers-for-dummies--net-8039(no offense from the title; it looked like a pretty thorough article) Skip down to HTTP Headers in HTTP RequestsJust eyeballing the list, the most important headers are for content negotiation:Content-Type Most servers will need this to parse & route your request to the right function:Content-Type: application/jsonAccept Tells the server what it can send backAccept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8Authorization In my work, I usually have to provide an authorization key. But the server will tell you whether you need this or not.Authorization: Bearer aasdadadadadadsasdThe other ones are either optional, or get added by the browser. You can open the dev console in your browser and look at the network messages going back and forth & do a search on individual headers to see what they mean.
_cs.54239
During an interview I was asked to calculate the big theta complexity for the following algorithm that receives 3 sorted arrays of variable size and returns a new array which has the elements of the original 3 arrays.The algorithm is pretty basic: we set indexes at the beginning of each array and use such indexes for accessing the elements, in that fashion we find the minimum element for the 3 arrays (at the position given by the indexes) and then we insert the element into the resulting array and we increase such index. We repeat until we are done processing every element.My answer was that the complexity was linear because we are processing n elements and we are doing a constant number of comparisions for finding the minimum element out of the 3 arrays (at the given index position). Yet, I was told that the complexity is not linear but it is higher than nlogn.I have a few ideas but could someone explain the actual complexity of this algorithm for me?Thanks for your time.
Complexity for merging 3 sorted arrays using this specific algorithtm
complexity theory;runtime analysis
Assuming that you're using some random-access model of computation (i.e., not an ordinary Turing machine) and that comparisons can be done in constant time, the algorithm you describe is linear. Each element of the final array is produced by comparing at most three elements of the original arrays, so each element of the output is produced in constant time.Perhaps you misunderstood the question and they were actually asking about something else? Perhaps they mis-stated their question and they were trying to ask about the complexity of three-way mergesort (sorting an array by splitting into three parts, recursively sorting the parts, then merging them)? Perhaps they were just wrong.
_softwareengineering.330921
I am trying to build a very basic instant messaging platform. I have three basic immutable types, and each of them has a subclass for dealing with CRUD (for SRP purposes, separating the class from the database logic).Conversation:public class Conversation{ public uint Id { get; private set; } public List<Participant> Participants { get; private set; } public List<Message> Messages { get; private set; } /* Some extra properties */ public Conversation(uint id, List<Participant> participants, List<Message> messages) { Id = id; Participants = participants; Messages = messages; } public static class CRUD { static void Create(...) {} static void Read(...) {} static void Update(...) {} static void Delete(...) {} }}Message:public class Message{ public uint Id { get; private set; } public Conversation Conversation { get; private set; } public Participant Sender { get; private set; } public DateTime SendingTime { get; private set; } public string Content { get; private set; } /* Constructor */ /* CRUD */}Participant:public class Participant{ public Conversation Conversation { get; private set; } public Employee Employee { get; private set; } /* Constructor */ /* CRUD */}I thought Message.CRUD.Read(...) should get the messages from the database, and Participant.CRUD.Read(...) should get the participant from the database. But then What should Conversation.CRUD.Read(...) read and what should it return?I mean, should it get from the database all the information about the conversation that has no class representation in the code (i.e. not Message and Participant), and then, should it return a non-complete object of Conversation with some nulls or should it do something else? What is the best practice here? Is there any?
What should a Read (as in CRUD) method return for a class that uses another class with a Read method?
c#;crud
Your problem is that your Conversation class does not correspond to one record in the database. The Message class and the Participants classes do.If you do want to apply the same CRUD technique to conversations you should have a ConversationParticipant class (loading the list of participants from its table and the participant information via the Participant class) and ConversationMessage class (similarily loading via the Message class).Then the Conversation class could use these two classes to load the participants and the messages and it could load the main information on the Conversation itself.
_webmaster.27180
I have recently put my site live - http://www.soundplaza.co.ukI then bumped into a few articles mentioning about page length and depth and I was wondering if I should change the URL structure while the site is new.Change From:http://www.soundplaza.co.uk/speakers/tannoy-revolution-signature-dc4t/10Change To:http://www.soundplaza.co.uk/speakers/tannoy-revolution-signature-dc4t-10As you can probably see I am using the ID at the end to bring the page content through.Do you think its worth removing the extra level, or do you think it will confuse the product name?
Removing page levels/ keeping url clean
url;url rewriting;clean urls
It looks like your current URL paths are of the form /category/redundant-descriptive-title/id, where only the category and id parts are actually needed to identify the content. (For example, I can link to http://www.soundplaza.co.uk/speakers/blah-blah-who-reads-this-anyway/10 and see the exact same content as on the page you linked in your question.)I would suggest changing that structure to /category/id/redundant-descriptive-title, so that the descriptive part of the URL is the last one. (If that looks familiar to you, it's the exact same URL structure as used by the StackExchange software.)That order has a natural hierarchical structure: the first part identifies the category, the second identifies the product in the category, and the third... doesn't actually identify anything in this case, since it's redundant to the first two, but conceptually it could narrow down the identification even further.I would also strongly suggest setting up either 301 redirects or rel=canonical links from URLs with incorrect (and/or outdated) descriptive parts to the correct canonical URLs for each product. If you don't do that, any links with outdated or mistyped or just plain bogus titles, like the one I demonstrated above, may be seen by search engines as duplicate content.(Ps. Swapping the order of the URL path elements around like that might make dealing with legacy links a bit tricky, but I'd really consider that an excellent reason to do it ASAP rather than later. As long as none of your existing URLs have all-numeric middle parts, something like the following rewrite rule ought to redirect them to the new format:RewriteRule ^/?([^/]+)/([0-9]*[^/0-9][^/]*)/([0-9]+)$ /$1/$3/$2 [NS,L,R=301]Of course, you may want to adjust that regexp — especially the category part — to match your existing URLs structure more strictly.)Edit: Per comments below, I might set up the rewrite rules something like this:RewriteEngine OnRewriteBase /# 301 redirect from speakers/title/id to speakers/id/titleRewriteRule ^speakers/([0-9]*[^/0-9][^/]*)/([0-9]+)$ /speakers/$2/$1 [NS,L,R=301]# Internally rewrite speakers/id/title to details.phpRewriteRule ^speakers/([0-9]+)/(.*)$ details.php?dealID=$1&name=$2 [NS]I left out the [L] from the second rule, since it probably doesn't do what you expect when used with internal rewrites in an .htaccess file. If you really want to skip all later rewrite rules, use [END] instead.As noted above, I would also recommend making details.php either:include a rel=canonical link pointing to the correct http://www.soundplaza.co.uk/speakers/id/title URL for the item in the HTML <head> section, and/orcompare the title passed in via the name parameter to the title the product is supposed to have, and, if they don't match, return a 301 redirect to the correct canonical URL.In fact, I'd suggest doing both: there are various corner cases that each of these techniques will handle that the other might not.
_unix.305524
I was wondering if it is possible to keep a file containing history per current working directory. So for example if I was working in /user/temp/1/ and typed a few commands, these commands would be saved in /user/temp/1/.his or something. I am using bash.
Create history log per working directory in bash
bash;command history;working directory
Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.function ch () { cd $@ export HISTFILE=$(pwd)/.bash_history}automatically exporting the new HISTFILE value each time ch is called.The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.A complete solution consists of adding two more lines to your ~/.bash_profile,shopt -s histappendPROMPT_COMMAND=history -a;$PROMPT_COMMANDchanging the history mode to append with the first line and then configuring the history command to run at each prompt.
_unix.137904
Preferably something similar to iptables. Basically, I want to do domain filtering/whitelisting/blacklisting like I would with IPs in iptables. Are there any recommendations on how to do this?
How to do domain filtering in Linux?
linux;firewall;domain
null
_unix.225275
I just started playing with the fish shell, and I really like is so far. However, I can't figure out what the purpose of fishd is. So, why does fish need to start up a daemon process? What is the daemon process used for?
Why does the fish shell need to start a daemon process?
fish
null
_unix.30228
Job control is probably my favorite thing about Linux. I find myself, often, starting a computationally demanding process that basically renders a computer unusable for up to days at a time, and being thankful that there is always CTRL-Z and fg, in case I need to use that particular computer during that particular time period.Sometimes, however, I want to insert a job onto the job stack. I've never figured out how to do that.I'm using bash. It would probably look something like:$ ./reallybigjob^Z[1]+ Stopped reallybigjob$ (stuff I don't know) && ./otherbigjob$ fg
Basic job control: stop a job, add a job onto the stack, and `fg`
bash;job control;jobs
There is no job stack, each job is handled independently.You can do fg; otherbigjob. That will put reallybigjob back to the foreground, then when the fg command stops run otherbigjob. This isn't the same thing as queuing otherbigjob for execution after the first job: if you press Ctrl+Z then otherbigjob starts immediately. If you press Ctrl+C then reallybigjob is killed. You can't leave otherbigjob in the background and queue another job after it.If the jobs are CPU-intensive, then the batch utility can let you schedule the next job when the CPU isn't busy.
_unix.28451
I'm trying to send cron output to an email address and am struggling... I'm running the following command:13 15 * * 1-5 root /path/to/mysql-backup.sh 2>&1 | mail -s Daily Database Backup Report [email protected] shows this error within /var/mail/root/usr/bin/mail: line 1: syntax error near unexpected token `('/usr/bin/mail: line 1: `Config file not found (-s)'Is this trying to validate/execute the output of the cron?Do you do this on your server? If so, how?
Sending cron output to email?
email;cron
In my experience, /usr/bin/mail is a binary executable, but on your system the shell seems to be loading and interpreting it. syntax error near unexpected token is a bash diagnostic.This can happen if you have overwritten an executable. Is there any conceivable chance that you have overwritten /usr/bin/mail with the text Config file not found (-s), causing said text to be fed to the shell when you try to execute it?
_softwareengineering.260075
BackgroundI have a class TextDrawable which draws text on top of a shape. There are a number of properties that can be set while creating a TextDrawable object. Mandatory Properties:TextShapeOptional Properties:ColorWidthHeightFontBorder...... etc.The class will have constructors that look like:public TextDrawable(String text, Shape shape) {}public TextDrawable(String text, Shape shape, int color) {}public TextDrawable(String text, Shape shape, int color, int width, int height) {}// and so on..Builder Pattern :I decided to use the Builder Pattern to make it more convenient to create TextDrawable objects. I followed the design as explained in Effective Java, and here in this highly upvoted answer. I came up with the builder class which will be used as follows:TextDrawable drawable = new TextDrawable.Builder(AK, Shape.RECT) .width(10) .height(10) .useFont(Typeface.DEFAULT_BOLD) .build();Possible Problem:There seems to be a problem with this design. Since the mandatory fields are passed in the constructor of the builder, the builder cannot be reused.What if I wanted to create another TextDrawable of same height, width, font etc but with different text and color. I will have to create another builder object and repeat the same code as above.TextDrawable oct = new TextDrawable.Builder(OCT, Shape.RECT) .width(10) .height(10) .useFont(Typeface.DEFAULT_BOLD) .build();TextDrawable nov = new TextDrawable.Builder(NOV, Shape.OVAL) .width(10) .height(10) .useFont(Typeface.DEFAULT_BOLD) .build();Proposed Method:What if I move the mandatory parameters from the constructor of the builder to the build method as follows:TextDrawable drawable = new TextDrawable.Builder() .width(10) .height(10) .useFont(Typeface.DEFAULT_BOLD) .build(AK, Shape.RECT);This way allows for more flexibility as I can create one instance of the builder and reuse it to create multiple objects. (Also avoids repeating the same code every time I create a new object.) The new usage will look something like:TextDrawable.Builder builder = new TextDrawable.Builder() .width(10) .height(10) .useFont(Typeface.DEFAULT_BOLD);TextDrawable oct = builder.build(OCT, Shape.RECT);TextDrawable nov = builder.build(NOV, Shape.OVAL);It prevents boilerplate code. Also allows the build method to fit into the fluency idiom as follows:TextDrawable oct = builder.buildRect(OCT);TextDrawable nov = builder.buildOval(NOV);Questions:Is the problem identified above valid or do I lack understanding of the builder pattern? Should we not reuse builder objects to created multiple instances?Is the proposed modification to the well known builder pattern valid? Are there any disadvantages of moving the mandatory fields into the build() method?If there are some possible drawbacks, what is a better way of achieving what I want? Should I be using a director object or something that encapsulates the builder to achieve what I want?
Is there a limitation when using the Bloch's Builder Pattern with mandatory fields?
java;design patterns;object oriented design
1. Is the problem identified above valid or do I lack understanding of the builder pattern? Should we not reuse builder objects to created multiple instances?It can be, depending on your situation. Here you've identified that you have mandatory fields that are unique, therefore making them parameters to your build method allows you to reuse the same pre-configured builder over and over, which is handy.2. Is the proposed modification to the well known builder pattern valid? Are there any disadvantages of moving the mandatory fields into the build() method?As far as advantages or disadvantages go, I think that the other option you haven't considered here is allowing the required fields to be set the same way the other fields are. Take the following code for example:TextDrawable.Builder builder = new TextDrawable.Builder(OCT, Shape.RECT) .width(10) .height(10) .useFont(Typeface.DEFAULT_BOLD);// Make the rectangleTextDrawable oct = builder.build();// Build the new shapeTextDrawable oct = builder.name(NOV).shape(Shape.OVAL).build();Obviously this is very similar to what you had though, and either approach is equally valid. It really comes down to how much you want to configure, and how much you know will always change. If you'll be building a bunch of rectangles of the same size, but only changing the name, this solution allows you to remove the shape parameter.3. If there are some possible drawbacks, what is a better way of achieving what I want? Should I be using a director object or something that encapsulates the builder to achieve what I want?A director would allow you to set up predefined builders more easily. You could have a director for making circles of the same size, or a director that takes in only one length and only makes squares. It's job is to reduce the boilerplate even further, but does so at added class complexity of the overall application. I would really only go this option if you are going to absolutely need it, and stick with your solution of re-using builders where possible.
_webmaster.82983
I have entered data into DHIS2 using data entry forms and would like to delete it, individually or in bulk for multiple geographical units - is there an easy way to do this?Additionally - when I update a data entry form for a data set in DHIS2 to include additional data elements - the update is not reflected in the data entry module. Is it necessary to clear the existing data entered on the original data entry form - to have the updated form available for re-entry?
How do I bulk delete data in DHIS2 that has been entered via data entry forms
data
null
_unix.233744
On my Dell XPS 13 9343 my touchpad can work with I2C bus or in PS2 mode.What is the difference between those two modes ? Why are they both available ?The output of xinput is : Virtual core pointer id=2 [master pointer (3)] Virtual core XTEST pointer id=4 [slave pointer (2)] DLL0665:01 06CB:76AD UNKNOWN id=13 [slave pointer (2)] SynPS/2 Synaptics TouchPad id=15 [slave pointer (2)]DLL0665:01 06CB:76AD UNKNOWN is the touchpad using I2C bus.
What is the difference between I2C and PS2 mode?
hardware;touchpad
null
_vi.2521
If I type :registers, I see a lot of <09>:1 <09><09><09>d = self / i.to_f^J<09><09><09>r = d.to_s^J<09><09><09>p r =~ /0$/^J2 <09><09><09>puts ''^J3 <09><09><09>p #{self}, #{i}^J<09><09><09>p d^JThe <09> represents a Tab character; they're displayed in blue.If I use :set display&vim, I get something marginally better:1 ^I^I^Id = self / i.to_f^J^I^I^Ir = d.to_s^J^I^I^Ip r =~ /0$/^J2 ^I^I^Iputs ''^J3 ^I^I^Ip #{self}, #{i}^J^I^I^Ip d^JBut it's still not useful enough to easily scan the output for the line I want..I know this is a feature, and I understand why it's there, but I find this extremely unhelpful when looking for the register I want.Is there any way to either not show it at all or show them as spaces?
Don't show tab characters as ^I or <09> in the output of :registers
register;tab characters
null
_unix.375971
Firefox is very slow, and I have tried many related posts about it, without success. One thing I noticed though is that I have IPv6 enabled:id@id:~$ test -f /proc/net/if_inet6 && echo Running kernel is IPv6 readyRunning kernel is IPv6 readyMaybe this is slowing down the browser. I have no problems with Chrome.I want to know if disabling IPv6 is safe, and if it will not cause other applications to fail. Here is the output of sudo netstat -tulpnActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 127.0.0.1:6342 0.0.0.0:* LISTEN 7841/megasync tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 6301/smbd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9356/nginx: master tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 1634/dnsmasq tcp 0 0 0.0.0.0:17500 0.0.0.0:* LISTEN 7832/dropbox tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 6301/smbd tcp 0 0 127.0.0.1:17600 0.0.0.0:* LISTEN 7832/dropbox tcp 0 0 127.0.0.1:17603 0.0.0.0:* LISTEN 7832/dropbox tcp6 0 0 :::139 :::* LISTEN 6301/smbd tcp6 0 0 :::80 :::* LISTEN 9356/nginx: master tcp6 0 0 :::443 :::* LISTEN 9356/nginx: master tcp6 0 0 :::17500 :::* LISTEN 7832/dropbox tcp6 0 0 :::445 :::* LISTEN 6301/smbd udp 0 0 0.0.0.0:17500 0.0.0.0:* 7832/dropbox udp 0 0 0.0.0.0:5353 0.0.0.0:* 1000/avahi-daemon: udp 0 0 0.0.0.0:44093 0.0.0.0:* 1000/avahi-daemon: udp 0 0 0.0.0.0:56476 0.0.0.0:* 1634/dnsmasq udp 0 0 127.0.1.1:53 0.0.0.0:* 1634/dnsmasq udp 0 0 0.0.0.0:68 0.0.0.0:* 1625/dhclient udp 0 0 192.168.1.255:137 0.0.0.0:* 6379/nmbd udp 0 0 192.168.1.100:137 0.0.0.0:* 6379/nmbd udp 0 0 0.0.0.0:137 0.0.0.0:* 6379/nmbd udp 0 0 192.168.1.255:138 0.0.0.0:* 6379/nmbd udp 0 0 192.168.1.100:138 0.0.0.0:* 6379/nmbd udp 0 0 0.0.0.0:138 0.0.0.0:* 6379/nmbd udp 0 0 0.0.0.0:631 0.0.0.0:* 6968/cups-browsedudp6 0 0 :::5353 :::* 1000/avahi-daemon: udp6 0 0 :::54618 :::* 1000/avahi-daemon: (I can't see Firefox there!) (I also notice that I have nginx running. Do I need that?)
Is is safe to disable IPv6 to speed up Firefox?
firefox;ipv6
null
_codereview.82524
This is my first open source release and I'd like to get some feedback on my code styling/organization. Implementation tips are appreciated as well.The code is for an AngularJS select box that allows you to select from a list of values, or enter in free text. The control can be configured to:compare against an attribute of the source items. return a specific attribute (EG for searching names, but returning an id). return the source object or the value (generating a object in the case of freetext input.GitHubExample usage:HTML<body ng-app=test><script type=text/javascript> angular.module(test, ['fzSelect']) .controller(test, function($scope){ $scope.myItems = [{name: 'one', value: 1}, {name: 'two', value: 2}, {name: 'three', value: 3}]; $scope.myValue = { value: something }; })</script><div style=width: 600px; ng-controller=test> <h1> {{myValue.value}} </h1> <div fz-select fz-select-items=myItems fz-match-attribute=name fz-return-attribute=value fz-return-objects=false ng-model=myValue.value /> </div></body>Angular Codeangular.module( fzSelect, [] ).directive( fzSelect, ['$filter', '$timeout', '$parse', function($filter, $timeout, $parse){ return { restrict: 'EA', // require: ['ngModel', 'fzSelectItems'], template: '<div class=input-group >'+ '<input class=form-control ng-model=searchString></input>'+ '<span class=input-group-btn>'+ '<button class=btn btn-primary ng-click=showAll() >&#9660;</button>'+ '</span>'+'</div>'+'<div class=fz-select-results-container ng-if=resultsVisible.value> '+ '<div class=fz-select-results-row '+ 'ng-repeat=item in filteredItems '+ 'ng-click=resultItemClicked(item)>{{getItemDisplayString(item)}}</div>'+'</div>', link: function($scope, element, attrs){ angular.element(element).addClass('fz-select-component'); var itemsGetter = $parse(attrs.fzSelectItems); var valueGetter = $parse(attrs.ngModel); var valueSetter = valueGetter.assign; var itemAttributeName = null; var itemAttributeGetter = null; if( attrs.hasOwnProperty('fzMatchAttribute') ){ itemAttributeGetter = $parse(attrs.fzMatchAttribute); itemAttributeName = attrs.fzMatchAttribute; } var itemReturnAttributeName = value; var itemReturnAttributeGetter = null; if( attrs.hasOwnProperty('fzReturnAttribute') ){ itemReturnAttributeGetter = $parse(attrs.fzReturnAttribute); itemReturnAttributeName = attrs.fzReturnAttribute; } else if( attrs.hasOwnProperty('fzMatchAttribute') ){ itemReturnAttributeGetter = $parse(attrs.fzMatchAttribute); itemReturnAttributeName = attrs.fzMatchAttribute; } var returnObjects = false; if( attrs.hasOwnProperty(fzReturnObjects) ){ returnObjects = attrs.fzReturnObjects == true; } $scope.items = itemsGetter($scope); $scope.searchString = valueGetter($scope); $scope.filteredItems = []; $scope.resultsVisible = {value: false}; $scope.selectedValue = null; var valueWasSelected = false; $scope.showResults = function(show){ $timeout(function(){ $scope.resultsVisible.value = show; }); }; $scope.getItemDisplayString = function(item){ if( itemAttributeGetter != null ){ return itemAttributeGetter(item); }else{ return item; } }; $scope.showAll = function(){ $scope.filteredItems = $scope.items; $scope.showResults(true); }; $scope.updateSourceValue = function(){ if($scope.selectedValue != null){ if( itemReturnAttributeGetter != null && !returnObjects){ valueSetter($scope, itemReturnAttributeGetter($scope.selectedValue)); } else { valueSetter($scope, $scope.selectedValue); } } else { if(returnObjects){ var returnObject = {} returnObject[itemReturnAttributeName] = $scope.searchString; valueSetter($scope, returnObject); } else { valueSetter($scope, $scope.searchString); } } }; $scope.resultItemClicked = function(item){ $scope.selectedValue = item; $scope.searchString = $scope.getItemDisplayString(item); valueWasSelected = true; $scope.showResults(false); }; $scope.filterItems = function(){ var searchObject = {}; if( itemAttributeName != null ){ searchObject[itemAttributeName] = $scope.searchString; } else { searchObject = $scope.searchString; } var tempList = $filter('filter')($scope.items, $scope.searchString); $scope.filteredItems = tempList; if( $scope.searchString.length > 0 && !$scope.resultsVisible.value ) $scope.showResults(true); if( $scope.searchString.length == 0 && $scope.resultsVisible.value ) $scope.showResults(false); }; $scope.$watch('searchString', function(){ $scope.filterItems(); if( !valueWasSelected ) $scope.selectedValue = null; else valueWasSelected = false; $scope.updateSourceValue(); }, true); } } }])
AngularJS select box
javascript;angular.js
null
_unix.321296
Could you please advise on the following:infra-server with IP x.x.x.x (with no internet connectivity) does the following request:$ wget http://google.com--2016-11-04 09:32:55-- http://google.com/Resolving google.com (google.com)... 172.217.22.110, 2a00:1450:4001:81d::200eConnecting to google.com (google.com)|172.217.22.110|:8888... failed: Connection timed out.proxy-server (squid listening on 8888) has the following interfaces:eth1: 1.1.1.1 where all incoming requests from infra-server are coming ineth2: 2.2.2.2 which has internet connectivity with a default route (80,443) because its address is translated in the firewall (gateway)By doing a tcpdump on proxy-server and eth1 (incoming interface) I see correctly the traffic arriving:09:49:10.033951 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204336400 ecr 0,nop,wscale 7], length 009:49:11.034310 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204337402 ecr 0,nop,wscale 7], length 009:49:13.042720 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204339408 ecr 0,nop,wscale 7], length 009:49:17.047283 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204343416 ecr 0,nop,wscale 7], length 009:49:22.303238 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [R], seq 258250387, win 1400, length 009:49:25.060419 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204351424 ecr 0,nop,wscale 7], length 009:49:30.321096 IP x.x.x.x.45977 > 1.1.1.1.8888: Flags [R], seq 258250387, win 1400, length 0By doing a tcpdump on the proxy-server and eth2 (outgoing interface) I do not see any outgoing http trafficWhat I have changed in the configuration of squid is only the following:acl infra-server src x.x.x.x/32http_access allow infra-serverhttp_port 1.1.1.1:8888System-wise, SElinux is set to permissive:# getenforcePermissiveand how firewalld is configured is:# firewall-cmd --list-all --zone=internalinternal (active) interfaces: eth1 sources: services: dhcpv6-client ipp-client mdns samba-client ssh ports: 8888/tcp masquerade: no forward-ports: icmp-blocks: rich rules: # firewall-cmd --list-all --zone=externalexternal (active) interfaces: eth2 sources: services: http https ssh ports: masquerade: yes forward-ports: icmp-blocks: rich rules: I just need the rule to forward traffic from eth1 to eth2 (I think).Could you please advise ?
firewalld + squid : how-to setup a proxy
linux;networking;proxy;squid;firewalld
null
_unix.323256
This is as much a question about suspending processes/SIGSTOP as it is about stressSo I'm using stress to simulate memory pressure on my system. stress --vm X --vm-bytes YMThis works fine, but I notice that it consumes a lot of CPU. root@ET0021B703EB23:~# ps -aux | grep stressroot 11800 0.0 0.0 2192 232 pts/4 S+ 15:21 0:00 stress --vm 1 --vm-bytes 10Mroot 11801 83.5 0.2 12436 2436 pts/4 R+ 15:21 0:03 stress --vm 1 --vm-bytes 10MNow CPU load isn't something I want to be concerned about in this test. I used Ctrl + Z to suspend my stress, and I now see that the CPU consumed has fallen but the memory remains, which is what I wanted.root@ET0021B703EB23:~# ps -aux | grep stressroot 9080 0.0 0.0 2760 296 pts/2 S+ 15:18 0:00 grep stressroot 17030 0.0 0.0 2192 172 pts/2 T 14:51 0:00 stress --vm 1 --vm-bytes 10Mroot 17031 2.7 0.4 12436 4860 pts/2 T 14:51 0:44 stress --vm 1 --vm-bytes 10MAs I understand it, keeping a process suspended will keep it in memory. Can I therefore use this method to reliably simulate memory pressure without CPU cost?My concern is if there is something in linux that will kill, or otherwise remove the memory impact of, a suspended process under memory pressure or something (like Android's lowmemorykiller). Does such a thing exist, or is there any reason why this wouldn't work?
Can I suspend a process (`stress`) to simulate memory pressure minus the CPU cost?
linux;memory;signals
I found this Oracle article about OOM Killer (Out Of Memory Killer) answer a half of your question, specially in 'Configuring the OOM Killer' chapter.I extract from there two important commands (I think):Disable OOM Killer root@host:~# sysctl vm.overcommit_memory=2Exclude a process from OOM Killer root@host:~# echo -17 > /proc/<pid>/oom_adjOther very interesting answer is 1.4 in this FAQ from stress project page, it says:1.4 Why is my CPU getting hammered but not my RAM? This is because stress if faily conservative in its default options. It is pretty easy to render a system temporarly unusable by forcing the virtual memory manager to thrash. So make sure you understand how much memory you have and then pass the appropriate options. On a dual-core Intel system with 3 GB of RAM a reasonable invocation is this:stress -m 1 --vm-bytes 2GRight, your question has not been answered yet. Let's look at stress manual ... -c, --cpu N     spawn N workers spinning on sqrt()Maybe the above option could help, try to set it to zero. Oops, It doesn't work!?After a look at the code I noticed that this option is disabled by default. And I've also noticed that --vm-hang option may be what you want.The default action of --vm is spinning on malloc()/free(), and it's CPU intensive! --vm-hang makes stress program do a pause for seconds every time it allocates until free().Try to use the following (consumes ~128MB of RAM):root@host:~# stress --vm 1 --vm-bytes 128000000 --vm-hang 3600And do a test in another terminal:root@host:~# top
_unix.237660
I want to make ssh connection to my server but I don't want to enter password. I want to save output to a file like so:$ ssh [email protected] -p 22 1>output 2>&1but when I run it the output is shown to me:[email protected]'s password:I want this state redirect to a file and not show to me then close ssh connection immediately...What should I do?
how to redirect output of ssh to a file
bash;ssh;io redirection;stdout;stderr
null
_webmaster.16028
The google adsense code contains a reference to a javascript file. If I have 3 ad units on a single page, can I remove this reference from the other two because it is just the same. Will it violate the don't manipulate the code rule of google adsense?
Google Adsense code?
google adsense
Best to let Google do its thing without manipulating the code.As this support page mentions, Google will optimize based on your pages:http://www.google.com/adsense/support/bin/answer.py?hl=en&answer=9735
_webmaster.104390
Google Search Console flags duplicate titles for the following pages on my site - they all have the title 'prodname'/de/products/georadar/prodname/es/products/georadar-gpr-radar-de-penetracion-terrestre/prodname/fr/products/georadar/prodname/zh/products/gpr/prodnameHowever, each page is in a different language (set by lang in the html tag) and the pages link to each other using:<link rel=alternate hreflang=es href=... /> and so onSurely this should not be treated as duplicate titles, since each title is distinct on my site for each language? I have a lot of pages like these on my site, as the title is generated from the product name, and the product name is not translated. Each page has translated content. Is this really likely to be an issue to Google?
Duplicate titles being flagged are on pages with different languages
google search console;html;duplicate content;language;titles
null
_cstheory.832
Following the discussion on lower bounds for 3SAT [1], I'm wondering what are the main lower bound results formulated as space-time tradeoffs. I'm excluding results such as, say, Savitch's theorem; a good entry would focus on a single problem and its bounds. An example would be :Let T and S be the running time and space bound of any SAT algorithm. Then we must have TSn2cos(/7)o(1) infinitely often. (Given in [1] by Ryan Williams.)orSAT cannot be solved simultaneously in n1+0(1) time andn1- space for any >0 on generalrandom-access nondeterministic Turing machines. (Lance Fortnow in 10.1109/CCC.1997.612300)Further, I'm including definitions of natural space-time tradeoff complexity classes (excluding circuit classes).
Space-time tradeoff lower bounds
cc.complexity theory;ds.algorithms;big list;space time tradeoff
Here are a few additional references. More can be found by looking at the papers that cite these.Duris and Galil (1984) give a language in $P$ which requires $T^2 S \geq \Omega(n^3)$ on one-tape Turing machines with any constant number of read-write heads. Karchmer (1986) showed that the same lower bound holds for the element distinctness problem. Babai, Nisan, and Szegedy (1989) give a very natural language (generalized inner product) that is solvable in $O(n)$ time and $O(1)$ space on a $k+1$-head one-tape Turing machine, that requires $T S \geq \Omega(n^2)$ on any $k$-head one-tape Turing machine.Ajtai (1999) shows time-space tradeoffs for deterministic random access machines computing element distinctness. In particular if $S \leq o(n)$, then $T \geq \omega(n)$. Subsequent work by Beame, Saks, Sun, and Vee (2000) proves time-space tradeoffs for randomized computations.Santhanam (2001) showed that $TS \geq \Omega(n^2)$ holds for multitape Turing machines solving SAT, building on Cobham's analogous lower bound for PALINDROMES.
_scicomp.20540
I have been trying to solve the following nonlinear ordinary differential equation:$$-\Phi''-\frac{3}{r}\Phi'+\Phi-\frac{3}{2}\Phi^{2}+\frac{\alpha}{2}\Phi^{3}=0$$with boundary conditions$$\Phi'(0)=0,\Phi(\infty)=0.$$My solution is supposed to reproduce the following plots:Now, to produce the plots given above, I wrote the following Mathematica code: = 0.99;lower = 0;upper = 5;For[counter = 0, counter <= 198, counter++, 0 = (lower + upper)/2; r0 = 0.00001; r0 = 0 + (1/16) (r0^2) (2 (0) - 3 (0^2) + (0^3)); pr0 = (1/8) (r0) (2 (0) - 3 (0^2) + (0^3)); diffeq = {-''[r] - (3/r) '[r] + [r] - (3/2) ([r]^2) + (/2) ([r]^3) == 0, [r0] == r0, '[r0] == pr0}; sol = NDSolve[diffeq, , {r, r0, 200}, Method -> ExplicitRungeKutta]; test = [200] /. sol[[1]]; upper = If[(test < 0) || (test > 1.2), 0, upper]; lower = If[(test < 1.2) && (test > 0), 0, lower];]Plot[Evaluate[{[r]} /. sol[[1]]], {r, 0, 200}, PlotRange -> All, PlotStyle -> Automatic] In the code, I used Taylor expansion at $r=0$ due to the $-\frac{3}{r}\Phi'$ term. Moreover, I used shooting method and continually bisected an initial interval from $\Phi_{\text{upper}}=5$ to $\Phi_{\text{lower}}=0$ to obtain more and more precise values of $\Phi(0)$.With the code above, I was able to produce the plots for $\alpha = 0.50, 0.90, 0.95,0.96,0.97$. For example, my plot for $\alpha = 0.50$ is as follows:However, my plot for $\alpha = 0.99$ does not converge to the required plot:Can you suggest how I might tackle this problem for $\alpha = 0.99$? Also, is there an explanation for the plots shooting upwards and oscillating after a prolonged asymptotic trend towards the positive $r$-axis?
Solving an ODE using shooting method
ode
null
_unix.77194
I sometimes see the command :notify-send -u critical -t 3000 ExampleHowever, with -u critical, it seems like the notification doesn't time out. What is the purpose of adding a timeout option then?Do you have a link which explains exactly what the notify-send does? The ones I found were not very detailed in their explanations.What is the purpose of the -u option, btw?
notify-send command with -u critical and -t option
linux;notifications
null
_softwareengineering.29782
I am novice developer.While development is going on, we come across different error issues. However for the novice of programming, it is always hard to directly understand them & solve them.I believe, errors are generally related to typing error OR data structure error OR run-time memory error - which is related to hardware OR else.How to elaborate and solve those errors very fast ?
How to Solve an Error?
debugging;errors
My thoughts:I don't think many errors are related to typing errors. Typos will generally not produce stuff that will compile so rarely produces anything that gets even as far as unit testing, let alone beyond that. Those few that do are generally very easy to spot.In 16 years in development the only issues that I've seen which were caused by a hardware fault were so major (i.e. system / sub-system down) that it was instantly obvious and was picked up by the sysadmins. Once it makes it as far as the programmer I'd suggest that you remove the possibility of hardware error from your mind until you see some very very strong evidence to suggest that that's the case as generally it's so unlikely you shouldn't waste time thinking about it.Errors fall into three categories:1) Misunderstandings - that is the system is working correctly but someone has misunderstood what it's meant to do. The best way to find out if this is the case is to get as much information as possible, ideally by speaking to someone who has actually seen the error and ask what they saw and what they expected to see.2) Configuration Errors - while there are very few errors which are caused by hardware errors, there are plenty caused by machines being set up differently as far as software configuration goes. This is particularly likely if you can't reproduce the error on your development set up which is likely to be pretty non-standard because of the assorted tools you've got installed and changes you've made to be productive. The best thing to do here is to have a development test environment which is a clone of production and try and reproduce the error on there. Once you have you can start comparing that environment to the ones where it works and see what the differences are.3) Code Errors - the code is out and out wrong. There are common problems (not checking return values or badly handled errors, incorrect loops and checks - for instance not checking the final record in an array or collection because the developer got confused about whether it ended at i or i-1) but exactly how common they are varies from project to project and in any case, they're easy enough to spot by walking the code. The main things I'd say here are make sure you can reproduce the error (this may involved getting details of a specific record where the error occurs from the user) and walk the code line by line.Broadly speaking I'd suggest the following hints:1) Own the problem. It's your problem and you need to fix it regardless of what it is or who originally caused it. This may involve you looking into things that aren't your area of specialisation but it that's what it takes, that's what you do.2) Speak to the user. The thing which slows down problem resolution the most in my experience is bad information so cut that out by going straight to the user and find out what's happening. Have them walk you through it, what they did, what they saw, what they expected to see. Ask if it happens all the time or just some of the time. If it's just some of the time ask them about patterns, get details of specific records where it occurs. Question everything and assume nothing. And when I say speak to them, I mean speak to them - you'll find out more than through some e-mail conversation and you'll do so far far faster.3) Reproduce the problem. Don't guess at the solution, reproduce it, it's the only way of knowing you've really found what's happening. Walk the code step by step and see what's actually happening. This may involve reproducing the environment or getting a copy of the database - if you have to, that's what you do.4) Be realistic. It's not a hardware problem and you've not found a problem with the compiler. Once you've worked out it's a real problem (that is that the user is not mistaken about what it's meant to be doing) and you've reproduced it, by far the most likely issue is that the code is wrong so don't kid yourself otherwise.5) Fix the root problem, not the symptom. If they say everything is out by 1, don't just subtract 1 from everything, find out WHY it was out by 1 and fix that. If you only fix the symptom, you will see the problem again.
_webmaster.77959
I am a beginner developer who knows HTML, CSS and lately have entered in web development world with learning some beginning php scripts.I just want to know is there a clean CMS that allows me to lunch a dynamic website including forms and registration with my current knowlege? (i don't want a CMS limit my created HTML page in design.)And for last, it is very useful if this CMS be rich in functional developments, maybe in future i can develop bigger projects, and just for mention i don't like using too many plugins for sample things, i just want this CMS be functionaly easy and do not limit me.thanks
A CMS for a beginner developer
html;css;cms;design
null
_unix.360416
Good Day,I am a novice to programming and i am trying to run the livehelperchat open source code(https://livehelperchat.com/) in my ubuntu-16.04 instance and I have Nginx as default server listening port 80 and also php 5.6 running.my /var/www/html/sites-enabled/default server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name xxxxxxxxx; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5.6-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } }I can visit php info page in my web browser by visiting my server's domain name or public IP address followed by /info.phpI have my code at /var/www/html/livehelperchat/I have fallowed the below link to set up the project in nginxhttps://livehelperchat.com/nginx-configuration-tips-132a.htmlmy /var/www/html/sites-enabled/example.conf server { listen 80; server_name xxxxxxxxxxxxxxxxxxxxxxxxxxx; root /var/www/html/livehelperchat; location ~* (^(?!(?:(?!(php)).)*/(albums|bin|var|lib|cache|doc|settings|pos|modules)/).*?(index\.php|upgrade\.php)$) { include /etc/nginx/livehelperchat_fastcgi_params; fastcgi_pass unix:/var/run/php5.6-fpm.sock; fastcgi_index index.php; fastcgi_param PATH_INFO $query_string; # fastcgi_param SCRIPT_FILENAME /var/livehelperchat/$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } #Allow hotlinking to normal and thumb size images location ~* (normal_|thumb_|^/design|^/cache|^/var/storagetheme)(.*)\.(gif|jpe?g?|png|mp3|svg|otf|woff|eot|ttf|ogg|wav|bmp|htm|swf|css|js|swf|pdf|ico)$ { ## @todo: add expires headers... # favicon is only stored in 1 dir, the design one; But browsers ask for it in the root if ($http_user_agent ~* (WebReaper|wget|SiteSucker|SuperBot|Mihov Picture Downloader|TALWinHttpClient|A1 Website Download|WebCopier|Download Ninja|Microsoft URL Control|GetRight|Arachmo|MJ12bot|Gaisbot|Anonymous|Yanga|Twiceler|psbot|Irvine|Indy Library|HTTrack) ) { return 403; } if ($http_referer ~* (stockingteensex.info|cbox.ws|teensos.net|dpstream.net|tagged.com|kaskus.us|gorilladatingservice.info|taringa.net|discuss.com|craigslist.org|poringa.net)) { return 403; } #sendfile off; #aio on; directio 512; expires max; access_log off; root /var/www/html/livehelperchat; } # Do not allow to hotlink full size images except our self and major search engines location ~* \.(gif|jpe?g?|png|bmp|swf|css|js|svg|otf|eot|ttf|woff|swf|mp3|ogg|wav|pdf|ico|txt)$ { ## @todo: add expires headers... valid_referers none blocked server_names ~(livehelperchat.com|google.|reddit.|bing.|yahoo.); if ($invalid_referer) { return 403; } if ($http_user_agent ~* (WebReaper|wget|SiteSucker|SuperBot|Mihov Picture Downloader|TALWinHttpClient|A1 Website Download|WebCopier|Download Ninja|Microsoft URL Control|GetRight|Arachmo|MJ12bot|Gaisbot|Anonymous|Yanga|Twiceler|psbot|Irvine|Indy Library|HTTrack) ) { return 403; } if ($http_referer ~* (stockingteensex.info|cbox.ws|teensos.net|dpstream.net|tagged.com|kaskus.us|gorilladatingservice.info|taringa.net|discuss.com|craigslist.org|poringa.net)) { return 403; } #sendfile off; #aio on; directio 512; expires max; root /var/www/html/livehelperchat; } location / { rewrite ^(.*)$ /index.php?$1 last; } }Now I am getting an error on doing nginx -tnginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_size: 64nginx: configuration file /etc/nginx/nginx.conf test failedAny Help is Highly Appreciated. Thanks in Advance
nginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_size: 64
ubuntu;php;nginx
null
_unix.74663
My host is Ubuntu 12.04 and guest is a Debian squeeze (LAMP server). I want to allow the host to connect the guest. and allow the guest to connect the internet. The guest should not be enabled from outside. That's the reason why I don't use network-bridge. I want to setup a static IP for the host. I followed this tutorial.So I took these steps but I can not connect via ssh from host to guest. I cannot call the server via browser. ping works however!I've created a virtual host-only network adapter (vboxnet0) with following settings:IPv4-Adress: 192.168.56.1IPv4-Netmask: 255.255.255.0ifconfig in Ubuntu host shows this:eth0 Link encap:Ethernet Hardware Adresse XX:XX:XX:XX:XX:XX inet Adresse:192.168.2.100 Bcast:192.168.2.255 Maske:255.255.255.0 inet6-Adresse: XXXX:XXX:XXXX:XXXX:X:X/XX Gltigkeitsbereich:Globalvboxnet0 Link encap:Ethernet Hardware Adresse XX:XX:XX:XX:XX:XX inet Adresse:192.168.56.1 Bcast:192.168.56.255 Maske:255.255.255.0 inet6-Adresse: XXXX:XXX:XXXX:XXXX:X:X/XX Gltigkeitsbereich:Verbindung UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:10069 errors:0 dropped:0 overruns:0 carrier:0 Kollisionen:0 Sendewarteschlangenlnge:1000 RX-Bytes:0 (0.0 B) TX-Bytes:1539501 (1.5 MB)On the Debian squeeze guest, the /etc/network/interfaces looks like this: # The host-only network interface auto eth1 iface eth1 inet static address 192.168.56.1 netmask 255.255.255.0 network 192.168.56.0 broadcast 192.168.56.255I've already tried to change eth1 to eth0 without a result.In VirtualBox settings the promiscuous-mode allows VMs and Host to connect.I have reached the limits of my knowledge. the output of:netstat --inet --inet6 -ln | grep :22is nothing.the output of:sudo iptables -L INPUT -nvis: Chain INPUT (policy ACCEPT 166 packets, 30786 bytes) pkts bytes target prot opt in out source destination
Virtualbox NAT + Host-Only Adapter
linux;debian;networking;virtualbox;ip
null
_datascience.11393
I'm doing some data prep on a dataset provided by a telecommunication company. There is a continuous variable that indicates how many months have passed since a customer renewed her contract. However, 20% of observations have missing values. I figured out that there are two reasons why a value might be missing:1- a customer did not renew the contract 2- a customer is still on her first contract and therefore never had the chance to renew it.What I want to do is to fill the missing values with respectively Not renewed and Not applicable, and then discretize the rest of the numerical values through a supervised algorithm (chi2, MDLP) so that the variable would turn into a categorical one.In the end, for this variable I'd have some observations categorized through simple labeling, while others through a supervised discretization algorithm.Question: is it correct to do so? If not, how should I handle the problem?Thanks!Please see my comment below for additional information.
How to model this variable?
dataset;data cleaning
null
_unix.285116
How can I retrieve and compare two values from the first two lines of a file?I have the following text:05-24-2016, 2:59:32,0,005-24-2016, 2:59:37,0,005-24-2016, 2:59:42,0,005-24-2016, 2:59:47,0,005-24-2016, 2:59:52,0,005-24-2016, 2:59:57,0,005-24-2016, 3:00:02,0,0and I need to compare the first row's values in a particular column (e.g. 2:59:52)and check the difference in seconds.I am using the following command but still I am not getting itawk '{ print $2 }' <filename>Only the difference between the first two rows is required (and the rest of the rows should be ignored).
How can I retrieve and compare two values from a file?
text processing;csv
This shell script will get you the difference in seconds between the timestamps in column two of the first two rows:( IFS=, read -r _ a _; IFS=, read -r _ b _; a=$(date --date $a +%s); b=$(date --date $b +%s); echo $a - $b | bc | tr -d - ) <filenameIt can be broken down like this, too, if you prefer:( IFS=, read -r junk a junk # Get second comma separated field IFS=, read -r junk b junk a=$(date --date $a +%s) # Convert to seconds since the epoch b=$(date --date $b +%s) echo $a - $b | bc | tr -d - # Compute signed difference, then discard unary minus sign) <filename
_webmaster.3785
I visit many sites but click on their ads very rarely. I suppose many people do the same thing.Do you think that publishing an article under pay per click policy, can have good earnings?
Is pay per click really effective?
google adsense
null
_unix.346894
From my understanding , the electronic components in HDDs can store memory in flash memory chips. I am not interested in the disc platters. I would like to dump only this flash memory using a Linux distro to examine it.What are the locations I should be using to access this memory - eg with dd?
What locations should I use for dumping flash memory from electronic components in HDDs?
linux kernel;memory;hard disk;dd
null
_reverseengineering.16023
I'm writing an analog of GetProcAddress function. When looking inside the export table I see the exports like this in advapi32.dll for example:.text:4C362BAA aEventregister db 'EventRegister',0 ; DATA XREF: .text:off_4C35FE10o.text:4C362BB8 ; Exported entry 1290. EventRegister.text:4C362BB8 public EventRegister.text:4C362BB8 EventRegister db 'ntdll.EtwEventRegister', 0So it is like a redirect to ntdll function. How to process these entries and how to detect if they lead to another library call?Currently I just find the function ordinal by name and get its address, but for exports like this addresses are invalid (inside the address there is junk code).Do I need to just read the string ntdll.EtwEventRegister at the ordinal address, split it by dot and get dll/function names?If this is the case, how do I detect that the export address is just a string with this dll/function name? I need to somehow check if there is a valid string there, there should be other way, like some flag etc.
Exports that redirects to other library
disassembly;c;pe;executable
This is called export forwarding and you can explore it here with nice explanation:The PE file formatThe next 32-bit-value 'AddressOfFunctions' is a RVA to the list of exported items. It points to an array of 'NumberOfFunctions' 32-bit-values, each being a RVA to the exported function or variable.There are 2 quirks about this list: First, such an exported RVA may be 0, in which case it is unused. Second, if the RVA points into the section containing the export directory, this is a forwarded export. A forwarded export is a pointer to an export in another binary; if it is used, the pointed-to export in the other binary is used instead. The RVA in this case points, as mentioned, into the export directory's section, to a zero-terminated string comprising the name of the pointed-to DLL and the export name separated by a dot, like otherdll.exportname, or the DLL's name and the export ordinal, like otherdll.#19.
_reverseengineering.14312
I am working on debugging tools detection.What i am looking for is a tool than can log EACH cpu instruction which is run by CPU.I am looking for Dynamic Symbolic Execution tools. The code is not executed by a kind of software cpu, so it is easy to put breakpoints, dump memory or pause process.I have found some information on pintools (intel), but i am wondering how it works for tracing binary programs. Does it work with a symbolic CPU ? Or is it a sort of debugger which interacts with kernel and real process ? If so, i think there is a way to detect pintool trace for a malware ?Thanks
Does pintool works with virtual/symbolic CPU
pintool
null
_softwareengineering.40649
In development, what is the best way to manage delays? For example, you're doing a task, new requirements come in/something which further steepens the learning curve of something that must be learnt right there and then, and you need to communicate this to the PM/manager. What is the most effective way of doing this?
What is the most effective way of communicating potential delays in software development?
project management;time management;deadlines
null
_unix.207826
I am trying to install nemiver debugger in my CentOS machine. I followed the instructions listed here: Walkthrough. I got stuck however because despite the successful installation of gtksourceviewmm-3.0, I cannot complete the configuration of nemiver successfully.I get this error again:$./configure --prefix=/usr --libdir=/usr/lib64configure error: No package 'gtksourceviewmm-3.0' foundAny advice?
Install nemiver in CentOS 7
centos
null
_unix.163052
I'm new at scripting, and need some help. Will appreciate your answers.I got this assignment, which is to find the sum of all five-digit numbers (in the range 10000 - 99999) containing exactly two out of the following set of digits: { 4, 5, 6 }. These may repeat within the same number, and if so, they count once for each occurrence.Some examples of matching numbers are 42057, 74638, and 89515.I only have this little piece of code, don't even know if it helps.#! /bin/bashfor (( CON1=10000; CON1<=99999; CON1++ )) ; do ## UNKNOWN COMMANDS done
How to sum match numbers
bash;shell script;scripting
null
_softwareengineering.314685
First of all, I want to say I wasn't sure if I should post this here or in math.stackexchange but I think the question is too programming-related to belong to the latter community. Definetly not a SO question, though.A brief introduction of my program: I am developing a scheduler for sport events using CSP. Each event can have different categories, for example, in a tennis event you could have a men's draw, a women's draw and a doubles' draw. In a football tournament you could have group A, group B, group C... In the tennis event though, we can have players playing in different categories simoultaneously. My solver has that in mind.For a specific purpose, I need to track which match-up combinations have already been tried. For a match-up combination we understand a specific combination of predefined match-ups between players. For example, in the tennis tournament, a specific combination could be:Men's draw -> [Man1, Man6], [Man3, Man5], [Man2, Man4]Women's draw -> [Woman3, Woman4], [Woman6, Woman2], [Woman1, Woman5]Double's draw -> [Man6, Woman4, Woman1, Man3], [Man2, Man1, Woman2, Woman5], [Man4, Woman3, Woman6, Man5], [Man7, Woman8, Woman7, Man8](I think haven't missed any combination, but I hope you get the idea)This combination is created from a pool of players defined for each category that composes the tournament. The following represents all players that play in each category:Men's draw -> [Man1, Man2, Man3, Man4, Man5, Man6]Women's draw -> [Woman1, Woman2, Woman3, Woman4, Woman5, Woman6]Double's draw -> [Man1, Man2, Man3, Man4, Man5, Man6, Woman1, Woman2, Woman3, Woman4, Woman5, Woman6, Man 7, Man8, Woman7, Woman8]If the resolution process doesn't work for a specific combination, which has been generated randomly, we go ahead and try with anothe randomly generated combination. We repeat until we find a solution.Now, keeping track of the visited combinations would mean a huge cost in memory usage, because of all the information to be stored. I doubt the memory in a regular PC can handle the amount of combinations in a moderatly big tournament.I think the proper way of doing this is, instead of storing the whole combination, we can store an integer representing a unique combination.So, for example, the combination above maps to the integer 1, and so on. We could easily store set of integers. And for the next combinations we could check the identifier of the generated combination with the contents of that integet set to see if it has been already visited.However, I can't think of an algorithm to represent a combination with a unique integer. Could this be done? Is it easier to do than it sounds? Is it a good idea at all to do what I am suggesting?
Mapping match-up combinations into an integer
design;algorithms;scheduling;rules and constraints;combinatorics
null
_webmaster.6541
Something is seriously wrong after I updated my site with new templates, moved to a new server and started writing on English rather than Norwegian.I know from Google Analytics, that most of my readers comes from Google.I do a quick test by googling (google.no) Oslo Fashion Fair 2009. This is the name of the article and is the title of my page. ( http://www.google.no/search?hl=no&q=Oslo+Fashion+Fair+2009&aq=f&aqi=&aql=&oq=&gs_rfai= )The page that I trying to find is this: http://www.norwegianfashion.no/news/oslo-fashion-fair-2009/This used to be one of the first pages in Google. Now you don't see my site until Page 4, and that is a link to something completely different.On page 4 in the google search, you see this:Designere - Norwegian Fashion Norske designere Nr man tenker fashion,tenker de fleste p designere som Yves Saint ... Fashion Week Guide 16-22 august 2010 Oslo Fashion Fair 2009 ... www.norwegianfashion.no/blog/designereThere are a few problems with this:The headline says Designere - Norwegian Fashion. I no longer have a page called Designere. It's now called Designers.The link points to www.norwegianfashion.no/blog/designere. But I've never had that a URL with that name. The page does not exist.When you click the link, a completely different page opens.I also noticed that I ahve lost Page Rank. My Page-RAnk add-on in Firefox will no longer rate my site, and Googles own Page Rank checker can't check my site for page ranking.So what kind of SEO have I done? I've put the <title> tag at the top, followed by the meta tags <description> and KeywordsFor new pages, I use my intro texst in the description field.I've made sure to use appropriate H1 - H3 tagsI've got relative content in headline vs intro and main body text, as well as appropriate keywords.I've added my site to GoogleI've used Google Webmaster Tools to optimize my siteI've added a sitemap.xml I don't know why I'm suddenly not being indexed by any search engines. What have I done wrong?UPDATEUsing Google Webmaster tool, I can see issues Google encountered when crawling my site. Thre are a lot of 404 Page not found errors.Example of 404 errors:http://www.norwegianfashion.no/2009/nyhetsarkivnyhetsarkiv is now called newshttp://www.norwegianfashion.no/author/marianneI have deleted marianne ase user in Wordpress. This author do not exists any morehttp://www.norwegianfashion.no/category/fashion-report/page/40/Not sure what this is. I'v enever used this permalink structure.
Help! My articles are not indexed correctly by search engines
seo;search engines;pagerank
null
_unix.311882
This is a question/answer post, intended for people encountering the same issue.This problem only happens when using a separate toolchain (gcc, binutils, libtool) which is not in the standard path. i.e., which gcc gives a location that is not listed bysudo env | grep -w PATH=This was necessary to compile octave-4.2 on OpenSUSE 13.2 (the standard gcc was too old).On a standard system, where there is only one toolchain, and this toolchain is in the standard path, sudo make install works just fine.Here is the error, on sudo make install:libtool: warning: relinking 'Magick++/lib/libGraphicsMagick++.la'/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:Magick++/lib/.libs/Magick___lib_libGraphicsMagick___la-Image.o: unrecognized relocation (0x2a) in section `.text'/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: final link failed: Bad valuecollect2: error: ld returned 1 exit statuslibtool: error: error: relink 'Magick++/lib/libGraphicsMagick++.la' with the above command before installing it
Why is `sudo make install` failing with unrecognized relocation?
software installation;sudo;opensuse;path;toolchain
null
_unix.47527
Is there any possibility to limit the bandwidth of an SFTP user? My server has an upload of ~500kb/s and I don't want to 'spend' it all on one user
Limit bandwidth SFTP user
sftp;bandwidth
If you are using WHM (Web Host Manager), you can simply go to Limit Bandwidth Usage under the Account Functions section. Choose an account and then enter a limit.If not, you can use a utility called trickle - http://monkey.org/~marius/pages/?page=trickle
_cs.192
I've not gone much deep into CS. So, please forgive me if the question is not good or out of scope for this site.I've seen in many sites and books, the big-O notations like $O(n)$ which tell the time taken by an algorithm. I've read a few articles about it, but I'm still not able to understand how do you calculate it for a given algorithm.
How to come up with the runtime of algorithms?
algorithms;algorithm analysis;runtime analysis;reference question
null
_unix.162917
Is it possible to create your own Linux OS right onto a USB drive? I know you can just download a Linux distro onto a USB thumbdrive and plug it into a computer and run it from the USB, but I'd like to create my own OS on a USB that I can plug into any computer and use. I've looked around for an answer to my question and couldn't find any pertaining to creating an OS onto a USB specifically, so if anyone knows the answer or a link to the same question, help would be much appreciated.
Create own Linux OS on USB Flash drive
usb drive
null
_unix.53937
Possible Duplicate:How can I reboot into windows from inside my Linux shell? When I reboot and want to select another kernel image in grub2 or another OS like windows I have to wait until grub comes up and then select manually the image I want. Sometimes I switch multiple times between linux and windows or between two different kernel versions, then I find it pretty annoying to select this manually. What I want is to choose the image when I type in the reboot command. In pseudocode: sudo reboot to windows. Then I could get a cup of coffee and my box will automatically reboot to windows. Is it possible to to something like this?I guess that somebody would point out a VirtualBox solution instead. I know this, but I don't want it in this case.
How can I choose which OS grub will reboot me intobefore I reboot?
grub2;reboot
null
_codereview.160077
I need to get some ids from contacts and contactgroups to be able to collect the data. My example works but i dont know if this is the way to go.getIdArray() {let contactIds = [];let groupIds = [];let contacts = this.http.get('Contacts/').map(res => res.json());let contactGroup = this.http.get('ContactGroups/').map(res =>res.json());Observable.forkJoin([contacts, contactGroup]).subscribe(res => { for (let b of res[0].contacts) { console.log(b.contactId); contactIds.push(b.contactId) } for (let b of res[1].contactgroups) { console.log(b.contactgroupId) groupIds.push(b.contactgroupId) } this.loadContacts(contactIds); this.loadGroups(groupIds); });}loadContacts(contactId) {console.log(ids + JSON.stringify(contactId));Observable.forkJoin( contactId.map( i => this.http.get('Contacts/' + i) .map(res => res.json()) ) ).subscribe(data => { for (let b of data) { console.log(b); }});}loadGroups(groupIds){console.log(ids + JSON.stringify(groupIds));Observable.forkJoin( groupIds.map( i => this.http.get('ContactGroups/' + i) .map(res => res.json()) )).subscribe(data => { for (let b of data) { console.log(b); }});}
Making multiple http request Angular2
angular.js;http;typescript
null
_unix.84469
I just tried burning both a Debian CD and a Debian DVD from their .iso files and I've got a weird behavior: the checksum of the CD is correct but the one of the DVD ain't.Here's what working:downloaded the two .iso files verified the checksum of the two .iso filesburn the CD debian-7.1.0-amd64-CD-1.iso to a CDverify that the CD is correct by issuing:dd if=/dev/sr0 | md5sum (or sha-1 or sha-256)And this works fine: the checksum(s) I get from the CD by using dd and piping into md5, sha-1 or sha-256 do match the official checksums.Now what I don't get is that I did burn a DVD from the DVD .iso --and I know that the file has been correctly downloaded seen that the .iso file checksum is correct.However if I put the DVD in the drive and issue the same:dd if=/dev/sr0 | md5sum (or sha-1 or sha-256)then I get a bogus checksum.The DVD still looks correct in that the files all seem to be there.So here's my question: can I verify that a DVD has been correctly burned by using dd and piping its output into md5sum (or sha-1 or sha-256) or is there something special that would make dd work for verifying burned CDs but not burned DVDs?*(note that I used Disk Utility on OS X to burn both the CD and the DVD)*
How to take sha-1, sha-256 or MD5 of CDs / DVDs?
linux;devices;dd;checksum
In addition to Gilles answer,If you still have the ISO image, you could use cmp instead of checksums. It would tell you at which byte the difference happens. It would also make the check faster as if there is an error early on, it would tell you right away, whereas the checksum always has to read the entire media.$ cmp /dev/cdrom /path/to/cdrom.isoIn case of error it should print something like this/dev/cdrom /path/to/cdrom.iso differ, byte 123456789, line 42In case it's correct it should print nothing, or this:cmp: EOF on /path/to/cdrom.isoWhich means there is more data on /dev/cdrom than in the ISO, most likely zero-padding.Even before starting any comparisons, you could check the size.$ blockdev --getsize64 /dev/cdrom123456999$ stat -c %s /path/to/cdrom.iso123456789If it's identical, the checksum should match also. If /dev/cdrom is larger, it should be zero padded at the end. You could check that with hexdump. Use the ISO size for the -s parameter.$ hexdump -s 15931539256 -C /dev/cdrom3b597ff38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|*3b597fff8 00 00 00 00 00 00 00 00 |........|hexdump is also useful for having a look at difference at any other position in a file, in case a damage was caused deliberately by something.
_cogsci.999
Sometimes when I meet new people, I feel like I have seen them before. Their faces might look similar to people's faces, I have really have met before. The wiki article on Difficulties with Facial Recognition states that:Prosopagnosia is an inability to identify faces and face-like objects. This represents a failure to encode incoming visual information. Neurological studies indicate that prosopagnosia is associated with bilateral lesions of the central visual system, primarily located in the mesial occipitotemporal region. I don't have problems with identifying faces, I just group them too often. QuestionsWhy do novel faces sometimes look familiar?Is this related to a kind of face-blindness?What is the neural basis for this phenomena?Related questionsDoes the fusiform face area in patients with Prosopagnosia (face blindness) show lower activity under an fMRI?
Face-Blindness: Have I seen you before?
terminology;perception;autism;neurology
Feeling as though you have seen a face before is perfectly normal. It may reflect actual similarities between the new face and the face you have seen before. There are people who genuinely look like each other, an example being celebrity look-a-likes. It may also reflect a commonly observed cultural/ethnic effect where people of a different ethnicity look more similar (Meissner & Bringham, 2001).In terms of what happens in the brain, besides processing by the basic visual system (LGN, V1), the ventral visual pathway and areas associated with object and face recognition are involved with identifying the face. Particularly, these three core regions show space-specific responses: fusiform gyrus, lateral inferior occipital gyri , and posterior superior temporal sulcus (Haxby et al., 2000; 2001). A model of the distributed human neural system for face perception (Image from Haxby et al., 2000.)There is ongoing debate that the fusiform area plays a broader role in that of visual expertise, rather than just face perception (Gaulthier et al., 2000; Xu, 2005). Although less is known about temporal aspects of face processing, this is starting to be the focus of newer studies such as Zheng et al., 2012. I haven't found any known explanation but if you feel that the way you perceive similarity in faces is not normal, then you may be interested in reading about false facial recognition problems following brain damage (*Rapcsak et al., 1996) or (slightly different) misidentification syndromes (Hudson & Grace, 1999; Breen et al., 2000). *Unfortunately I could not access this article to summarize it. ReferencesBreen, N., Caine, D., Coltheart, M. (2000). Models of face recognition and delusional misidentification: A critical review. Cognitive Neuropsychology. 17(1/2/3):55-71.Gauthier, I., Skudlarski, P., Gore, J. C., Anderson, A. W. (2000). Expertise for cars and birds recruits brain areas involved in face recognition. Nature Neuroscience 3:191-197. Haxby, J. V., Hoffman, E. A., Gobinni M. I. (2000). The distributed neural system for face perception. Trends in Cognitive Science, 4(6):223-233.Haxby, J. V., Hoffman, E. A., Gobinni M. I. (2001). Human neural systems for face recognition and social communication. Biological Psychology, 51(1):59-67.Hudson, A. J., Grace, G. M. (1999). Misidentification syndromes related to face specific area in the fusiform gyrus. J Neurol Neurosurg Psychiatry, 69(5):645-648.Meissner, C. A.; Brigham, J. C. (2001). Thirty years of investigating the own-race bias in memory for faces: A meta-analytic review. Psychology, Public Policy, and Law, 7(1):3-35.Rapcsak S. Z., Polster M. R., Glisky M. L., Comer J. F. False recognition of unfamiliar faces following right hemisphere damage: neuropsychological and anatomical observations. Cortex; a Journal Devoted to the Study of the Nervous System and Behavior. 32(4):593-611.Xu, Yaoda. (2005). Revisiting the role of the fusiform face area in visual expertise. Cereb Cortex. 15(8):1234-1242.Zheng, X., . Mondloch, C. J., Segalowitz, S. J. (2012). The timing of individual face recognition in the brain. Neuropsychologia, 50(7):1451-1461.
_datascience.17469
Where exactly bigdata platforms fit in to a data science/ machine learning projects ?Say I have a large dataset for a binary classification problem - cats and dogs.Now I need to create a model for real time classificationHere is my question.1 Since dataset is huge I can make use any distributed platform for faster computation and model creation right?2 Once the model is ready, then there is no need of these distributed platform right ? or are they needed for feature extractions ?
Deploying models on bigdata platforms like Hadoop and Spark
machine learning;data mining;bigdata;apache spark;apache hadoop
null
_codereview.153452
I'm currently building an interactive web application that allows users to create flow charts using Angular2, typescript and PixiJS (the latter is a 2D rendering library).The core part of my application is a PixiJS object housed within an Angular2 component. This PixiJS object contains other graphical UI elements which the user can interact with. Some examples of these graphical UI elements are FlowChartSquareInstance, FlowChartCircleInstance, and FlowChartConnectorInstance.I need to implement a context menu feature in my app. When right clicking on graphical UI elements like the above, a context menu should appear. However, each graphical UI instance will have a different set of options in its context menu. Hence, the context menu needs to be created dynamically, at runtime.I found the simplest way to do this is attach a right-click listener to each graphical UI element, which will call a function to create the context menu. The context menu will be created using elements from the PixiJS rendering library.I defined the following interface:/*ContextMenuDisplayer.tsAll UI components that need to display a context menu on right click shouldimplement this interface*/export interface ContextMenuDisplayer { /* Use to create the context menu object. Needs to use the string array returned by getContextMenuOptions */ createContextMenu(contextMenuOptions : string[]) : void; /* Return a string array of context menu options */ getContextMenuOptions() : string[];}The idea is that all graphical UI elements will implement this interface, and their right-click listener function will call the methods defined in this interface.Consider this example:class FlowChartSquareInstance implements ContextMenuDisplayer{ constructor(){ //The listener function this.on(right click, this.onRightClick, this); } onRightClick(){ this.createContextMenu(this.getContextMenuOptions); } createContextMenu(contextMenuOptions : string[]){ //create the context menu using PixiJS } getContextMenuOptions() : string[] { return [delete, copy, duplicate]; } //Other methods}Is this a good way of adding a context menu feature? Or can it be improved upon? The idea of the interface was to define a way for future developers to add context menu's to any new graphical UI elements they might create. Not all graphical UI elements need to have context menus in my application.I've decided to post here even though there isn't much code to review to nip this in the bud if it's not a good way of doing it.
Using Interface for context menu for a web application
javascript;object oriented;design patterns;typescript
null
_unix.372990
I have an automatic process setup. It's still pretty new and obviouslyin need of better error handling because now I find myself in a bad state.I run snapshot-create-as across all my vms, then do zfs replication tothe target backup system, then blockcommit everything.virsh snapshot-create-as --domain $vm snap --diskspec$DISK,file=$VMPREFIX/$vm-snap.qcow2 --disk-only --atomic --no-metadata--quiesce...virsh blockcommit $vm $DISK --active --pivotThis has been working fine, though something went wrong on the 20th.something happened to make the blockcommit fail, but the -snap file got deleted (note to self - check return code from blockcommit command!)So now I'm in a bad state. The domain is still running. but it's running off the -snap.qcow2 that is in the xml but deleted. I googled around for how to recover a blockcommit from a deleted snapshot, but didn't find anything. (pointers welcome)# virsh domblklist serv1r2 Target Source------------------------------------------------vda /var/lib/libvirt/images/serv1r2-snap.qcow2fda -hdb /var/lib/libvirt/images/virtio-win-0.1.126.isoI can see the size increasing on the deleted file in lsof:qemu-kvm 48994 49033 qemu 97u REG 0,44 1855913984 1078 /var/lib/libvirt/images/serv1r2-snap.qcow2 (deleted)...qemu-kvm 48994 49033 qemu 97u REG 0,44 1856110592 1078 /var/lib/libvirt/images/serv1r2-snap.qcow2 (deleted)I can't see a way to blockcommit this, though maybe there's some clever option to use that I'm not aware of.so, do I need to rollback the zfs snapshot image or is there some otherway to recover from this snafu?Thanks.
orphaned libvirt snapshot file removed by lack of error checking, any way to fix?
kvm;snapshot;libvirt
null
_unix.175769
I recently installed Pear OS 8 and have ran into many problems since. Essentially, I can't download or install anything. At first I was getting a failed to download repository information error. I tried sudo apt-get clean and sudo apt-get update commands neither of which worked. After doing more research and trying other commands (I don't even remember what all I tried now), the install button in software center disappeared. I researched this and found out that my download from server was server from france. I tried to change this both to United states and main server to fix the problem (also running sudo apt-get update command after both of those changes) and nothing is working still.
Can't install or download anything in pear os 8
ubuntu;software installation;apt;sudo
null
_webapps.90693
I want to embed a Google Form in my website, but make it unstyled, etc., so it looks neat and can be placed in widget form.
How can I make a minimal, unstyled HTML form which works with Google Forms?
google forms;html;embed
null
_unix.58476
Is it a security issue not using the tls-remote option in OpenVPN? That is not verifying the server's common name. Is a MITM attack possible? Could this be an issue, especially with services like dyndns.org?
What is the security impact of not using tls-remote with OpenVPN
security;vpn;openvpn
null
_unix.132256
Currently running into a headache trying to figure out why my CPU speed is stuck as such a low frequency. After doing some research, I found that cpuspeedutil does actually control the state of the CPU rather than the BIOS it seems, but every change I try to make using CPUFREQUTIL does not affect the CPU whatsoever.Currently setup:Intel(R) Xeon(R) CPU E3-1270 v3 @ 3.50GHzRHEL 6.5 with kernel 2.6.32-431.el6.x86_64Every time I run a command to change the min and max freq settings (CPUSPEEDUTILS), it changes some items as you can see below:FYI: The code below is only from A SINGLE CPU CORE (#0 out of 7 Cores)As you can see here, I set the Current gov. policy to performance by running:cpufreq-set -g performance[root@f1-w2 /]# cpufreq-infocpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009Report errors and bugs to [email protected], please.analyzing CPU 0: driver: **acpi-cpufreq** CPUs which run at the same hardware frequency: 0 1 2 3 4 5 6 7 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 10.0 us. hardware limits: 800 MHz - 3.50 GHz available frequency steps: 3.50 GHz, 3.50 GHz, 3.30 GHz, 3.10 GHz, 2.90 GHz, 2.70 GHz, 2.50 GHz, 2.30 GHz, 2.10 GHz, 2.00 GHz, 1.80 GHz, 1.60 GHz, 1.40 GHz, 1.20 GHz, 1000 MHz, 800 MHz available cpufreq governors: userspace, performance current policy: **frequency should be within 800 MHz and 3.50 GHz.** The governor performance may decide which speed to use within this range. **current CPU frequency is 800 MHz (asserted by call to hardware).**It seems that whatever I do to change any of the settings, the above line always reads: current CPU frequency is 800 MHz (asserted by call to hardware).You can see below running the cpuinfo shows that the CPU is running @ 3501.000, but when I run ./i7z, it still shows that the frequency is set to 800mhz: [root@f1-w2 ~]# **cat /proc/cpuinfo**processor : 0vendor_id : GenuineIntelcpu family : 6model : 60model name : Intel(R) Xeon(R) CPU E3-1270 v3 @ 3.50GHzstepping : 3**cpu MHz : 3501.000** cache size : 8192 KBphysical id : 0siblings : 8core id : 0cpu cores : 4apicid : 0initial apicid : 0fpu : yesfpu_exception : yescpuid level : 13wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtmbogomips : 6983.18clflush size : 64cache_alignment : 64address sizes : 39 bits physical, 48 bits virtualpower management:Here is a ls -la of sys/devices/system/cpu/cpu0:total 0drwxr-xr-x 8 root root 0 May 23 15:13 .drwxr-xr-x 12 root root 0 May 23 15:05 ..drwxr-xr-x 6 root root 0 May 23 15:05 cachedrwxr-xr-x 2 root root 0 May 23 15:13 cpufreqdrwxr-xr-x 7 root root 0 May 27 11:02 cpuidle-r-------- 1 root root 4096 May 23 15:05 crash_notesdrwxr-xr-x 2 root root 0 May 27 11:02 microcodelrwxrwxrwx 1 root root 0 May 27 11:02 node0 -> ../../node/node0drwxr-xr-x 2 root root 0 May 23 15:10 thermal_throttledrwxr-xr-x 2 root root 0 May 23 15:05 topologyhere is a cat of sys/devices/system/cpu/cpu0/cpufreq:total 0drwxr-xr-x 2 root root 0 May 23 15:13 .drwxr-xr-x 8 root root 0 May 23 15:13 ..-r--r--r-- 1 root root 4096 May 27 10:28 affected_cpus-r-------- 1 root root 4096 May 27 10:28 cpuinfo_cur_freq-r--r--r-- 1 root root 4096 May 27 10:28 cpuinfo_max_freq-r--r--r-- 1 root root 4096 May 27 10:28 cpuinfo_min_freq-r--r--r-- 1 root root 4096 May 27 10:28 cpuinfo_transition_latency-r--r--r-- 1 root root 4096 May 27 10:28 related_cpus-r--r--r-- 1 root root 4096 May 27 10:28 scaling_available_frequencies-r--r--r-- 1 root root 4096 May 23 15:31 scaling_available_governors-r--r--r-- 1 root root 4096 May 27 10:28 scaling_cur_freq-r--r--r-- 1 root root 4096 May 27 10:28 scaling_driver-rw-r--r-- 1 root root 4096 May 23 15:39 scaling_governor-rw-r--r-- 1 root root 4096 May 27 10:28 scaling_max_freq-rw-r--r-- 1 root root 4096 May 27 10:28 scaling_min_freq-rw-r--r-- 1 root root 4096 May 27 11:02 scaling_setspeedAs you can see, even when I changed settings VIA CPUFREQ, you can see that the MHZ is still set to 800MHZ:[root@f1-w2 cpufreq]# cat cpuinfo_min_freq800000[root@f1-w2 cpufreq]#Immediately changed the MIN CPU FREQ to 2.00ghz and ran cpufreq-info:[root@f1-w2 cpufreq]# cpufreq-infocpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009Report errors and bugs to [email protected], please.analyzing CPU 0: driver: acpi-cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 4 5 6 7 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 10.0 us. hardware limits: 800 MHz - 3.50 GHz available frequency steps: 3.50 GHz, 3.50 GHz, 3.30 GHz, 3.10 GHz, 2.90 GHz, 2.70 GHz, 2.50 GHz, 2.30 GHz, 2.10 GHz, 2.00 GHz, 1.80 GHz, 1.60 GHz, 1.40 GHz, 1.20 GHz, 1000 MHz, 800 MHz available cpufreq governors: userspace, performance current policy: frequency should be within **2.00 GHz** and 3.50 GHz. The governor performance may decide which speed to use within this range. **current CPU frequency is 800 MHz (asserted by call to hardware).**Thought I changed the min freq, it shows between 2.0 and 3.5 ghz, but you can see above that the current CPU FREQ is still 800mhz.Output from i7z shows it still stuck @ 800mhz:Cpu speed from cpuinfo 3491.00Mhzcpuinfo might be wrong if cpufreq is enabled. To guess correctly try estimating via tscLinux's inbuilt cpu_khz code emulated nowTrue Frequency (without accounting Turbo) 3491 MHz CPU Multiplier 35x || Bus clock frequency (BCLK) 99.74 MHzSocket [0] - [physical cores=4, logical cores=8, max online cores ever=4] TURBO DISABLED on 4 Cores, Hyper Threading ON Max Frequency without considering Turbo 3491.00 MHz (99.74 x [35]) Max TURBO Multiplier (if Enabled) with 1/2/3/4 Cores is 39x/39x/38x/37x Real Current Frequency 798.04 MHz [99.74 x 8.00] (Max of below) Core [core-id] :Actual Freq (Mult.) C0% Halt(C1)% C3 % C6 % Temp Core 1 [0]: 797.97 (8.00x) 1.4 98.7 1 0 28 Core 2 [1]: 797.94 (8.00x) 1 100 0 0 28 Core 3 [2]: 798.04 (8.00x) 1 100 0 0 29 Core 4 [3]: 797.81 (8.00x) 1 99 1 0 28Any information would be greatly appreciated!!EDIT: Currentl BIOS SETTINGS:
Intel Xeon stuck at 800mhz CPU Freq on RHEL 6.5
linux;centos;kernel;cpu;intel
null
_softwareengineering.343802
There is a @Mark Seemann's cite from a conversation which states that an abstraction must never implement IDisposable:I like how @nblumhardt put it almost six years ago:an interface [...] generally shouldn't be disposable. There's no way for the one defining an interface to foresee all possible implementations of it - you can always come up with a disposable implementation of practically any interface.Is this applicable for the ISerializable interface as well (meaning that an abstraction must never implement it)?
Are there any cases when an abstraction should inherit ISerializable?
.net;abstraction;serialization
null
_codereview.107523
I am getting two different lists of members, then if certain conditions meet, I add more members to the list before converting into an array.Is there any way this could be improve? I guess we can use Linq and cast but I am not advanced in either of the skills I mentioned. List<Member> Members = new List<Member>(); foreach (SPListItem mItem in GetList(Url).Items) { Member m = new Member(); m.ID = mItem.ID; m.Name = mItem.Title; m.Company = Utilities.ObjectToStringOrEmpty(mItem[companyCol]); m.eMail = Utilities.ObjectToStringOrEmpty(mItem[emailCol]); m.Comment = Utilities.ObjectToStringOrEmpty(mItem[commentCol]); m.Membership = Utilities.ObjectToStringOrEmpty(mItem[msCol]); Members.Add(m); } if (DateTime.Now < row.EndDate) { var cd = new MemberManager().GetMoreMembers(Url + /); var activeMembers = cd.Where(am => am.MembershipStatus == Active || am.MembershipStatus == Pending).ToList(); if (activeMembers != null || activeMembers.Count() > 0) { foreach (var am in activeMembers) { if (!Members.Any(a => a.eMail.ToLowerInvariant() == am.Email.ToLowerInvariant())) { Member m = new Member(); m.Name = am.FirstName + + am.LastName; m.eMail = am.Email; m.IsVip = true; Members.Add(m); } } } } md.Members = Members.ToArray();
Comparing two lists
c#
You can shorten the following snippet by using LINQ and a projection:List<Member> Members = new List<Member>();foreach (SPListItem mItem in GetList(Url).Items){ Member m = new Member(); m.ID = mItem.ID; m.Name = mItem.Title; m.Company = Utilities.ObjectToStringOrEmpty(mItem[companyCol]); m.eMail = Utilities.ObjectToStringOrEmpty(mItem[emailCol]); m.Comment = Utilities.ObjectToStringOrEmpty(mItem[commentCol]); m.Membership = Utilities.ObjectToStringOrEmpty(mItem[msCol]); Members.Add(m);}becomesList<Member> Members = GetList(Url).Items.Select(item => new Member { ID = item.ID, Name = item.Title}).ToList(); // Do this for every field you're interested invar cd = new MemberManager().GetMoreMembers(Url + /);If a method doesn't require instance-level information, you should make it static. It will save you another object allocation and it just makes more sense to write MemberManager.GetMoreMembers() then.am.MembershipStatus == Active || am.MembershipStatus == PendingThis would make more sense as an enum rather than a string. There's only a limited amount of values that status can be.if (activeMembers != null || activeMembers.Count() > 0)Boolean logic! You mean to useif (activeMembers != null && activeMembers.Count() > 0)a.eMail.ToLowerInvariant() == am.Email.ToLowerInvariant()This will create 2 new string objects every iteration. Instead use string.Equals(a.eMail, am.Email, StringComparison.InvariantCultureIgnoreCase);Notice also the eMail and Email discrepancy.You can also shorten the above block by usingvar newMembers = activeMembers.Where(activeMember => !Members.Any(member => string.Equals(activeMember.eMail, member.Email, StringComparison.InvariantCultureIgnoreCase)) .Select(newMember => new Member { Name = newMember.FirstName + + newMember.LastName, eMail = newMember.Email, IsVip = true });Members = Members.Concat(newMembers);The above is written without any IDE but I think you can figure out the solution to any syntax errors in it.
_webmaster.32511
I have created a company blog and have begun implementing various social sharing plugins, had a look at integrating with OG and now Facebook won't pull any images when the page is shared.The debugger tool says that it can find a suitable image (the featured image for each post) and when I share the same link to LinkedIn the images pull fine.I can't work out for the life of me what might be wrong, again it's not that Facebook isn't pulling the right image... it's not pulling ANY.Does anyone have experience with this/know what might be wrong?http://www.chapman-freeborn.com/en/blog
Facebook sharing won't pull through ANY images anymore,
wordpress;facebook;addthis;sharing
How are your saving your files?See belowFacebook does not like .png files so if youre saving your images in that format and experiencing this issue, try changing your images to .jpg or .gif format.One of the main issues with images not displaying on Facebook is the file path that they are located at. Facebook does not like spaces in the name of an image or in the name of a folder that an image is in. Facebook also doesnt like when there is extra stuff added to the end of an image URL such as image dimensions.Source (with further info): http://ansonalex.com/troubleshooting/fix-articles-linked-on-facebook-dont-display-thumbnails-images/
_unix.101987
So what I'm trying to do should be fairly simple but I can't seem to figure it out. I need to kill a certain process on different boxes, they all have a defined IP range although they will eventually change.Let's say for example,arp |sort |awk '{print $1}'|grep 10.20.30.18 # IP's range from 180 to 189 so this does the trickoutput isxxx.xxx.xxx.180xxx.xxx.xxx.181So I want to SSH into both and dops -ef | grep X11 | grep -v grep | awk '{print $2}' | xargs killHow would I go on about this without having to SSH into each one and then killing the process?
Run an SSH command on two hosts whose name comes from another command
shell;ssh
null
_unix.127685
I have a bash script that is asking a user for input, then passes that variable to a find command. I've tried quoting/escaping the variable every way I know, but it keeps failing.read -p Please enter the directory # to check: MYDIRcount=`/usr/bin/find /path/to/$MYDIR -name *.txt -mmin -60 | wc -l`if [ $count != 0 ] then echo There have been $count txt files created in $MYDIR in the last hour else echo There have been no txt files created in the last hour in $MYDIR fiWhen running, I get this:Please enter the directory # to check: temp_dir/usr/bin/find: paths must precede expressionUsage: /usr/bin/find [-H] [-L] [-P] [path...] [expression]There have been no txt files created in the last hour in temp_dir
Trying to pass user generated variable to an external command
bash;shell script;find
You must quote the pattern in -name option:count=$(/usr/bin/find /path/to/$MYDIR -name '*.txt' -mmin -60 | wc -l)If you don't use the quote, so the shell will expand the pattern. Your command become:/usr/bin/find /path/to/$MYDIR -name file1.txt file2.txt ... -mmin -60 | wc -lYou feed all files, which has name end with .txt to -name option. This causes syntax error.
_softwareengineering.134432
Can someone provide me with a canonical answer on the differences between an Observer and a Mediator, and a summary of when you should use one pattern over the other?I am unsure of what kind of situation would require an Observer and what kind would require a Mediator
Mediator vs Observer?
design patterns
In the original book that coined the terms Observer and Mediator, Design Patterns, Elements of Reusable Object-Oriented Software it says that the Mediator pattern can be implemented by using the observer pattern. However it can also be implemented by having Colleagues (roughly equivalent to the Subjects of the Observer pattern) have a reference to either a Mediator class or a Mediator interface.There are many cases when you would want to use the observer pattern, they key is that on object should not know what other objects are observing it's state.Mediator is a little more specific, it avoids having classes communicate directly but instead through a mediator. This helps the Single Responsibility principle by allowing communication to be offloaded to a class that just handles that.A classic Mediator example is in a GUI, where the naive approach might lead to code on a button click event saying if the Foo panel is disabled and Bar panel has a label saying Please enter date then don't call the server, otherwise go ahead, where with the Mediator pattern it could say I'm just a button and have no earthly business knowing about the Foo panel and the label on the Bar panel, so I'll just ask my mediator if calling the server is O.K. right now.Or, if it is implemented using the observer pattern the button would say Hey, observers (which would include the mediator), my state changed (someone clicked me). Do something about it if you care. In my example that probably makes less sense, but sometimes it would, and the difference between Observer and Mediator would be more one of intent than a difference in the code itself.
_codereview.167165
I have a PHP function which sets/unsets something (category and tags) in the cookie and then makes a dynamic query based on it:public function tagged(){ $this->specific_tag = true; function unset_cookie($cookie_name) { setcookie($cookie_name, , time() - 3600, '/'); unset($_COOKIE[$cookie_name]); } function set_cookie($cookie_name, $cookie_value) { setcookie($cookie_name, $cookie_value, 2147483647, '/'); $_COOKIE[$cookie_name] = $cookie_value; } if ( isset($_GET['c']) ) { if ( empty($_GET['c']) ) { unset_cookie('qanda_questions_category'); } else { set_cookie('qanda_questions_category', $_GET['c']); } } if ( isset($_GET['t']) ) { if ( empty($_GET['t']) ) { unset_cookie('qanda_questions_tag'); } else { set_cookie('qanda_questions_tag', $_GET['t']); } } $this->consider_category_tag_cookies(); if ( $this->category_cookie || $this->tag_cookie ) { $query_where = $query_join = ''; if ( $this->category_cookie ) { $query_where .= AND qa.category = :c; $this->parameters[:c] = $_COOKIE['qanda_questions_category']; } if ( $this->tag_cookie ) { $query_join .= INNER JOIN qanda_tags qt ON qt.qanda_id = qa.id INNER JOIN tags ON tags.id = qt.tag_id; $query_where .= AND tags.name = :t; $this->parameters[:t] = $_COOKIE['qanda_questions_tag']; } return $this->index($query_where, $query_join, __FUNCTION__); } else { return header(Location: /myweb/questions.make_url_query($_GET, [],['c','t'])); }}I've tried so much to write it clean and functional, but it contains lots of if statements. It bothers me and I think it should be possible to reduce some of them. Do you have any idea?Do I need to add more function to the code? Or should I chop the code into multiple separated functions? Anyway, how can I write it more cleanly?
How can I reduce if statement in the code?
php;functional programming
First suggestion is that you shouldn't write the same code twice. Your $_GET-if-conditions can be put into a separate function.$this->handleCookieByGetParameter('c', 'qanda_questions_category');$this->handleCookieByGetParameter('t', 'qanda_questions_tag');public function handleCookieByGetParameter($parameter, $name){ if ( isset($_GET[$parameter]) ) { if ( empty($_GET[$parameter]) ) { unset_cookie($name); } else { set_cookie($name, $_GET[$parameter]); } }}and then I recommend that you check your error before you handle your other stuff:if ( !$this->category_cookie && !$this->tag_cookie ) { return header(Location: /myweb/questions.make_url_query($_GET, [],['c','t'])); // better an RedirectException}$query_where = $query_join = '';if ( $this->category_cookie ) { $query_where .= AND qa.category = :c; $this->parameters[:c] = $_COOKIE['qanda_questions_category'];}if ( $this->tag_cookie ) { $query_join .= INNER JOIN qanda_tags qt ON qt.qanda_id = qa.id INNER JOIN tags ON tags.id = qt.tag_id; $query_where .= AND tags.name = :t; $this->parameters[:t] = $_COOKIE['qanda_questions_tag'];}return $this->index($query_where, $query_join, __FUNCTION__);my next step would be to look to extract the query code into a separate function, so I could use it for other methods too.
_webapps.100706
Do I need to use a custom domain with Google's G Suite (formerly Google Apps)? I can't see any way to sign up for the service without wiring up a domain. Isn't there some kind of default domain that could be used, like [email protected]?
G Suite (Google Apps) without a custom domain?
google apps;domain;g suite
null
_cstheory.17216
I know the definition of the independent set problem in graph theory. An independent set cannot contain any two adjacent vertices.How about if you allow no more than $k$ pairs of adjacent vertices? Does this more general problem have a name? Are there techniques for solving it? In particular, are there any techniques for solving it with linear programming?
Generalization of independent set
ds.algorithms;graph theory;co.combinatorics;linear programming;independence
Not exactly what you're looking for, but Dinur and Safra, in their celebrated paper on the hardness of vertex cover, prove that the following promise problem is NP-hard for every fixed $r,\epsilon > 0$ (using the PCP theorem and Raz's parallel repetition theorem).Instance: A graph $G$ whose vertex set is composed of $m$ sets $V_1,\ldots,V_m$ of size $r$, each of them forming an $r$-clique.Problem: Distinguish between the following two cases:YES case: $G$ has an independent set of size $m$.NO case: Every set $A \subseteq V$ containing more than $\epsilon m$ vertices contains a clique of size $h = \lfloor \epsilon r^{1/c} \rfloor$ (where $c$ is some universal constant).More explicitly, for any NP language $L$ there is a polytime $f$ mapping instances of $L$ to instances of this promise problem, in such a way that if $x \in L$ then $f(x)$ is a YES instance, and if $x \notin L$ then $f(x)$ is a NO instance.
_datascience.9249
Keras supports both TensorFlow and Theano as backend: what are the pros/cons of choosing one versus the other, besides the fact that currently not all operations are implemented with the TensorFlow backend?
Choosing between TensorFlow or Theano as backend for Keras
neural network;deep learning;theano;tensorflow;keras
null
_codereview.146947
I'm currently facing the problem of unmarshalling a huge number (47) of attributes to a Java object. Changing the format of the XML file to be more structured is sadly not an option. The following should serve as an example. Imagine each request element has 47 attributes instead of two.<Data time=20161031111103> <Request name=John Doe id=123/> <Request name=Jane Doe id=124/></Data>So far I've found three possible solutions, but I'm not really happy with any of them. ContextThe XML file is refreshed minutely on the customers server and then polled and parsed by the client application. I have no influence on how it is generated or formatted.1 Use a BeanThis is probably the most naive solution, but this gets really boilerplate heavy with more than 600 lines for 47 attributes. On the other hand, this would probably be the easiest to parse. import java.io.Serializable;import javax.xml.bind.annotation.XmlAttribute;import javax.xml.bind.annotation.XmlType;import javafx.beans.property.SimpleStringProperty;@XmlType(name = Request)public class Request implements Serializable { private final SimpleStringProperty name = new SimpleStringProperty(); private final SimpleStringProperty id = new SimpleStringProperty(); public String getName() { return name.get(); } @XmlAttribute(name = name) public void setName(String name) { this.name.set(name); } public SimpleStringProperty nameProperty() { return name; } public String getId() { return id.get(); } @XmlAttribute(name = id) public void setId(String id) { this.id.set(id); } public SimpleStringProperty idProperty() { return id; }}2 Use a Map with String keysA bit more manageable boilerplate-wise, but still you'd require 47 constants for all the attribute names and it leaves you inflexible if you'd need something other than a SimpleStringProperty, a SimpleDoubleProperty for example.package xml.model;import javafx.beans.property.SimpleStringProperty;import java.util.HashMap;import java.util.Map;public class Request2 { private final Map<String, SimpleStringProperty> properties = new HashMap<>(); private static final String NAME_PROPERTY = name; private static final String ID_PROPERTY = id; public String getValue(String property) { SimpleStringProperty result = properties.get(property); return result == null ? null : result.getValue(); } public void setValue(String property, String value) { properties.putIfAbsent(property, new SimpleStringProperty()); properties.get(property).set(value); } public SimpleStringProperty valueProperty(String property) { return properties.get(property); }}3 Use a Map with Enum keysThe same downsides as 2, defining 47 enum constants and being inflexible with other Property types.import java.util.Arrays;import java.util.Collections;import java.util.HashMap;import java.util.Map;import java.util.stream.Collectors;import javafx.beans.property.SimpleStringProperty;public class Request { private final Map<Key, SimpleStringProperty> properties = new HashMap<>(); public String getValue(Key property) { SimpleStringProperty result = properties.get(property); return result == null ? null : result.getValue(); } public void setValue(Key property, String value) { properties.putIfAbsent(property, new SimpleStringProperty()); properties.get(property).set(value); } public SimpleStringProperty valueProperty(Key property) { return properties.get(property); } public enum Key { NAME(name), ID(id); private static final Map<String, Key> lookup = Collections .unmodifiableMap(Arrays.stream(values()) .collect(Collectors.toMap(Key::getName, r -> r))); private final String name; Key(String name) { this.name = name; } public static Key get(String name) { return lookup.get(name); } public String getName() { return this.name; } }}I feel like the sensible thing would be to spread the attributes to multiple classes, but that would leave me with as much, if not more, boilerplate and would complicate things a fair bit. Is it really in any way sane or feasible to have a class with 47 fields like in 1? It just feels super bad.
Reading and working with a large number of XML attributes
java;comparative review;xml;properties
I think the best solution is the first one because it exists some tools that are able to automatically generate classes (in bean-style) from XML.All you need is an XML Schema so that you can use XJC (provided with Java) to let it generate these classes. Of course the generated Request class will be quite heavy with a lot of boilerplate but since it is done automatically it's not really a problem...Going one step furtherSince this class will be auto-generated, it means that you must let it untouched. Therefore it means that you can't use this class as a model (in the MVC sense) because no behaviour can be added to it.You will have to create your own business model of a Request and this class can be much better structured. Possible example:public final class Request { private final User sender private final User receiver; private final Data command; ...}With User and Data beeing other classes modeling a subpart of a request's behaviour.What's missing now ? A bridge between your business model and the bean. This is where you can use an XmlAdapter to fill this gap. This is basically the glue between the two worlds, able to translate from the business world to the XML world and the opposite.JAXB class <-> XMLAdapter <-> Business class
_unix.193145
I need to create new file which contains spaces in it. And it is passed through the argument. This code below creates 2 sepate files. Can anyone help me how to create 1 file which will contains space? Thankstouch $meno
Create new file with spaces from argument BASH
bash;shell;quoting
Try this:IFS=$(echo -en \n\b)touch $yourfile
_codereview.74924
I created this script to take informations at-the-moment of this site:Pictures of name channelName of channelPictures channelTimesTitleTypeMy script (Work):<?php$url=http://www.programme-tv.net/programme/toutes-les-chaines/en-ce-moment.html#Grandes%20cha%C3%AEnes;$code_page = file_get_contents($url);preg_match_all('/<div class=channelItem>(.*?)<img src=(.*?) alt=Le programme de (.*?) width=70 height=30>/is', $code_page, $chaines);preg_match_all('/<div class=show (.*?) at-the-moment current (.*?)>(.*?)<div class=show-infos>(.*?)<\/div>/is', $code_page, $channels);$i=0;foreach ($channels as $channel) { if($i==3){ for ($j=0; $j < 38; $j++) { preg_match_all('/<span class=(.*?)><img src=http:\/\/static.programme-tv.net\/var\/epgs\/169\/80x\/(.*?) alt=(.*?) width=80 \/><\/span>/', $channel[$j], $image[$j]); } }if($i==4){ for ($j=0; $j < 38; $j++) { preg_match_all('/<p class=time>(.*?)<\/p>/', $channel[$j], $time[$j]); preg_match_all('/<p class=title>(.*?)<\/p>/', $channel[$j], $title[$j]); preg_match_all('/<p class=type>(.*?)<\/p>/', $channel[$j], $type[$j]); } } $i++;}for ($i=0; $i < 38; $i++) { $test = strpos($chaines[2][$i],' </div>'); if($test != true){ echo 'Chaines images: <img src='.$chaines[2][$i].'/><br />'; echo 'Chaines: '.$chaines[3][$i].'<br />'; echo 'image : <img src=http://static.programme-tv.net/var/epgs/169/80x/'.$image[$i][2][0].' /><br />'; echo 'Temps : '.trim($time[$i][1][0]).'<br />'; echo 'Titre : '.substr($title[$i][1][0], strpos($title[$i][1][0], '>') + 1, strrpos($title[$i][1][0], '<')).'<br />'; echo 'Type : '.$type[$i][1][0].'<br />'; echo '<hr>'; }}?>I would like to improve and find a better regular expression pattern because I use 6 regular expression pattern.
Improvement of a regular expression pattern
php;html;parsing
null
_unix.267771
I configured an NTP server on a CentOS 7 machine (a virtual one) and also configured the ntp.conf file of the clients (which also are virtual and run CentOS 7). The NTP synchronization works perfectly when I explicitly start/restart the ntpd service with systemctl (re)start ntpd on the client machines. But when I try to test the automatic synchronization by changing the time on the server, the clients will neither be notified nor update their clocks (the clocks stay as they were synchronized during the last restart of ntpd). I even tried to change the polling frequency from the ntp.conf file of the clients, but nothing seemed to work. I would really appreciate some help. PS: here are the ntp.conf files from the server and one client:Server:# For more information about this file, see the man pages# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not# permit the source to query or modify the service on this system.restrict default nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict 127.0.0.1 restrict ::1# Hosts on local network are less restricted.#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver 127.127.1.0fudge 127.127.1.0 stratum 1#broadcast 192.168.1.255 autokey # broadcast server#broadcastclient # broadcast client#broadcast 224.0.1.1 autokey # multicast server#multicastclient 224.0.1.1 # multicast client#manycastserver 239.255.254.254 # manycast server#manycastclient 239.255.254.254 autokey # manycast client# Enable public key cryptography.#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating# with symmetric key cryptography. keys /etc/ntp/keys# Specify the key identifiers which are trusted.#trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility.#requestkey 8# Specify the key identifier to use with the ntpq utility.#controlkey 8# Enable writing of statistics records.#statistics clockstats cryptostats loopstats peerstats# Disable the monitoring facility to prevent amplification attacks using ntpdc# monlist command when default restrict does not include the noquery flag. See# CVE-2013-5211 for more details.# Note: Monitoring will not be disabled with the limited restriction flag.disable monitorClient:# For more information about this file, see the man pages# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not# permit the source to query or modify the service on this system.restrict default nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict 127.0.0.1 restrict ::1# Hosts on local network are less restricted.#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver 192.168.1.38 #This is the ip address of the server#broadcast 192.168.1.255 autokey # broadcast server#broadcastclient # broadcast client#broadcast 224.0.1.1 autokey # multicast server#multicastclient 224.0.1.1 # multicast client#manycastserver 239.255.254.254 # manycast server#manycastclient 239.255.254.254 autokey # manycast client# Enable public key cryptography.#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating# with symmetric key cryptography. keys /etc/ntp/keys# Specify the key identifiers which are trusted.#trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility.#requestkey 8# Specify the key identifier to use with the ntpq utility.#controlkey 8# Enable writing of statistics records.#statistics clockstats cryptostats loopstats peerstats# Disable the monitoring facility to prevent amplification attacks using ntpdc# monlist command when default restrict does not include the noquery flag. See# CVE-2013-5211 for more details.# Note: Monitoring will not be disabled with the limited restriction flag.disable monitor
NTP synchronization in CentOS 7
centos;ntp;ntpd
null
_webmaster.5277
I am the first developer in a large scale web project, in the real estate sector. I am not an expert in any field, I know the basic of all, programming, databases, something about design and a little bit about SEO, and website optimization / caching. And I have some knowledge about other technologies and stuff that could be required in the project.So I am a developer, my boss does some drawing on a paper to present me his ideas and then I start programming and I show him the result. Until now there was no problem, but now the web application is large enough, and it lacks a little bit of database optimization and intuitive user interface. Beside the website, the project also has an offline newspaper, and a desktop application that is a reduced version of the online one, both this things are not managed by me, but by other people or developers that are external to the company.We do not use a collaboration tool for sharing knowledge between the people working on this project, just emails, and we do not use a development methodology, as for the team, we are: the developer(me), a designer, a secretary and the boss.I have the possibility to ask the boss hire the people I want so I can increase the team and have the right person dealing with the right part of the project.This is the story, the real question is, what should be my attitude towards the project and the company? Should I stay a developer and participate in taking decisions and organizing tasks from time to time to help the boss? Or should I get more serious about this and try to learn project management and implement everything I consider it's required to ensure the quality of the work and final results?I am the one who best knows what has been developed until now, should I try to organize all the work and the team? Or should I ask my boss to hire some expert to do that?I hope someone before has been in my position before and can give me any good indications..Thanks!
What should I be responsible for as the first developer in a large scale web project?
web development
There are multiple steps in designing a new project. The first step starts with the generic idea of what you want. Or in this case, what your boss wants. He provides you information and you write down notes and collect information about his precise wishes. Stay away from your computer, unless you just use it to keep notes!In step two, you open your favorite text editor and start writing down a basic plan based on the ideas you've just collected. You determine your needs and make estimates about how long each feature will take to design, develop and test. You write a nice document and you let your Boss read it to make sure you're on the right track.In step 3, you start designing some code examples, simple databases, some mock-up and whatever else to provide you more details on what needs to be built. You are at this level now! It's far from finished but it will allow you to divide the project in logical blocks. This is also a good point to start generating lots of diagrams, preferably UML diagrams, that will provide plenty of details of the whole project. This should give you more detailed information on all the parts of the project and to make better estimates of the time needed to finish each part.Step 4 is basically the part where the workload gets divided. You know the parts, you know how long each part will take, approximately and you should have detailed information about what each part should do. Use this information to decide if you need more developers and let each developer write a technical design for the piece of the project that they will be working on. These technical designs then need to be reviewed to make sure they all fit together.Writing code is step 5. Now the real code-monkeys will start working! All code written up to this moment will just have to be stored and might be used as reference material, but should NOT be used for production code without proper checks. Use a Source/Version Control System to maintain the code between all developers.Still not ready, you now go to step 6, which is testing. Developers should never test their own code, or the code of their team-members. So you will need to find/hire some experienced testers who are willing to test the whole project. If you deliver your project untested, you will definitely lose customers and the value of your project will be next to nothing.Finally, step 7: deliver the product to the users. For web applications, this means making the server accessible for the World.I estimate that you're halfway step 3 at this moment. While whatever you've build might look great to you, don't even think it will be nearly finished! What you have could still be used for small-scale situations but you have a long road to go. You will have to pick some development methodology and you will need to start creating a lot more documentation. Functional designs, technical designs, UML diagrams and whatever more. And yes, this takes a lot of valuable time, but also keep in mind that all these documents can be used from a marketing perspective too! Your boss could use it to find investors, who can now examine what you're trying to createYou have a very small team so I would think you will need some additional help. I would suggest that you find two more developers and an additional tester. While your secretary could do some of the testing, their regular job will make it impossible for them to do complete tests. Most likely, they will click 5 buttons and then tell you it's broken... An experienced tester will tell you where the final product is having errors and where it stops following the original design!And you? You should become a project manager! As you say, you have some experience but to build a large-scale project, you will definite need an expert. Preferably two or more. You would be their chief and you will be the one who will make the technical decisions. And the developers will first have to write technical documentation, which you will need to approve before they can write the code.Don't stay a developer, though! You're too inexperienced to handle large-scale projects! You would be great to manage the whole project, but not to build it yourself!
_webapps.85883
I do not use Facebook very much but I remeber reading some documentation a long time ago about Facebook apps being available by third-party developers.Where do I view the list and how can I browse and install some of these (just like Android and iPhone users can download and install apps from the respective play store or equivalent)??
Where can I view a list of Facebook apps to install from?
facebook;facebook apps
Facebook currently lists games this wayPoint your browser to https://www.facebook.com/games/From there you should be able to search for other apps as well and send it to mobile to install.
_unix.90925
I'm using apticron to notify myself about available updates. However, I've got an installation on a VPN that seems to notify about packages I DON'T have installed. For example, it keeps (daily) suggesting that I upgrade sysvinit - I have upstart installed, not sysvinit. I used to have it for a number of other packages (basic libraries that weren't installed in my original Debian-wheezy image), so I've shut up those warnings just by installing the libraries. However, I don't really want to ditch upstart for sysvinit just to make apticron play more nicely.Any ideas how to make it stop?
Apticron notifying about uninstalled packages
apt;debian
null
_unix.22988
I want a simple little command to strip an XML-Header and Footer from a file:<?xml version=1.0 encoding=UTF-8?><conxml><MsgPain001> <HashValue>A9C72997C702A2F841B0EEEC3BD274DE1CB7BEA4B813E030D068CB853BCFECA6</HashValue> <HashAlgorithm>SHA256</HashAlgorithm> <Document> ... </Document> <Document> ... </Document></MsgPain001></conxml>...Should become just <Document> ... </Document> <Document> ... </Document>(note the indenting, the indent of the first document-tag should be stripped of.This sounds like a (greedy) regex <Document>.*</Document>But I don't get it due to the linefeeds. Could someone provide a simple sed script or similar to get it?I need it in a pipe to compute a hash over the contained documents.
simple command to strip header and footer from a file
sed;regular expression
Using sed: sed -n '/<Document>/,/<\/Document>/ p' yourfile.xmlExplanation:-n makes sed silent, meaning it does not output the whole file contents,/pattern/ searches for lines including specified pattern,a,b (the comma) tells sed to perform an action on the lines from a to b (where a and b get defined by matching the above patterns),p stands for print and is the action performed on the lines that matched the above. Edit: If you'd like to additionally strip the whitespace before <Document>, it can be done this way: sed -ne '/ <Document>/s/^ *//' -e '/<Document>/,/<\/Document>/ p' yourfile.xml
_webapps.89446
I'm trying to have people go back in after they've submitted the form and fix things. I've marked the entries incomplete and want to, whenever the form is deemed incomplete, have an automatic email response sent to the enterer asking them to complete other details. How do I do this?
How to allow someone to correct their Cognito Form submission
cognito forms
null
_unix.344445
I have a USB-CAN adapter called USBtin (http://www.fischl.de/usbtin/). It's connected to a Raspberry Pi 2 running Raspbian (Linux raspberrypi 4.4.16-v7+ #1 SMP Fri Aug 5 14:49:49 UTC 2016 armv7l GNU/Linux).My goal is to send and receive CAN messages in a Python application. For that I thought using slcan would be a good idea. I compiled slcan-support into the kernel, and to use it I basically followed the Lawicel CANUSB tutorial.I added 90-slcan.rules to /etc/udev/rules.d/ so it should work with the USBtin:ACTION==add, ENV{ID_MODEL}==USBtin, ENV{SUBSYSTEM}==tty, \ RUN+=/usr/bin/logger [udev] USBtin detected - running slcan_add.sh!, \ RUN+=/usr/local/bin/slcan_add.sh $kernelACTION==remove, ENV{ID_MODEL}==USBtin, ENV{SUBSYSTEM}==usb, \ RUN+=/usr/bin/logger [udev] USBtin removed - running slcan_remove.sh!, \ RUN+=/usr/local/bin/slcan_remove.shThe add script looks like this:#!/bin/shsleep 7#slcand -o -c -f -s4 /dev/$1 slcan0/usr/local/bin/slcand -o -c -f -s4 /dev/$1logger Return value of slcand was $?sleep 2ifconfig slcan0 upIn the syslog I can see that these are executed when I plug-in / remove the adapter. I also see the sys-logging produced by slcand. The last thing I see from the slcand in the syslog is: attached TTY /dev/ttyACM0 to netdevice slcan0 (see below). However, afterwards the daemon is not running and the slcan0 interface is also not there.If I manually runsudo /usr/local/bin/slcand -o -c -f -s4 /dev/ttyACM0on a console though, the daemon runs just fine.Any idea why it doesn't work when I just plug it in and let udev do it? I don't know if it helps but the code of slcand can be found on GitHub (I'm using the latest version from the trunk).Syslog:Feb 12 17:38:28 raspberrypi kernel: [ 668.511547] usb 1-1.4: new full-speed USB device number 4 using dwc_otgFeb 12 17:38:28 raspberrypi kernel: [ 668.616867] usb 1-1.4: New USB device found, idVendor=04d8, idProduct=000aFeb 12 17:38:28 raspberrypi kernel: [ 668.616899] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0Feb 12 17:38:28 raspberrypi kernel: [ 668.616916] usb 1-1.4: Product: USBtinFeb 12 17:38:28 raspberrypi kernel: [ 668.616933] usb 1-1.4: Manufacturer: Microchip Technology, Inc.Feb 12 17:38:28 raspberrypi mtp-probe: checking bus 1, device 4: /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4Feb 12 17:38:28 raspberrypi mtp-probe: bus: 1, device: 4 was not an MTP deviceFeb 12 17:38:28 raspberrypi kernel: [ 668.671845] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM deviceFeb 12 17:38:28 raspberrypi kernel: [ 668.673109] usbcore: registered new interface driver cdc_acmFeb 12 17:38:28 raspberrypi kernel: [ 668.673130] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adaptersFeb 12 17:38:28 raspberrypi logger: [udev] USBtin detected - running slcan_add.sh!Feb 12 17:38:35 raspberrypi slcand[1379]: starting on TTY device /dev/ttyACM0Feb 12 17:38:35 raspberrypi slcand[1380]: attached TTY /dev/ttyACM0 to netdevice slcan0Feb 12 17:38:35 raspberrypi logger: Return value of slcand was 0Feb 12 17:42:29 raspberrypi systemd[1]: Starting Cleanup of Temporary Directories...This is the output of udevadm info -a -n /dev/ttyACM0:Udevadm info starts with the device specified by the devpath and thenwalks up the chain of parent devices. It prints for every devicefound, all possible attributes in the udev rules key format.A rule to match, can be composed by the attributes of the deviceand the attributes from one single parent device. looking at device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/tty/ttyACM0': KERNEL==ttyACM0 SUBSYSTEM==tty DRIVER== looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0': KERNELS==1-1.4:1.0 SUBSYSTEMS==usb DRIVERS==cdc_acm ATTRS{bInterfaceClass}==02 ATTRS{bmCapabilities}==2 ATTRS{bInterfaceSubClass}==02 ATTRS{bInterfaceProtocol}==01 ATTRS{bNumEndpoints}==01 ATTRS{authorized}==1 ATTRS{supports_autosuspend}==1 ATTRS{bAlternateSetting}== 0 ATTRS{bInterfaceNumber}==00 looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4': KERNELS==1-1.4 SUBSYSTEMS==usb DRIVERS==usb ATTRS{bDeviceSubClass}==00 ATTRS{bDeviceProtocol}==00 ATTRS{devpath}==1.4 ATTRS{idVendor}==04d8 ATTRS{speed}==12 ATTRS{bNumInterfaces}== 2 ATTRS{bConfigurationValue}==1 ATTRS{bMaxPacketSize0}==8 ATTRS{busnum}==1 ATTRS{devnum}==4 ATTRS{configuration}== ATTRS{bMaxPower}==100mA ATTRS{authorized}==1 ATTRS{bmAttributes}==80 ATTRS{bNumConfigurations}==1 ATTRS{maxchild}==0 ATTRS{bcdDevice}==0100 ATTRS{avoid_reset_quirk}==0 ATTRS{quirks}==0x0 ATTRS{version}== 2.00 ATTRS{urbnum}==77 ATTRS{ltm_capable}==no ATTRS{manufacturer}==Microchip Technology, Inc. ATTRS{removable}==removable ATTRS{idProduct}==000a ATTRS{bDeviceClass}==02 ATTRS{product}==USBtin looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1': KERNELS==1-1 SUBSYSTEMS==usb DRIVERS==usb ATTRS{bDeviceSubClass}==00 ATTRS{bDeviceProtocol}==02 ATTRS{devpath}==1 ATTRS{idVendor}==0424 ATTRS{speed}==480 ATTRS{bNumInterfaces}== 1 ATTRS{bConfigurationValue}==1 ATTRS{bMaxPacketSize0}==64 ATTRS{busnum}==1 ATTRS{devnum}==2 ATTRS{configuration}== ATTRS{bMaxPower}==2mA ATTRS{authorized}==1 ATTRS{bmAttributes}==e0 ATTRS{bNumConfigurations}==1 ATTRS{maxchild}==5 ATTRS{bcdDevice}==0200 ATTRS{avoid_reset_quirk}==0 ATTRS{quirks}==0x0 ATTRS{version}== 2.00 ATTRS{urbnum}==38 ATTRS{ltm_capable}==no ATTRS{removable}==unknown ATTRS{idProduct}==9514 ATTRS{bDeviceClass}==09 looking at parent device '/devices/platform/soc/3f980000.usb/usb1': KERNELS==usb1 SUBSYSTEMS==usb DRIVERS==usb ATTRS{bDeviceSubClass}==00 ATTRS{bDeviceProtocol}==01 ATTRS{devpath}==0 ATTRS{idVendor}==1d6b ATTRS{speed}==480 ATTRS{bNumInterfaces}== 1 ATTRS{bConfigurationValue}==1 ATTRS{bMaxPacketSize0}==64 ATTRS{authorized_default}==1 ATTRS{busnum}==1 ATTRS{devnum}==1 ATTRS{configuration}== ATTRS{bMaxPower}==0mA ATTRS{authorized}==1 ATTRS{bmAttributes}==e0 ATTRS{bNumConfigurations}==1 ATTRS{maxchild}==1 ATTRS{interface_authorized_default}==1 ATTRS{bcdDevice}==0404 ATTRS{avoid_reset_quirk}==0 ATTRS{quirks}==0x0 ATTRS{serial}==3f980000.usb ATTRS{version}== 2.00 ATTRS{urbnum}==26 ATTRS{ltm_capable}==no ATTRS{manufacturer}==Linux 4.4.16-v7+ dwc_otg_hcd ATTRS{removable}==unknown ATTRS{idProduct}==0002 ATTRS{bDeviceClass}==09 ATTRS{product}==DWC OTG Controller looking at parent device '/devices/platform/soc/3f980000.usb': KERNELS==3f980000.usb SUBSYSTEMS==platform DRIVERS==dwc_otg ATTRS{hnp}==HstNegScs = 0x0 ATTRS{srp}==SesReqScs = 0x1 ATTRS{regvalue}==invalid offset ATTRS{hsic_connect}==HSIC Connect = 0x1 ATTRS{guid}==GUID = 0x2708a000 ATTRS{mode}==Mode = 0x1 ATTRS{srpcapable}==SRPCapable = 0x1 ATTRS{regdump}==Register Dump ATTRS{gpvndctl}==GPVNDCTL = 0x00000000 ATTRS{ggpio}==GGPIO = 0x00000000 ATTRS{hprt0}==HPRT0 = 0x00001005 ATTRS{wr_reg_test}==Time to write GNPTXFSIZ reg 10000000 times: 500 msecs (50 jiffies) ATTRS{driver_override}==(null) ATTRS{hcd_frrem}==HCD Dump Frame Remaining ATTRS{mode_ch_tim_en}==Mode Change Ready Timer Enable = 0x0 ATTRS{gnptxfsiz}==GNPTXFSIZ = 0x01000306 ATTRS{remote_wakeup}==Remote Wakeup Sig = 0 Enabled = 0 LPM Remote Wakeup = 0 ATTRS{busconnected}==Bus Connected = 0x1 ATTRS{hcddump}==HCD Dump ATTRS{gotgctl}==GOTGCTL = 0x001c0001 ATTRS{spramdump}==SPRAM Dump ATTRS{grxfsiz}==GRXFSIZ = 0x00000306 ATTRS{gsnpsid}==GSNPSID = 0x4f54280a ATTRS{gusbcfg}==GUSBCFG = 0x20001700 ATTRS{hptxfsiz}==HPTXFSIZ = 0x02000406 ATTRS{devspeed}==Device Speed = 0x0 ATTRS{fr_interval}==Frame Interval = 0x1d4c ATTRS{rem_wakeup_pwrdn}== ATTRS{bussuspend}==Bus Suspend = 0x0 ATTRS{buspower}==Bus Power = 0x1 ATTRS{hnpcapable}==HNPCapable = 0x1 ATTRS{rd_reg_test}==Time to read GNPTXFSIZ reg 10000000 times: 1410 msecs (141 jiffies) ATTRS{enumspeed}==Device Enumeration Speed = 0x1 ATTRS{inv_sel_hsic}==Invert Select HSIC = 0x0 ATTRS{regoffset}==0xffffffff looking at parent device '/devices/platform/soc': KERNELS==soc SUBSYSTEMS==platform DRIVERS== ATTRS{driver_override}==(null) looking at parent device '/devices/platform': KERNELS==platform SUBSYSTEMS== DRIVERS==
USB-CAN Adapter works manually but not via udev
usb;udev
null
_unix.268115
How do I specify the log when autostarting a program in linux mint. For example I change the Dropbox startup script to:[Desktop Entry]Name=DropboxGenericName=File SynchronizerComment=Sync your files across computers and to the webExec=export DBUS_SESSION_BUS_ADDRESS=''; dropbox start -i > /tmp/dropbox.log 2>&1Terminal=falseType=ApplicationIcon=dropboxCategories=Network;FileTransfer;StartupNotify=truebut /tmp/dropbox.log does not exist.
How to specify a log when autostarting in linux mint
linux;linux mint;dropbox
null
_webmaster.106383
First, some prefacing which I believe will help give important context to my question.All of our clients' sites (150+ of them) have a few things in common:They're all in the same field.They're local businesses.Lead gen sites only, with no e-commerce.In part because of these things, they tend to be very low monthly traffic. I would wager that for any of them above 1,000 hits a month (which is very few of them), the great majority of their hits will be non-local, non-leads. Since we're lead-gen only, this traffic is very low priority to us.Our clients use templated websites and content. Duplicate? Yes; however we've done some testing and have found that we don't lose traffic as a result of this. We suspect it's because the sites' focuses are so heavily localized.This industry has some major players in the medical field who tend to produce popular content for queries at the top of the conversion funnel; we don't try to compete with these and instead focus almost entirely on bottom-of-the-funnel traffic.Here's my question: What are some best practices for link building in a situation like this? Ordinarily, the general strategy might include generating great quality content, building a network with high authority sites, etc. However this seems to go out the window when we're looking at trying to do this for 150+ sites. Our standard approach is to work with local partners and affiliates to build a network. We've had some success with this, although it has some lower, finite limitations than a more global business would have.
Backlink building for multiple local businesses in same industry
backlinks;local seo;link building
null
_softwareengineering.22265
I'm still at school, and I know I have problems dealing with other people.I'm not an angry or shy or different, I just like to work my way and with my opinions while respecting other's, I have a big curiosity and hunger for knowledge, but I lack practice and I guess people don't want to work with me because they might fear I would talk some kind of morale. (For example I started to learn programming using linux instead of windows, even if I use windows a lot. And I have a mac).What happens to programmers who lack teamwork? Where does the problems begin? Does being a good programmer compensate at least a little? Is it normal for a programmer to have a vision about his work instead of just doing what he is told?
How bad can it be to lack teamwork when you are a programmer?
teamwork
Your behavior is pretty common at your age. I was like you.The good news is that most of the time, it evolves in the good direction. You will learn how to integrate yourself within a team. You will love it! But I met some people that weren't able to make it and are now stuck is depression.Depending on the style of management of your company, you will either be rejected by your team or simply fired after a while. So you must be prepared to face some difficulties.France's most common style of management is based on fear and punishment. This is not a good news for you since it will encourage your individualism. So it will encourage your behavior.That said, you already know there is a problem with you, so it's a pretty good indication that you have all you need to evolve without external help. The first step is being aware. The second one, the most difficult, is acting on it.
_unix.312399
I have recently installed Debian 8 (Jessie) on my laptop. I am using an external monitor as the primary display and the laptop monitor as a secondary display.The laptop monitor shows text etc on startup and then goes blank when the login screen loads.After logging in I can make the laptop monitor work by changing the resolution. After this the laptop monitor works until I log out again. It seems like it doesn't matter what resolution I change it to, just the act of changing the resolution makes it work. I am using Gnome.Can someone tell me how I can configure the system so that I do not have to do the aforementioned workaround?
Debian Jessie problems with dual monitors on laptop
debian;laptop;dual monitor
null
_codereview.133597
The method medianOfThreereturns the median of the first, center and last element in arraysorts the first, center, and last element of the array, so they are in order EXCEPT places the center in the second to last position.Examples:INPUT: 1,2,3 RETURN:2 EFFECT:1,2,3 INPUT: 3,2,1 RETURN:2 EFFECT:1,2,3 INPUT: 2,3,1 RETURN:2 EFFECT:1,2,3INPUT: -2,-3,-8,1,20 RETURN:-2 EFFECT:-8,-3,1,-2,20 INPUT: 15,20,5,10 RETURN:15 EFFECT:10,5,15,20 NOTE: when the center is moved to the second to last position, it doesn't matter where the value that was previously there goes (as long as it's still in the array). Though this probably isn't relevant. In fact, as long as the first, last and one before last are in the correct place, the rest of the elements can get scrambled.Here is the code. I tested it, but since it is rather complex it was hard to test (need to check return value and array and think carefully of expected result). Any suggestions for tools that make testing code like this easier? /**Sorts first, center and last element, swaps the new center element with the one before the new last and returns its value.*/public static int medianOfThree(int[] sample, int start, int end) { if(sample.length < 3) { throw new IllegalArgumentException(arrays of length three or greater); } int center = (int)Math.floor((end-start)/2); if(sample[start] > sample[end]) swap(sample, start, end); if(sample[start] > sample[center]) swap(sample, start, center); if(sample[center] > sample[end]) swap(sample, center, end);int secondLast = end - 1 swap(sample, center, secondLast ); return sample[secondLast];}//swaps two elements in array given their positionsprivate static void swap(int[] sample, int x, int y) { int temp = sample[x]; sample[x] = sample[y]; sample[y] = temp;}
Finding median of 3 elements in array, and sorting them
java;sorting
Bug when finding centerYour code for finding the center is wrong:int center = (int)Math.floor((end-start)/2);For example, if start is 10 and end is 20, your calculation makes center be 5 when it should be 15. Also, you don't need Math.floor because you are using integer arithmetic so there is nothing to round up or down. You should change your code to this:int center = start + (end-start)/2;
_unix.43932
I have a Linux network Bonding interface for two Ethernet interfaces (eth0 and eth1) $ cat /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 BOOTPROTO=static ONBOOT=yes IPADDR=XX.XX.XX.XX NETMASK=255.255.255.0 GATEWAY=XX.XX.XX.XXX How i can add another IPADDR to this bonding Interface ?
Add another IP address to a Bonding Interface
networking;fedora;rhel;bonding
null
_unix.372856
I need to get the shell equivalent ofexport PYTHONHTTPSVERIFY=0to work in an autotools .am file, but can't get it working. I currently have this declaration in my Makefile.am file:PYTHONHTTPSVERIFY=0but when the build runs it is not behaving as though that variable is set as an environment variable. Can anyone advise on what the correct syntax is?
How to set shell environment variable from autotools .am file?
shell;make;variable;autotools
To declare environment variables is better to user the configure.ac file. There you can write:export PYTHONHTTPSVERIFY=0However, I am not sure what are you trying to achieve with that. Do you need an environmental variable to run your program or to compile it? In the former case, other methods are preferable.
_cs.39508
This question was asked by my professor in optional brain teaser section, I have tried to solve it for last 48 hours, I am not able to construct a deterministic Turing Machine, Can someone provide hint or something because this seems like impossible to me :( ..
How to design a Turing Enumerator which either ends with 011 or is of odd length?
turing machines
I'm assuming you're looking for a Turing machine that decides the language $L$ consisting of all words ending with 011 or of odd length.Hint: You're lucky since $L$ is regular. Construct a DFA for $L$ and rephrase it as a Turing machine.
_softwareengineering.110266
My organization finally upgraded to MS Visual Studio 2010 this year. One of the big new features that Visual Studio 2010 offers is the F# programming language.I understand that F# offers a functional programming paradigm, similar to Lisp. Unlike Lisp though, F# is compiled into managed code for the .net framework.Right now, I work in database-driven web application development. Right now, I'm working with an n-tier application with SQL code on the back end and a C#.net AJAX web application on the front-end. I would like to know if F# offers anything that would be particularly useful for this type of development.
Does F# offer anything particularly useful for database-driven web development?
web development;.net;asp.net;sql;f#
null
_unix.336482
I did git fetch and git fetch --all but there was no output for the same. after that when I do git pull again I get the below error again.I am willing to fetch the origin from the remote to my local.I even did this below but still there is an error.[root@connect /myurl/fd-ansible]# git fetch origin masterPassword:From https://github.com/myurl/fd-ansible * branch master -> FETCH_HEAD[root@connect /myurl/fd-ansible]# git clean -df[root@connect /myurl/fd-ansible]# git pullPassword:Updating 8bf6b66..a0b2167error: Your local changes to 'group_vars/system1' would be overwritten by merge. Aborting.Please, commit your changes or stash them before you can merge.Edited with @Stephen Kitt solution [root@connect /myurl/fd-ansible]# git checkout group_vars/system1[root@connect /myurl/fd-ansible]# git pullPassword:Updating 8bf6b66..a0b2167Fast-forward cmdb/vm.csv | 118 +++++++++++++++++++++++++------------------------- group_vars/system1 | 56 ++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 59 deletions(-)
Git pull merge issue with remote origin
github
To overwrite your local file (losing your changes):git checkout group_vars/system1Then you should be able to git pull.
_unix.174884
using virt-manager quite successfully. I am wondering if it's possible to specify in the virtual DHCP server, that some virtual machines will have a specific IP address (maybe via MAC address mapping?).Any ideas on how to do this? Otherwise I have to resort to simpler, and less elegant solutions, such as configuring the ip address from inside the VMs.
virt-manager: is it possible to assign specific IP addresses to certains VMs via the virtual DHCP?
virtual machine;kvm;virtualization;qemu
AFAIK virt-manager can only assign MAC-addresses. So what you would need to do is setup your DHCP server to map those to specific IP addresses. Even if a different machine (e.g. your router) normally provides DHCP addresses, but cannot be easily modified programmatically, you can set a DHCP server up on the hosts of the VMs, that serves only to specific MAC addresses and as long as those are not in the range the other DHCP server gives out, you will not run into a problem.Update prompted by Pavel's comment, you can set IP addresses via libvrt (although I rather have all my IP addresses in one spot)...<mac address='00:16:3E:5D:C7:9E'/><domain name=example.com/><dns> <txt name=example value=example value /> <forwarder addr=8.8.8.8/> <forwarder addr=8.8.4.4/> <srv service='name' protocol='tcp' domain='test-domain-name' target='.' port='1024' priority='10' weight='10'/> <host ip='192.168.122.2'> <hostname>myhost</hostname> <hostname>myhostalias</hostname> </host></dns><ip address=192.168.122.1 netmask=255.255.255.0> <dhcp> <range start=192.168.122.100 end=192.168.122.254 /> <host mac=00:16:3e:77:e2:ed name=foo.example.com ip=192.168.122.10 /> <host mac=00:16:3e:3e:a9:1a name=bar.example.com ip=192.168.122.11 /> </dhcp></ip><ip family=ipv6 address=2001:db8:ca2:2::1 prefix=64 /><route family=ipv6 address=2001:db9:ca1:1:: prefix=64 gateway=2001:db8:ca2:2::2 />
_codereview.113861
A interesting challenge was brought to my attention: to flip an array. I thought it might be more convenient if its bounds were symmetrical, say [-N..N] instead of [0 .. 2N + 1].Now I'm curious about what could be done to make this Array more mature. Say, like a Boost component.#include <cassert>#include <iostream>#include <algorithm>template <typename T, int LoBound, int HiBound> class Array { T arr_[HiBound - LoBound + 1];public: Array() { std::fill(arr_, arr_ + sizeof(arr_) / sizeof(arr_[0]), T{}); } Array(const Array& other) :arr_(other.arr_) {} Array(std::initializer_list<T> initList) { std::copy(initList.begin(), initList.end(), arr_); } T& operator[](int ix) { assert(ix >= LoBound && ix <= HiBound); return arr_[ix - LoBound]; } const T& operator[](int ix) const { assert(ix >= LoBound && ix <= HiBound); return arr_[ix - LoBound]; }};int main(){ enum {LoBound = -2, HiBound = 2}; using A1D = Array<int, LoBound, HiBound>; Array<A1D, LoBound, HiBound> arr = { A1D{ 1, 2, 3, 4, 5}, A1D{ 6, 7, 8, 9, 10}, A1D{11, 12, 13, 14, 15}, A1D{16, 17, 18, 19, 20}, A1D{21, 22, 23, 24, 25} }; for (int i = LoBound; i <= HiBound; ++i) { for (int j = LoBound; j <= HiBound; ++j) { std::cout << arr[-i][-j] << ; } std::cout << \n; } return 0;}
Fixed array with configurable bounds
c++;array;template meta programming
It looks pretty clean to me.The copy constructor doesn't have to be explicitly declared, you could = default it or just omit.You shouldn't fill() the array. It is already default constructed, so that's just duplicated work. The default constructor again could be = default or omitted. Actually, maybe could provide an explicit constructor that takes a fill value. That can be handy.A size() method to return sizeof(arr_) / sizeof(arr_[0]) should be useful, for both internal and external uses.Mark the class final? I'd probably do it, but that's probably a matter of personal preference.If you're interested in making this class Standard compliant, well, there's a long road ahead ;). It needs iterators and several other methods ([c]begin/[c]end/front/back/at...). Look into std::array for the details.
_unix.166475
There is one parameter -adcdev Name of audio device to use for input., but it doesn't say if this can be stdin. Can pocketsphinx_continuous read from stdin?
Can pocketsphinx_continuous read from stdin?
stdin;speech recognition
Yes, in version 0.8, you can use -infile as in pocketsphinx_continuous -infile /dev/stdin. The documentation is still trying to catch up with this new feature!
_unix.316897
this is driving me crazy, I've been searching for a good answer why this doesn't work for months now.. So basically, what I'm trying to do is to sync home folders with NFS to a server.This is the LDAP scheme: --- defines a map inside that mapautomountMapName=auto_masterINSIDE: objectClass: TopobjectClass: automountMapautomountMapName: auto_master---automountKey=/Network/Servers/Servername/---INSIDE---objectClass: automount---automountKey:/Network/Servers/servername---automountInformation:autouser--------------------------------------------------automountMapName=auto_userINSIDE: objectClass: TopobjectClass: automountMapautomountMapName: auto_user---automountKey=home---INSIDE:---objectClass:automount---automountKey: home---automountInformation:servernameFQDN:/homeThis is the /etc/exports file:/home 192.168.1.0/255.255.255.0(rw,subtree_check,no_root_squash,insecure)This is the permissions inside the home folders: drwxr-xr-x 1 username staff 18 17 okt 08.43 usernameWhen I try to sync by using this command: /usr/bin/rsync -az --delete /Users/username/ /Network/Servers/servername/home/username/I receive the following error message: rsync: ERROR: cannot stat destination /Network/Servers/servername/home/username/: Stale NFS file handle (70)I get the same error message when trying to change directory to /Network/Servers/servername/home/usernameAlso worth mentioning is that it have worked before, but that might've been on other OSX versions.
Automount OSX home folders (NFS & OPENLDAP)
nfs;openldap;autofs
null
_unix.53938
I'm using sparse raw image files for guest VMs and OCFS2 on the host (local-only, not clustered) for the reflink feature. I understand from Googling around that OCFS2 is one of the filesystems that can punch holes back into sparse files.If I understand correctly, it may be possible (and apparently can be achieved with XFS) to combine this feature with TRIM/discard support in the guest machines so that when files in the guest are deleted, space on the host is automatically reclaimed. However despite much experimentation, I haven't been able to demonstrate this working.Is this possible, and if it depends on versions of the kernel and/or QEMU, what are the minimum versions I need? Also have I missed anything with the configuration? I've:mounted the (ext4) guest filesystem with the discard option in /etc/fstabtried the current beta of Debian Wheezy for host and guest, and CentOS 6.2 for hosttried running fstrim on the guest (I get FITRIM ioctl failed: Operation not supportedbut I'm not 100% sure if this is relevent)tried bus=ide and bus=virtio (with CentOS 6.2 host)
Can QEMU/KVM+OCFS2 be configured to punch holes in sparse image files when files are deleted in the guest?
virtualization;qemu;sparse files
You should be able to recover space by using virtio-scsi devices and specifying discard=unmap in the libvirt definition for the disk. I haven't tried this in CentOS/RHEL but I did get this to work in later versions of Fedora. I wrote a blog post about it.I would say to give it a try and see if it works.
_unix.52476
I've got a Thinkpad T400 with Gentoo Linux installed. Suspend-to-RAM works like a charm.However, Susped-to-Disk doesn't work: if I suspend, the Laptop powers down and accesses the HD for around 30s. However, if I switch it back on, it just boots as normal, but doesn't resume to the previous state.Here's the /var/log/pm-suspend.log just before the suspend:Sun Oct 21 14:16:44 CEST 2012: Finished.Initial commandline parameters: Blacklisting 01grub.Sun Oct 21 15:26:06 CEST 2012: Running hooks for hibernate.Running hook /usr/lib64/pm-utils/sleep.d/00logging hibernate hibernate:Linux rgs-lenovo 3.4.9-gentoo #1 SMP Fri Aug 31 18:55:03 CEST 2012 x86_64 Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz GenuineIntel GNU/LinuxModule Size Used bycdc_wdm 8704 0 cdc_acm 14890 0 rfcomm 21490 0 bnep 9782 0 btusb 10904 0 bluetooth 162465 5 rfcomm,bnep,btusbmmc_block 16408 0 nls_iso8859_1 4521 0 nls_cp850 5362 0 vfat 8384 0 fat 45316 1 vfattwofish_x86_64_3way 19478 0 lrw 3622 1 twofish_x86_64_3waytwofish_x86_64 5539 1 twofish_x86_64_3waytwofish_common 14649 2 twofish_x86_64_3way,twofish_x86_64aes_x86_64 7768 0 aes_generic 26983 1 aes_x86_64xts 2912 1 twofish_x86_64_3waygf128mul 7431 2 lrw,xtsdm_crypt 13973 0 dm_mod 62853 1 dm_cryptrndis_host 6143 0 cdc_ether 4584 1 rndis_hostusbnet 17584 2 rndis_host,cdc_etherarc4 1345 2 sdhci_pci 10056 0 sdhci 20883 1 sdhci_pcifirewire_ohci 27077 0 mmc_core 82856 3 mmc_block,sdhci_pci,sdhcifirewire_core 49742 1 firewire_ohcicrc_itu_t 1635 1 firewire_coreiwlwifi 233406 0 snd_hda_codec_conexant 43770 1 mac80211 338064 1 iwlwificfg80211 156724 2 iwlwifi,mac80211snd_hda_intel 22760 4 snd_hda_codec 88731 2 snd_hda_codec_conexant,snd_hda_intelsnd_pcm 73911 3 snd_hda_intel,snd_hda_codecsnd_timer 18324 2 snd_pcmsnd_page_alloc 7332 2 snd_hda_intel,snd_pcmloop 15063 0 vboxnetflt 12915 0 vboxdrv 1759366 1 vboxnetfltfuse 60817 1 thinkpad_acpi 64233 0 snd 59641 12 snd_hda_codec_conexant,snd_hda_intel,snd_hda_codec,snd_pcm,snd_timer,thinkpad_acpi total used free shared buffers cachedMem: 8062552 6417912 1644640 0 427824 4174720-/+ buffers/cache: 1815368 6247184Swap: 12582908 0 12582908/usr/lib64/pm-utils/sleep.d/00logging hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/00powersave hibernate hibernate:Blacklisting 01grub./usr/lib64/pm-utils/sleep.d/00powersave hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/01grub hibernate hibernate:/usr/lib64/pm-utils/sleep.d/01grub hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/49bluetooth hibernate hibernate:/usr/lib64/pm-utils/sleep.d/49bluetooth hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/75modules hibernate hibernate:/usr/lib64/pm-utils/sleep.d/75modules hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/90clock hibernate hibernate:/usr/lib64/pm-utils/sleep.d/90clock hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/94cpufreq hibernate hibernate:/usr/lib64/pm-utils/sleep.d/94cpufreq hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/95led hibernate hibernate:/usr/lib64/pm-utils/sleep.d/95led hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/98video-quirk-db-handler hibernate hibernate:Kernel modesetting video driver detected, not using quirks./usr/lib64/pm-utils/sleep.d/98video-quirk-db-handler hibernate hibernate: success.Running hook /usr/lib64/pm-utils/sleep.d/99video hibernate hibernate:/usr/lib64/pm-utils/sleep.d/99video hibernate hibernate: success.Sun Oct 21 15:26:08 CEST 2012: performing hibernateIn the /var/log/syslog I found the following line:Oct 21 15:27:10 lenovo kernel: PM: Hibernation image not present or could not be loaded.Here's my grub config:title Gentoo Linuxroot (hd0,0)kernel /3.4.9-gentoo root=/dev/sda3 rootfstype=ext4 resume=swap:/dev/sda2 i915.modeset=1 fan_control=1/dev/sda2 is my swap partition.What could be wrong?
Thinkpad T400: Suspend to HD doesn't resume
power management;suspend;thinkpad
I fixed this issue by changing my grub config. The swap: in the resume parameter is not needed. My config now looks like this:title Gentoo Linuxroot (hd0,0)kernel /3.4.9-gentoo root=/dev/sda3 rootfstype=ext4 resume=/dev/sda2 i915.modeset=1 fan_control=1