id
stringlengths 5
27
| question
stringlengths 19
69.9k
| title
stringlengths 1
150
| tags
stringlengths 1
118
| accepted_answer
stringlengths 4
29.9k
⌀ |
---|---|---|---|---|
_unix.160295 | I'm trying to build an NFS server on my Raspberry Pi which will be writable by any server on the network. The NFS share is a directory on an external device mounted at boot:$ cat /etc/fstabproc /proc proc defaults 0 0/dev/mmcblk0p1 /boot vfat defaults 0 2/dev/mmcblk0p2 / ext4 defaults,noatime 0 1# This is my external device/dev/sda1 /data ext4 defaults,nofail 0 2I configured my /etc/exports as follows:$ cat /etc/exports /data *(rw,sync,all_squash,no_subtree_check,anonuid=1000,anongid=1000)/data/share *(rw,sync,all_squash,no_subtree_check,anonuid=1000,anongid=1000)The User ID and Group ID of 1000 is the pi user and pi group, which owns both /data and /data/share:$ ls -la /datatotal 28drwxrwxrwx 4 pi pi 4096 Sep 30 08:41 .drwxr-xr-x 23 root root 4096 Oct 9 15:54 ..drwx------ 2 pi pi 16384 Sep 25 14:57 lost+founddrwxrwxrwx 2 pi pi 4096 Sep 30 08:41 shareWhen I try to mount the share from my Mac, I get the following error:$ mount 192.168.101.10:/data tmpmount_nfs: can't mount /data from 192.168.101.10 onto /Users/davejlong/Downloads/tmp: Operation not permittedHere is the output of exportfs -v$ sudo exportfs -v/data <world>(rw,wdelay,root_squash,all_squash,no_subtree_check,anonuid=1000,anongid=1000)/data/share <world>(rw,wdelay,root_squash,all_squash,no_subtree_check,anonuid=1000,anongid=1000)I'm not sure what I'm doing wrong with my configuration. | Building NFS Server to be world writable | nfs;raspberry pi;raspbian | null |
_webapps.30193 | I joined many groups on LinkedIn, and I visit most of them daily.The groups sends me a summary of their posts daily, I know there's an option to turn them off, but I can't find it. Can anyone help me in that? | Turning off Group emails | linkedin;linkedin groups | Found any easier way to do this. Hover your mouse pointer over your name at top right corner click on settings Login again Click on Group, Companies and Applications tab Click on Set the frequency of group digest emailsSelect the options for each of your groupClick Save ChangesThanks Alex for the help too. |
_codereview.42387 | I have my program working. I just need to redo it a little bit, and it could use some improvements.I got different % rates depending on what the income and status is.#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <cstdio>//functions calledfloat wages_loop();float other_loop();float interest_loop();float dividends_loop();int dependatnts_loop();void check_status();float get_total_income(float wage, float div, float intre, float other, int dep);int single_total = 0;int mj_total = 0;int ms_total = 0;int sh_total = 0;//start main int main(void){ char another[10]; char buffer[80][90]; float wages, other_income, interest, dividends, income_tax; int dependents; printf(Would you like to start: ); gets_s(another); if (another[0] != 'y' && another[0] != 'n') { while (another[0] != 'y' && another[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Would you like to start. (y or n)); gets_s(another); } } while (another[0] == 'y') { //add all info together. wages = wages_loop(); other_income = other_loop(); interest = interest_loop(); dividends = dividends_loop(); //enter dependats dependents = dependatnts_loop(); //function to indicate the status and other things. income_tax = get_total_income(wages, other_income, dividends, interest, dependents); if (income_tax < 0) { printf(\n\n\t\t Your income tax RETURN is: %.2f \n, income_tax); } else if (income_tax >= 0) { printf(\n\n\t\t Your income tax OWED is: %.2f \n, income_tax); } printf(Would you like to do anoter: ); gets_s(another); if (another[0] != 'y' && another[0] != 'n') { while (another[0] != 'y' && another[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Would you like anoter. (y or n)); gets_s(another); }//end if } } //end loop printf(\n\n\t\t\t Number of Singles filleing: %i \n, single_total); printf(\n\n\t\t\t Number of Married Filing Jointly: %i \n, mj_total); printf(\n\n\t\t\t Number of Married Filing Separately: %i \n, ms_total); printf(\n\n\t\t\t Number of Single Head of Household filleing: %i \n, sh_total); system(pause); return 0;}//end mainfloat wages_loop(){ char again[10]; char buffer[80]; float wages, total_wages = 0; printf(\n How much in Wages. ); gets_s(buffer); wages = atof(buffer); total_wages = wages + total_wages; printf(\n Do you have any more wages. (y or n)); gets_s(again); if (again[0] != 'y' && again[0] != 'n') { while (again[0] != 'y' && again[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Do you have any more wages. (y or n)); gets_s(again); } } while (again[0] == 'y') { printf(\n Enter Wages: ); gets_s(buffer); wages = atof(buffer); total_wages = wages + total_wages; printf(\n Do you have any more wages. ); gets_s(again); } return total_wages;}//end wage_loopfloat other_loop(){ char again[10]; char buffer[80]; float other_income, total_other_income = 0; printf(\n How much in other income. ); gets_s(buffer); other_income = atof(buffer); total_other_income = other_income + total_other_income; printf(\n Do you have any more other income. (y or n)); gets_s(again); if (again[0] != 'y' && again[0] != 'n') { while (again[0] != 'y' && again[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Do you have any more other income. (y or n)); gets_s(again); } } while (again[0] == 'y') { printf(\n Enter other income: ); gets_s(buffer); other_income = atof(buffer); total_other_income = other_income + total_other_income; printf(\n Do you have any more other income. ); gets_s(again); } return total_other_income;}float interest_loop(){ char again[10]; char buffer[80]; float interest, total_interest = 0; printf(\n How much in interest. ); gets_s(buffer); interest = atof(buffer); total_interest = interest + total_interest; printf(\n Do you have any more interest. (y or n)); gets_s(again); if (again[0] != 'y' && again[0] != 'n') { while (again[0] != 'y' && again[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Do you have any more interest. (y or n)); gets_s(again); } } while (again[0] == 'y') { printf(\n Enter interest: ); gets_s(buffer); interest = atof(buffer); total_interest = interest + total_interest; printf(\n Do you have any more interest. ); gets_s(again); } return total_interest;}float dividends_loop(){ char again[10]; char buffer[80]; float dividends, total_dividends = 0; printf(\n How much in dividends. ); gets_s(buffer); dividends = atof(buffer); total_dividends = dividends + total_dividends; printf(\n Do you have any more dividends. (y or n)); gets_s(again); if (again[0] != 'y' && again[0] != 'n') { while (again[0] != 'y' && again[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Do you have any more dividends. (y or n)); gets_s(again); } } while (again[0] == 'y') { printf(\n Enter dividends: ); gets_s(buffer); dividends = atof(buffer); total_dividends = dividends + total_dividends; printf(\n Do you have any more dividends. ); gets_s(again); } return total_dividends;}//end dividends_loop//dependantsint dependatnts_loop(){ char again[10]; char buffer[80]; int dependants, total_dependants = 0; printf(\n How much in dependants. ); gets_s(buffer); dependants = atof(buffer); total_dependants = dependants + total_dependants; printf(\n Do you have any more dependants. (y or n)); gets_s(again); if (again[0] != 'y' && again[0] != 'n') { while (again[0] != 'y' && again[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Do you have any more dependants. (y or n)); gets_s(again); } } while (again[0] == 'y') { printf(\n Enter dependants: ); gets_s(buffer); dependants = atof(buffer); total_dependants = dependants + total_dependants; printf(\n Do you have any more dependants. ); gets_s(again); } total_dependants = total_dependants * 2800; return total_dependants;}void check_status(){ char status[10]; int check = 0; while (check != 1) { printf(What is your Status: ); gets_s(status); if (status[0] == 'S' && status[1] == 'H') { printf(\n\n CORRECT ANSWER. SH \n\n); single_total = single_total + 1; check = 1; } else if (status[0] == 'S' && status[1] == '\0') { printf(\n\n CORRECT ANSWER. S \n\n); single_total = single_total + 1; check = 1; } else if (status[0] == 'M' && status[1] == 'J') { printf(\n\n CORRECT ANSWER. MJ \n\n); mj_total = mj_total + 1; check = 1; } else if (status[0] == 'M' && status[1] == 'S') { printf(\n\n CORRECT ANSWER. MS \n\n); ms_total = ms_total + 1; check = 1; } else { printf(\n\n INCORRECT NSWER. noting \n\n); } } }float get_total_income(float wage, float div, float intre, float other, int dep){ char status[10]; float income = 0, sum = 0, adjusted_income = 0; int check = 0; sum = wage + div + intre + other; income = sum - dep; while (check != 1) { printf(\n\nWhat is your Status: ); gets_s(status); if (status[0] == 'S' && status[1] == 'H') { sh_total = sh_total + 1; check = 1; if (income <= 6000) { adjusted_income = income * 0.0; } else if (income > 6000 && income <= 9000) { adjusted_income = income * .038; } else if (income > 9000 && income <= 15000) { adjusted_income = income * .074; } else if (income > 15000 && income <= 21000) { adjusted_income = income * .110; } else if (income > 21000 && income <= 25000) { adjusted_income = income * .138; } else if (income > 25000 && income <= 30000) { adjusted_income = income * .154; } else if (income > 30000) { adjusted_income = income * .35; } else { printf(\n\n INCORRECT ANSWER. CODE IS WRONG. \n\n); } } else if (status[0] == 'S' && status[1] == '\0') { single_total = single_total + 1; check = 1; if (income <= 6000) { adjusted_income = income * .028; } else if (income > 6000 && income <= 9000) { adjusted_income = income * .075; } else if (income > 9000 && income <= 15000) { adjusted_income = income * .096; } else if (income > 15000 && income <= 21000) { adjusted_income = income * .135; } else if (income > 21000 && income <= 25000) { adjusted_income = income * .155; } else if (income > 25000 && income <= 30000) { adjusted_income = income * .174; } else if (income > 30000) { adjusted_income = income * .35; } else { printf(\n\n INCORRECT ANSWER. CODE IS WRONG. \n\n); } } else if (status[0] == 'M' && status[1] == 'J') { mj_total = mj_total + 1; check = 1; if (income <= 6000) { adjusted_income = income * 0.0; } else if (income > 6000 && income <= 9000) { adjusted_income = income * .052; } else if (income > 9000 && income <= 15000) { adjusted_income = income * .083; } else if (income > 15000 && income <= 21000) { adjusted_income = income * .122; } else if (income > 21000 && income <= 25000) { adjusted_income = income * .146; } else if (income > 25000 && income <= 30000) { adjusted_income = income * .163; } else if (income > 30000) { adjusted_income = income * .35; } else { printf(\n\n INCORRECT ANSWER. CODE IS WRONG. \n\n); } } else if (status[0] == 'M' && status[1] == 'S') { ms_total = ms_total + 1; check = 1; if (income <= 6000) { adjusted_income = income * .023; } else if (income > 6000 && income <= 9000) { adjusted_income = income * .072; } else if (income > 9000 && income <= 15000) { adjusted_income = income * .089; } else if (income > 15000 && income <= 21000) { adjusted_income = income * .131; } else if (income > 21000 && income <= 25000) { adjusted_income = income * .152; } else if (income > 25000 && income <= 30000) { adjusted_income = income * .172; } else if (income > 30000) { adjusted_income = income * .35; } else { printf(\n\n INCORRECT ANSWER. CODE IS WRONG. \n\n); } } else { printf(\n\n INCORRECT STATUS. Enter (S, MJ, MS, or SH) \n\n); } } printf(\n\n\n\t YOUR WAGES: %.2f, wage); printf(\n\t YOUR OTHER INCOME: %.2f, other); printf(\n\t YOUR DIVIDENS: %.2f, div); printf(\n\t YOUR INTEREST: %.2f, intre); printf(\n\t YOUR INCOME AFTER DEPENDANTS: %.2f, income); return adjusted_income;} | Total income program | c | Things you did well:You used the function gets_s, which is a C11 function. Not many people use this standard yet because it is newer. I was surprised to see it in your code.Your organization of the prototype functions is good.You initialize your variables as soon as you create them in some areas.Things you could improve:There is a lot that could be improved in this code, so I doubt I will be able to mention them all.PreprocessorYou include both <stdio.h> and <cstdio>.#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <cstdio>I couldn't get the code to compile as C code with the #include <cstdio> in there, so it should be removed.User-experienceYou ask the user if he is ready to start.printf(Would you like to start: );gets_s(another);if (another[0] != 'y' && another[0] != 'n'){ while (another[0] != 'y' && another[0] != 'n') { printf(\n\n INCORRECT ANSWER. \n\n); printf(\n Would you like to start. (y or n)); gets_s(another); }}The user initiated your program for a reason. Asking him if he would like start is useless, and can be frustrating to a user. To add onto the annoyance, you then tell the user that his input is incorrect, if he doesn't input 'y', and you then loop the question. I would remove the whole thing.LogicSome of your logic can be simplified.if (status[0] == 'S' && status[1] == 'H'){ printf(\n\n CORRECT ANSWER. SH \n\n); single_total = single_total + 1; check = 1;}else if (status[0] == 'S' && status[1] == '\0'){ printf(\n\n CORRECT ANSWER. S \n\n); single_total = single_total + 1; check = 1;}Both times you are checking if status[0] == 'S', so use that as the master if test condition. Use the other tests as children tests.if (status[0] == 'S'){ if (status[1] == 'H') puts(Correct answer: SH); if (status[1] == '\0') puts(Correct answer: S); single_total = single_total + 1; check = 1;}Pull out the code that the original test conditions had in common to the master condition, and you have a refined test condition statement!You sometimes have logic that will print out to the console that the logic in the code is wrong.else{ printf(\n\n INCORRECT ANSWER. CODE IS WRONG. \n\n);}I would use assert() instead. If this expression evaluates to 0, this causes an assertion failure that terminates the program. Also, assertions are the right mechanism to use, since those positions in the code would only be reachable due to programmer error, not due to unanticipated runtime conditions.else{ assert(income > 30000); adjusted_income = income * .35;}VariablesYou have a lot of magic numbers in your code. if (income <= 6000){ adjusted_income = income * 0.0;}else if (income > 6000 && income <= 9000){ adjusted_income = income * .038;}else if (income > 9000 && income <= 15000){ adjusted_income = income * .074;}else if (income > 15000 && income <= 21000){ adjusted_income = income * .110;}else if (income > 21000 && income <= 25000){ adjusted_income = income * .138;}else if (income > 25000 && income <= 30000){ adjusted_income = income * .154;}else if (income > 30000){ adjusted_income = income * .35;}You should extract all of those numbers to variables in case you have to change them later. Then you only have to change one number in one place, instead of changing the number in multiple different places. What if you missed a place?Your variable char buffer[80][90] is unused and should be removed.It's generally good practice to initialize all of your non-static variables when possible.Don't use global variables.int single_total = 0;int mj_total = 0;int ms_total = 0;int sh_total = 0;The problem with global variables is that since every function has access to these, it becomes increasingly hard to figure out which functions actually read and write these variables.If you don't rely on global variables, you can pass state around between different functions as needed. That way you stand a much better chance of understanding what each function does, as you don't need to take the global state into account.SyntaxYou use too much space when printing to the console. Also, use puts() instead of printf() in some cases where you are not actually formatting the string but just printing it with a newline character at the end.mj_total = mj_total + 1 can be simplified to mj_total += 1.InputYour code can't handle the input of a string properly.How much in other income. tenIt should tell the user that it is unacceptable input and ask for re-entry of the data.Your program can't handle the input of a malformed string properly.How much in other income. 107tIt should tell the user that it is unacceptable input and ask for re-entry of the data.Your program can't handle the input of a \n (new-line) character (pressing enter).How much in other income. <enter>It should tell the user that it is unacceptable input and ask for re-entry of the data.Your program is very unforgiving when asking the status of the user. printf(\n\nWhat is your Status: );gets_s(status);If you input a lower-case character, it won't be accepted. Use the toupper() function on your input character to fix this. You have this same issue when asking the user if he has more wages, dividends, etc.printf(\n Would you like anoter. (y or n));gets(another);Here you might want to use the tolower() function. |
_webmaster.86773 | Identical desktop and mobile URLs, no subdomain or sub-folder:Desktop URLsite-name.com<link rel=canonical href=index.php?/...>Mobile URLsite-name.com<link rel=canonical href=index.php?/...>Mobile UsabilityTouch elements too close 307Content not sized to viewport 306Small font size 170Viewport not configured 170Accessed last time: 7days agoWhat googlebot-mobile does is crawl:http://site-name.com/index.php?/.../&mobile=falseLast time: 7days agoRobots.txt:Disallow: *&mobile=falsechanges were made around 3-4 months agoWhich is a link on the mobile layout to force-switch visitors to the desktop version.All the above mobile usability issues are from the desktop version, which will obviously get all those issues.The mobile theme is live since end of March, just a little bit before the new mobile ranking rules came out.I blocked it with the robots.txt, because it created duplicate content on the desktop as well (which I now read, is not the best practice). That's why it is not just googlebot-mobile that is excluded.How do I tell googlebot-mobile to leave the desktop content alone? Should I use the URL Parameters to clear this little misunderstanding up?Thanks for any help here! | Why does Googlebot-Mobile crawl desktop content? | seo;googlebot;mobile;googlebot mobile | Looking at your setup...Identical desktop and mobile URLs, no subdomain or sub-folder:Desktop URLsite-name.com<link rel=canonical href=index.php?/...>Mobile URLsite-name.com<link rel=canonical href=index.php?/...>I see an issue. you're confusing the heck out of google. you need to create an association between desktop and mobile site, not indicate that neither is original.Here's what you doWhat you need on your desktop pages is the following between <head> and </head><link rel=alternate media=only screen and (max-width: 111px) href=http://mobilesite.example.com>...but change the 111 in 111px to the maximum number of pixels the remote device connecting your site should have for you to recommend the mobile site. Change http://mobilesite.example.com to the full URL to the mobile equivalent of the page you put the above HTML code on.Then on the mobile version, you use:Of course change http://desktop.example.com to the full URL of the desktop equivalent site.Once you do that, configure your server so mobile devices automatically are redirected to the mobile version of your site, then you can test the desktop version of the page in page-speed insights.Mobile Usability Touch elements too close 307Content not sized to viewport 306Small font size 170Viewport not configured 170If you're getting a host of errors like this, then include this between <head> and </head> on all mobile pages:<meta name=viewport content=width=device-width,initial-scale=1>That will set the window to the actual mobile device size. then when you get errors about things that are too wide, you'll know the width limit.How do I tell googlebot-mobile to leave the desktop content alone?Earlier, you mentioned ...Which is a link on the mobile layout to force-switch visitors to the desktop version.. Don't make links to incompatible pages too easy for robots with limited capabilities to access The problem is that the link is on at least one mobile page that anyone including googlebot can access.Since google doesn't touch post-based data, what I'd suggest is to create a special warning page telling users who insist on the desktop version what they really are getting into, and if they want to continue, then they can select a button that will take them in. This is an example of how to make the button:<form action=/path/to/url-to-desktop-switcher method=POST><input type=hidden name=mydata value=1><input type=submit value=switch></form>The reason why I suggest this is because when user clicks the button, the data is sent to the server via POST method, not the GET method, and bots normally don't click form buttons.I added a hidden form item so that data can be passed into the script when the button is selected. The good news is that the button can be styled, but the bad news is that the text in the button can't have too many characters or it will be too large for the mobile screen. |
_softwareengineering.203970 | I see that Java has Boolean (class) vs boolean (primitive). Likewise, there's an Integer (class) vs int (primitive). What's the best practice on when to use the primitive version vs the class? Should I basically always be using the class version unless I have a specific (performance?) reason not to? What's the most common, accepted way to use each? | When to use primitive vs class in Java? | java;class;usage | null |
_unix.10661 | I just got a new, strong ubuntu desktop. First time linux user.I'm trying the Run Application app ( Alt+F2 ), try Ch for Chrome, and the app thinks for 2-3 seconds before displaying the list of apps starting with ch. This is semi-consistent - some searches are a bit faster, then they're slower again afterwards. What's up with that? | Why is Run Application (Alt-F2) very sluggish on a new computer? | ubuntu;gnome;run dialog | null |
_scicomp.10766 | For a nonsingular lower or upper triangular square matrix $A$, how to solve such linear system in Eigen:$$A x = b$$ | How to use TrangularView class in Eigen C++ | linear solver;c++;eigen | As documented here:x = A.triangularView<Upper>().solve(b);orx = A.triangularView<Lower>().solve(b); |
_unix.134998 | This is not a What is best but a Is there any at all (and which)? question.A friend of mine wants to improve the handling of her customers' appointment wishes. The idea is that they can enter their suitable time spans on a web site and the application checks whether all of them (or: how many) can be combined.I am not familiar with this kind of optimization algorithm thus it would be much easier to use an existing tool than write one myself... Thus (if there is no such application) hints to resources about appropriate algorithms would be helpful. | Applications for handling appointment wishes | web | null |
_webapps.3164 | Can I get a single feed combining all of my subscriptions out of Google Reader?I mean I'm subscribed to 80 something feeds in Reader, and I want to use that as a single feed in another app.Is that possible? If so how? | Global RSS feed from Google Reader | google reader;rss | null |
_hardwarecs.7585 | I'm building a custom NAS as a backup server for multiple laptops in my house. I'm planning on buying four 2TB mechanical SATA hard drives that will be run in RAID 1 (Hard drives: https://www.newegg.com/Product/Product.aspx?Item=N82E16822236342&ignorebbr=1)The drives will be going in this case here: https://www.newegg.com/Product/Product.aspx?Item=9SIA00Y50Z9087&ignorebbr=1The case has 4 SATA cable connectors that will be connected to a SATA cable to USB adapter and they will be connected to my logic boards USB ports. My question for all of you is what power supply would you recommend to power ONLY the hard drives. This power supply will not be powering my logic board. I want to make sure that I won't fry a hard drive, but I also want to make sure that the power supply has enough wattage for expansion in the future (should I need use bigger hard drives / SSDs). IMPORTANT POINTSThe hard drives must be powered by a power supply independent from my logic board. The hard drives SATA data cables must be connected to USB. Because the SATA data cables are not connected to the logic board, the power supply must provide at least 2 SATA Power Connector cables.I'm shooting in the ballpark of no more than $150. Note: I know this is a weird build and I understand the bottleneck of USB with SATA, but I want to see if this configuration is possible before completely buying all new hardware. Thanks in advance! | 2TB NAS HDD Power Supply Recommendations | hard disk;server;nas;sata | null |
_codereview.67954 | This is a PHP database class. Yes, I know it's using the MySQL functions, which are deprecated, but I shall be updating it to MySQLi soon. Can you please review this code and give any comment on any improvements or changes you think I should make?<?phpnamespace Revolution;if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }class engine{ private $initiated; private $connected; private $connection; final public function __construct() { $this->Initiate(); } final public function Initiate() { global $_CONFIG; if(!$this->initiated) { $this->setMySQL('connect', mysql_connect); $this->setMySQL('pconnect', mysql_pconnect); $this->setMysql('select_db', mysql_select_db); $this->setMySQL('query', mysql_query); $this->setMySQL('num_rows', mysql_num_rows); $this->setMySQL('fetch_assoc', mysql_fetch_assoc); $this->setMySQL('fetch_array',mysql_fetch_array); $this->setMySQL('result', mysql_result); $this->setMySQL('free_result', mysql_free_result); $this->setMySQL('escape_string', mysql_real_escape_string); $this->initiated = true; $this->connect($_CONFIG['mysql']['connection_type']); } }final public function setMySQL($key, $value){ $this->mysql[$key] = $value;}/*-------------------------------Manage Connection-------------------------------------*/final public function connect($type){ global $core, $_CONFIG; if(!$this->connected) { $this->connection = $this->mysql[$type]($_CONFIG['mysql']['hostname'], $_CONFIG['mysql']['username'], $_CONFIG['mysql']['password']); if($this->connection) { $mydatabase = $this->mysql['select_db']($_CONFIG['mysql']['database'], $this->connection); if($mydatabase) { $this->connected = true; } else { $core->systemError('MySQL Engine', 'MySQL could not connect to database'); } } else { $core->systemError('MySQL Engine', 'MySQL could not connect to host'); } }}final public function disconnect(){ global $core; if($this->connected) { if($this->mysql['close']) { $this->connected = false; } else { $core->systemError('MySQL Engine', 'MySQL could not disconnect.'); } }}/*-------------------------------Secure MySQL variables-------------------------------------*/final public function secure($var){ return $this->mysql['escape_string'](stripslashes(htmlspecialchars($var)));}/*-------------------------------Manage MySQL queries-------------------------------------*/final public function query($sql){ return $this->mysql['query']($sql, $this->connection) or die(mysql_error());}final public function num_rows($sql){ return $this->mysql['num_rows']($this->mysql['query']($sql, $this->connection));}final public function result($sql){ return $this->mysql['result']($this->mysql['query']($sql, $this->connection), 0);}final public function free_result($sql){ return $this->mysql['free_result']($sql);}final public function fetch_array($sql){ $query = $this->mysql['query']($sql, $this->connection); $data = array(); while($row = $this->mysql['fetch_array']($query)) { $data[] = $row; } return $data;}final public function fetch_assoc($sql){ return $this->mysql['fetch_assoc']($this->mysql['query']($sql, $this->connection));}}?> | PHP MySQL Database class | php;database;mysqli | null |
_webapps.104080 | I have a table that, for 30 people, marks their dietary needs. The first 3 rows are diet category, the remainder are restrictions:----------|Jane|Joe|Ali|Vegetarian| 1 | | |Vegan | | 1 | |Omnivore | | | 1 |No gluten | | | 1 |No nuts | | 1 | |Now I am trying to create lists of which restrictions are associated with which dietary type- the result will be, e.g:Vegan: No nutsVegetarian: Omnivore: No glutenI've done this in a clumsy way by specifying a separate rule for every restriction- this prints the Column A value (name) of a restriction if there is any person who has that restriction and is also vegetarian: | Vegetarian | =if(SUM(FILTER(C2:AF2,NOT(ISBLANK(C5:AF5)))), A5 & , )&if(SUM(FILTER(C2:AF2,NOT(ISBLANK(C6:AF6)))), A6 & , )&if(SUM(FILTER(C2:AF2,NOT(ISBLANK(C7:AF7)))), A7 & , )| Vegan | =if(SUM(FILTER(C3:AF3,NOT(ISBLANK(C5:AF5)))), A5 & , )&if(SUM(FILTER(C3:AF3,NOT(ISBLANK(C6:AF6)))), A6 & , )&if(SUM(FILTER(C3:AF3,NOT(ISBLANK(C7:AF7)))), A7 & , )Considering that the only difference for all the rules in the vegetarian food restrictions count is the column number, I'm sure there's a more effective way to do this, but I haven't worked it out. In pseudocode, what I'm looking for is something like this:A3..A5.for_each do |row_num| if(SUM(FILTER(C2:AF2,NOT(ISBLANK(Crow_num:AFrow_num)))), Arow_num & , )end | What's a better way to check for the presence of a value across all rows? | google spreadsheets | I think the following does the job: =join(, , filter(A$6:A$10, mmult(N(C$6:AF$10), N(transpose(C2:AF2)))))The key part is matrix multiplication. Multiplying the array of preferences by the transpose of the row such as C2:AF2 results is nonzero elements corresponding to the rows where there is an overlap with C2:AF2. Then the column with the names of restrictions is filtered by the result of multiplication, and the results joined, separated by comma-space. The N() function performs conversion of blank cells to zeros, otherwise mmult complains about non-numeric numbers. The formula uses absolute row references for 6-10 which in my example are the rows with restrictions. The reference to row 2 (vegetarian) is relative. So, copy-pasting this formula down the column will result in correct answers for other diets. |
_unix.72504 | I'm trying to install Red Hat on my Windows system but Im facing a problem. I get only one option during installation which is Minimal and even if I check Gnome desktop in customize options, I only get the command line after installation completes. What am I doing wrong?I'm using a USB stick to install. Also another stange thing is that I get many options alongside Minimal when installing in Virtualbox - like Desktop, Server, etc. | Why don't I get a Gnome GUI when I install Red Hat? | rhel;gnome;system installation | null |
_unix.163653 | I have a bunch of swfs, these swfs include links to other swfs inside them.I use this to convert them to xml: swf2xml Disc1.swf Disc1.swf.xml. Then I use this to remove every single line that does not include an swf link: sed -i '' '/swf/!d' Disk1.swf.xmlId like to do this with 501 different swf files, there are two challenges:I have to run the command on 500 different files and specify output.I have to sed them allIm trying to build a scriptCurrently I have thisswf2xml Disc1.swfswf2xml NV.swf... | How do I extract information with what I have right now? | sed;conversion | for swf in *.swf; do xml=$swf.xml swf2xml $swf $xml sed -i '' -n '/swf/p' $xmldone |
_vi.4920 | I really want to know why doesn't Vim's v:lnum return 1 for very first line. I tried googling and searching in Vim's docs, but I can't find an answer. I understand that v:lnum returns line number, but I don't understand which line v:lnum is referring to..? A little aside; from help v:lnum I understand that you can only use v:lnum with some expressions including indentexpr (the one I'm interested in the most for my indentation script). workflow test 1make a .vim file. e.g check.vimappend echo v:lnumopen new vim window and :source check.vimappend some text to the file and :source check.vim againno matter how many lines I add to the file I always get 0 backI think I understand this, since Vim docs say that v:lnum only works in conjunction with some specific expressions then you would expect 0 when I'm trying to use v:lnum by itself.workflow test 2make check.vim fileappendsetlocal indentexpr=Check()function! Check() let line = getline(v:lnum) echo v:lnum lineendfunctionopen new vim window and :source check.vimappend some text to the file and :call Check() functionI DON'T get first line no matter what I do.. I can get any other lines.. e.g if I only type in one line into the file and :call Check() I get 0 and ''if I type in second line into the file and :call Check() I get 2 and check line two backif I keep adding lines to the file and run :call Check() on lets say the fifths line I get 5 and check line fiveI think I understand that v:lnum returns index of the last line typed into the file. But why doesn't it return the index of the very first line type? | Why `v:lnum` doesn't return 1 for the first line? | vimscript;indentation | v:lnum is a Vim internal variable, that is only valid while evaluating the indentexpr, foldexpr, formatexpr options. In other contexts this does nothing. This means, that in you indentexpr or formatexpr you can find out, what line is currently being evaluated and react accordingly.For indentexpr this means, it will get filled, once you start indenting your file, e.g. using gg=G, for formatexpr this will be evaluated when defining your foldmethod and folding is enabled and formatexpr will be evaluated using the gq command.In other context, this is really invalid. It should actually be always 0 so there might be a (minor) bug there. |
_computerscience.3885 | I'm passing my vertex shader a bunch of vertices and color data. I would like to first render the triangles and then render a point at each vertex. The triangles render fine, but I can't think of a way to render the triangles and the points without making and calling a whole new method for rendering points, which I guess I could do, but I'd like to know if there is some shader magic that accomplish it for me.Thanks in advance!This is my vs:#version 120uniform mat4 projection;void main() {gl_Position = projection * ftransform();gl_PointSize = 1.0;gl_FrontColor = gl_Color;}This is my fs:#version 120#define point_color vec3(1,1,1)void main() {vec4 color = gl_Color;gl_FragColor = vec4(color);}This is the code behind it. I'm using lwjgl.public void render() { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnable(GL_PROGRAM_POINT_SIZE); glBindBuffer(GL_ARRAY_BUFFER, VBO_id); glVertexPointer(3, GL_FLOAT, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, c_id); glColorPointer(4, GL_FLOAT, 0, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_id); glDrawElements(GL_TRIANGLES, draw_count, GL_UNSIGNED_INT, 0); glDrawArrays(GL_POINTS, 0, draw_count_v); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_PROGRAM_POINT_SIZE);} | Can I use the same vertices to render multiple things? | opengl;rendering;glsl | If your intention is to render some textured or colored triangles and points colored diferently at the same time at vertex postions with one draw call:glDrawElements(GL_TRIANGLES, draw_count, GL_UNSIGNED_INT, 0);In order to access vertex data in vertex shader, you can create vertex array object which references to vertex buffer object with data you provided (vertices) for example at index 0.then in vertex shader you have:layout (location = 0) in vec3 vPosition; //positions for each vertexYou might then do something like that (vertex shader):flat out vec3 fpos; //not interpolated verticesout vec3 pos; //interpolated vertices (for default)void main(void){ pos = vPosition; fpos = vPosition;}And then in fragment shader:if(length(fpos-pos)<threshold) //small threshold fragColor = pointColor;else fragColor = triangleColor; |
_softwareengineering.351721 | Consider this simplified example: In an online ticket sale website, tickets have variable prices that change over time. User searches for tickets. Once he finds a ticket he wants, clicks Buy and then a quote is issued. Quotes are persisted and they have they own locator that is sent by email. The quote page opens, showing the breakdown of what he is going to pay, and a button to pay. At this point, the ticket is still available for others. If the user clicks on Pay now, a payment process starts and a Purchase Order is issued with his details.When a purchase order is paid, the quote status must be set as Accepted and reference the purchase order; the ticket status is set as Sold. As per requirements, this must happen in an atomic fashion, meaning that it is not acceptable to have a paid purchase order referencing a non accepted quote, or a non sold ticket at any given time. Essentially, eventual consistency is not allowed.There are two big aggregates, Quote and PurchaseOrder. The first manages the breakdown calculation, taxes, etc... The second manages payment details for a quote, payment event raising, etc... The problem I have is that right now it seems I have to use a transaction across ticket, quote and purchase order when the last is paid.How may I model this honoring the Transactions should not cross aggregate boundaries rule? | How can I avoid a cross aggregate transaction? | design;domain driven design;transaction;aggregate | null |
_unix.78980 | I have my keyboard layouts (two of them) and switching between them configured via the following command:setxkbmap -layout us,ru -option -option grp:lctrl_lshift_toggle,ctrl:nocapsNow I want to switch to us layout, using some command line command. Is that possible? | How do I change currently selected keyboard layout from command line? | x11;keyboard;keyboard layout;xkb | You could use xkb-switch (-n switches to next layout):xkb-switch -nor xkblayout-state (with set +1 to wrap around, in your case) :xkblayout-state set +1or xte from xautomation to simulate Control_L+Shift_L key press/release:xte 'keydown Control_L' 'keydown Shift_L' 'keyup Shift_L' 'keyup Control_L' |
_codereview.131507 | I want to extract the creation of different objects in a factory class for the reason of reusability. The problem is that within the current code the objects are configured also for the specific problem. Now I want to reuse only the creation of the objects within another code place. if (FieldConfiguration.FIELD_TYPE.TEXTFIELD == type) { TextField textField = new TextField(caption); textField.setNullRepresentation(); bind(textField, propertyId); field = textField; if (field.getValue() == null && isNestedProperty) { ObjectProperty property = new ObjectProperty(, String.class); textField.setPropertyDataSource(property); } } else if (FieldConfiguration.FIELD_TYPE.SEARCHFIELD == type) { SearchBox searchField = new SearchBox(caption); bind(searchField, propertyId); field = searchField; } else if (FieldConfiguration.FIELD_TYPE.DATEFIELD == type) { DateField dateField = new DateField(); dateField.setCaption(caption); dateField.setDateFormat(UilibI18N.dateFormat.getText()); dateField.setResolution(Resolution.DAY); bind(dateField, propertyId);I want to reuse only the creation of the objects at another code place too, can anybody give me a hint what's the right way to extract the creation logic? | Factory for object init and configuration | java | null |
_webmaster.29481 | I have: www.mywebsite.com which redirects to en.mywebsite.com, es.mywebsite.com, fr.mywebsite.com depending on the user language, so there's not an indexed website in www.mywebsite.comHowever, when I put links to my website in other websites, I do not do it directly to the subdomain:Instead of this:http://fr.mywebsite.com/article/article123/I do this:http://www.mywebsite.com/article/article123/So the user gets redirected to that article in his language, or english if the user's language is not avaiable:http://en.mywebsite.com/article/article123/My question is, how do this affect SEO? Will the subdomains benefit from the backlinks? or just the main domain? (which would be a problem as there's no real content indexed there). | SEO: Linking to a domain that redirects to a subdomain | seo;domains;redirects;subdomain | null |
_codereview.11858 | These are the steps to determine coordinates of the 4 points (P1, P2, P3, P4) that make up a tangential trapezoid connecting to circles. Another way of looking at it is to think of the tangential segments of being the parts of a belt that would not be wrapped around the pulleys. The math should work regardless of the orientation of the two circles in coordinate space.Code (usage @ bottom):internal class TrapezoidBuilder{ private const double RadiansToDegrees = 180/Math.PI; private readonly double _bufferDistanceC0; private readonly double _bufferDistanceC1; private readonly Point _pointC0; private readonly Point _pointC1; public TrapezoidPoints TrapezoidPoints; public TrapezoidBuilder(Point pointC0, Point pointC1, double bufferDistanceC0, double bufferDistanceC1) { _pointC0 = pointC0; _pointC1 = pointC1; _bufferDistanceC0 = bufferDistanceC0; _bufferDistanceC1 = bufferDistanceC1; TrapezoidPoints = new TrapezoidPoints(); CalculateTrapezoidPoints(); } public void CalculateTrapezoidPoints() { // Get the angle of the line C0-C1 in degrees. This will be used in conjunction with angleA to determine the vector of these points double angleRelativeToPositiveXAxis = CalculateAngleRelativeToXAxis(_pointC0, _pointC1); // Get angleA double angleA = CalculateAngleA(_pointC0, _pointC1, _bufferDistanceC0, _bufferDistanceC1); //// Calculate P1 and P2 coordinates first double positiveAngle = angleRelativeToPositiveXAxis + angleA; double cosPositiveAngle = Math.Cos(positiveAngle/RadiansToDegrees); double valueToAddToC0X = cosPositiveAngle*_bufferDistanceC0; // Set P1's X coordinate TrapezoidPoints.P1.X = _pointC0.X + valueToAddToC0X; double valueToAddToC1X = cosPositiveAngle*_bufferDistanceC1; // Set P2's X coordinate TrapezoidPoints.P2.X = _pointC1.X + valueToAddToC1X; double sinPositiveAngle = Math.Sin(positiveAngle/RadiansToDegrees); double valueToAddToC0Y = sinPositiveAngle*_bufferDistanceC0; // Set P1's Y coordinate TrapezoidPoints.P1.Y = _pointC0.Y + valueToAddToC0Y; double valueToAddToC1Y = sinPositiveAngle*_bufferDistanceC1; // Set P2's Y coordinate TrapezoidPoints.P2.Y = _pointC1.Y + valueToAddToC1Y; //// Calculate P3 and P4 coordinates double negativeAngle = angleRelativeToPositiveXAxis - angleA; double cosNegativeAngle = Math.Cos(negativeAngle/RadiansToDegrees); valueToAddToC0X = cosNegativeAngle*_bufferDistanceC0; // Set P4's X coordinate TrapezoidPoints.P4.X = _pointC0.X + valueToAddToC0X; valueToAddToC1X = cosNegativeAngle*_bufferDistanceC1; // Set P3's X coordinate TrapezoidPoints.P3.X = _pointC1.X + valueToAddToC1X; double sinNegativeAngle = Math.Sin(negativeAngle/RadiansToDegrees); valueToAddToC0Y = sinNegativeAngle*_bufferDistanceC0; // Set P4's Y coordinate TrapezoidPoints.P4.Y = _pointC0.Y + valueToAddToC0Y; valueToAddToC1Y = sinNegativeAngle*_bufferDistanceC1; // Set P3's Y coordinate TrapezoidPoints.P3.Y = _pointC1.Y + valueToAddToC1Y; Debug.WriteLine(C0 + _pointC0.X + + _pointC0.Y); Debug.WriteLine(C1 + _pointC1.X + + _pointC1.Y); Debug.WriteLine(P1 + TrapezoidPoints.P1.X + + TrapezoidPoints.P1.Y); Debug.WriteLine(P2 + TrapezoidPoints.P2.X + + TrapezoidPoints.P2.Y); Debug.WriteLine(P3 + TrapezoidPoints.P3.X + + TrapezoidPoints.P3.Y); Debug.WriteLine(P4 + TrapezoidPoints.P4.X + + TrapezoidPoints.P4.Y); } private double CalculateAngleA(Point pointC0, Point pointC1, double radius0, double radius1) { double xDistance = pointC1.X - pointC0.X; double yDistance = pointC1.Y - pointC0.Y; double distance = Math.Sqrt((xDistance*xDistance) + (yDistance*yDistance)); double radius2 = radius0 - radius1; double cosA = radius2/distance; double angleAInRadians = Math.Acos(cosA); double angleAInDegrees = angleAInRadians*RadiansToDegrees; return angleAInDegrees; } private double CalculateAngleRelativeToXAxis(Point point0, Point point1) { try { // In order to use ATAN2, point C1 has to be considered as the origin, i.e. 0, 0. // So C1x is subtracted from C2x and C1y from C2y. Note that its important to subtract // the 1st value from the 2nd to help determine which quadrant the angle is in. double x = point1.X - point0.X; double y = point1.Y - point0.Y; // Get the angle in radians double angleInRadians = Math.Atan2(x, y); // Convert to degrees double angleInDegrees = angleInRadians*RadiansToDegrees; // Subtract from 90 to get the angle relative to the positive X-axis double relativeAngleInDegrees = 90 - angleInDegrees; // Return result return relativeAngleInDegrees; } catch (Exception err) { Debug.WriteLine(err.Message); } // If no result, return zero return 0; }}internal class TrapezoidPoints{ public Point P1; public Point P2; public Point P3; public Point P4;}// UsagePoint C1 = new Point(5,7);Point C2 = new Point(6.516, 7.875);double buffer0 = 1;double buffer1 = .375;var trapezoidBuilder = new TrapezoidBuilder(C1, C2, buffer0, buffer1); | C# code to derive tangential points between two circles to create a trapezoid | c#;computational geometry | null |
_unix.340975 | I have a Bind9 on a host.I have several guest virtual machines.I want my virtual machines to use the Bind9 located on the host. I know how to make Bind9 accept requests from my vitual machines (listen-on + allow-recursion).I want to achieve it using iptables/netfilter, without modifing Bind9 configuration (aka listen only on 127.0.0.1).--> this is just a local port redirection. I know how to do it with socat, but I'm stuck when doing it with iptables/netfilterBind listen only on 127.0.0.1, so the packets must originate from 127.0.0.1The virtual machines are on a bridge vmbr0 10.10.10.0/24The host is also on the bridge at 10.10.10.1Should I make the packets enter into a custom chain, then DNAT+SNAT them, or is there a simplier way?I did that (but does not work):sysctl -w net.ipv4.conf.vmbr0.route_localnet=1 # not sure if necessary. Let's see that when everything will workiptables --table nat --new-chain dns-preroutingiptables --table nat --append PREROUTING --source 10.10.10.0/24 --destination 10.10.10.1 --protocol udp --destination-port 53 --jump dns-preroutingiptables --table nat --append PREROUTING --source 10.10.10.0/24 --destination 10.10.10.1 --protocol tcp --destination-port 53 --jump dns-preroutingiptables --table nat --new-chain dns-postroutingiptables --table nat --append POSTROUTING --source 10.10.10.0/24 --destination 127.0.0.1 --protocol udp --destination-port 53 --jump dns-postroutingiptables --table nat --append POSTROUTING --source 10.10.10.0/24 --destination 127.0.0.1 --protocol tcp --destination-port 53 --jump dns-postroutingiptables --table nat --append dns-prerouting --jump DNAT --to-destination 127.0.0.1iptables --table nat --append dns-postrouting --jump SNAT --to-source 127.0.0.1 | Common DNS for virtual machines - with iptables/netfilter | iptables;port forwarding;bind;nat | You have to use sysctl -w net.ipv4.conf.XXX.route_localnet=1 as you did, but probably on the virtual Ethernet interface.This allow the kernel to keep martin packets. Also keep in mind that locally generated packets does not pass into the PREROUTING chain. So you have to use the OUTPUT chain.And finally don't try to NAT for this very special case. Use --jump TPROXY instead.I can't give you a working example by memory, you have to find the exact setup. Then please complete the answer for future reference. |
_codereview.54713 | I'm following thislet StringOfLengthConstructor<'c> (input:string, length:int, defaultConstructor:string->'c) = match input with | null -> None | x when x.Length = length -> Some(defaultConstructor(input)) | _ -> Nonetype String3 = | String3 of stringlet String3 input = StringOfLengthConstructor<String3>(input, 3, String3) type String4 = | String4 of stringlet String4 input= StringOfLengthConstructor<String4>(input, 4, String4)type String5 = | String5 of stringlet String5 input = StringOfLengthConstructor<String5>(input, 5, String5)type String6 = | String6 of stringlet String6 input = StringOfLengthConstructor<String6>(input,6, String6)and am trying to make more of these with hopefully less repetition. Can this be done without having to repeat type String3 =| String3 of string followed by this?let String3 input = StringOfLengthConstructor<String3>(input, 3, String3) See all the repetition? For the purpose of defining a zip code, a US zip code could be defined astype ZipCode = | Us of String5ortype ZipCode = | Us of String5*(String4 option) | Canadian of String3*String3 | Defining a zip code string | strings;f# | The solution can be made cleaner by re-arranging the order of the arguments and using pointfree style.let StringOfLengthConstructor<'c> (length : int) (defaultConstructor : string -> 'c) (input : string) = match input with | x when x <> null && x.Length = length -> Some (defaultConstructor input) | _ -> Nonetype String3 = String3 of stringlet String3 = StringOfLengthConstructor 3 String3However, I don't think that String5 * (String4 option) is a good definition of a zip code. The code should be validating on more than just the string length. |
_unix.295165 | I'm using zsh with prezto (on OSX and inside tmux, not sure if it matters), and from time to time history gets shared between multiple terminals.I already added unsetopt share_history and also unsetopt SHARE_HISTORY to the end of my .zpreztorc, but it keeps mixing up history.The output of setopt shows that sharehistory is still there! Even after adding unsetopt sharehistory. | zsh keeps sharing history even when shared history is disabled | zsh;prezto | Try adding:setopt no_share_historyunsetopt share_historyto ~/.zshrc ... this should work |
_codereview.63193 | This is a follow up on JS Progress Bar WidgetI've rewritten it as a jQuery Widget Factory widget, attempting to follow that standard as much possible and fixing the various problems pointed out in my first question.Here is a demo fiddle: http://jsfiddle.net/slicedtoad/eo5hy4LL/Ooh, I didn't know this was live. Duplicate of the fiddle:////////////////////////////// Progress Tracker Widget(function($){ $.widget(dan.progresstracker, { options: { step: 1, // current step steps:['','',''], // default is 3 no-name steps jumpDirection: back, // values: none,back,forward,both jumpables: .step-number, .step-label, // callbacks jumpforward: null, jumpback: null, complete: null }, // Constructor _create: function() { this.options.step = this._constrain(this.options.step); this.element.addClass(hasProgressTracker) .append(this._build()); this._bind(); this.update(); }, // Unbinds and then binds a click event for each jumpable _bind: function(){ this._off(this.element,click); var onMap = {}; onMap[click +this.options.jumpables] = function(e){ this._stepClick(e); }; this._on(this.element, onMap); }, // Limit step to an integer >= 0 and <= the number of steps+1 _constrain: function(step){ step = parseInt(step) || 0; if(step>this.options.steps.length) {return this.options.steps.length+1;} else if(step<0) {return 0;} else {return step;} }, // Builds and returns a jQuery element that is the progress tracker in a neutral state. _build: function() { var $node = $(<ol class='progresstrack container'></ol>); var html = ; for(var step in this.options.steps){ html += <li class='step'> + <div class='step-number'>+(parseInt(step)+1)+</div> + <div class='step-line'></div> + <div class='step-label-wrap'> + <label class='step-label'>+this.options.steps[step]+</label> + </div> + </li>; } $node.html(html); return $node; }, // Options setter override. // Handles options that need updates or rebuilds after changing _setOptions: function( options ) { var that = this, update = false, rebuild = false, rebind = false; $.each( options, function( key, value ) { if(key === step){ that.step(value); // use the setter }else{ that._setOption( key, value ); if(key === jumpDirection){ update = true; }else if(key === steps){ rebuild = true; }else if(key === jumpables){ update = true; rebind = true; } } }); if( rebuild ){ this.element.find(.progresstrack).replaceWith(this._build()); this.step(this.options.step); this.update(); } if( rebind ){ this._bind(); } if( update ){ this.update(); } }, // Handler for user clicking on a jumpable element // Triggers relevant callbacks _stepClick: function(e){ var step = this.element.find(.step) .index($(e.target).closest('.step'))+1; var jumpable = ($(e.target).parents('.jumpable').length)?true:false; if(step===this.options.step){ return; // Nothing changed, return }else if(step>this.options.step && jumpable){ if(!this._trigger(jumpforward,e,{step:step})){ return; // Canceled } }else if(step<this.options.step && jumpable){ if(!this._trigger(jumpback,e,{step:step})){ return; // Canceled }; }else{ return; // Wrong direction } this.step(step); // Apply change }, // step() gets the current step // step(int) sets the current step. Does not trigger callbacks except complete. step: function(step){ if(typeof step === 'undefined') { return this.options.step; }else{ this.options.step = this._constrain(step); this.update(); if(this.options.step === this.options.steps.length+1){ // if complete this._trigger(complete); } return this; } }, // Increments step by one. // Convenience function since this will usually be the most common action. // Only triggers complete callback and only if it actually changed to complete (and wasn't there already) next: function(){ var nextstep = this.options.step+1; if(this._constrain(nextstep)===this.options.step){ return this; }else{ this.step(nextstep); return this; } }, // Update the <ol> and <li> classes to reflect the current step update: function(){ // Reset progress bar status $e = this.element; $e.find(.step-current).removeClass(step-current); $e.find(.step-finished).removeClass(step-finished); $e.find(.jumpable).removeClass(jumpable); // If complete if(this.options.step>this.options.steps.length){ $e.find('.step').addClass(step-finished); $e.addClass(complete); if((this.options.jumpDirection===back || this.options.jumpDirection===both)){ // if jumpback // add jumpable to all steps $e.find(.step).addClass(jumpable); } return this; } // If current == 0 (pre-first step) if(this.options.step===0){ if((this.options.jumpDirection===forward || this.options.jumpDirection===both)){ // if jumpforward // add jumpable to all steps $e.find(.step).addClass(jumpable); } return this; } // Set current step var $current = $e.find(.step:nth-child(+this.options.step+)) .addClass(step-current); var $prevAll = $current.prevAll('.step').addClass(step-finished); if((this.options.jumpDirection===back || this.options.jumpDirection===both)){ $prevAll.addClass(jumpable); } if((this.options.jumpDirection===forward || this.options.jumpDirection===both)){ $current.nextAll('.step').addClass(jumpable); } return this; } });})(jQuery);////////////////////////////// Usage// Tracker 1 test - all options and callbacksvar $pbar = $(#ProgressTracker1);var steps = [[Date,Items,Preview,Details,Confirm],[Cart,Shipping,Checkout]];var toggle = 0;$pbar.progresstracker({ step: 1, steps:steps[toggle], jumpDirection:both, jumpforward:function(e,data){ if(data.step === 3){ $(#Events).append(<br/>Cancelled forward jump to +data.step); return false; } $(#Events).append(<br/>Jumped forward to step +data.step); }, jumpback:function(e,data){ $(#Events).append(<br/>Jumped back to step +data.step); }, complete:function(){ $(#Events).append(<br/>Progress complete.); }});$(#next).on(click,function(){ $pbar.progresstracker(next)});$(#previous).on(click,function(){ $pbar.progresstracker(step,$pbar.progresstracker(step)-1)});$(#steps).on(click,function(){ toggle = !toggle; $pbar.progresstracker(option,{steps:steps[toggle|0]});});$(#jumpdir).on(change,function (e) { var valueSelected = this.value; $pbar.progresstracker(option,{jumpDirection:this.value});});// Tracker 2 test - defaultvar $pbar2 = $(#ProgressTracker2).progresstracker();$(#next2).on(click,function(){ $pbar2.progresstracker(next)});$(#previous2).on(click,function(){ $pbar2.progresstracker(step,$pbar2.progresstracker(step)-1)});/*Default progresstrack CSS*/ol.progresstrack { list-style-type: none; padding-left:0;}.progresstrack.container { display: flex; align-items: flex-end; padding-top: 22px;}.progresstrack .step { flex-grow:1; position:relative; text-align: center; z-index:1;}.progresstrack .step-number { position:relative; z-index:10; width: 20px; height: 20px; border-radius: 10px; background-color:white; display:inline-block; text-align: center; line-height: 20px; border:1px solid;}.progresstrack .jumpable .step-number:hover{ cursor: pointer;}.progresstrack .step-finished .step-number{ background-color: green;}.progresstrack .step-current .step-number{ background-color:lightblue;}.progresstrack .step-label-wrap { position: absolute; width:100%; top: -22px;}.progresstrack .step-label { padding: 0px 1px;}.progresstrack .step-line { width: 100%; height: 0px; overflow: auto; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: -100%; background-color: white; border:1px solid;}.progresstrack .step:last-of-type .step-line{ display:none;}/*User CSS*/#ProgressTracker1.hasProgressTracker{ border:1px solid; background-color:lightgrey;}#ProgressTracker1 .progresstrack .step-number{ -webkit-transition: .2s; -moz-transition: .2s;}#ProgressTracker1 .progresstrack .step-line{ -webkit-transition: .2s; -moz-transition: .2s; }#ProgressTracker1 .progresstrack .jumpable .step-number:hover{ -webkit-transform: scale(1.2); -moz-transform: scale(1.2);}#ProgressTracker1 .progresstrack .step-finished .step-line { background-color: green;}#ProgressTracker1 .progresstrack .step-current .step-line { background-color: lightblue;}#ProgressTracker1 .progresstrack .step-line { height:1px; background-color: white;}#ProgressTracker1 .step-label { -webkit-transition: .2s; -moz-transition: .2s; border:1px solid; padding:0px 2px; background:white;}#ProgressTracker1 .step-finished .step-label{ background-color: green;}#ProgressTracker1 .step-current .step-label { background-color: lightblue;}#ProgressTracker1 .progresstrack .jumpable .step-label:hover{ cursor: pointer;}<script src=https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js></script><script src=//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js></script><div id='ProgressTracker2'>Default Progress Tracker</div><button type='button' id='previous2'>Previous</button><button type='button' id='next2'>Next</button><hr/><div id='ProgressTracker1'>Custom Progress Tracker</div><button type='button' id='previous'>Previous</button><button type='button' id='next'>Next</button><button type='button' id='steps'>Change Steps</button><br/><label for='jumpdir'>Jump Direction</label><select id='jumpdir'> <option>both</option> <option>forward</option> <option>back</option> <option>none</option></select><p id=Events>Tracker Callbacks: </p>Focuslow couplingsimple interface allowing for lots of flexibility without too many optionscustomization: as much as possible with just css, other things with the options method.standards. I tried to use the patterns/conventions that are outlined in the widget factory docs but there are something I'm unsure about:naming conventions (of everything, but specifically the css classes: do the hyphenated class names make sense?)public methods vs _setOptions override. For example, I have a next method for convenience but no previous method since this is a less used action and still available through options. Does this make sense?support for modern browsers only.One thing I decided not to do that was suggested in my previous answer was to define the ol in the html and have the widget add the functionality. I attempted but it got too messy and I've dropped it.InterfaceMethodsprogresstracker(options): Creates a progress tracker with the specified options object.step(step): Changes the tracker's current step.next(): Changes the tracker to the next step.update(): Sets the appropriate css classes according to the current step. This should be called automatically unless the progresstracker is modified by another class.Optionsstepintdefault 1stepsstring arraydefault [,,]jumpDirectionstring (none, back, forward, or both)default backjumpablescomma delim string (list of classes that trigger jump events when clicked)default .step-number, .step-labeljumpforwardcallback(event,data)return false cancels the jumpjumpbackcallback(event,data)return false cancels the jumpcompletecallback()CodeProgress Tracker Widget(function($){ $.widget(dan.progresstracker, { options: { step: 1, // current step steps:['','',''], // default is 3 no-name steps jumpDirection: back, // values: none,back,forward,both jumpables: .step-number, .step-label, // callbacks jumpforward: null, jumpback: null, complete: null }, // Constructor _create: function() { this.options.step = this._constrain(this.options.step); this.element.addClass(hasProgressTracker) .append(this._build()); this._bind(); this.update(); }, // Unbinds and then binds a click event for each jumpable _bind: function(){ this._off(this.element,click); var onMap = {}; onMap[click +this.options.jumpables] = function(e){ this._stepClick(e); }; this._on(this.element, onMap); }, // Limit step to an integer >= 0 and <= the number of steps+1 _constrain: function(step){ step = parseInt(step) || 0; if(step>this.options.steps.length) {return this.options.steps.length+1;} else if(step<0) {return 0;} else {return step;} }, // Builds and returns a jQuery element that is the progress tracker in a neutral state. _build: function() { var $node = $(<ol class='progresstrack container'></ol>); var html = ; for(var step in this.options.steps){ html += <li class='step'> + <div class='step-number'>+(parseInt(step)+1)+</div> + <div class='step-line'></div> + <div class='step-label-wrap'> + <label class='step-label'>+this.options.steps[step]+</label> + </div> + </li>; } $node.html(html); return $node; }, // Options setter override. // Handles options that need updates or rebuilds after changing _setOptions: function( options ) { var that = this, update = false, rebuild = false, rebind = false; $.each( options, function( key, value ) { if(key === step){ that.step(value); // use the setter }else{ that._setOption( key, value ); if(key === jumpDirection){ update = true; }else if(key === steps){ rebuild = true; }else if(key === jumpables){ update = true; rebind = true; } } }); if( rebuild ){ this.element.find(.progresstrack).replaceWith(this._build()); this.step(this.options.step); this.update(); } if( rebind ){ this._bind(); } if( update ){ this.update(); } }, // Handler for user clicking on a jumpable element // Triggers relevant callbacks _stepClick: function(e){ var step = this.element.find(.step) .index($(e.target).closest('.step'))+1; var jumpable = ($(e.target).parents('.jumpable').length)?true:false; if(step===this.options.step){ return; // Nothing changed, return }else if(step>this.options.step && jumpable){ if(!this._trigger(jumpforward,e,{step:step})){ return; // Canceled } }else if(step<this.options.step && jumpable){ if(!this._trigger(jumpback,e,{step:step})){ return; // Canceled }; }else{ return; // Wrong direction } this.step(step); // Apply change }, // step() gets the current step // step(int) sets the current step. Does not trigger callbacks except complete. step: function(step){ if(typeof step === 'undefined') { return this.options.step; }else{ this.options.step = this._constrain(step); this.update(); if(this.options.step === this.options.steps.length+1){ // if complete this._trigger(complete); } return this; } }, // Increments step by one. // Convenience function since this will usually be the most common action. // Only triggers complete callback and only if it actually changed to complete (and wasn't there already) next: function(){ var nextstep = this.options.step+1; if(this._constrain(nextstep)===this.options.step){ return this; }else{ this.step(nextstep); return this; } }, // Update the <ol> and <li> classes to reflect the current step update: function(){ // Reset progress bar status $e = this.element; $e.find(.step-current).removeClass(step-current); $e.find(.step-finished).removeClass(step-finished); $e.find(.jumpable).removeClass(jumpable); // If complete if(this.options.step>this.options.steps.length){ $e.find('.step').addClass(step-finished); $e.addClass(complete); if((this.options.jumpDirection===back || this.options.jumpDirection===both)){ // if jumpback // add jumpable to all steps $e.find(.step).addClass(jumpable); } return this; } // If current == 0 (pre-first step) if(this.options.step===0){ if((this.options.jumpDirection===forward || this.options.jumpDirection===both)){ // if jumpforward // add jumpable to all steps $e.find(.step).addClass(jumpable); } return this; } // Set current step var $current = $e.find(.step:nth-child(+this.options.step+)) .addClass(step-current); var $prevAll = $current.prevAll('.step').addClass(step-finished); if((this.options.jumpDirection===back || this.options.jumpDirection===both)){ $prevAll.addClass(jumpable); } if((this.options.jumpDirection===forward || this.options.jumpDirection===both)){ $current.nextAll('.step').addClass(jumpable); } return this; } });})(jQuery);Default CSSol.progresstrack { list-style-type: none; padding-left:0;}.progresstrack.container { display: flex; align-items: flex-end; padding-top: 22px;}.progresstrack .step { flex-grow:1; position:relative; text-align: center; z-index:1;}.progresstrack .step-number { position:relative; z-index:10; width: 20px; height: 20px; border-radius: 10px; background-color:white; display:inline-block; text-align: center; line-height: 20px; border:1px solid;}.progresstrack .jumpable .step-number:hover{ cursor: pointer;}.progresstrack .step-finished .step-number{ background-color: green;}.progresstrack .step-current .step-number{ background-color:lightblue;}.progresstrack .step-label-wrap { position: absolute; width:100%; top: -22px;}.progresstrack .step-label { padding: 0px 1px;}.progresstrack .step-line { width: 100%; height: 0px; overflow: auto; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: -100%; background-color: white; border:1px solid;}.progresstrack .step:last-of-type .step-line{ display:none;}Example Use// Initialize$(#ProgressTracker).progresstracker({ step: 1, steps:[Date,Items,Preview,Details,Confirm], jumpDirection:both, jumpforward:function(e,data){ if(data.step === 3){ return false; //cancel forward jumps to step 3 } //do something }, jumpback:function(e,data){ //do something; }, complete:function(){ //do something }});//Make changes to options$(#ProgressTracker).progresstracker(option,{steps:steps[a,b,c]}); | jQuery Widget - Progress Tracker | javascript;jquery;html;css;jquery ui | ReadabilityThe writing style is seriously hurting readability at some places, but especially here:_constrain: function(step){ step = parseInt(step) || 0; if(step>this.options.steps.length) {return this.options.steps.length+1;} else if(step<0) {return 0;} else {return step;}}With the if, else if, else nicely laid out, this becomes:_constrain: function(step) { step = parseInt(step) || 0; if (step > this.options.steps.length) { return this.options.steps.length + 1; } else if (step < 0) { return 0; } else { return step; }}When laid out like this, it's easier to see new opportunities for simplification. For example:_constrain: function(step) { step = parseInt(step) || 0; if (step > this.options.steps.length) { return this.options.steps.length + 1; } return step < 0 ? 0 : step;}Parsing integersThe documentation of parseInt says to always specify a radix parameter:parseInt(step, 10);Inconsistent writing styleSometimes you write if statements like this:if(step===this.options.step){And sometimes like this:if( rebind ){ this._bind();}if( update ){ this.update();}It looks as if the code had been written by 2 different people.It would be better to pick one style and stick with it.Which one you pick is a matter of taste, my preference is as you can see in earlier examples.Ternary on booleanThis is just silly:var jumpable = ($(e.target).parents('.jumpable').length)?true:false;Instead of the ternary operator (or if-else) on boolean-y expressions,you can be more direct:var jumpable = $(e.target).parents('.jumpable').length > 0; |
_codereview.22915 | I have written a lock free MPMC FIFO in C based on a ring buffer. It uses gcc's atomic built-ins to achieve thread safety. The queue is designed to return -1 if it's full on enqueue or empty on dequeue. After some feedback, I've changed by design. I have tested this code to work, but testing multithreaded code is hardly enough to prove it's correct. struct queue{ void** buf; size_t num; uint64_t writePos; uint64_t readPos;};queue_t* createQueue(size_t num){ struct queue* new = xmalloc(sizeof(*new)); new->buf = xmalloc(sizeof(void*) * num); memset(new->buf, 0, sizeof(void*)*num); new->readPos = 0; new->writePos = 0; new->num = num; return new;}void destroyQueue(queue_t* queue){ if(queue) { xfree(queue->buf); xfree(queue); }}int enqueue(queue_t* queue, void* item){ for(int i = 0; i < kNumTries; i++) { if(__sync_bool_compare_and_swap(&queue->buf[queue->writePos % queue->num], NULL, item)) { __sync_fetch_and_add(&queue->writePos, 1); return 0; } } return -1;}void* dequeue(queue_t* queue){ for(int i = 0; i < kNumTries; i++) { void* value = queue->buf[queue->readPos % queue->num]; if(value && __sync_bool_compare_and_swap(&queue->buf[queue->readPos % queue->num], value, NULL)) { __sync_fetch_and_add(&queue->readPos, 1); return value; } } return NULL;}(link to the previous iteration) | Lock free MPMC Ring buffer implementation in C | c;multithreading;thread safety;circular list | null |
_unix.107861 | Is it possible, within a shell script, to write to the screen while STDOUT and STDERR is being redirected?I have a shell script that I want to capture STDOUT and STDERR. The script will run for perhaps an hour or more, so I want to occasionally write some status messages to the screen that will be displayed and not redirected (not captured).For a minimal example, I have a shell script, let's say ./myscript.sh:#!/bin/sh -uecho Message A: This writes to STDOUT or wherever '1>' redirects to.echo Message B: This writes to STDOUT or wherever '1>' redirects to.>&1echo Message C: This writes to STDERR or wherever '2>' redirects to.>/dev/stderrecho Message D: This writes to STDERR or wherever '2>' redirects to.>&2echo Message E: Write this to 'screen' regardless of (overriding) redirection. #>??? Then, for example, I'd like to see this output when I run the script like this: [~]# ./myscript.sh > fileout 2> filerrMessage E: Write this to 'screen' regardless of (overriding) redirection.[~]# ./myscript.sh > /dev/null 2>&1Message E: Write this to 'screen' regardless of (overriding) redirection.[~]# If this cannot be done directly, is it possible to temporarily discontinue redirection, then print something to the screen, then restore redirection as it was?Some info about the computer: [~]# uname -srvmpioLinux 3.2.45 #4 SMP Wed May 15 19:43:53 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux[~]# ls -l /bin/sh /dev/stdout /dev/stderrlrwxrwxrwx 1 root root 4 Jul 18 23:18 /bin/sh -> bashlrwxrwxrwx 1 root root 15 Jun 29 2013 /dev/stderr -> /proc/self/fd/2lrwxrwxrwx 1 root root 15 Jun 29 2013 /dev/stdout -> /proc/self/fd/1 | How to output to screen overriding redirection | bash;shell script;io redirection | null |
_unix.157459 | I've recently set up a new system with MSI Z97 gaming 5 motherboard however the first issue I've encountered was that the sound was crackling.I've fixed that by updating the kernel to 3.16.3Now the issue I have is that the sound is really silent on every output(audio jack, usb). Here are the things I've tried.Checking Alsamixer: Checking KDE audio/video settings and pulse.Before trying to fix modprobe.h/alsa-base.conf by adding: options snd-hda-intel vid=8086 pid=8ca0 snoop=0to fix the crackling. (full alsa-base.conf here: http://paste.kde.org/p2mzluohd)Am I missing something here? I have everything on 100% but it sounds like 20% on windows on every output (I've tried logitech speakers via generic audio jack, sony headphones via generic audio jack and logitech g930 headset via usb). | Low sound volume issues on Z97 motherboard and linux mint KDE | linux mint;kde;audio;alsa;pulseaudio | So today I woke up turned on my system and everything works fine. Not sure what happened but I did reinstalls on pulseaudio before that and changed the snoop=0 to snoop=1 in the etc/modprobe.h/alsa-base.conf to the previous command I had there. So one of those things fixed it.If someone comes up with the same issue be sure to install the latest stable kernel before you do any of the stuff I did.EDIT: Also seems like sometimes the os thinks headphones are running instead of analog output thus resulting in lower sound volumes, you might want to look into that as well. |
_unix.357798 | I was installing some packages and during the install of one, the system hung and the package was not installed. But, the package was added to the list of installed packages. So, I restart the system and I try the following:When I try to remove the package, it doesn't work because it can't find a config file.When I try to install the package, it says the package is already installed, and therefore won't install itWhen I try to update, it tries to remove the package, and encounters the error above.So, my question is asking if there's a way to manually remove a package from the list of installed packages, or is there another way to solve this problem?When I run: sudo apt-get upgradeError is:Reading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following packages will be REMOVED: libglade2.0-cil libglib2.0-cil libgtk2.0-cil0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.18 not fully installed or removed.After this operation, 2,819 kB disk space will be freed.Do you want to continue? [Y/n] Y(Reading database ... 119043 files and directories currently installed.)Removing libglade2.0-cil (2.12.26-0xamarin1) ...E: File does not exist: /usr/share/cli-common/packages.d/policy.2.8.glade-sharp.installcligacdpkg: error processing package libglade2.0-cil (--remove): subprocess installed post-removal script returned error exit status 1Removing libgtk2.0-cil (2.12.26-0xamarin1) ...E: File does not exist: /usr/share/cli-common/packages.d/policy.2.6.gtk-dotnet.installcligacdpkg: error processing package libgtk2.0-cil (--remove): subprocess installed post-removal script returned error exit status 1Removing libglib2.0-cil (2.12.26-0xamarin1) ...E: File does not exist: /usr/share/cli-common/packages.d/policy.2.6.glib-sharp.installcligacdpkg: error processing package libglib2.0-cil (--remove): subprocess installed post-removal script returned error exit status 1Errors were encountered while processing: libglade2.0-cil libgtk2.0-cil libglib2.0-cilE: Sub-process /usr/bin/dpkg returned an error code (1) | Unable to remove CLI library packages | debian;apt;package management;raspbian;mono | There are a couple of approaches to try.The first is to fix /usr/share/cli-common/policy-remove so it doesnt fail if the policy is absent: edit its last line so that it runs rm -f instead of rm. That should allow the packages to be removed correctly.If that fails, and since youre trying to remove all the Mono packages, it should be safe enough to remove the failing postrm scripts:sudo rm /var/lib/dpkg/info/lib{glade,glib,gtk}2.0-cil.postrmThe only operation the postrm scripts do is unregister the policies, which you dont care about since youre removing everything anyway.Youre not the only person to have suffered from this issue: it was reported in 2012 as Debian bug 692962. |
_cs.11607 | Given an undirected graph $G=(V,E)$ could we build a tree $T$ that approximates the distances from given vertex $r$ and the total weight, i.e. $\forall x \in V, d_G(r,x) \le d_T(r,x) \le 3 \cdot d_G(r,x)$ and $w(T) \le 3\cdot w(\text{MST}(G))$, where $\text{MST}$ is the minimum spanning tree and $w(\cdot)$ is the weight function i.e. $w:\Bbb E \to \Bbb R^+$. $d_G(v,u)$ denotes the shortest path distance between $v$ and $u$ in $G$, and $d_T(v,u)$ is the shortest path distance between $v$ and $u$ in $T$.Could any one help me to understand how to build this tree and if there is any material that would help? | Finding a tree that approximates the distances and total weights | algorithms;approximation | Your problem is solved in the following paper by Khuller, Raghavachari, and Young. They show that you can construct a tree in which distances from the root are stretched by at most $\alpha$ and the total weight of the tree is at most $1 + 2/(\alpha - 1)$ times the weight of the MST. So, with $\alpha=3$, you can get $2$ times the weight of the MST. The algorithm does a depth-first traversal of the MST, and adds paths from the shortest path tree when necessary, roughly speaking maintaining a shortest path structure in the current graph, which consists of the MST edges and the edges added from the shortest path three. Check the paper for details.As I mentioned in the comment, there are graphs in which the weight of the shortest path tree rooted at some vertex is greater than the MST weight by $\Omega(n)$. One example is a path of unit weight edges, and edges from the first vertex in the path to the $i$-th vertex of weight just slightly less than $i-1$. |
_softwareengineering.200259 | As I have been taught - one controller = one use case.But I have:OutsiderControllerSupplierController (which extends OutsiderController)SubContractorController (which also extentds OutsiderController)And I want to do the SSD for SupplierController and SubContractorController. What do I do? Do I write in both SSDs the methods from OutsiderController? | Creating a System Sequence Diagram from an [extended] use case | java;design patterns;mvc | null |
_webapps.18485 | I've been searching but what I've found was always about uploading a video to Tumblr or about adding audio only on Tumblr. None of the results has a solution for my problem. I just want to display a video that's already uploaded on YouTube, not uploading it to Tumblr. How do I embed YouTube video on a Tumblr text post? | Embed YouTube video on Tumblr | youtube;tumblr;embed | I think you misinterpret what the user interface is saying.There are two options in the video interface.Embed a videoUpload a videoYou want option 1. If you want to add some text you can use the caption.Another way to do this will be a regular Add a Text PostFrom there you can use html and YouTube embed option (using the share link at the bottom of a YouTube video) to place it where ever you wish.Example<p>Go for text</p><iframe width=560 height=345 src=http://www.youtube.com/embed/IwX3FdwMCUs frameborder=0></iframe><p>And here goes the rest.</p> |
_unix.305833 | I am following this tutorial on using a mobile phone's accelerometer.In order for it to work properly you have to run three commands on startup every time...rfkill unblock bluetoothkillall bluetoothdhciconfig hci0 upIs there a way to do this with a script on startup instead of manually doing it every time? | Running Commands on Startup | startup;yocto | null |
_codereview.45455 | Below is some code which verifies a credit card number using the checksum as well as check if number of digits are appropriate as well if digits start with right numbers. I am not sure if converting the double into a string was the best bet. I wasn't going to at first but had trouble figuring out the modulo math to get every second digit without knowing the length of the double (# of digits).Also, in my use of strtok(), what should I be doing with the balance of the string after the delimiter? Is that hanging out in memory somewhere?#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ double cardnumber; printf(Give me a number: \n); scanf(%lf, &cardnumber); if(cardnumber < 1000000000000 || cardnumber > 10000000000000000) { printf(INVALID\n); return 0; } if(cardnumber < 100000000000000 && cardnumber > 9999999999999) { printf(INVALID\n); return 0; } char creditcard[17]; sprintf(creditcard, %f, cardnumber); char* ptr_cc; ptr_cc = strtok(creditcard,.); int card_size = strlen(ptr_cc); int sum = 0; for(int i = 1; i < card_size; i+=2) { int x = creditcard[card_size-1-i] - '0'; int prod = 2 * x; if(prod>=10) { prod = prod%10 + prod/prod%10; } sum += prod; } for(int i = 0; i < card_size; i+=2) { int x = creditcard[card_size-1-i] - '0'; sum += x; } if(sum%10 != 0) { printf(INVALID\n); return 0; } else if(creditcard[0] == '4') { printf(VISA\n); return 0; } else if(creditcard[0] == '3' && (creditcard[1] == '7' || creditcard[1] =='4')) { printf(AMEX\n); return 0; } else if(creditcard[0] == '5' && (creditcard[1] >='1' && creditcard[1] <='5')) { printf(MASTERCARD\n); return 0; } else { printf(INVALID\n); return 0; } } | Credit card verification: string conversion most optimal? | c;validation;finance | As @Keith says, credit card numbers should be treated as strings, not numbers, and definitely not floating-point numbers. If you want to ensure that the input contains only digits (and maybe spaces), use strspn(). Squeeze out any spaces, then validate the length using strlen().The Luhn checksum check should be in its own function. The loop indexes would be more natural counting down, I think, since you are taking every other digit starting from the right.int is_valid_luhn(const char *creditcard){ int card_size = strlen(creditcard); int sum = 0; for(int i = card_size - 2; i >= 0; i -= 2) { int digit = creditcard[i] - '0'; int prod = 2 * digit; sum += prod / 10 + prod % 10; /* No special case needed */ } for(int i = card_size - 1; i >= 0; i -= 2) { sum += creditcard[i] - '0'; } return sum % 10 == 0;} |
_softwareengineering.135450 | How is it legally possible to take a project initially released as open source back to closed source? Especially one licensed with the GPL any version. | Taking an open source project to closed source | licensing;legal;closed source | There are two things here:revoking the open source license which has been given. It will probably depend on the text of the license. If the license has no provision, I'm not sure it is possible if the licensee hasn't infringed it. And some license like GPL version 3, are explicit in that:All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met.re-licensing under other terms. It is possible as long as you get the agreement of all copyright holders. If you had the foresight to get it before accepting the contributions (some GNU projects like GCC ask you to assign the copyright to the FSF for instance) it is easy. If you didn't, it will be difficult (some project do that voluntarily so that a change of license is in practice impossible, getting the agreement of everybody or tracking and removing the contributions of those who didn't being impractical).(Mandatory mention: I'm not a lawyer, see yours, and some aspect may be localised and depend on your jurisdiction). |
_webapps.91669 | I forgot my Yahoo! password, I tried many times to recover it but I cant, and I called Yahoo! customer service, they said that I have to pay for it. Please help me to recover it. | How to reset forgot Yahoo! password? | yahoo;yahoo mail | null |
_unix.303169 | Perhaps not the most cardinal question on this site, but: The Debian project has been using release names which are characters from the Pixar animation film 'Toy Story'. But - they're about to run out of characters soon. What will they use afterwards? I'm curious. | What will Debian releases be called after they run out of Toy Story characters? | debian;version | Since 1995 (the release of Toy Story), Debian has been using 15 names. The first Toy Story had about 18 named characters (people and toys, both of which have been used for Debian releases), Toy Story 2 added another 8 names, and Toy Story 3 another 17 (I might have missed, double counted one or two). Toy Story 4 is in the making.The stories have been adding Debian names at a rate of 2.04 per year and Debian has been using them at a rate of 0.71 per year. Clearly that means that Debian will never run out of names to use, assuming that Debian will persist to exist and that Toy Story sequels will be made ad infinitum. Even if Toy Story 4 were the last and would not have any additional names we have enough names another 40 or so years of release of Debian. |
_reverseengineering.14751 | I am writing a reversing challenge where I need to seed a bug. It's important to have a particular ordering of local variable on stack in a method. However, gcc seems to shuffle those around. How can I control variable ordering in such cases? | How can I control local variable ordering on stack in gcc? | stack;gcc;local variables | null |
_datascience.554 | I am a CS master student in data mining. My supervisor once told me that before I run any classifier or do anything with a dataset I must fully understand the data and make sure that the data is clean and correct.My questions:What are the best practices to understand a dataset (high dimensional with numerical and nominal attributes)?Practices to make sure the dataset is clean?Practices to make sure the dataset doesn't have wrong values or so? | Datasets understanding best practices | statistics;dataset | null |
_codereview.3244 | I have the following code, but it's too slow. How can I make it faster?<?phpclass Ngram {const SAMPLE_DIRECTORY = samples/;const GENERATED_DIRECTORY = languages/;const SOURCE_EXTENSION = .txt;const GENERATED_EXTENSION = .lng;const N_GRAM_MIN_LENGTH = 1;const N_GRAM_MAX_LENGTH = 6;public function __construct() { mb_internal_encoding( 'UTF-8' ); $this->generateNGram();}private function getFilePath() { $files = array(); $excludes = array('.', '..'); $path = rtrim(self::SAMPLE_DIRECTORY, DIRECTORY_SEPARATOR . '/'); $files = scandir($path); $files = array_diff($files, $excludes); foreach ($files as $file) { if (is_dir($path . DIRECTORY_SEPARATOR . $file)) fetchdir($path . DIRECTORY_SEPARATOR . $file, $callback); else if (!preg_match('/^.*\\' . self::SOURCE_EXTENSION . '$/', $file)) continue; else $filesPath[] = $path . DIRECTORY_SEPARATOR . $file; } unset($file); return $filesPath;}protected function removeUniCharCategories($string){ //Replace punctuation(' # % & ! . : , ? ) become space //Example : 'You&me', become 'You Me'. $string = preg_replace( /\p{Po}/u, , $string ); //-------------------------------------------------- $string = preg_replace( /[^\p{Ll}|\p{Lm}|\p{Lo}|\p{Lt}|\p{Lu}|\p{Zs}]/u, , $string ); $string = trim($string); $string = mb_strtolower($string,'UTF-8'); return $string;}private function generateNGram() { $files = $this->getFilePath(); foreach($files as $file) { $file_content = file_get_contents($file, FILE_TEXT); $file_content = $this->removeUniCharCategories($file_content); $words = explode( , $file_content); $tokens = array(); foreach ($words as $word) { $word = _ . $word . _; $length = mb_strlen($word, 'UTF-8'); for ($i = self::N_GRAM_MIN_LENGTH, $min = min(self::N_GRAM_MAX_LENGTH, $length); $i <= $min; $i++) { for ($j = 0, $li = $length - $i; $j <= $li; $j++) { $token = mb_substr($word, $j, $i, 'UTF-8'); if (trim($token, _)) { $tokens[] = $token; } } } } unset($word); $tokens = array_count_values($tokens); arsort($tokens); $ngrams = array_slice(array_keys($tokens), 0); file_put_contents(self::GENERATED_DIRECTORY . str_replace(self::SOURCE_EXTENSION, self::GENERATED_EXTENSION, basename($file)), implode(PHP_EOL, $ngrams)); } unset($file);}}$ii = new Ngram();?> | N-gram generation | performance;regex;php5;natural language processing;unicode | null |
_webapps.98867 | I called my dentist recently to schedule an appointment. Didn't have to do any web searches since I already had the number. Once there, I did not make any payments with my credit card, didn't even have to show my insurance card since they already had that info. Not sure if I called from my iPhone or landline but I don't have LinkedIn app installed on my iPhone so it's irrelevant.Today, I logged into LinkedIn and my dentist is first on the list of suggestions to connect to. Now, if that is not creepy, I don't know what is.How in the world would they suggest my dentist since there were no emails exchanged with my dentist, no web searches of my dentist, no credit card transactions at the dentist office or anything else traceable?Do they get data from the NSA or something? It's so creepy I'm considering closing my LinkedIn account... | How LinkedIn knows my dentist? | linkedin;social networks | null |
_webmaster.95018 | I've been having some indexing issues that I've had a development team working on trying to fix for a week but no progress has been made. The site has an overwhelming amount of 404 errors as indicated by Google Search Console. This site is about 800 pages but there are almost 1300 404 errors. This site is built on WordPress. All of said errors are existent on the Desktop portion of GSC but not on the Smartphone portion. The 404's are all from pages that I have no recollection of ever existing and all follow the same format /URLPath/index.html. One of these is errors is explicitly /2014/12/index.html. The page /2014/12 exists as do all of the other pages mentioned in the 404 list as long as you drop the /index.html that appends to the end of the URL. Investigating I can see that the URL was crawled earlier in May and that this page is being linked from 5 other URLS (using the page mentioned above). Of these 5 URLS, none of them link to /2014/12/index.html or /2014/12/ and no changes have been made to this page since it was published. A similar theme occurs for all of the other 404 errors and there linked from pages. Is it possible that these crawl errors are contributing to my indexing problem?(A Site: search shows Google has over 1400 pages indexed but there are only about 800)Why would these pages, appending /index.html, be created without me creating them?NOTE:All of these errors appeared over a 2 day period at the start of May. This is happening for every tag & category as well /tag/index.html, /category/index.html, /category/helloWorld/index.html, etc. This website used to be www and now uses the non-www version of the site.A sitemap was submitted at the end of May with only the 800-ish pages that exist and only 98 are recorded as index by GSC. EDIT:I looked into the server logs to see who accessed the URLs that append /index.html but the entire server log is empty. There's no trace of anyone visiting a page that 404s. | 404's from nonexistent URL | indexing;404 | null |
_softwareengineering.255129 | I'm reading a paper describing a NLP work, and I hardly catch the concept of a term, latent parsing.Original paper: http://web.stanford.edu/~angeli/papers/2013-acl-temporal.pdfThe figure in the page 6 seems to be helpful (I can't upload the figure because of my reputation) | What is latent parsing in NLP? | parsing;natural language processing | Let me try to explain what I understand after quickly looking at the paper. Latent is used to describe techniques that uncover the hidden meaning of a piece of text (see e.g. http://en.wikipedia.org/wiki/Latent_semantic_indexing). In this paper the authors are using machine learning to do latent semantic parsing of temporal expressions.Essentially one wants to compute a unique represesentation of a temporal expression, for example March 14 could mean March 14th but also March 2PM. By using regular expressions one can't tell what March 14 means but by using estimation one knows that March 14th would be the most likely interpretation of that expression and so get the (most likely) correct parsing. |
_unix.328101 | The useful option wget --convert-links or wget -k makes links in downloaded HTML or CSS point to local files. It makes two passes:Pass 1: download files.Pass 2: convert links.I want to do pass 1 now and pass 2 later. I want to invoke the two passes separately. I want wget to stop after pass 1, let me do some stuff, and only then continue with pass 2. I just want to convert links as a separate command, whether the command is wget or something else. How, please?And if wget won't do this, then is there a Perl module, Python module or the like that will?(For reference: this answer partly answers my question. This question is similar, but its answer seems to fail. At any rate, neither gives something that actually works as far as I can tell.) | Using wget or another command, how to download now but convert links later? | wget;html | null |
_unix.104996 | I can't connect to a WiFi network. I tried various methods such as wpa_supplicant and wicd. At the moment I'm trying netctl.When I enter the command: systemctl --type=service I see the following errors:netctl start wireless-homeJob for netctl@wireless\x2dhome.service failed. See 'systemctl statusnetctl@wireless\x2dhome.service' and 'journalctl -xn' for details.This is the profile file for wireless-home:Description='A simple WPA encrypted wireless connection'Interface=wlan0Connection=wirelessSecurity=wpaIP=dhcpESSID='Pruthenia 3.OG'Key='XXXXXXXXXX'systemctl status netctl@wireless\[email protected] - Networking for netctl profile wirelessx2dhome Loaded: loaded (/usr/lib/systemd/system/[email protected]; static) Active: inactive (dead) Docs: man:netctl.profile(5)journalctl -xn output --> Dec 12 08:01:01 webcampi CROND[2765]: pam_unix(crond:session): session closed for user rootDec 12 09:01:01 webcampi crond[3490]: pam_unix(crond:session): session opened for user root by (uid=0)Dec 12 09:01:01 webcampi CROND[3491]: (root) CMD (run-parts /etc/cron.hourly)Dec 12 09:01:01 webcampi CROND[3490]: pam_unix(crond:session): session closed for user rootDec 12 10:01:01 webcampi crond[4216]: pam_unix(crond:session): session opened for user root by (uid=0)Dec 12 10:01:01 webcampi CROND[4217]: (root) CMD (run-parts /etc/cron.hourly)Dec 12 10:01:01 webcampi CROND[4216]: pam_unix(crond:session): session closed for user rootDec 12 11:01:01 webcampi crond[4941]: pam_unix(crond:session): session opened for user root by (uid=0)Dec 12 11:01:01 webcampi CROND[4942]: (root) CMD (run-parts /etc/cron.hourly)Dec 12 11:01:01 webcampi CROND[4941]: pam_unix(crond:session): session closed for user rootHow can I fix this? | Can't connect to WLAN with netctl | arch linux;wifi;raspberry pi;netctl | null |
_softwareengineering.291150 | I am trying to write an utility which traverses through a list of files and searches for a string in each file. On finding the string in a file, I will add it to a list and display the list. Which design pattern should I use for the same? | Design Patterns: What design pattern should I use for the following? | java;design patterns | null |
_softwareengineering.143509 | When I start learning a new language, I have a couple of simple implementations that I like to complete to familiarise myself with the language. Currently, I write:Fibonacci and/or factorial to get the hang of writing and calling methods, and basic recursionDjikstras shortest path (with a node type) to get to grips with making classes (or whatever the language equivalent is) with methods and properties, and also using them in slightly more complex code.I was wondering: does anybody else have any techniques or tools they like to use when getting off the ground in a new language? I'm always looking for new things to add to my start-up routine. | Techniques for getting off the ground in any language | learning;self improvement;language agnostic | I have constructed a small hello, world task I have used to make sure I learn some important parts of languages. The program needs to read and parse a CSV file (I make sure to use regex if available), and then - based on command line arguments - it needs to output the data in either json, yaml or XML format to a new file. For constructing the output I usually try not to use to many loops, but instead find the language equivalents of map and reduce.I've found that modelling this problem is complex enough to be quite valuable. For instance I try not to use a switch/case, but somehow apply the open/close principle and thereby making it extendable (object-based polymorphism, dynamic dispatch table etc.) |
_webapps.29924 | For each user on Wikipedia, I'd like to find which pages were created by those users. How can I find all of the pages that were created by a specific Wikipedia or Mediawiki user? | How can I see all pages that were created by a specific Wikipedia user? | mediawiki;wikipedia | As far as I know, there is no simple way to do this. But I can see some possibilities (starting with those that practically won't work):Use the API. The API doesn't have any direct way to do this, but you could try to work around that:Go though all pages and for each of them, find out the creator. Because of the limitations of the API when working with revisions, this would mean 1 request per page, which makes this completely unfeasible for a wiki as big as Wikipedia.The first query would look something like: http://en.wikipedia.org/w/api.php?action=query&generator=allpages&gaplimit=1&prop=revisions&rvdir=newer&rvprop=user&rvlimit=1For each user, go through his contributions and find out which of his edits created a new page. Because the API won't let you filter the contributions to show only page creations, you would have to filter that by yourself. This would be probably much faster than the option above, but still way too slow for Wikipedia:The query for User:Svick would look like: http://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=Svick&ucprop=title|flags&uclimit=maxDownload the stub-meta-history dump (32 GB compressed for the English Wikipedia), which contains information about revisions of all pages in XML. You could go through that to find out the creator of each page (assuming no revisions were deleted).On the Wikimedia Toolserver, I run a script (originally not written by me) that periodically updates the table u_svick_enwiki_page_creators_p, which contains information about users that created each page. This table is accessible to other users of the Toolserver, but not to the public.To sum up: there is no good solution and you have pretty much two choices: download and parse 32 GB of data, or get a Toolserver account and then use the table I mentioned. |
_softwareengineering.145378 | So, I've been working for a bank for the past 4 years. My main responsibility has been online banking. Over the past year, we've been implementing the scrum methodology. We've also changed to domain driven design.Now, my problem is regarding what management is planning on doing. They want to split the online banking team between the domain teams, so one developer from the online banking team will go into each domain team and work on online banking projects that are part of the domains. For example, if software development gets a project to create a new loan overview in the online bank, the loan team will handle it all the way from from database to UI. My problem with this is that there is no focus on the online bank as a product anymore. There is no way to veto any new feature. The product owners in the domains can just dump any obscure new feature into the online bank that they want to. There is also no work happening to revamp core features that our users use all the time. Every project is to make something new and once it's release, developers have to start working on a new project immediately. There is no teamwork, each web developer has to work on a separate UI for a separate domain. No hardening.Our suggestion to management is that the online banking team be it's own scrum team focusing on the online bank as a product. That team would have it's own scrum master and the online bank would have a product owner. That product owner would coordinate with the product owners of the domains and prioritize projects that have to happen in the online banks. If a project from one domain has higher priority than a project from another domain, he would explain to the domain PO that we have to work on the higher priority one first.Management hasn't listened to us.My question is, what is the right way to do this? | Scrum, DDD, and front-end development in an enterprise environment | web development;scrum;domain driven design | The approach you describe is what is commonly termed a Scrum of Scrums...except there doesn't appear to be collaboration between the teams in terms of integration. Without that, you do risk having a hodgepodge of features without any consistency between them. The transition might be noticeable and jarring to the users as they go from say managing their mortgage to checking their savings balance. Basically, you'll end up with a series of Silos with few of the benefits of either approach (Scrum or DDD). That being said, it's tough to judge from a few paragraphs what counterbalances have been put in place to avoid this scenario. For example, if the Product Owners do regularly meet and collaborate on features and approach then hopefully, they will address the system as a unified whole and the separation of teams is really just for simplification from a management perspective.I'd say, give it a chance you might find that they know more than they're letting on at first ;) |
_unix.81149 | I did a pvresize (decrease) on /dev/sda2 so that I can have about 48 GBytes free... and I wanted to create a partition on that free space, but the /dev/sda3 device didn't created.. why? Do I need a reboot for it? (didn't rebooted after the reducing of the PV...)[root@SERVER ~]# parted -s /dev/sda print freeModel: ATA Hitachi HTS72503 (scsi)Disk /dev/sda: 320GBSector size (logical/physical): 512B/4096BPartition Table: msdosNumber Start End Size Type File system Flags 32,3kB 1049kB 1016kB Free Space 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 272GB 271GB primary lvm 272GB 320GB 48,3GB Free Space[root@SERVER ~]#[root@SERVER ~]# [root@SERVER ~]# parted /dev/sda printModel: ATA Hitachi HTS72503 (scsi)Disk /dev/sda: 320GBSector size (logical/physical): 512B/4096BPartition Table: msdosNumber Start End Size Type File system Flags 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 272GB 271GB primary lvm[root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# parted /dev/sda mkpart primary 272GB 320GBWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Az eszkz vagy erforrs foglalt). As a result, it may not reflect all ofyour changes until after reboot.[root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# parted /dev/sda printModel: ATA Hitachi HTS72503 (scsi)Disk /dev/sda: 320GBSector size (logical/physical): 512B/4096BPartition Table: msdosNumber Start End Size Type File system Flags 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 272GB 271GB primary lvm 3 272GB 320GB 48,3GB primary[root@SERVER ~]# [root@SERVER ~]# parted -s /dev/sda print freeModel: ATA Hitachi HTS72503 (scsi)Disk /dev/sda: 320GBSector size (logical/physical): 512B/4096BPartition Table: msdosNumber Start End Size Type File system Flags 32,3kB 1049kB 1016kB Free Space 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 272GB 271GB primary lvm 3 272GB 320GB 48,3GB primary 320GB 320GB 352kB Free Space[root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# env LC_MESSAGES=EN ls -la /dev/sda*brw-rw----. 1 root disk 8, 0 Jun 29 18:53 /dev/sdabrw-rw----. 1 root disk 8, 1 Jun 28 12:56 /dev/sda1brw-rw----. 1 root disk 8, 2 Jun 28 12:56 /dev/sda2[root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# partprobeWarning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Az eszkz vagy erforrs foglalt). As a result, it may not reflect all of your changes until after reboot.[root@SERVER ~]#[root@SERVER ~]#[root@SERVER ~]# env LC_MESSAGES=EN ls -la /dev/sda*brw-rw----. 1 root disk 8, 0 Jun 29 18:55 /dev/sdabrw-rw----. 1 root disk 8, 1 Jun 28 12:56 /dev/sda1brw-rw----. 1 root disk 8, 2 Jun 28 12:56 /dev/sda2[root@SERVER ~]# [root@SERVER ~]# env LC_MESSAGES=EN fdisk -lDisk /dev/sda: 320.1 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk identifier: 0x0007e24d Device Boot Start End Blocks Id System/dev/sda1 * 1 66 524288 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 66 33039 264859648 8e Linux LVM/dev/sda3 33039 38914 47185920 83 Linux[root@SERVER ~]# head -1 /etc/issueScientific Linux release 6.4 (Carbon)[root@SERVER ~]# UPDATE: [root@SERVER ~]# kpartx -av /dev/sdadevice-mapper: reload ioctl on sda1 failed: Invalid argumentcreate/reload failed on sda1add map sda1 (0:0): 0 1048576 linear /dev/sda 2048device-mapper: reload ioctl on sda2 failed: Invalid argumentcreate/reload failed on sda2add map sda2 (0:0): 0 529719296 linear /dev/sda 1050624device-mapper: reload ioctl on sda3 failed: Invalid argumentcreate/reload failed on sda3add map sda3 (0:0): 0 94371840 linear /dev/sda 530769920[root@SERVER ~]# [root@SERVER ~]# env LC_MESSAGES=EN ls -la /dev/sda*brw-rw----. 1 root disk 8, 0 Jun 29 22:05 /dev/sdabrw-rw----. 1 root disk 8, 1 Jun 28 12:56 /dev/sda1brw-rw----. 1 root disk 8, 2 Jun 28 12:56 /dev/sda2[root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# sh rescan-scsi-bus.sh WARN: /usr/bin/sg_inq not present -- please install sg3_utils or rescan-scsi-bus.sh might not fully work.Host adapter 0 (ata_piix) found.Host adapter 1 (ata_piix) found.Host adapter 2 (ahci) found.Host adapter 3 (ahci) found.Host adapter 4 (ahci) found.Scanning SCSI subsystem for new devicesScanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 0 0 0 0 ... OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: MATSHITA Model: DVD/CDRW UJDA775 Rev: CB03 Type: CD-ROM ANSI SCSI revision: 05Scanning host 1 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNsScanning host 2 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 2 0 0 0 ... OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: Hitachi HTS72503 Rev: GHBO Type: Direct-Access ANSI SCSI revision: 05Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNsScanning host 4 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs0 new device(s) found. 0 device(s) removed. [root@SERVER ~]# [root@SERVER ~]# [root@SERVER ~]# env LC_MESSAGES=EN ls -la /dev/sda*brw-rw----. 1 root disk 8, 0 Jun 29 22:05 /dev/sdabrw-rw----. 1 root disk 8, 1 Jun 28 12:56 /dev/sda1brw-rw----. 1 root disk 8, 2 Jun 28 12:56 /dev/sda2[root@SERVER ~]# | Why doesn't /dev/sda3 created? | partition;scientific linux | You are running an old version of parted which still uses the BLKRRPART ioctl to have the kernel reload the partition table, instead of the newer BLKPG ioctl. BLKRRPART only works on a disk that does not have any partitions in use, hence, the error about informing the kernel of the changes, and suggesting you reboot.Update to a recent version of parted and you won't get this error, or just reboot for the changes to take affect, as the message said. Depending on how old the util-linux package is on your system, you may be able to use partx -a or for more recent releases, partx -u to add the new partition without rebooting. |
_unix.314715 | For historical reasons, deploying one of our tools relies on two different versions of Java at various stages in the process. The way this is handled is by repeatedly editing the JAVA_HOME variable in .bash_profile.For example, the deployment instructions has a step in the middle like this:Edit .bash_profile to uncomment the following line: JAVA_HOME=/path//to/java/jdk1.6.0_07/source .bash_profile~~First deployment steps~~Edit .bash_profile to comment out the previous line and uncomment the following line:JAVA_HOME=/path//to/java/jdk1.7.0_47/source .bash_profile~~More deployment steps~~This is quite obviously a braindead way of doing this.What's the quickest/shortest/most correct way of changing an environment variable on the fly? | Quickly changing values of environment variables in .bash_profile | bash;shell | null |
_vi.3018 | When I have heredoc and I format it with gq I want it to be aligned in a way so each line starts at the same column like this: Long text goes here ... 80 chars | <- whitespace preserved ... 80 chars | <- still whitespace ... 80 chars |Here is what I get instead: Long text goes here ... 80 chars |<- whitespace preserved ... 80 chars |<- still whitespace ... 80 chars |Is there a way to reflow the text while preserving the left whitespace? | `gq` with left whitespace intact | formatting | :set autoindent will ensure that new lines have the same indentation as the previous line. This will also happen when you hit enter in insert mode (or any other time you add a new line, like o/O).Note that this is a local setting, so it would have to be set in each buffer you want this to happen in. To get around this, you can use autocmds or filetype files so that the setting is applied whenever you open a new buffer with a certain filetype. |
_webmaster.23462 | I need some urgent advice please with regard to Google analytics and multiple domains, and how best to handle them.Got a very sensitive customer who has a number of domains:EGsomethingvauxhall.co.uk, somthing-vauxhall.co.uk, something-group.co.uk, somethinggroup.co.uk, somethinggroup.com etcI was under the impression it was always best to funnel all domains down to a single master domain. For example all the domains hitting this site are forwarded to www.somethinggroup.com.Now I'd heard it was best to do this using a 301 Redirect. if memory serves. For a number of reasons I was unable to do this due to the setup on our server, so instead had to code forwarding manually in the codebehind (asp.NET). Like this: if(domain != www.somethinggroup.com) { string forwardURL = http://www.somethinggroup.com/; if(path != ) { forwardURL = forwardURL + path; } if(queryString != ) { forwardURL = forwardURL + ? + queryString; } Response.Redirect(forwardURL); }This now looks like this was a really bad idea because although the traffic levels look fine across the site, it's screwed up things like referring sites etc.My question is this really:a) Was this a bad move?b) Would a 301 redirect me better from an analytics point of view? Or is it best just to let people hit the site using whatever domain name? | Google analytics and multiple domains | google;domains;google analytics;multiple domains;top level domains | There are a variety of usability and historical SEO reasons to use permanent redirects over temporary redirects, however, the need to do so for SEO purposes has been mitigated by the advent of canonical link specifications (and you could use the setDomainName function to force somethinggroup.com for analytics purposes) - still, that's no reason to avoid using a permanent redirect if that's what you intend to do.The Response.Redirect() method issues a 302 Object Moved response - this is not the same as a 301 Moved Permanently response.You can change your ASP.NET code to send the proper redirect headers:if(domain != www.somethinggroup.com){ string forwardURL = http://www.somethinggroup.com/; if(path != ) { forwardURL = forwardURL + path; } if(queryString != ) { forwardURL = forwardURL + ? + queryString; } Response.Status = 301 Moved Permanently; Response.AddHeader(Location, forwardURL);} |
_unix.34945 | I have a default, unchanged installation of the Mumble server on Debian Squeeze (package mumble-server). On a previous setup, starting the server (called murmurd) on boot using the default init scripts worked fine. On a new setup, that seems to me to be identical in every way, murmurd doesn't seem to bind to a network address on boot. No clients can thus connect until I restart the process after booting.The logs are quite telling. On boot:<W>2012-03-25 00:15:01.543 Murmur 1.2.2 (1.2.2-6+squeeze1) running onX11: Debian GNU/Linux 6.0.4 (squeeze): Booting servers <W>2012-03-2500:15:01.617 1 => Announcing server via bonjour <W>2012-03-2500:15:01.650 1 => Not registering server as publicand no clients can connect. Using service mumble-server restart after boot, however, gives:<W>2012-03-25 00:22:27.529 Murmur 1.2.2 (1.2.2-6+squeeze1) running onX11: Debian GNU/Linux 6.0.4 (squeeze): Booting servers <W>2012-03-2500:22:27.549 1 => Server listening on [::]:64738 <W>2012-03-2500:22:27.559 1 => Announcing server via bonjour <W>2012-03-2500:22:27.570 1 => Not registering server as publicNotice the third line.It thus seems to me that the init script tries to start the daemon before the network is up and running. The /etc/rc2.d/S19mumble-server script that comes with the package says, though:# Required-Start: $network $local_fs $remote_fs dbusThe exact same setup works fine on a different machine (also running Debian Squeeze), so I'm beginning to suspect it has something to do with timing on boot, or some other nondeterministic factor.Ideas? | Mumble doesn't bind to network address on boot, needs to be restarted (doesn't properly wait for network?) | debian;networking | null |
_softwareengineering.154615 | I cannot count the number of times I read statements in the vein of 'unit tests are a very important source of documentation of the code under test'. I do not deny they are true.But personally I haven't found myself using them as documentation, ever. For the typical frameworks I use, the method declarations document their behaviour and that's all I need. And I assume the unit tests backup everything stated in that documentation, plus likely some more internal stuff, so on one side it duplicates the ducumentation while on the other it might add some more that is irrelevant.So the question is: when are unit tests used as documentation? When the comments do not cover everything? By developpers extending the source? And what do they expose that can be useful and relevant that the documentation itself cannot expose? | Are unit tests really used as documentation? | unit testing;documentation | They're NOT an ABSOLUTE Reference DocumentationNote that a lot of the following applies to comments as well, as they can get out of sync with the code, like tests (though it's less enforceable).So in the end, the best way to understand code is to have readable working code.If at all possible and not writing hard-wired low-level code sections or particularly tricky conditions were additional documentation will be crucial.Tests can be incomplete:The API changed and wasn't tested,The person who wrote the code wrote the tests for the easiest methods to test first instead of the most important methods to test, and then didn't have the time to finish.Tests can be obsolete.Tests can be short-circuited in non-obvious ways and not actually executed.BUT They're STILL an HELPFUL Documentation ComplementHowever, when in doubt about what a particular class does, especially if rather lengthy, obscure and lacking comments (you know the kind...), I do quickly try to find its test class(es) and check:what they actually try to check (gives a hint about the most important tidbits, except if the developer did the error mentioned above of only implementing the easy tests),and if there are corner cases.Plus, if written using a BDD-style, they give a rather good definition of the class's contract. Open your IDE (or use grep) to see only method names and tada: you have a list of behaviors.Regressions and Bugs Need Tests TooAlso, it's a good practice to write tests for regression and for bug reports: you fix something, you write a test to reproduce the case. When looking back at them, it's a good way to find the relevant bug report and all the details about an old issue, for instance.I'd say they're a good complement to real documentation, and at least a valuable resource in this regard. It's a good tool, if used properly. If you start testing early in your project, and make it a habit, it COULD be a very good reference documentation. On an existing project with bad coding habits already stenching the code base, handle them with care. |
_webapps.62701 | I've starred a project on Github. I'd like to receive via email notification of major updates of that project (basically commits on the master branch).I know there is the Watch options but I don't really want to receive emails for all issues and so on, I just want official updates on the project.How can I do this? | Github receive updates of starred projects via email of commits on master branch | github;notifications | Actually there is finally a super simple service doing right what is neededhttps://sibbell.com/Get with github account, and you can get notification of new releases based on watch and/or stars. Totally free! It can get even more granular on a per base repository filter with some premium features, totally awesome! |
_unix.173812 | On my Debian Wheezy VPS I keep getting the errors relating to locale and locale changes, when switching users, for example:-su: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)And when doing almost anything related to installation (apt-get and dpkg):perl: warning: Setting locale failed.perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = en_US.UTF-8, LANG = en_US.UTF-8 are supported and installed on your system.perl: warning: Falling back to the standard locale (C).locale: Cannot set LC_CTYPE to default locale: No such file or directorylocale: Cannot set LC_MESSAGES to default locale: No such file or directorylocale: Cannot set LC_ALL to default locale: No such file or directoryI've looked into it, and found several questions about this kind of errors already.The output of locale -a is:locale: Cannot set LC_CTYPE to default locale: No such file or directorylocale: Cannot set LC_MESSAGES to default locale: No such file or directorylocale: Cannot set LC_COLLATE to default locale: No such file or directoryCC.UTF-8POSIXI've also tried installing the locales package, which didn't work either, for example locale-gen, doesn't change anything.Edit: The output of strace locale -a is the following (a whole bunch bunch of text, be warned)execve(/usr/bin/locale, [locale, -a], [/* 13 vars */]) = 0brk(0) = 0x191b000access(/etc/ld.so.nohwcap, F_OK) = -1 ENOENT (No such file or directory)mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6c1353000access(/etc/ld.so.preload, R_OK) = -1 ENOENT (No such file or directory)open(/etc/ld.so.cache, O_RDONLY) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=30161, ...}) = 0mmap(NULL, 30161, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe6c134b000close(3) = 0access(/etc/ld.so.nohwcap, F_OK) = -1 ENOENT (No such file or directory)open(/lib/x86_64-linux-gnu/libc.so.6, O_RDONLY) = 3read(3, \177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\357\1\0\0\0\0\0..., 832) = 832fstat(3, {st_mode=S_IFREG|0755, st_size=1603600, ...}) = 0mmap(NULL, 3717176, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe6c0daa000mprotect(0x7fe6c0f2c000, 2097152, PROT_NONE) = 0mmap(0x7fe6c112c000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x182000) = 0x7fe6c112c000mmap(0x7fe6c1131000, 18488, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe6c1131000close(3) = 0mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6c134a000mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6c1349000mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6c1348000arch_prctl(ARCH_SET_FS, 0x7fe6c1349700) = 0mprotect(0x7fe6c112c000, 16384, PROT_READ) = 0mprotect(0x606000, 4096, PROT_READ) = 0mprotect(0x7fe6c1355000, 4096, PROT_READ) = 0munmap(0x7fe6c134b000, 30161) = 0brk(0) = 0x191b000brk(0x193c000) = 0x193c000open(/usr/lib/locale/locale-archive, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/share/locale/locale.alias, O_RDONLY) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6c1352000read(3, # Locale name alias data base.\n#..., 4096) = 2570read(3, , 4096) = 0close(3) = 0munmap(0x7fe6c1352000, 4096) = 0open(/usr/lib/locale/en_US.UTF-8/LC_CTYPE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en_US.utf8/LC_CTYPE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en_US/LC_CTYPE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en.UTF-8/LC_CTYPE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en.utf8/LC_CTYPE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en/LC_CTYPE, O_RDONLY) = -1 ENOENT (No such file or directory)write(2, locale: , 8locale: ) = 8write(2, Cannot set LC_CTYPE to default l..., 37Cannot set LC_CTYPE to default locale) = 37write(2, : No such file or directory, 27: No such file or directory) = 27write(2, \n, 1) = 1open(/usr/lib/locale/en_US.UTF-8/LC_MESSAGES, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en_US.utf8/LC_MESSAGES, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en_US/LC_MESSAGES, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en.UTF-8/LC_MESSAGES, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en.utf8/LC_MESSAGES, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en/LC_MESSAGES, O_RDONLY) = -1 ENOENT (No such file or directory)write(2, locale: , 8locale: ) = 8write(2, Cannot set LC_MESSAGES to defaul..., 40Cannot set LC_MESSAGES to default locale) = 40write(2, : No such file or directory, 27: No such file or directory) = 27write(2, \n, 1) = 1open(/usr/lib/locale/en_US.UTF-8/LC_COLLATE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en_US.utf8/LC_COLLATE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en_US/LC_COLLATE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en.UTF-8/LC_COLLATE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en.utf8/LC_COLLATE, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale/en/LC_COLLATE, O_RDONLY) = -1 ENOENT (No such file or directory)write(2, locale: , 8locale: ) = 8write(2, Cannot set LC_COLLATE to default..., 39Cannot set LC_COLLATE to default locale) = 39write(2, : No such file or directory, 27: No such file or directory) = 27write(2, \n, 1) = 1open(/usr/lib/locale/locale-archive, O_RDONLY) = -1 ENOENT (No such file or directory)open(/usr/lib/locale, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3getdents(3, /* 3 entries */, 32768) = 80getdents(3, /* 0 entries */, 32768) = 0close(3) = 0stat(/usr/lib/locale/C.UTF-8/LC_IDENTIFICATION, {st_mode=S_IFREG|0644, st_size=168, ...}) = 0open(/usr/share/locale/locale.alias, O_RDONLY) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0mmap(NULL, 2570, PROT_READ, MAP_SHARED, 3, 0) = 0x7fe6c1352000lseek(3, 2570, SEEK_SET) = 2570fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0munmap(0x7fe6c1352000, 2570) = 0close(3) = 0fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe6c1352000write(1, C\n, 2C) = 2write(1, C.UTF-8\n, 8C.UTF-8) = 8write(1, POSIX\n, 6POSIX) = 6exit_group(0) = ?Edit 2: Output of gcc -v:Using built-in specs.COLLECT_GCC=gccCOLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapperTarget: x86_64-linux-gnuConfigured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnuThread model: posixgcc version 4.7.2 (Debian 4.7.2-5)Edit 3: Sorry but, this is not a duplicate. As I said, I have looked through a ton ton of questions, and none of the answers have helped me or fixed the issue, including the one you nominated as a duplicate. It may seem like a duplicate, and in theory it is, but since my issue is not solved - I don't think reopening an old question would help the issue get solved sooner than opening a new one. | Locale error on Debian | debian;locale | null |
_softwareengineering.179808 | In a C++ program that doesn't contain legacy C code, is there a guideline regarding the maximum number of levels of indirection that should be used in the source code? I know that in C (as opposed to C++), some programmers have used pointers to pointers for a multiple dimension array, but for the case of arrays, there are data structures in C++ that can be used to avoid the pointers to pointers. Are users who still create pointers to pointers (or more than this) trying to use pointers to pointers only for performance ETC. reasons? I have tried NOT to use any more than a pointer to a pointer, only in the case that a pointer needed modification; does anyone have any other official or unofficial guidelines or rules regarding the number of levels of indirection? | C++ Pointers: Number of levels of Indirection | c++;pointers | null |
_unix.372733 | I am writing a bash script; I execute a certain command and grep. pfiles $1 2> /dev/null | grep name # $1 Process IdThe response will be something like: sockname: AF_INET6 ::ffff:10.10.50.28 port: 22peername: AF_INET6 ::ffff:10.16.6.150 port: 12295The response can be no lines, 1 line, or 2 lines.In case grep returns no lines (grep return code 1), I abort the script; if I get 1 line I invoke A() or B() if more than 1 line. grep's return code is 0 when the output is 1-2 lines.grep has return value (0 or 1) and output.How can I catch them both ? If I do something like: OUTPUT=$(pfiles $1 2> /dev/null | grep peername)Then variable OUTPUT will have the output (string); I also want the boolean value of grep execution. | get output and return value of grep in single operation in bash | bash;shell;grep;return status | null |
_unix.93761 | I want to cut a video into about 10 minute parts like this.ffmpeg -i video.mp4 -ss 00:00:00 -t 00:10:00 -c copy 01.mp4ffmpeg -i video.mp4 -ss 00:10:00 -t 00:10:00 -c copy 02.mp4ffmpeg -i video.mp4 -ss 00:20:00 -t 00:10:00 -c copy 03.mp4With for it will be like this.for i in `seq 10`; do ffmpeg -i video.mp4 -ss 00:${i}0:00 -t 00:10:00 -c copy ${i].mp4; done;But it works only if duration is under a hour.How can I convert number to time format in bash shell? | how to convert number to time format in shell script? | bash;shell;time;ffmpeg;arithmetic | BASH isn't that bad for this problem. You just need to use the very powerful, but underused date command.for i in {1..10}; do hrmin=$(date -u -d@$(($i * 10 * 60)) +%H:%M) outfile=${hrmin/:/-}.mp4 ffmpeg -i video.mp4 -ss ${hrmin}:00 -t 00:10:00 -c copy ${outfile}donedate Command Explaineddate with a -d flags allows you to set which date you want displayed (instead of the current date and time, which is the default). In this case, I am setting it to a UNIX time by prepending the @ symbol before an integer. The integer in this case is the time in ten minute increments (calculated by the BASH built-in calculator: $((...))).The + symbol tells date that you would like to specify a format for displaying the results. In our case, we care only about the hour (%H) and the minutes (%M).And finally, the -u is to display as UTC time instead of local. This is important in this case because we specified the time as UTC when we gave it the UNIX time (UNIX time is always as UTC). The numbers would most likely not start from 0 if you didn't specify -u.BASH Variable Substitution ExplainedThe date command gave us just what we needed. But colons in a file name might be problematic/non-standard. So, we substitute the ':' for a '-'. This can be done by the sed or cut or tr command, but because this is such a simple task, why spawn a new subshell when BASH can do it?Here we use BASH's simple expression substitution. To do this, the variable must be contained within curly braces (${hrmin}) and then use the standard forward slash notation. The first string after the first slash is the search pattern. The second string after the second slash is the substitution.BASH variable substitution and more can be found at http://tldp.org/LDP/abs/html/parameter-substitution.html. |
_softwareengineering.288818 | Suppose,There is a user list.<a href=user/5>Edit</a><a href=user/6>Edit</a> When a system user clicked to edit a user info. Then it goes to url to browser like as http://abc.com/user/5He can manually replace 5 to 155 and edit(update) the user info. It is a problem to me. How can I remove this problem?I have an idea: Calling the edit page by ajax. So that the number will be hidden. Is there any good idea? | How can I keep browser URL secret when editing data? | php;javascript;html;mysql;jquery | Your application probably have different actions with different access levels, for example an admin will probably be allowed more things than a simple user. So you better build some data-matrix summarizing user(-roles) access-rights and check brefore treating any request if the current logged-in user (or even unlogged Guest if you happen to have such a role) has the right or not to perform this action. Of course this might look overkill, but if you mind about security you definitely need it. You can NEVER trust the user, you always have to validate server-side. |
_softwareengineering.115960 | I am reading the following in a book on algorithms (Cormen's to be specific): That is, we are concerned with how the running time of an algorithm increases with the size of the input in the limit, as the size of the input increases without bound.I can not understand what is the meaning of the phrase: with the size of the input in the limit.What is the limit refering about? UPDATE: Please note that at this point in the book (early fundamentals of chapter 2) there has been no formal definition or mention of Big O or other asymptotic notation except a vague reference on Theta notationAny help? | Help on clarification of a formal statement concerning algorithms running time | algorithms;computer science;theory | null |
_softwareengineering.230417 | I have decided to work as a freelancer. I have developed a software and have successfully given the presentation demo. The client liked it and has agreed to implement the project in his organisation.But the client has asked me make it sure that I wont run away with the money without completing the project. The cost of project is high and it is not possible to complete it without acquiring the advance from the client.What are the practice that is usually followed ? I myself somehow agree with the client query. I know I will be able to complete the project. I do not intend to cheat. But how to prove it to client? What to do in such situation? | How to assure client that we will complete our project and won't run away with the money | project management;programming practices;freelancing;project;client | How do you ensure the builder that you contracted to build an extension to your house won't leave you with a half-finished extension? You sign a contract in which it is specified that payment occurs in several installments, with final payment only after acceptance of the finished product.For software development, the same kind of agreement can be used, especially if it is a longer running project (more than a couple of weeks), with the intermediate payments either based on time (monthly?) or on intermediate deliveries.Regarding the size of payments, the intermediate payments should be enough to cover the costs you make (it shouldn't be needed that you eat into your reserves while working on a paid project), and the final payment should be a significant portion of the total sum to have an incentive to finish the project. |
_unix.80110 | I am using a system that runs twm and I am wondering if it is possible to switch between windows using keyboard shortcuts, as I do in gnome with Alt+Tab. | switching windows in twm with keyboard shortcuts | x11;keyboard shortcuts;window management;twm | null |
_codereview.173672 | Code ObjectiveI'm writing an AutoHotkey script which takes in department data copied to the clipboard from a Microsoft Excel spreadsheet. It then uses this data to auto-fill forums in the web-app Kronos Workforce Central.Source DataWhen data is copied from Microsoft Excel, each cell in a row is stored in the clipboard as strings delimited by tabs \t, with each row separated by newlines \r\n.DeptID Job Name Abbreviation Service Line 0368 Administrator ADMIN OPS3945 Programmer PRGRM NON NRSG4596 Software Engineer SFTWRE-ENG NON NRSGCurrent MethodCurrently, I'm parsing this copied-data by splitting the data into an array of rows with StrSplit(), then using a second StrSplit() inside a for-loop to parse my data.; Autofill data from clipboard#d:: addLocationsWindow := Add Locations WinActivate, %addLocationsWindow% ; Window MUST be active rowArray := StrSplit(Clipboard, `r`n) ; Split copied rows from Excel by newlines for index, row in rowArray { tempArray := StrSplit(row, `t) ; Split each row by tabs deptID := tempArray[1] jobName := tempArray[2] If (deptID == ) ; skip empty cells continue IfWinNotActive(addLocationsWindow) ; check for active window { MsgBox '%addLocationsWindow%' window not found. Stopping script... Exit, 1 } ; DoStuff(jobName, deptDisplayName, index) }ReturnThe IssueMy method of string parsing feels hacky and unintuitive. It means I can only manipulate a single row at a time, as each each row's data is only split temporarily. I would need to re-run the costly StrSplit() to access data from a row again.In Java, I could store my Excel data in a single 2D array. Unfortunately, arrays are a bit tricky to use in AutoHotkey, which is why my current code is a bit messy. | Parse copied data from Excel using AutoHotkey | array;autohotkey | null |
_softwareengineering.206230 | Forgive the title -- it needs work. I am struggling to find better English to express my issue. Edits encouraged.Example to describe my issue:Checker MethodI have an argument checking method called public static void StringArgs.checkIndexAndCount(String, int, int). Given a string, an index, and a count, confirm the string is not null, and the index & counts are reasonable. Unchecked (runtime) exceptions are used to report errors. There is a battery of unit tests written to check all angles of this method.Layered (or Derived) MethodThe checker method is called by other methods, such as public static String removeByIndexAndCount(String, int, int). The first line of this method checks the arguments by calling the above checker.Unit Test StrategyWhen I write unit tests for the second/layered/derived method, how do I account for the existing set of unit tests for the checker method? It seems to violate duplication/copy-paste principles to simple re-add the same unit tests (modified slightly) from the checker method to the second method.Please advise.My code is Java, but I don't think that particularly relevant, as this same issue could occur in any language. | Unit test strategy for layered (or derived) method calls | unit testing | null |
_unix.307592 | I wanted to start the metasploit service to start armitage. But when i am typing in my console the command:sudo service metasploit start It says: Failed to start metasploit.service: Unit metasploit.service not found.I installed metasploit. It is connected to postgresql, so the question is how can I start or install this service? | How to start the metasploit service in Linux Mint? | linux mint;services;metasploit | null |
_webmaster.27636 | So I have a problem - I have my main site on apache web server on debian on port 80; I develop a web server (in some C++ or C#) and it currently runs on port 6666. But some people are living under firewalls and can access only port 80. I wonder if it is possible via apache map all requests to say mysite.com:80/6666/url as if they were to mysite.com:6666/url, not map via redirection, but really make apache stream content from my site to user as if it were in some folder? | How to proxy with apache site from same domain but another port as a subfolder? | apache;proxy;configuration | null |
_webmaster.11442 | Possible Duplicate:Which Content Management System (CMS) should I use? I've been trying to find an image gallery that plays nice with our custom CMS. I've evaluated a number of them, but none of them seems to have the feature list that I would like:Run on LAMP environmentFree software or low license costs (the website belongs to a non-profit organisation)Multi-user supportMultiple albums. We're posting concert pictures, and would like an album per event.Pluggable authentication system. I want to reuse the accounts we have for our CMS. Permissions can be done inside the gallery itself, but I want to have a single sign on solution in a maintainable manner, by writing my own plugin/add-on for the software.Upload support (multiple images at the same time)And preferrably also:Can be integrated into a PHP page layout without IFRAMEsAutomatic resizing of uploaded images to a maximum sizeAbility for visitors to place commentsThis combination is proving hard to find, especially the authentication requirement. I don't want to mess around all over the place in the source code to make it use the existing authentication. A plugin would be ideal, but alternatively a well thought out software design that allows for maintainable surgical changes would be acceptable.Any suggestions on which software I should take a closer look into? | PHP Image gallery that integrates well into custom CMS | looking for a script;photo gallery | null |
_cs.33002 | I'm going through Brewer's theorem and its proof by Nancy Lynch and Seth Gilbert. But the paper left me with one question. What prevents the theorem from being applicable to a single node?I havent encountered any explicit definition of network partition that restricts its applicability to a network. There are some hints in [1] that suggest that a network partition with a single node would mean cutting off all communication to that node itself. This doesnt make a whole lot of sense to me because you could always have a partition with all the service nodes on one side and the client node on the other. No service could possibly tolerate that. A single node data object can be consistent and available if requests sent to it get through. To me, the definition of a network partition and where it applies leaves something to be desired. What am I missing here? [1] Brewers Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services by Seth Gilbert and Nancy Lynch | Applying Brewer's theorem (CAP) to a single node | computer networks;database theory | In my opinion, the CAP theorem is applicable intentionally to distributed systems. To quote the article Perspectives on the CAP Theorem @ IEEE Computer'2012 by Gilbert and Lynch:Brewer first presented CAP in the context of a Web service implemented by a set of servers distributed over a set of geographically diverse datacenters. Clients issue requests to the service, which sends back responses.In this context, the network in CAP theorem refers to communications among servers (instead of communications among clients or between clients and servers). This can be justified by the following two arguments.To quote the above article again (with emphasis added):Unlike the other two requirements, partition tolerance is really a statement about the underlying system rather than the service itself: communication among the servers is unreliable, and the servers can be partitioned into multiple groups that cannot communicate with one another.In the proof of the CAP theorem in the above article, it says,Consider an execution in which the servers are partitioned into two disjoint sets: $\{p_1\}$ and $\{ p_2, \ldots, p_n\}$. Some client send a read request to server $p_2$.The proof followed is based on the communication among the two disjoint sets of servers.To summarize, CAP theorem (again, it is my own opinion) does not consider the situation in which client nodes and server nodes are partitioned. After all, we can do almost nothing in this bad situation. In other words, CAP theorem assumes that the communications between clients and servers behave well and focuses on the theory and implementation of the distributed service itself. |
_unix.103728 | Is there anyway to display the size of each file next to it after executing the locate command? | How to display size of each file next to it after executing the locate command? | size;locate | If your locate implementation understands the option -0:locate -0 PATTERN | xargs -0 ls -sdOtherwise:locate PATTERN | xargs -I {} ls -sdOf course you may want to vary the flags passed to ls, e.g. add -h to get human-readable sizes, add --color=auto to have special files in color, etc.If some of the files in the locate database have been removed since the database was generated, ls will print error messages. To hide them, add 2>/dev/null at the end of the command. |
_unix.28812 | I've written a Python CGI script that invokes bash commands, and it needs to test for a successful login on the host.How do I write a test for that?For example, could I create a bash script that tests a given username and password combination against the registered user on the host? | How do I write a test for system login? | linux;bash;security;login;testing | Using PAM is the best solution. You can write small C code, or install python-pam package and use a python script which comes with the python-pam package. See /usr/share/doc/python-pam/examples/pamtest.py |
_webmaster.108433 | I used this line to extract unique IPs from my access_log for the last minute:grep 2017:19:23 /var/log/nginx/access_log | awk '{print $2}' | sort -n | uniq -c | sort -nr | head -20000 | wc -lResult: 185I then tried again for 10 seconds:grep 2017:19:23:0 /var/log/nginx/access_log | awk '{print $2}' | sort -n | uniq -c | sort -nr | head -20000 | wc -lResult: 74What does google analytics realtime tell me? 37. I've not seen it go over 50 all day and I'm confident that at time my concurrent users has been more like 200+.Any idea why this would be? | Google Analytics real time numbers don't seem to come close to unique IP addresses in my access_log? | google analytics;real time | null |
_hardwarecs.6789 | Im looking for a WLAN router that runs only free/libre software. It doesnt need to contain a modem.ThinkPenguin.com offered the Free Software Wireless-N Broadband Router for GNU / Linux (TPE-NWIFIROUTER2), which even got FSFs RYF certification, but its no longer for sale/available.I would prefer a router that ships without any proprietary software, but if there isnt one, Im fine with a router that ships with proprietary software, as long as a free/libre OS (and free/libre firmware) can be installed without voiding the warranty, ideally officially supported. | Free/libre WLAN router | router;wlan;floss | null |
_codereview.39718 | I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code.If you are unfamiliar with unity3d, ignore the use of UnityEngine, the heritage from MonoBehaviour as well as the Debug.Log();, Debug.LogWarning();, and Debug.LogError();Awake is called directly after the constructor.I use int length instead of a function to return the size of List<Gender> genders. Not sure what is preferred (or best).An XML Example can be seen further down./// <summary>/// Gender manager./// Access length by GenderManager.Length/// Access gender by index GenderManager.gender[int]/// /// Left to do: Singleton/// /// Author: Emz/// Date: 2014-01-21/// </summary>using UnityEngine;using System.Collections;using System.Collections.Generic;using System.Xml;using System;public class GenderManager : MonoBehaviour { private static List<Gender> genders; private static int length; // Use this for initialization public GenderManager () { genders = new List<Gender> (); length = 0; } void Awake () { DontDestroyOnLoad (this); XmlDocument doc = new XmlDocument (); doc.Load (@genders.xml); XmlNodeList gs = doc.SelectNodes (genders/gender); foreach (XmlNode g in gs) { Gender tg = new Gender (); tg.Name = g.SelectSingleNode(name).InnerText; tg.Desc = g.SelectSingleNode(desc).InnerText; XmlNodeList ams = g.SelectNodes(attributemodifiers/attributemodifier); foreach (XmlNode am in ams) { // check if attribute does exist in public enum AttributeName under Skill.cs if (Enum.IsDefined(typeof(AttributeName), am.SelectSingleNode (attribute).InnerText)) { int ta = (int)Enum.Parse(typeof(AttributeName), am.SelectSingleNode (attribute).InnerText); // returns 0 if conversion failed int tv = Convert.ToInt32(am.SelectSingleNode (value).InnerText); tg.AddAttributeModifier (ta, tv); // if attribute does not exist in SkillName under Skill.cs } else { Debug.LogError (Invalid Attribute Name: + am.SelectSingleNode (attribute).InnerText); } } XmlNodeList sms = g.SelectNodes(skillmodifiers/skillmodifier); foreach (XmlNode sm in sms) { // check if skill does exist in public enum SkillName under Skill.cs if (Enum.IsDefined(typeof(SkillName), sm.SelectSingleNode (skill).InnerText)) { int ts = (int)Enum.Parse(typeof(SkillName), sm.SelectSingleNode (skill).InnerText); // returns 0 if conversion failed int tv = Convert.ToInt32(sm.SelectSingleNode (value).InnerText); tg.AddSkillModifier (ts, tv); // if skill does not exist in SkillName under Skill.cs } else { Debug.LogError (Invalid Skill Name: + sm.SelectSingleNode (skill).InnerText); } } // off we go, increment length genders.Add (tg); ++length; } } public static int Length { get {return length;} } public static Gender Gender (int index) { return genders [index]; }}XML<?xml version=1.0 encoding=UTF-8?><genders> <gender> <name>Female</name> <desc>FemDesc</desc> <attributemodifiers> <attributemodifier> <attribute>Agility</attribute> <value>1</value> </attributemodifier> </attributemodifiers> <skillmodifiers> <skillmodifier> <skill>Charm</skill> <value>1</value> </skillmodifier> </skillmodifiers> </gender> <gender> <name>Male</name> <desc>MalDesc</desc> <attributemodifiers> <attributemodifier> <attribute>Strength</attribute> <value>1</value> </attributemodifier> </attributemodifiers> <skillmodifiers> <skillmodifier> <skill>Intimidation</skill> <value>1</value> </skillmodifier> </skillmodifiers> </gender> <gender> <name>Neuter</name> <desc>NeuDesc</desc> <attributemodifiers> <attributemodifier> <attribute>Attunement</attribute> <value>1</value> </attributemodifier> </attributemodifiers> <skillmodifiers> <skillmodifier> <skill>Coercion</skill> <value>1</value> </skillmodifier> </skillmodifiers> </gender></genders>Enums for AttributeName and SkillNamepublic enum AttributeName { Strength, Agility, Quickness, Endurance, Attunement, Focus};public enum SkillName { Weight_Capacity, Attack_Power, Intimidation, Coercion, Charm};And lastly, the Gender classusing System.Collections.Generic;public class Gender { private string _name; private string _desc; private List<GenderBonusAttribute> _attributeMods; private List<GenderBonusSkill> _skillMods; public Gender () { _name = string.Empty; _attributeMods = new List<GenderBonusAttribute> (); _skillMods = new List<GenderBonusSkill> (); } public string Name { get {return _name;} set {_name = value;} } public string Desc { get {return _desc;} set {_desc = value;} } public void AddAttributeModifier (int a, int v) { _attributeMods.Add (new GenderBonusAttribute (a, v)); } public void AddSkillModifier (int s, int v) { _skillMods.Add (new GenderBonusSkill (s, v)); } public List<GenderBonusAttribute> AttributeMods { get {return _attributeMods;} } public List<GenderBonusSkill> SkillMods { get {return _skillMods;} }}public class GenderBonusAttribute { public int attribute; public int value; public GenderBonusAttribute (int a, int v) { attribute = a; value = v; }}public class GenderBonusSkill { public int skill; public int value; public GenderBonusSkill (int s, int v) { skill = s; value = v; }}I don't want to hardcode the genders for various reasons.Does this code look good enough? If not, what changes should be made and where can I read more about them? | Dynamic Storing Objects from XML in RPG | c#;xml;unity3d | Your code style is really inconsistent. As if you were copypasting code blocks from various places and didn't bother to refactor it. Part of the reason your code is hard to read. A somewhat accepted code style is: a) prefix field names with underscores, b) if possible use auto-properties for public members instead of fields and properties with backing fieldspublic GenderBonusAttribute (int a, int v) what is a? what is v? no way to tell without digging into your code. You should use descriptive names.Using static fields in GenderManager and setting them via non-static constructor is a mess. Length is not descriptive. What is length? If it is the length of genders, then why dont you expose genders.Count instead?In my opinion XmlDocument is somewhat depricated. I would use XDocument and Linq-to-Xml instead. It would simplify your code. Though in a sense its probably a matter of taste. I think some light weight data base will do a better job in storing game mechanics then xml files. |
_computergraphics.4684 | I'm new to computer graphics. I played around with OpenGL and now am trying out Vulkan.Basically what I want to do, in 2D is have an 800x800 window, and I want that to represent 800 meters by 800 meters. Then I want a circle with a radius of 1 meter.I am going off of the Vulkan tutorial. My data structure is this:struct Vertex { glm::vec2 pos;};I create my circle:const int NUM_POINTS = 20;uint32_t angle = 360/NUM_POINTS;Vertex vertex;std::vector<Vertex> vertices;for(uint32_t i=0; i <= 360; i+=angle){ vertex.pos.x = cos(glm::radians(float(i))); vertex.pos.y = sin(glm::radians(float(i))); vertices.push_back(vertex);}Something to do with the viewport:VkViewport viewport = {};viewport.x = 0.0f;viewport.y = 0.0f;viewport.width = (float) swapChainExtent.width;viewport.height = (float) swapChainExtent.height;viewport.minDepth = 0.0f;viewport.maxDepth = 1.0f;viewport.width and viewport.height both equal 800.0f.Projection matrices:struct UniformBufferObject{ glm::mat4 model; glm::mat4 view; glm::mat4 proj;};projections:ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));ubo.proj = glm::perspective(glm::radians(45.0f), swapChainExtent.width / (float) swapChainExtent.height, 0.1f, 10.0f);ubo.proj[1][1] *= -1;This shows the circle, but it's almost as big as the window and it's tilted 45 away from me.First of all, I don't understand why, if I make the first argument to glm::lookAt be glm::vec3(0.0f, 0.0f, 2.0f), I see nothing. I mean the circle is in the x-y plane. If I move in the z-direction, shouldn't I see it?Then I tried glu::orthoubo.proj = glm::ortho(0.0f, 800.0f, 800.0f, 0.0f);But I still see nothing. | understanding glm::perspective vs glm::ortho | projections;vulkan;glm | null |
_unix.330558 | I am working on an embedded device with ARM CPU and Debian Jessie constructed using multistrap. It seems I need to install a slightly patched version of ModemManager into that system and what I am asking for is any guidance on how to do that. What I've tried so far is chrooting into the rootfs created by multistrap, downloading the source code of ModemManager using apt-get and building it chrooted. So far, I haven't even got the configure script to pass due to dependencies I can't get satisfied.Patching is needed in order to solve the known problem of ModemManager that it may confuse hardware by scanning serial ports for modems. There is a way to work around that by blacklisting devices via udev rules, but in this case the serial port is part of the tty sub-system, for which blacklisting is not supported. I have check that in ModemManager's source code.I am also very open for easier ways to solve this if there are such, but I haven't noticed them so far. | Building software for Linux generated using multistrap | debian;arm;cross compilation | null |
_codereview.142896 | I'm beginner java programmer and would like to ask you to take a look at my code. I wrote small rest service among with tests. Now I have to questions to ask. The test methods:@Transactionalpublic class CustomerControllerTests extends RestApplicationTests{ @Autowired private WebApplicationContext context; private MockMvc mockMvc; @Before public void setup(){ mockMvc = MockMvcBuilders .webAppContextSetup(context) .build(); } @Test public void getRequestSent_then200IsRecived() throws Exception{ mockMvc.perform(get(/customers)) .andExpect(status().isOk()); } @Test public void getRequestSend_thenJSONisRecived() throws Exception{ mockMvc.perform(get(/customers)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)); } @Test public void givenUserDoesNotExists_whenUserInfoIsRetrieved_then404IsRecived() throws Exception{ final String id = 666634443255233321; mockMvc.perform(get(/customers/ + id)) .andExpect(status().isNotFound()); } @Test public void givenPutRequest_whenRequestBodyIsValid_then200IsRecived() throws Exception{ Customer customerStub = new Customer.Builder() .firstName(Adam) .lastName(Nawalka) .town(Boston) .customerId(8888) .build(); Gson gson = new Gson(); String entityAsJson = gson.toJson(customerStub); mockMvc.perform(put(/customers).with(anonymous()) .content(entityAsJson) .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); } @Test public void givenPutRequest_whenIdIsMissing_thenIllegalArgumentExceptionAsCause() throws Exception{ Customer customerStub = new Customer.Builder() .firstName(Adam) .lastName(Nawalka) .town(Boston) .build(); Gson gson = new Gson(); String entityAsJson = gson.toJson(customerStub); try{ mockMvc.perform(put(/customers) .content(entityAsJson) .contentType(MediaType.APPLICATION_JSON_UTF8)); } catch(NestedServletException e){ Assert.assertEquals(NestedServletException.class, e.getClass()); Assert.assertEquals(IllegalArgumentException.class, e.getCause().getClass()); Assert.assertEquals(Can not update with id equal to 0, e.getCause().getLocalizedMessage()); } } @Test public void givenPutRequest_whenEntityIsNotCompatible_then400BadRequest() throws Exception{ Customer customerStub = new Customer.Builder() .firstName(Adam) .town(Boston) .customerId(8888) .build(); Gson gson = new Gson(); String entityAsJson = gson.toJson(customerStub); mockMvc.perform(put(/customers) .content(entityAsJson) .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isBadRequest()); } @Test public void givenPutRequest_whenEntityIsNotCompatible_thenExplanationInBody() throws Exception{ Customer customerStub = new Customer.Builder() .firstName(Adam) .town(Boston) .customerId(8888) .build(); Gson gson = new Gson(); String entityAsJson = gson.toJson(customerStub); mockMvc.perform(put(/customers) .content(entityAsJson) .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content() .string(Entity contains forbidden values: + Can not update entity with field \lastName\ set to: null)); } @Test public void givenPutRequest_whenEntityIsNotCompatible_thenDataInputException() throws Exception{ Customer customerStub = new Customer.Builder() .firstName(Adam) .town(Boston) .customerId(8888) .build(); Gson gson = new Gson(); String entityAsJson = gson.toJson(customerStub); try{ mockMvc.perform(put(/customers) .content(entityAsJson) .contentType(MediaType.APPLICATION_JSON_UTF8)); } catch(DataInputException e){ Assert.assertEquals(DataInputException.class, e.getClass()); } } @Test public void givenPostRequest_whenRequestBodyIsValid_then200IsRecived() throws Exception{ Customer customerStub = new Customer.Builder() .firstName(Adam) .lastName(Nawalka) .town(Boston) .customerId(8888) .build(); Gson gson = new Gson(); String entityAsJson = gson.toJson(customerStub); mockMvc.perform(post(/customers) .content(entityAsJson) .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isCreated()); } @Test public void givenDeleteRequest_whenUserExists_then204NoContent() throws Exception{ mockMvc.perform(delete(/customers/1)) .andExpect(status().isNoContent()); }}Is my approach separating different results to different methods correct? I could do more compressed assertions checking for exceptions and result body and result status in one method. Isnt it better approach?To run the tests I'm using my main database, Is it possible to somehow mock my database so that I could have full controll during the test what's in the database and did not have to use the main db? | Testing controller class using mockito mvc | java;beginner;unit testing;mocks | null |
_unix.122270 | till now I defined just image files.But I have a logical partition and I'd like to share it by iscsi.Is it possible or I am limited to single files? | Is it possible to set a whole hard disk(partition) as iscsi target? | iscsi | null |
_unix.323948 | Could someone please explain this code that deletes all leading blank lines at the top of a file:sed '/./,$!d' fileI understand that it is a regex, matching only the first character, but then don't understand the ,$!d part. Is this what it's being replaced by, or are they options for the match?Is this even a search command if it does not start with 's/'...?Sorry this is a bad question, I just don't know where to look. (and so, how would you recommend me finding the answer to this myself in the future?)Code source (from another question) | Sed Explanation: sed '/./,$!d' file | sed | sed '/./,$!d'From the first line which contains a character (blank or not) to the end of the file - negate (which then means from the beginning of the file to the line before the first line which contains a character) - delete.This deletes leading empty lines, not blank lines. To delete leading blank lines (lines which are empty or contain only whitespace characters) say '/\S/,$!d'.Read Sed, an introduction and tutorial at http://www.grymoire.com/Unix/Sed.html. Then read the reference manual at https://www.gnu.org/software/sed/manual/sed.html.In short:The general form of a sed command is [selector][negation]command[flags] (square brackets indicate optional parts)The selector, if present, selects the lines on which the command appliesIf ! appears it negates the selector, that is, makes the command apply to the lines which do not match the selector.If no selector is present the command applies to all lines.A selector can select one line (by number) or a set of lines (by regular expression), or the lines between a start line (by number or regular expression) and an end line (by number or regular expression).In our case the selector is /./,$ which means from the first line found which matches /./ (that is, contains at least one character) to the end of the file ($ is used as a line number and means the last line in the file).It is negated by !, so that the command applies to the lines from the beginning of the file to the line before the first line matching /./.The command d deletes the selected lines. |
_unix.291186 | Is there any such essential process launched in the user space... ALso should take care of headless servers | Is there a process that is always running that uniquely identifiers a user in linux. | linux | null |
_webmaster.2232 | I'm planning what is essentially a business card website for myself, and have been looking at domains. My primary site (a .com) is for my blog and portfolio and the like, but I want a separate site for basic information, contact, networks, and the like.In this light, there are a few TLDs that seem to be suitable: .info, .me, and .name.I'd appreciate remarks on the differences between these options, and suggestion on which would be suitable for my need. | Which TLD would be suited to a personal site? | domains;top level domains | .infoThe name is derived from information indicating that the domain is intended for informative Internet resources, although registration requirements do not prescribe any theme orientation..meYou're in Montenegro? Seriously, I am not a fan of using other country codes for other uses. I don't like things whose legal jurisdiction is not my own..nameIt is intended for use by individuals for representation of their personal names, nicknames, screen names, pseudonyms, or other types of identification labels.I think .name is the most appropriate one to use.That said, the one that's easiest to remember and communicate to people is always going to be best. I like .com and .org best for personal sites.But to each his or her own. The original intent of TLDs has been subverted over the years, people do as they please. Use the one you like the best. |
_webapps.50338 | How do I search for websites that start with dl on Google?For example, returned sites search will be likedl.webaddr.comdl.something.comdl.others.com | Search for specific text at the start of the URL in Google search | google search | null |
_cs.64883 | I am having some trouble with turning the following mathematical expressions into as balanced binary trees as possible.This is what I have done so far, but is there a way to make them even more balanced?$( 3)(^2 + 1)$$4( 1)( 2)( 3)$ | Making mathematical expressions as balanced trees as possible | optimization;trees;arithmetic | Since these are mathematical expressions, you can bracket the second one as (4 (x-1)) ((y-2) (z-3)) to make it more balanced. In many programming languages this wouldn't be allowed, because with floating point arithmetic, the order of operations will often change the result. Can't see any way to improve the first one. |
_unix.109596 | I have a strange problem with a Linux router.The setup is like this:host1 === Linux router === host2a.b.c.d --- a.b.c.e/g.h.i.j --- g.i.h.kEvery five minutes host1 tries to reach host2.If host2 is down, the Linux router makes an ARP request for a.b.c.d onthe left network with address g.h.i.j (i.e. from network on the right side).After receiving the MAC address from host1 the router sends anICMP-unreachable packet with g.h.i.j as sender address.If host2 is up, everything is fine.The router makes the ARP request with its address a.b.c.e.On the router I have$ uname -aLinux pfc 3.6.9-voyage #1 SMP Tue Dec 11 09:53:27 HKT 2012 i586 GNU/LinuxThere is no proxy_arp involved.The problem is: in my eyes the route should not use the IP address from the right hand network for the ARP request. Or am I missing something here? | ARP request with wrong IP address | linux;router;arp | null |
_webapps.104367 | I would like to add icons to individual reports in a reports module in CommCare. Is it possible to add icons to individual reports within a report module? | Is it possible to add icons to individual reports in a report module in CommCare? | commcare | null |
_webmaster.83422 | A client has moved their website to another provider who does not support secure (HTTPS) browsing. The previous site was served over HTTPS and sent HSTS headers and was included on the Chrome HSTS preload list, so many browsers automatically attempt a redirect to HTTPS, resulting in an error.Chromium Issue 467486: Remove website from HSTS list highlights one specific website that required a whole discussion with developers to be removed. Is raising an issue to the Chromium team the only method to request removal? | Removal from HSTS preload list? | https;hsts | null |
_webapps.104326 | Is it possible to specify multiple languages for the Display Text Field portion of a select option in a multiple choice lookup table question? Note, I'm speaking specifically about the Choice definition, not the label for the question itself which does support multi-language already. | Multi-language support for Multiple Choice Lookup Table questions | commcare | You can use an attribute in the lookup table and a bit of a hack to get the current app locale ID to accomplish this.There's a writeup on it here that covers it pretty well: https://confluence.dimagi.com/display/commcarepublic/Using+Lookup+Tables+with+Multiple+Languages |
_cs.77968 | I read this answer below and got into another question.Why is the consensus number for test-and-set, 2?I also read that read/write registers have consensus number 1.But I see that in test&set (also in compare&swap) by using read write registers alone, we still arrive at consensus.I think I am missing something very fundamental here. Need help.The protocol in the accepted answer of the link is as mentioned belowSuppose that we have two threads 0 and 1 that need to reach consensus. We could do this by letting each thread follow the consensus protocol below:Write your proposed value to A[t], where t is the thread id and A is an array of size 2Perform the test-and-set instruction on some register R, with R initialised to 0. If the return value is 0, you were first: return A[t]. Otherwise, you were second: return A[|t1|]. | Consensus anomaly about read-write registers and test&set | distributed systems;consensus | Consensus number and consensus hierarchy are defined in the classic paper Wait-Free Synchronization by Maurice Herlihy, 1991.Note the keyword: wait-free.Since you did not give the algorithms for test&set using read/write registers only, I guess that they are not wait-free. (They may be lock-free instead.)Added: After the discussions with the OP in the comments, I realize that the OP has not fully understood the difference between atomic test&set registers and atomic read/write registers. He/she thought that the protocol given in the post uses read/write registers only. In fact, it uses test&set registers/operations/instructions in the second step. A test&set register supports the test&set operation, which is a combination of test and set that cannot be interrupted. See this wiki for more details. |
_webapps.24796 | I would like to some people to be able to see some of the photos I'm tagged in, but not all of them. Is this possible?I know I can make a list of people that won't be able to see any of the photos I'm tagged in, but is there a way to do this on a per-photo basis? | On Facebook, is there any way to restrict access to individual photos I'm tagged in? | facebook;photos | null |
_codereview.1635 | Given the following exercise:Exercise 2.5Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2^a * 3^b. Give the corresponding definitions of the procedures cons, car, and cdr.I wrote the following:(define (cons a b) (* (expt 2 a) (expt 3 b)))(define (car x) (if (= 0 (remainder x 3)) (car (/ x 3)) (/ (log x) (log 2))))(define (cdr x) (if (= 0 (remainder x 2)) (cdr (/ x 2)) (/ (log x) (log 3))))What do you think? | Represent pairs of nonnegative integers using 2^a * 3^b | lisp;scheme;sicp | Your definition of cons is perfect.Your definitions of car and cdr contain the log operation, which is a floating-point operation. Not only are its results imprecise, it is not needed to solve this problem. Furthermore, notice that the two definitions look very similar to each other. Whenever one sees a repeated pattern, one ought to consider factoring it out.To address the above two concerns, one may write a helper function, log-x, which is a specialized log function that takes integer parameters x and n and returns integer p such that x ^ p * y = n, where x does not divide y. Then, car and cdr may call log-x, with x being 2 and 3 respectively.In the following implementation, I have renamed the definitions so they do not conflict with primitives.(define (cons-np a b) (* (expt 2 a) (expt 3 b)))(define (log-x x n) (if (= (remainder n x) 0) (+ 1 (log-x x (/ n x))) 0))(define (car-np np) (log-x 2 np))(define (cdr-np np) (log-x 3 np)) |
_unix.377595 | I set up an Elementary Linux laptop for my kids to play Minecraft on.. only to find that it cannot ping or otherwise access any of the hosts on my local network. I can access stuff beyond the gateway without issues.Output from ipconfig:root@nevill:~# ifconfig eno1 Link encap:Ethernet HWaddr 00:26:b9:f4:87:06 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:20 Memory:e9600000-e9620000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:6923 errors:0 dropped:0 overruns:0 frame:0 TX packets:6923 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:721205 (721.2 KB) TX bytes:721205 (721.2 KB)wlp3s0 Link encap:Ethernet HWaddr 5c:ac:4c:97:03:da inet addr:192.168.1.84 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::c95a:b72b:7d45:820d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6015890 errors:0 dropped:0 overruns:0 frame:2040510 TX packets:2005419 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1149192406 (1.1 GB) TX bytes:161487281 (161.4 MB) Interrupt:17 Output from arp:root@nevill:~# arpAddress HWtype HWaddress Flags Mask Iface192.168.1.254 ether 4c:8b:30:12:3b:40 C wlp3s0192.168.1.68 ether 4c:8b:30:a9:f0:80 C wlp3s0192.168.1.100 (incomplete) wlp3s0UFW is off, as far as I can tell:root@nevill:~# ufw statusStatus: inactiveRouting table looks normal to me, but it doesn't really align with what I see on my Windows' hosts:Destination Gateway Genmask Flags Metric Ref Use Ifacedefault 192.168.1.254 0.0.0.0 UG 600 0 0 wlp3s0192.168.1.0 * 255.255.255.0 U 600 0 0 wlp3s0As best as I can understand, the incomplete entry in arp results tells me that the remote device is not responding.. I know this isn't the case, since the other hosts on the same network (same router, same wireless interface, etc) can access the host in question.I can ping the gateway (192.168.1.254), and hosts beyond the gateway, but nothing that's on the local network.I have not tested if this works with a wired connection.. that's in the ceiling somewhere :PHelp please? :)Thanks! | Ubuntu-based OS not able to access hosts on the local network, but can access external hosts | linux | null |
_unix.28473 | About a week ago my system began to freeze (deadlock, only manual shutdown with laptop button helped) from time to time.The frequency of deadlock is increasing. Today it was about 10 deadlocks with only browsing the internet and terminal emulator and vim. It usually happens when loading new url and then all the system is dead. It's very annoying for me as it happens more often.My system is Lubuntu 11.10 with xmonad window manager.Could you help me to find the cause of this problem? Are there some logs associated with deadlocks? Could it be hardware problem?(the system was dead twice while writing this question too)thank you | System freezes when browsing internet | ubuntu;logs;hardware;freeze;deadlock | null |
_webapps.5545 | Is there a way (at the Facebook end, not via filtering my end) to opt-out of receiving notifications every time someone else adds a comment to a thread I am involved in? | Opt out of Facebook comment updates | facebook | Click on the Account drop down menu (upper right hand corner of the page) then click Account Settings and go to the Notifications tab. Go through the list of notifications and deselect any notification you don't want. Fifteen out of the sixty-six notifications represented on this page are triggered by comments.To opt-out of notifications for treads you're involved in, deselect the six notifications that start with: Comments after me... |
_datascience.777 | New to the Data Science forum, and first poster here!This may be kind of a specific question (hopefully not too much so), but one I'd imagine others might be interested in.I'm looking for a way to basically query GitHub with something like this:Give me a collection of all of the public repositories that have more than 10 stars, atleast two forks, and more than three committers.The result could take any viable form: a JSON data dump, a URL to the web page, etc. It more than likely will consist of information from 10,000 repos or something large.Is this sort of thing possible using the API or some other pre-built way, or am I going to have to build out my own custom solution where I try to scrape every page? If so, how feasible is this and how might I approach it? | Getting GitHub repository information by different criteria | bigdata;data mining;python;dataset | My limited understanding, based on brief browsing GitHub API documentation, is that currently there is NO single API request that supports all your listed criteria at once. However, I think that you could use the following sequence in order to achieve the goal from your example (at least, I would use this approach):1) Request information on all public repositories (API returns summary representations only): https://developer.github.com/v3/repos/#list-all-public-repositories;2) Loop through the list of all public repositories retrieved in step 1, requesting individual resources, and save it as new (detailed) list (this returns detailed representations, in other words, all attributes): https://developer.github.com/v3/repos/#get;3) Loop through the detailed list of all repositories, filtering corresponding fields by your criteria. For your example request, you'd be interested in the following attributes of the parent object: stargazers_count, forks_count. In order to filter the repositories by number of committers, you could use a separate API: https://developer.github.com/v3/repos/#list-contributors.Updates or comments from people more familiar with GitHub API are welcome! |
_cstheory.16226 | Suppose a graph with node weights only (no edge weights). For a given source-sink pair, how can I find a path with the minimal sum of node weights? Does this problem have a name? Is it possible to reformulate this to a shortest-path problem?If both nodes and edges are weighted, is it still possible to find a min-weight path? | Finding a minimum node weight path | graph algorithms;shortest path | You can treat this as a directed graph problem, where the weights of all edges coming into a node are equal to that node's weight.If the edges are weighted too, add the node's weight and the edge's weight together to find the incoming edge's weight in the directed graph. |
_unix.139010 | I am new to shell scripting. When I want to run a bunch of Linux commands I do fine, but how do I give user input when another script is called and asks for input while it runs. Here is the situation where I am stuck. I install the same server setup in classrooms frequently so I want to completely automate it.#!/bin/bashsudo apt-get install python -ysudo apt-get install python-m2crypto -ysudo apt-get install git-core -ygit clone https://github.com/learningequality/ka-lite.gitcd ka-lite/./setup_linux.sh#the script works until here#now, while the setup script is running, the following needs to happen#I need to press enter twice#enter the password twice#press enter twice#press y and then enter#here are some things I tried, none of them workedsend yes\nsend yes\n#echo | <Press [enter] to continue...> #enter#echo | <return> #enterPassword8 #passwordPassword8 #passwordecho | <yourfinecommandhere> #enterecho | <return> #entery | How to simulate user interaction when running another script | shell;scripting | You can use TCL Expect or Perl::Expect.After trying them both I prefer the later because I am more familiar with Perl.This is a snipped of a script that I use to ssh into several test servers (not recommended for sensitive production servers):if( defined $password ) { $exp->expect( $timeout, [ qr/no\)\?\s+$/i => sub { my $self = shift; $self->send(yes\n); exp_continue; } ], [ qr/password:\s+$/i => sub { my $self = shift; $self->send($password\n); exp_continue; } ], '-re', qr/~/, #' wait for shell prompt, then exit expect );}You can look at the full source here: https://github.com/DavidGamba/bin/blob/master/cssh |
_unix.21075 | I know how to set Super_L (WinKey) buttonto open the Menu.gconftool-2 --set /apps/metacity/global_keybindings/panel_main_menu --type string Super_LCurrently, in order to close that menu, I am having to mouse click outside the menu area. I need to use the Super_L as a toggle button—pressing one time would open and pressing second time would close.So what I need now is to be able to close it when pressing it second time? | GNOME: Use WinKey (Super_L) as a main menu toggle | gnome;keyboard | (Edit) After having re-read the post and doing a bit more research into the subject, I found out my suggestion is a bit... stupid. But, I'll leave it here in case anyone finds inspiration from it in a similar venture.Try writing as small script called toggle.sh, put it somewhere.if `panel_is_open` close_panelelse open_panelorif [ `cat panel` == on ]; then close_panel echo 'off' > panelelse open_panel echo 'on' > panelfiSomething along those linesThen after --set use /path/to/toggle.sh |
_softwareengineering.273469 | I want my program to:read some input lines from CSV filewrite the output lines to plain string fileread some input from the same file in (2) and compare it to some calculated dataI want to consider these abstraction levels:create Dal interface with CRUD operationsimplement Dal<T1>, Dal<T2>, Dal<T3>create FileHandler interface with read and save operationsimplement CsvFileHandler, StringFileHandlerAnd then:Dal<T1> will implement read with a member of CsvFileHandlerDal<T2> will implement read and write with a member of StringFileHandlerDal<T3> will implement write with a member of StringFileHandlerIs it OK that Dal<T1> and Dal<T3> really implement Dal only partially (not all CRUD). Or should I choose other abstractions?I'm using guice DI and I need to differentiate Dal<T1> and Dal<T2> even though they both read / write type String. So I created a dummy different classes for T1, T2.Do you think I use too much abstraction? Are FileHandler and Dal overlapping?Any other way to differentiate Guice injection rather than create dummyTypes? | Do my dal and fileHandler interfaces overlap? | java;interfaces;persistence;google guice | null |
_codereview.128232 | I've got a simple Excel Data Manipulation Script to match one of my daily tasks, written in python 3. IntroLet's assume that I have 3 excel files: main.xlsx, 1.xlsx and 2.xlsx. In all of them I have a column named serial numbers. I have to:lookup for all serial numbers in 1.xlsx and 2.xlsx and verify if they are in main.xlsx.If a serial number is find:on the last column of main.xlsx, on the same row with the serial number that was find, write OK + name_of_the_file_in which_it_was_found. Else, write NOK. At the same time, write in 1.xlsx and 2.xlsx ok or nok on the last column if the serial number was found or not.Now, my script is simply creating new files with the last column appended (instead of appending directly to the same file), which is ok (but if you guys have a better method, shout it). What I'm looking for, is a way of making this as optimized as possible. I'm not looking for PEP8 comments as I'm aware of them, but I'll handle this part when I'll have this as optimized / improved as possible.Code:import petlmain = petl.fromxlsx('main.xlsx')one = petl.fromxlsx('1.xlsx', row_offset=1)two = petl.fromxlsx('2.xlsx')non_serial_rows = petl.select(main, lambda rec: rec['serial number'] is None)serial_rows = petl.select(main, lambda rec: rec['serial number'] is not None)main_join_one = petl.join(serial_rows, petl.cut(one, ['serial number']), key='serial number')main_join_one_file = petl.addfield(main_join_one, 'file', 'ok, 1.xlsx')main_join_two = petl.join(serial_rows, petl.cut(two, ['serial number']), key='serial number')main_join_two_file = petl.addfield(main_join_two, 'file', 'ok, 2.xlsx')stacked_joins = petl.stack(main_join_two_file, main_join_one_file)nok_rows = petl.antijoin(serial_rows, petl.cut(stacked_joins, ['serial number']), key='serial number')nok_rows = petl.addfield(nok_rows, 'file', 'NOK')output_main = petl.stack(stacked_joins, non_serial_rows, nok_rows)main_final = output_maindef main_compare(table): non_serial_rows = petl.select(table, lambda rec: rec['serial number'] is None) serial_rows = petl.select(table, lambda rec: rec['serial number'] is not None) ok_rows = petl.join(serial_rows, petl.cut(main, ['serial number']), key='serial number') ok_rows = petl.addfield(ok_rows, 'file', 'OK') nok_rows = petl.antijoin(serial_rows, petl.cut(main, ['serial number']), key='serial number') nok_rows = petl.addfield(nok_rows, 'file', 'NOK') return petl.stack(ok_rows, nok_rows, non_serial_rows)one_final = main_compare(one)two_final = main_compare(two)petl.toxlsx(main_final, 'mainNew.xlsx')petl.toxlsx(one_final, '1New.xlsx')petl.toxlsx(two_final, '2New.xlsx')Sample files, can be downloaded from here. (for those who have time to play a lil' bit with the code). | Excel Data Manipulation - parse, match and create | python;performance;python 3.x;excel | From a practical perspective, you should use object-oriented style for calling your transformations. It will reduce the amount of intermediate variables as you will be able to chain calls.From a conceptual perspective you want to apply the same transformations on all 3 files, there is not much differences whether you do it from n.xlsx to main.xlsx or the other way around. You need to:Extract serial numbers from a file;Associate them to a message (filename when used to fill main.xlsx or OK when used to fill n.xlsx);Add a column on an other file whose matching rows contains the messages and others contains NOK.Instead of that you:separate the row into categories (matching, not matching, no serial numbers);add a column to these categories depending on their kind;concatenate back those categories to get the resulting file out of them.The problems you run into doing that are that, for one you change the order of the rows by filtering and stacking back (but that doesn't seem to be an issue), and for two your filtering rules are both clumsy and iterating over the input more than once.The following approach iterates over each file exactly twice (one to extract the serial number/message pairs and one to add the required column) and uses functions to provide a generic approach that can easily be used to handle more files:import petlSERIAL_COLUMN = 'serial_number'def map_serial_to_message(table, message='OK'): return (table .selectisnot(SERIAL_COLUMN, None) .cut(SERIAL_COLUMN) .addfield('file', message))def create_new_column(table, allowed_serial, default_message='NOK'): return table.leftjoin( allowed_serial, key=SERIAL_COLUMN, missing=default_message)if __name__ == '__main__': main = petl.fromxlsx('main.xlsx') one = petl.fromxlsx('1.xlsx', row_offset=1) two = petl.fromxlsx('2.xlsx') files_serial = petl.stack( map_serial_to_message(one, 'OK, 1.xlsx'), map_serial_to_message(two, 'OK, 2.xlsx'), # other files if need be ) main_serial = map_serial_to_message(main) petl.toxlsx(create_new_column(main, files_serial), 'mainNew.xlsx') petl.toxlsx(create_new_column(one, main_serial), '1New.xlsx') petl.toxlsx(create_new_column(two, main_serial), '2New.xlsx')As regard to writing to the original file, you could look into creating the files in memory first and then, once they all are iterated over enough time, write them back. But if files are big, you might be limited by the amount of available memory.This is untested but it could look like:import petlSERIAL_COLUMN = 'serial_number'def map_serial_to_message(table, message='OK'): return (table .selectisnot(SERIAL_COLUMN, None) .cut(SERIAL_COLUMN) .addfield('file', message))def create_new_column(table, *args, default_message='NOK'): try: serials, = args except ValueError: serials = petl.stack(*args) sink = petl.MemorySource() (table .leftjoin(serials, key=SERIAL_COLUMN, missing=default_message) .toxlsx(sink)) return sink.getvalue()def write_to_file(data, filename): with open(filename, 'wb') as f: f.write(data)if __name__ == '__main__': main = petl.fromxlsx('main.xlsx') one = petl.fromxlsx('1.xlsx', row_offset=1) two = petl.fromxlsx('2.xlsx') main_serial = map_serial_to_message(main) # Warning, these may require large amount of memory new_main = create_new_column(main, map_serial_to_message(one, 'OK, 1.xlsx'), map_serial_to_message(two, 'OK, 2.xlsx'), # other files if need be ) new_one = create_new_column(one, main_serial) new_two = create_new_column(two, main_serial) # This is important to write after all transformations write_to_file(new_main, 'main.xlsx') write_to_file(new_one, '1.xlsx') write_to_file(new_two, '2.xlsx')I also changed the way to handle stacking serial-messages pairs from n.xlsx to provide a more automatic alternative. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.