Search is not available for this dataset
qid
int64
1
74.7M
question
stringlengths
1
70k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
0
115k
response_k
stringlengths
0
60.5k
1,354,385
I am using VMware Workstation 14 Pro, and I'm trying to run a virtual machine that I've downloaded from Microsoft and saved to an external USB solid-state drive. But when I attempt to open that VM (by selecting File|Open and navigating to the path on that drive), I get an Import dialog. [![Import Dialog Box](https://i.stack.imgur.com/XViYg.png)](https://i.stack.imgur.com/XViYg.png) I don't want to import the VM. I already have a bunch of VMs running from my hard drive. I just want to run the VM from its current location. In years past, I always ran VMs from a USB drive using VMWare Player. I realize it could hit performance problems but that's what I want to do. I really don't understand why this is a problem with VMWare Workstation.
2018/08/16
[ "https://superuser.com/questions/1354385", "https://superuser.com", "https://superuser.com/users/314943/" ]
This is because the downloaded VM is contained in an OVF file and needs to be imported. <https://pubs.vmware.com/workstation-9/index.jsp?topic=%2Fcom.vmware.ws.using.doc%2FGUID-DDCBE9C0-0EC9-4D09-8042-18436DA62F7A.html> Alternately, because an OVF file is just a compressed file containing all of the VM elements (configuration files, virtual hard disk, etc.) you can simply uncompress the OVF file with a tool like 7-Zip and then open it directly in VMware Workstation.
You can just use vmware to open (Workstation->File->Open) the VM. I might prompt you to ask whether the VM is copied or moved, selected moved.
31,768,830
I am doing a recursive walk through directories to make changes to files. My change file function needs the full path of the file to be able to do stuff. However, what my program is doing right now is just getting the name of the current file or folder but not the full path. My approach is that I would make a string and keeps appending names to it until I get the full path. However, because I'm doing recursion, I'm having troubles passing the string around to append more strings to it. This is my code: ``` #include <stdio.h> #include <stdlib.h> #include <regex.h> #include <string.h> #include <dirent.h> #include <unistd.h> #include <sys/types.h> #include <errno.h> void recursiveWalk(const char *pathName, char *fullPath, int level) { DIR *dir; struct dirent *entry; if (!(dir = opendir(pathName))) { fprintf(stderr, "Could not open directory\n"); return; } if (!(entry = readdir(dir))) { fprintf(stderr, "Could not read directory\n"); return; } do { if (entry->d_type == DT_DIR) { // found subdirectory char path[1024]; int len = snprintf(path, sizeof(path)-1, "%s/%s", pathName, entry->d_name); // get depth path[len] = 0; // skip hidden paths if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { continue; } fprintf(stdout, "%*s[%s]\n", level*2, "", entry->d_name); // Append fullPath to entry->d_name here recursiveWalk(path, fullPath, level + 1); } else { // files fprintf(stdout, "%*s- %s\n", level*2, "", entry->d_name); //changeFile(fullPath); } } while (entry = readdir(dir)); closedir(dir); } int main(int argn, char *argv[]) { int level = 0; recursiveWalk(".", "", level); return 0; } ```
2015/08/02
[ "https://Stackoverflow.com/questions/31768830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4807625/" ]
Well there are a number of little problems in your code. * you never use nor change `fullPath` in `recursiveWalk` * your formats are *weird* : you use `level*2` to limit the number of characters printed from an empty string * you compute the actual path only when you have found a directory, while you say you need it to change a file. * you add `path[len] = 0` after a `snprintf` when `snprintf` guarantees that but buffer is null terminated But apart from that, you correctly pass the path to the analyzed dir append to the path passed in initial call, but in `pathName` variable, and computed as `path`. So a possible fix for your code would be : * fix the formats for printf * remove the unused `fullPath` parameter from `recursiveWalk` * allways compute `path` and use it in the *file* branch * comment out the unnecessary `path[len] = '\0'` * I also replaced `while (entry = readdir(dir));` with `while ((entry = readdir(dir)));` to explicitely tell the compiler that I want to set entry and then test its value - and remove the warning Possible code: ``` #include <stdio.h> #include <stdlib.h> #include <regex.h> #include <string.h> #include <dirent.h> #include <unistd.h> #include <sys/types.h> #include <errno.h> void recursiveWalk(const char *pathName, int level) { DIR *dir; struct dirent *entry; if (!(dir = opendir(pathName))) { fprintf(stderr, "Could not open directory\n"); return; } if (!(entry = readdir(dir))) { fprintf(stderr, "Could not read directory\n"); return; } do { char path[1024]; int len = snprintf(path, sizeof(path)-1, "%s/%s", pathName, entry->d_name); // get depth // path[len] = 0; if (entry->d_type == DT_DIR) { // found subdirectory // skip hidden paths if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { continue; } fprintf(stdout, "%s [%s] (%d)\n", pathName, entry->d_name, level); // Append fullPath to entry->d_name here recursiveWalk(path, level + 1); } else { // files fprintf(stdout, "%s (%d)\n", path, level); //changeFile(fullPath); } } while ((entry = readdir(dir))); closedir(dir); } int main(int argn, char *argv[]) { int level = 0; recursiveWalk(".", level); return 0; } ```
Recursion is a succinct way to express things (especially walking directories), but actually you should normally avoid it in practice. If the directory tree is deep enough, it will crash your software. Using a queue eliminates the need for recursion, and is generally an efficient way to traverse. I'm including the code I use to process directory trees in a [project](https://github.com/uxcn/yafd)... ``` static int on_dir(const char* const dir, struct duplicate** dp) { bool r = opts.recurse; DIR* d = opendir(dir); if (!d) return - 1; struct dirent* de; while ((de = readdir(d))) { struct stat s; size_t bs = strlen(dir) + strlen(de->d_name) + 2; char b[bs]; const char* const a = strjoin(b, dir, de->d_name, '/'); if (lstat(a, &s)) { print_error("unable to stat %s", d); continue; } if (S_ISREG(s.st_mode)) if (on_file(a, &s, dp)) print_error("unable to process file %s/%s", dir, de->d_name); } if (!r) { if (closedir(d)) on_fatal("unable to close directory %s", dir); return 0; } rewinddir(d); while ((de = readdir(d))) { struct stat ds; size_t bs = strlen(dir) + strlen(de->d_name) + 2; char b[bs]; const char* const d = strjoin(b, dir, de->d_name, '/'); if (lstat(d, &ds)) { print_error("unable to stat %s", d); continue; } if (S_ISDIR(ds.st_mode)) { const char* const dot = "."; const char* const dotdot = ".."; if (!strcmp(dot, de->d_name) || !strcmp(dotdot, de->d_name)) continue; struct path* p = path_create(strcpy(fmalloc(bs), d)); queue_add(&paths, &p->queue); } } if (closedir(d)) print_error("unable to close directory %s", dir); return 0; } ``` and the code for `strjoin` ``` static inline char* strjoin(char* restrict const d, const char* restrict const a, const char* restrict const b, const char c) { size_t na = strlen(a); size_t nb = strlen(b); memcpy(d, a, na); d[na] = c; memcpy(d + na + 1, b, nb); d[na + nb + 1] = '\0'; return d; } ``` I'm hoping this helps. Please feel free to use any of the code you find in the git repository.
3,823,963
The same question is asked [here.](https://stackoverflow.com/questions/1675893/jquery-close-dialog-on-click-anywhere) but it doesn't state the source, and the solution given is not directly applicable in my case afaik. I might get modded down for this, but I am asking anyway. **My Entire Code:** ``` <html><head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/humanity/jquery-ui.css" type="text/css" /> </head> <body><div id="dialog" title="Title Box"> <p>Stuff here</p> </div> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 100, modal: true }); }); </script> <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Click to view</a> </body></html> ``` All script files are third party hosted, and I would want to keep it that way. ***How do I get "click anywhere (outside the box)to close the modal box" functionality?***
2010/09/29
[ "https://Stackoverflow.com/questions/3823963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/405861/" ]
``` <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/humanity/jquery-ui.css" type="text/css" /> </head> <body> <div id="dialog" title="Title Box"> <p>Stuff here</p> </div> <script type="text/javascript"> jQuery( function() { jQuery("#dialog") .dialog( { bgiframe: true, autoOpen: false, height: 100, modal: true } ); jQuery('body') .bind( 'click', function(e){ if( jQuery('#dialog').dialog('isOpen') && !jQuery(e.target).is('.ui-dialog, a') && !jQuery(e.target).closest('.ui-dialog').length ){ jQuery('#dialog').dialog('close'); } } ); } ); </script> <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Click to view</a> </body> </html> ```
Try this and tell me if it works (I don't have time to try right now) ``` $('body').click(function(){ if( $('#dialog').dialog("isOpen") ) { $('#dialog').dialog("close") } }); ```
3,823,963
The same question is asked [here.](https://stackoverflow.com/questions/1675893/jquery-close-dialog-on-click-anywhere) but it doesn't state the source, and the solution given is not directly applicable in my case afaik. I might get modded down for this, but I am asking anyway. **My Entire Code:** ``` <html><head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/humanity/jquery-ui.css" type="text/css" /> </head> <body><div id="dialog" title="Title Box"> <p>Stuff here</p> </div> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 100, modal: true }); }); </script> <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Click to view</a> </body></html> ``` All script files are third party hosted, and I would want to keep it that way. ***How do I get "click anywhere (outside the box)to close the modal box" functionality?***
2010/09/29
[ "https://Stackoverflow.com/questions/3823963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/405861/" ]
``` <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/humanity/jquery-ui.css" type="text/css" /> </head> <body> <div id="dialog" title="Title Box"> <p>Stuff here</p> </div> <script type="text/javascript"> jQuery( function() { jQuery("#dialog") .dialog( { bgiframe: true, autoOpen: false, height: 100, modal: true } ); jQuery('body') .bind( 'click', function(e){ if( jQuery('#dialog').dialog('isOpen') && !jQuery(e.target).is('.ui-dialog, a') && !jQuery(e.target).closest('.ui-dialog').length ){ jQuery('#dialog').dialog('close'); } } ); } ); </script> <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Click to view</a> </body> </html> ```
I know this has already has an accepted answer, but maybe this will help someone. It seems to me that it would be more efficient to bind a click onto the overlay div when the modal is opened. There is no need to unbind because jQueryUI destroys the overlay div on close. ``` jQuery(document).ready(function() { jQuery("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 100, modal: true, open: function(){ jQuery('.ui-widget-overlay').bind('click',function(){ jQuery('#dialog').dialog('close'); }) } }); }); ```
3,823,963
The same question is asked [here.](https://stackoverflow.com/questions/1675893/jquery-close-dialog-on-click-anywhere) but it doesn't state the source, and the solution given is not directly applicable in my case afaik. I might get modded down for this, but I am asking anyway. **My Entire Code:** ``` <html><head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/humanity/jquery-ui.css" type="text/css" /> </head> <body><div id="dialog" title="Title Box"> <p>Stuff here</p> </div> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 100, modal: true }); }); </script> <a href="#" onclick="jQuery('#dialog').dialog('open'); return false">Click to view</a> </body></html> ``` All script files are third party hosted, and I would want to keep it that way. ***How do I get "click anywhere (outside the box)to close the modal box" functionality?***
2010/09/29
[ "https://Stackoverflow.com/questions/3823963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/405861/" ]
I know this has already has an accepted answer, but maybe this will help someone. It seems to me that it would be more efficient to bind a click onto the overlay div when the modal is opened. There is no need to unbind because jQueryUI destroys the overlay div on close. ``` jQuery(document).ready(function() { jQuery("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 100, modal: true, open: function(){ jQuery('.ui-widget-overlay').bind('click',function(){ jQuery('#dialog').dialog('close'); }) } }); }); ```
Try this and tell me if it works (I don't have time to try right now) ``` $('body').click(function(){ if( $('#dialog').dialog("isOpen") ) { $('#dialog').dialog("close") } }); ```
28,034,653
I want to stack several images using imagemagick. The result I want is the same as I get when I import all images as layers into Gimp and set the layer transparency to some value. Each image is transparent with a circle in the center of various sizes. Overlaying all N images with a 100/N% opacity should give me something like a blurry blob with radially increasing transparency. Here are three example images. ![](https://i.stack.imgur.com/MvSLW.png) ![](https://i.stack.imgur.com/7ZLEg.png) ![](https://i.stack.imgur.com/HL6CG.png) However if I try to do this with imagemagick, I get a black background: ``` convert image50.png -background transparent -alpha set -channel A -fx "0.2" \( image60.png -background transparent -alpha set -channel A -fx "0.2" \) -compose overlay -composite -flatten result.png ``` Edit: After Mark Setchells latest comments, I got ![](https://i.stack.imgur.com/0zzoO.png) What I want is that those areas that appear in all images (the center in the example) add up to to non-transparent region, while those regions that appear only on fewer images get more and more transparent. Marks example seems to work for 3 images, but not for a larger stack. The result I would like to get would be this one (here I emphasize the transparent regions by adding a non-white background): ![](https://i.stack.imgur.com/Mx3VA.png) The example images are made from this one ![](https://i.stack.imgur.com/hjWgF.png) using this bash command: ``` for i in $(seq 10 10 90); do f="image$i.png" convert http://i.stack.imgur.com/hjWgF.png -quality 100 -fuzz $i% -fill white -transparent black $f done ```
2015/01/19
[ "https://Stackoverflow.com/questions/28034653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2108771/" ]
``` #!/bin/bash # Calculate how many images we have N=$(ls image*.png|wc -l) echo N:$N # Generate mask, start with black and add in components from each subsequent image i=0 convert image10.png -evaluate set 0 mask.png for f in image*png;do convert mask.png \( "$f" -alpha extract -evaluate divide $N \) -compose plus -composite mask.png done # Generate output image convert image*.png \ -compose overlay -composite \ mask.png -compose copy-opacity -composite out.png ```
What you need here is a different mode of compositing. You were using `-compose overlay` which is going to lighten up the result with each successive layer. What you probably want here is `-compose blend` to keep only the most saturated value or or just `-compose over` to layer them with no modifications.
36,500,784
Apologies if there is another feed with this same problem, I have tried different suggested solutions but I still get an error, and I cant see why! I want to update a row in my table using a html form. I have populated the form with the existing values, and want to be able to edit those and update them when the form is submitted, but I am getting this error: > > Fatal error: Uncaught exception 'PDOException' with message > 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' > in > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php:46 > Stack trace: #0 > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php(46): > PDOStatement->execute(Array) #1 {main} thrown in > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php > on line 46 > > > Here is the php / sql code: ``` if(isset($_POST['update'])) { $updateTitle = trim($_POST['title']); $updateDesc = trim($_POST['desc']); $updateRedeem = trim($_POST['redeem']); $updateStart = trim($_POST['start']); $updateExpiry = trim($_POST['expiry']); $updateCode = trim($_POST['code']); $updateTerms = trim($_POST['terms']); $updateImage = trim($_POST['image']); $updateUrl = trim($_POST['url']); $updateSql = 'UPDATE codes SET (title,description,redemption,start,expiry,textcode,terms,image,url) = (:title,:description,:redeem,:start,:exp,:code,:terms,:image,:url) WHERE id=:offerid'; $update = $db->prepare($updateSql); $update->execute(array(':title'=>$updateTitle,':description'=>$updateDesc,':redeem'=>$updateRedeem,':start'=>$updateStart,':exp'=>$updateExpiry,':code'=>$updateCode,':terms'=>$updateTerms,':image'=>$updateImage,':url'=>$updateUrl,':id'=>$offerID)); } ``` and the html form: ``` <form id="update_offer" class="col-md-6 col-md-offset-3" method="post" action="update_offer.php?id=<?php echo $offerID; ?>"> <div class="form-group col-md-12"> <label class="col-md-12" for="title">Title</label> <input id="title" class="form-control col-md-12" type="text" name="title" placeholder="Offer Title" value="<?php echo $title; ?>" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="desc">Description</label> <textarea id="desc" class="form-control col-md-12" name="desc" placeholder="Description" value="<?php echo $desc; ?>"></textarea> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="redeem">Redemption</label> <input id="redeem" class="form-control col-md-12" type="text" name="redeem" placeholder="Where to redeem" value="<?php echo $redeem; ?>" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="start">Start Date</label> <input id="start" class="form-control col-md-12" type="date" name="start" value="<?php echo $startDate->format('Y-m-d'); ?>" min="<?php echo date('Y-m-d') ?>" max="2021-12-31" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="expiry">Expiry Date</label> <input id="expiry" class="form-control col-md-12" type="date" name="expiry" value="<?php echo $expDate->format('Y-m-d'); ?>" min="<?php echo date('Y-m-d') ?>" max="2021-12-31" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="code">Code</label> <input id="code" class="form-control col-md-12" type="text" name="code" placeholder="Code (if applicable)" value="<?php echo $code; ?>"> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="terms">Terms</label> <textarea id="terms" class="form-control col-md-12" name="terms" placeholder="Terms & Conditions" value="<?php echo $terms; ?>" required></textarea> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="url">Offer URL</label> <input id="url" class="form-control col-md-12" type="text" name="url" placeholder="Offer URL (if applicable)" value="<?php echo $url; ?>"> </div> <div class="form-group col-md-12"> <label class="col-md-8" for="image">Image <img src="../images/offers/<?php echo $image; ?>" alt="" style="width: 200px;" /></label> <input id="image" class="form-control col-md-4" type="file" name="image"> </div> <div class="form-group col-md-12 pull-right"> <button id="update" type="submit" name="update" class="btn btn-primary"><i class="glyphicon glyphicon-refresh"></i> Update</button> </div> </form> ``` what am i doing wrong?! Im still learning php etc, so please be gentle, any help is much appreciated.
2016/04/08
[ "https://Stackoverflow.com/questions/36500784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5968121/" ]
First, you have wrong syntax for update statement, as other guys mentioned already, change: ``` UPDATE codes SET (title,description,redemption,start,expiry,textcode,terms,image,url) = (:title,:description,:redeem,:start,:exp,:code,:terms,:image,:url) WHERE id=:offerid ``` **Into** ``` UPDATE `codes` SET `title` = :title, `description` = :description, `redemption` = :redeem, `start` = :start `expiry` = :expiry `textcode` = :code `terms` = :terms `image` = :image `url` = :url WHERE `id` = :offerid ``` Learn more about the SQL Update syntax [here](http://dev.mysql.com/doc/refman/5.7/en/update.html). Then, one thing more you have a mistake in `execute()`. Change your `:id` into `:offerid` like below: ``` $update->execute(array( ':title' => $updateTitle, ':description' => $updateDesc, ':redeem' => $updateRedeem, ':start' => $updateStart, ':exp' => $updateExpiry, ':code' => $updateCode, ':terms' => $updateTerms, ':image' => $updateImage, ':url' => $updateUrl, ':offerid' => $offerID )); ```
You are using wrong syntax of Update It would be ``` $updateSql = "UPDATE codes SET title =:title, description =:description, redemption =:redeem, start =:start, expiry =:exp, textcode =:code, terms :=terms,image =:image, url =:url WHERE id=:id";// write id instead of offset because you are binding ':id'=>$offerID ``` Check <http://dev.mysql.com/doc/refman/5.7/en/update.html>
36,500,784
Apologies if there is another feed with this same problem, I have tried different suggested solutions but I still get an error, and I cant see why! I want to update a row in my table using a html form. I have populated the form with the existing values, and want to be able to edit those and update them when the form is submitted, but I am getting this error: > > Fatal error: Uncaught exception 'PDOException' with message > 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' > in > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php:46 > Stack trace: #0 > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php(46): > PDOStatement->execute(Array) #1 {main} thrown in > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php > on line 46 > > > Here is the php / sql code: ``` if(isset($_POST['update'])) { $updateTitle = trim($_POST['title']); $updateDesc = trim($_POST['desc']); $updateRedeem = trim($_POST['redeem']); $updateStart = trim($_POST['start']); $updateExpiry = trim($_POST['expiry']); $updateCode = trim($_POST['code']); $updateTerms = trim($_POST['terms']); $updateImage = trim($_POST['image']); $updateUrl = trim($_POST['url']); $updateSql = 'UPDATE codes SET (title,description,redemption,start,expiry,textcode,terms,image,url) = (:title,:description,:redeem,:start,:exp,:code,:terms,:image,:url) WHERE id=:offerid'; $update = $db->prepare($updateSql); $update->execute(array(':title'=>$updateTitle,':description'=>$updateDesc,':redeem'=>$updateRedeem,':start'=>$updateStart,':exp'=>$updateExpiry,':code'=>$updateCode,':terms'=>$updateTerms,':image'=>$updateImage,':url'=>$updateUrl,':id'=>$offerID)); } ``` and the html form: ``` <form id="update_offer" class="col-md-6 col-md-offset-3" method="post" action="update_offer.php?id=<?php echo $offerID; ?>"> <div class="form-group col-md-12"> <label class="col-md-12" for="title">Title</label> <input id="title" class="form-control col-md-12" type="text" name="title" placeholder="Offer Title" value="<?php echo $title; ?>" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="desc">Description</label> <textarea id="desc" class="form-control col-md-12" name="desc" placeholder="Description" value="<?php echo $desc; ?>"></textarea> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="redeem">Redemption</label> <input id="redeem" class="form-control col-md-12" type="text" name="redeem" placeholder="Where to redeem" value="<?php echo $redeem; ?>" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="start">Start Date</label> <input id="start" class="form-control col-md-12" type="date" name="start" value="<?php echo $startDate->format('Y-m-d'); ?>" min="<?php echo date('Y-m-d') ?>" max="2021-12-31" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="expiry">Expiry Date</label> <input id="expiry" class="form-control col-md-12" type="date" name="expiry" value="<?php echo $expDate->format('Y-m-d'); ?>" min="<?php echo date('Y-m-d') ?>" max="2021-12-31" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="code">Code</label> <input id="code" class="form-control col-md-12" type="text" name="code" placeholder="Code (if applicable)" value="<?php echo $code; ?>"> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="terms">Terms</label> <textarea id="terms" class="form-control col-md-12" name="terms" placeholder="Terms & Conditions" value="<?php echo $terms; ?>" required></textarea> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="url">Offer URL</label> <input id="url" class="form-control col-md-12" type="text" name="url" placeholder="Offer URL (if applicable)" value="<?php echo $url; ?>"> </div> <div class="form-group col-md-12"> <label class="col-md-8" for="image">Image <img src="../images/offers/<?php echo $image; ?>" alt="" style="width: 200px;" /></label> <input id="image" class="form-control col-md-4" type="file" name="image"> </div> <div class="form-group col-md-12 pull-right"> <button id="update" type="submit" name="update" class="btn btn-primary"><i class="glyphicon glyphicon-refresh"></i> Update</button> </div> </form> ``` what am i doing wrong?! Im still learning php etc, so please be gentle, any help is much appreciated.
2016/04/08
[ "https://Stackoverflow.com/questions/36500784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5968121/" ]
First, you have wrong syntax for update statement, as other guys mentioned already, change: ``` UPDATE codes SET (title,description,redemption,start,expiry,textcode,terms,image,url) = (:title,:description,:redeem,:start,:exp,:code,:terms,:image,:url) WHERE id=:offerid ``` **Into** ``` UPDATE `codes` SET `title` = :title, `description` = :description, `redemption` = :redeem, `start` = :start `expiry` = :expiry `textcode` = :code `terms` = :terms `image` = :image `url` = :url WHERE `id` = :offerid ``` Learn more about the SQL Update syntax [here](http://dev.mysql.com/doc/refman/5.7/en/update.html). Then, one thing more you have a mistake in `execute()`. Change your `:id` into `:offerid` like below: ``` $update->execute(array( ':title' => $updateTitle, ':description' => $updateDesc, ':redeem' => $updateRedeem, ':start' => $updateStart, ':exp' => $updateExpiry, ':code' => $updateCode, ':terms' => $updateTerms, ':image' => $updateImage, ':url' => $updateUrl, ':offerid' => $offerID )); ```
thanks for your replies. My original update syntax was actually as you mentioned, I had changed it when looking through some other solutions, and not changed it back, but either way, even with correct syntax, I still got the same error. Looking through your replies, I can see that I have ':id'=> $offerID but have used :offerid in the sql code, which obviously needs to be updated, so thanks for pointing that out! Hopefully that will fix the problem...
36,500,784
Apologies if there is another feed with this same problem, I have tried different suggested solutions but I still get an error, and I cant see why! I want to update a row in my table using a html form. I have populated the form with the existing values, and want to be able to edit those and update them when the form is submitted, but I am getting this error: > > Fatal error: Uncaught exception 'PDOException' with message > 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' > in > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php:46 > Stack trace: #0 > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php(46): > PDOStatement->execute(Array) #1 {main} thrown in > /Applications/XAMPP/xamppfiles/htdocs/love-deals/admin/update\_offer.php > on line 46 > > > Here is the php / sql code: ``` if(isset($_POST['update'])) { $updateTitle = trim($_POST['title']); $updateDesc = trim($_POST['desc']); $updateRedeem = trim($_POST['redeem']); $updateStart = trim($_POST['start']); $updateExpiry = trim($_POST['expiry']); $updateCode = trim($_POST['code']); $updateTerms = trim($_POST['terms']); $updateImage = trim($_POST['image']); $updateUrl = trim($_POST['url']); $updateSql = 'UPDATE codes SET (title,description,redemption,start,expiry,textcode,terms,image,url) = (:title,:description,:redeem,:start,:exp,:code,:terms,:image,:url) WHERE id=:offerid'; $update = $db->prepare($updateSql); $update->execute(array(':title'=>$updateTitle,':description'=>$updateDesc,':redeem'=>$updateRedeem,':start'=>$updateStart,':exp'=>$updateExpiry,':code'=>$updateCode,':terms'=>$updateTerms,':image'=>$updateImage,':url'=>$updateUrl,':id'=>$offerID)); } ``` and the html form: ``` <form id="update_offer" class="col-md-6 col-md-offset-3" method="post" action="update_offer.php?id=<?php echo $offerID; ?>"> <div class="form-group col-md-12"> <label class="col-md-12" for="title">Title</label> <input id="title" class="form-control col-md-12" type="text" name="title" placeholder="Offer Title" value="<?php echo $title; ?>" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="desc">Description</label> <textarea id="desc" class="form-control col-md-12" name="desc" placeholder="Description" value="<?php echo $desc; ?>"></textarea> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="redeem">Redemption</label> <input id="redeem" class="form-control col-md-12" type="text" name="redeem" placeholder="Where to redeem" value="<?php echo $redeem; ?>" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="start">Start Date</label> <input id="start" class="form-control col-md-12" type="date" name="start" value="<?php echo $startDate->format('Y-m-d'); ?>" min="<?php echo date('Y-m-d') ?>" max="2021-12-31" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="expiry">Expiry Date</label> <input id="expiry" class="form-control col-md-12" type="date" name="expiry" value="<?php echo $expDate->format('Y-m-d'); ?>" min="<?php echo date('Y-m-d') ?>" max="2021-12-31" required> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="code">Code</label> <input id="code" class="form-control col-md-12" type="text" name="code" placeholder="Code (if applicable)" value="<?php echo $code; ?>"> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="terms">Terms</label> <textarea id="terms" class="form-control col-md-12" name="terms" placeholder="Terms & Conditions" value="<?php echo $terms; ?>" required></textarea> </div> <div class="form-group col-md-12"> <label class="col-md-12" for="url">Offer URL</label> <input id="url" class="form-control col-md-12" type="text" name="url" placeholder="Offer URL (if applicable)" value="<?php echo $url; ?>"> </div> <div class="form-group col-md-12"> <label class="col-md-8" for="image">Image <img src="../images/offers/<?php echo $image; ?>" alt="" style="width: 200px;" /></label> <input id="image" class="form-control col-md-4" type="file" name="image"> </div> <div class="form-group col-md-12 pull-right"> <button id="update" type="submit" name="update" class="btn btn-primary"><i class="glyphicon glyphicon-refresh"></i> Update</button> </div> </form> ``` what am i doing wrong?! Im still learning php etc, so please be gentle, any help is much appreciated.
2016/04/08
[ "https://Stackoverflow.com/questions/36500784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5968121/" ]
You are using wrong syntax of Update It would be ``` $updateSql = "UPDATE codes SET title =:title, description =:description, redemption =:redeem, start =:start, expiry =:exp, textcode =:code, terms :=terms,image =:image, url =:url WHERE id=:id";// write id instead of offset because you are binding ':id'=>$offerID ``` Check <http://dev.mysql.com/doc/refman/5.7/en/update.html>
thanks for your replies. My original update syntax was actually as you mentioned, I had changed it when looking through some other solutions, and not changed it back, but either way, even with correct syntax, I still got the same error. Looking through your replies, I can see that I have ':id'=> $offerID but have used :offerid in the sql code, which obviously needs to be updated, so thanks for pointing that out! Hopefully that will fix the problem...
70,966,975
``` string = "C:\\folder\\important\\week1.xlsx" ``` I need to extract the file name alone, "week1.xlsx" from this string. But for some reason, it doesn't work.
2022/02/03
[ "https://Stackoverflow.com/questions/70966975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15044904/" ]
You can use `basename`: ``` import os str(os.path.basename("C:\\folder\\important\\week1.xlsx")) => 'week1.xlsx' ```
Try: ``` filename = string[string.rfind('\\')+1:] ``` Here's [more info on rfind()](https://www.geeksforgeeks.org/python-string-rfind-method/).
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
**First:** Hello. Welcome. Thank you for coming to see us today. Take a seat. Coffee. Put interviewee at ease. **Then:** *"Tell me about the experience you had getting here today."* It has no correct answer since the interviewer knows nothing about the journey. But the interviewee actually undertook the complete experience so should be very much in a comfort zone. It's great for seeing what was noticed, how it is communicated to someone who wasn't there, and of course it's very much a case of seeing if they pick up on what you are expecting of them and can convey the experience descriptively and passionately ( or not...) and if they can actually 'tell a story' in the process. It's such a lovely little big question.
1. Ask very open ended questions, as indicated in the other answers, to see if the person can explain and explore their world and their experience well, and communicate it to you. 2. Ask them slightly more focussed questions on what they like to see and don't like to see on sites and why. Make sure you are verifying their REASONING not their CHOICES. 3. Test them in an exercise, and be sure that their processes, not their results, are what you are looking at. 4. Quiz them on how they will deal with recalitrant developers, pushy managers, incompetent co-workers and over-optimistic sales people.
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
**First:** Hello. Welcome. Thank you for coming to see us today. Take a seat. Coffee. Put interviewee at ease. **Then:** *"Tell me about the experience you had getting here today."* It has no correct answer since the interviewer knows nothing about the journey. But the interviewee actually undertook the complete experience so should be very much in a comfort zone. It's great for seeing what was noticed, how it is communicated to someone who wasn't there, and of course it's very much a case of seeing if they pick up on what you are expecting of them and can convey the experience descriptively and passionately ( or not...) and if they can actually 'tell a story' in the process. It's such a lovely little big question.
**List five principles of a usable web site** <http://www.slideshare.net/eralston/top-5-usability-principles> <http://www.pjb.co.uk/t-learning/usability_principles.htm> <http://www.useit.com/papers/heuristic/heuristic_list.html> <http://www.luckydogarts.com/dm158/docs/posit.pdf> **Explain the basics of conducting a usability test** <http://www.utexas.edu/learn/usability/index.html> <http://www.webcredible.co.uk/user-friendly-resources/web-usability/usability-testing.shtml> <http://www.uie.com/articles/usability_testing_mistakes/> **Bring up a site with excellent user experience on my computer/laptop/projector; now show us why you think it is excellent** **Explain some likely UX issues with this web site (our web site, a random site, a huge site like Amazon or MSN)** **What others have to say:** <http://www.w3.org/WAI/EO/Drafts/UCD/questions.html> <http://www.stepforth.com/archives/2005-news/Kim-Krause-Berg-interview.shtml> <http://siwiki.wetpaint.com/page/Human+Computer+Interaction+Interview+Questions>
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
One thing we always do is a design exercise that is abstracted away from the specifics our application. It tests the creativity and interaction design talents of the applicant. There are half a dozen different answers, and any are good, we just want to see thought process. The specifics of the test have to do with taking something with alot of values and binning them into groups.
OH. I came across a [great doc on Slideshare](http://www.slideshare.net/nadeemkhan/user-experience-interview-questions) yesterday. It has common questions, UX/UI specific questions, and questions that were asked by Fortune companies.
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
If you had the power to change one object/device/software application you use regularly, what would it be? How would you change it? I would then listen for answers to the 2 questions I didn't ask "why change it?" and "what will the implications be?" Everyone can come up with ideas but few people can explain them well and see the bigger picture.
OH. I came across a [great doc on Slideshare](http://www.slideshare.net/nadeemkhan/user-experience-interview-questions) yesterday. It has common questions, UX/UI specific questions, and questions that were asked by Fortune companies.
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
One thing we always do is a design exercise that is abstracted away from the specifics our application. It tests the creativity and interaction design talents of the applicant. There are half a dozen different answers, and any are good, we just want to see thought process. The specifics of the test have to do with taking something with alot of values and binning them into groups.
**List five principles of a usable web site** <http://www.slideshare.net/eralston/top-5-usability-principles> <http://www.pjb.co.uk/t-learning/usability_principles.htm> <http://www.useit.com/papers/heuristic/heuristic_list.html> <http://www.luckydogarts.com/dm158/docs/posit.pdf> **Explain the basics of conducting a usability test** <http://www.utexas.edu/learn/usability/index.html> <http://www.webcredible.co.uk/user-friendly-resources/web-usability/usability-testing.shtml> <http://www.uie.com/articles/usability_testing_mistakes/> **Bring up a site with excellent user experience on my computer/laptop/projector; now show us why you think it is excellent** **Explain some likely UX issues with this web site (our web site, a random site, a huge site like Amazon or MSN)** **What others have to say:** <http://www.w3.org/WAI/EO/Drafts/UCD/questions.html> <http://www.stepforth.com/archives/2005-news/Kim-Krause-Berg-interview.shtml> <http://siwiki.wetpaint.com/page/Human+Computer+Interaction+Interview+Questions>
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
If you had the power to change one object/device/software application you use regularly, what would it be? How would you change it? I would then listen for answers to the 2 questions I didn't ask "why change it?" and "what will the implications be?" Everyone can come up with ideas but few people can explain them well and see the bigger picture.
One thing we always do is a design exercise that is abstracted away from the specifics our application. It tests the creativity and interaction design talents of the applicant. There are half a dozen different answers, and any are good, we just want to see thought process. The specifics of the test have to do with taking something with alot of values and binning them into groups.
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
1. Ask very open ended questions, as indicated in the other answers, to see if the person can explain and explore their world and their experience well, and communicate it to you. 2. Ask them slightly more focussed questions on what they like to see and don't like to see on sites and why. Make sure you are verifying their REASONING not their CHOICES. 3. Test them in an exercise, and be sure that their processes, not their results, are what you are looking at. 4. Quiz them on how they will deal with recalitrant developers, pushy managers, incompetent co-workers and over-optimistic sales people.
**List five principles of a usable web site** <http://www.slideshare.net/eralston/top-5-usability-principles> <http://www.pjb.co.uk/t-learning/usability_principles.htm> <http://www.useit.com/papers/heuristic/heuristic_list.html> <http://www.luckydogarts.com/dm158/docs/posit.pdf> **Explain the basics of conducting a usability test** <http://www.utexas.edu/learn/usability/index.html> <http://www.webcredible.co.uk/user-friendly-resources/web-usability/usability-testing.shtml> <http://www.uie.com/articles/usability_testing_mistakes/> **Bring up a site with excellent user experience on my computer/laptop/projector; now show us why you think it is excellent** **Explain some likely UX issues with this web site (our web site, a random site, a huge site like Amazon or MSN)** **What others have to say:** <http://www.w3.org/WAI/EO/Drafts/UCD/questions.html> <http://www.stepforth.com/archives/2005-news/Kim-Krause-Berg-interview.shtml> <http://siwiki.wetpaint.com/page/Human+Computer+Interaction+Interview+Questions>
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
1. Ask very open ended questions, as indicated in the other answers, to see if the person can explain and explore their world and their experience well, and communicate it to you. 2. Ask them slightly more focussed questions on what they like to see and don't like to see on sites and why. Make sure you are verifying their REASONING not their CHOICES. 3. Test them in an exercise, and be sure that their processes, not their results, are what you are looking at. 4. Quiz them on how they will deal with recalitrant developers, pushy managers, incompetent co-workers and over-optimistic sales people.
OH. I came across a [great doc on Slideshare](http://www.slideshare.net/nadeemkhan/user-experience-interview-questions) yesterday. It has common questions, UX/UI specific questions, and questions that were asked by Fortune companies.
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
If you had the power to change one object/device/software application you use regularly, what would it be? How would you change it? I would then listen for answers to the 2 questions I didn't ask "why change it?" and "what will the implications be?" Everyone can come up with ideas but few people can explain them well and see the bigger picture.
1. Ask very open ended questions, as indicated in the other answers, to see if the person can explain and explore their world and their experience well, and communicate it to you. 2. Ask them slightly more focussed questions on what they like to see and don't like to see on sites and why. Make sure you are verifying their REASONING not their CHOICES. 3. Test them in an exercise, and be sure that their processes, not their results, are what you are looking at. 4. Quiz them on how they will deal with recalitrant developers, pushy managers, incompetent co-workers and over-optimistic sales people.
16,643
Which questions are most successful at gauging the UX design experience in a candidate? What approaches are best used during a job interview for a UX design position?
2012/01/27
[ "https://ux.stackexchange.com/questions/16643", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/5113/" ]
**First:** Hello. Welcome. Thank you for coming to see us today. Take a seat. Coffee. Put interviewee at ease. **Then:** *"Tell me about the experience you had getting here today."* It has no correct answer since the interviewer knows nothing about the journey. But the interviewee actually undertook the complete experience so should be very much in a comfort zone. It's great for seeing what was noticed, how it is communicated to someone who wasn't there, and of course it's very much a case of seeing if they pick up on what you are expecting of them and can convey the experience descriptively and passionately ( or not...) and if they can actually 'tell a story' in the process. It's such a lovely little big question.
OH. I came across a [great doc on Slideshare](http://www.slideshare.net/nadeemkhan/user-experience-interview-questions) yesterday. It has common questions, UX/UI specific questions, and questions that were asked by Fortune companies.
27,593,856
`pair` looks like this: ``` std::vector<std::pair<uint64 /*id*/, std::string /*message*/> ``` And if I want 3 variables in `vector`? Can I use pair or what?
2014/12/21
[ "https://Stackoverflow.com/questions/27593856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3925125/" ]
If I have understood correctly you could use `std::tuple` declared in header `<tuple>`. For example ``` std::vector<std::tuple<uint64, std::string, SomeOtherType>> v; ```
In C++ sometimes I find quite useful to define trivial all-public data-only classes like ``` struct Event { int id = 0; std::string msg = ""; double time = 0.; }; ``` Surely a bit of typing, but IMO way better than having to use `e.second` or `std::get<1>(e)` instead of `e.msg` everywhere in the code. Writing is done once, reading many times. Saving writing time at the expense of increasing reading/understanding time is a Very Bad Idea. The drawback of this approach is that you cannot access the n-th member of the structure in metaprograms, but C++ metaprogramming is terribly weak anyway for a lot of other reasons so if you really need to have non-trivial metacode I'd suggest moving out of C++ and using an external C++ code generator written in a decent language instead of template tricks and hacks.
27,593,856
`pair` looks like this: ``` std::vector<std::pair<uint64 /*id*/, std::string /*message*/> ``` And if I want 3 variables in `vector`? Can I use pair or what?
2014/12/21
[ "https://Stackoverflow.com/questions/27593856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3925125/" ]
If I have understood correctly you could use `std::tuple` declared in header `<tuple>`. For example ``` std::vector<std::tuple<uint64, std::string, SomeOtherType>> v; ```
If you don't want C++11, you can use ``` std::pair<uint64, std::pair<std::string, SomeOtherType> > ``` But this is as wrong as trying to put three values to a *pair*. Why I consider it wrong? A *pair* means *two* values. If you put *three* or any other number of values in a *pair*, you are doing something like [this](https://stackoverflow.com/a/771974/446252).
27,593,856
`pair` looks like this: ``` std::vector<std::pair<uint64 /*id*/, std::string /*message*/> ``` And if I want 3 variables in `vector`? Can I use pair or what?
2014/12/21
[ "https://Stackoverflow.com/questions/27593856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3925125/" ]
In C++ sometimes I find quite useful to define trivial all-public data-only classes like ``` struct Event { int id = 0; std::string msg = ""; double time = 0.; }; ``` Surely a bit of typing, but IMO way better than having to use `e.second` or `std::get<1>(e)` instead of `e.msg` everywhere in the code. Writing is done once, reading many times. Saving writing time at the expense of increasing reading/understanding time is a Very Bad Idea. The drawback of this approach is that you cannot access the n-th member of the structure in metaprograms, but C++ metaprogramming is terribly weak anyway for a lot of other reasons so if you really need to have non-trivial metacode I'd suggest moving out of C++ and using an external C++ code generator written in a decent language instead of template tricks and hacks.
If you don't want C++11, you can use ``` std::pair<uint64, std::pair<std::string, SomeOtherType> > ``` But this is as wrong as trying to put three values to a *pair*. Why I consider it wrong? A *pair* means *two* values. If you put *three* or any other number of values in a *pair*, you are doing something like [this](https://stackoverflow.com/a/771974/446252).
906,752
Given any meromorphic function, can it be represented as $$c\prod\_i (z-z\_i)^{n\_i} $$ where $ n\_i\in\mathbb Z$ and $n\_i> 0$ denotes the multiplicity of the zero $ z\_i $ and $ n\_i <0$ for the poles?
2014/08/23
[ "https://math.stackexchange.com/questions/906752", "https://math.stackexchange.com", "https://math.stackexchange.com/users/163/" ]
Short answer: Not all, but... Turns out this is more complicated than [user170431's answer](https://math.stackexchange.com/a/906760/163) suggested, though it hinted at the correct direction. Given a meromorphic function $f(z)$ with poles at $\{p\_i\}$ of multiplicites $\{n\_{p\_i}\}$, one can indeed use [Mittag-Leffler's theorem](http://en.wikipedia.org/wiki/Mittag-Leffler%27s_theorem) to obtain a holomorphic function $$h(z) = f(z) - \sum\_i \pi\_{p\_i}(1/(z-p\_i))$$ where $\pi\_{p\_i}$ denotes a polynomial of degree $n\_{p\_i}$, and due to their finite order (meromorphic functions don't have essential singularities) one can expand $f(z)$ to the common denominator. What the other answer and my question's assumption did however neglect was the full extend of the [Weierstrass factorization theorem](http://en.wikipedia.org/wiki/Weierstrass_factorization_theorem), according to which $h(z)$ actually factorizes into $$h(z) = e^{g(z)}\prod\_j(z-z\_j)^{n\_{z\_j}}$$ where $n\_{z\_j}$ denotes the multiplicity of the zero $z\_j$ and $g(z)$ is an entire function. Note that I simplified matters here, for infinitely many zeros (or of infinite multiplicity) parts of the exponential are inside the product as "elementary factors" in order to have the infinite product converge. In my sloppy notation, they are part of $\exp g(z)$ though. Therefore, the actual representation of a meromorphic function is $$f(z) = e^{g(z)}\prod\_i(z-z\_i)^{n\_i}$$ (now the $z\_i$ also include the poles again, as in the question's notation). Only if there are finitely many zeros of finite multiplicities (i.e. a quotient of two polynomials), the representation without an exponential in front (i.e. a constant $g(z)$) is valid.
Yes, this is [Mittag-Leffler's theorem](http://en.wikipedia.org/wiki/Mittag-Leffler%27s_theorem) combined with the [Weierstrass factorization theorem](http://en.wikipedia.org/wiki/Weierstrass_factorization_theorem) after reducing to the common denominator.
23,246,560
I noticed that one of my submission pages with ReCaptcha is pulling this file: ``` http://www.google.com/js/th/tCBzJRqneV5tJFCAUdKmLPYTyVH8SN5m5IZzuhnsVzY.js ``` Of course, being hosted at Google, I want to assume this must be fine. Although the file contents start with this: ``` /* Anti-spam. Questions? Write to (rot13) [email protected] */ ``` ...followed by a very long `eval()` statement. This is the beginning of it (edit: this is now the entire code block): ``` (function(){eval('var f=function(a,b,c){if(b=typeof a,"object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;if(c=Object.prototype.toString.call(a),"[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==b&&"undefined"==typeof a.call)return"object";return b},n=function(a,b,c,d,e){c=a.split("."),d=g,c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(;c.length&&(e=c.shift());)c.length||b===k?d=d[e]?d[e]:d[e]={}:d[e]=b},p=Date.now||function(){return+new Date},r=/&/g,t=/</g,u=/>/g,w=/"/g,x=/\'/g,k=void 0,g=this,z,A="".oa?"".ma():"",E=(/[&<>"\']/.test(A)&&(-1!=A.indexOf("&")&&(A=A.replace(r,"&amp;")),-1!=A.indexOf("<")&&(A=A.replace(t,"&lt;")),-1!=A.indexOf(">")&&(A=A.replace(u,"&gt;")),-1!=A.indexOf(\'"\')&&(A=A.replace(w,"&quot;")),-1!=A.indexOf("\'")&&(A=A.replace(x,"&#39;"))),new function(){p()},function(a,b,c,d,e,h){try{if(this.j=2048,this.c=[],B(this,this.b,0),B(this,this.l,0),B(this,this.p,0),B(this,this.h,[]),B(this,this.d,[]),B(this,this.H,"object"==typeof window?window:g),B(this,this.I,this),B(this,this.r,0),B(this,this.F,0),B(this,this.G,0),B(this,this.f,C(4)),B(this,this.o,[]),B(this,this.k,{}),this.q=true,a&&","==a[0])this.m=a;else{if(window.atob){for(c=window.atob(a),a=[],e=d=0;e<c.length;e++){for(h=c.charCodeAt(e);255<h;)a[d++]=h&255,h>>=8;a[d++]=h}b=a}else b=null;(this.e=b)&&this.e.length?(this.K=[],this.s()):this.g(this.U)}}catch(l){D(this,l)}}),G=(E.prototype.g=function(a,b,c,d){d=this.a(this.l),a=[a,d>>8&255,d&255],c!=k&&a.push(c),0==this.a(this.h).length&&(this.c[this.h]=k,B(this,this.h,a)),c="",b&&(b.message&&(c+=b.message),b.stack&&(c+=":"+b.stack)),3<this.j&&(c=c.slice(0,this.j-3),this.j-=c.length+3,c=F(c),G(this,this.f,H(c.length,2).concat(c),this.$))},function(a,b,c,d,e,h){for(e=a.a(b),b=b==a.f?function(b,c,d,h){if(c=e.length,d=c-4>>3,e.ba!=d){e.ba=d,d=(d<<3)-4,h=[0,0,0,a.a(a.G)];try{e.aa=I(J(e,d),J(e,d+4),h)}catch(s){throw s;}}e.push(e.aa[c&7]^b)}:function(a){e.push(a)},d&&b(d&255),d=c.length,h=0;h<d;h++)b(c[h])}),K=function(a,b,c,d,e,h,l,q,m){return c=function(a,s,v){for(a=d[e.D],s=a===b,a=a&&a[e.D],v=0;a&&a!=h&&a!=l&&a!=q&&a!=m&&20>v;)v++,a=a[e.D];return c[e.ga+s+!(!a+(v>>2))]},d=function(){return c()},e=E.prototype,h=e.s,l=e.Q,m=e.g,q=E,d[e.J]=e,c[e.fa]=a,a=k,d},L=function(a,b,c){if(b=a.a(a.b),!(b in a.e))throw a.g(a.Y),a.u;return a.t==k&&(a.t=J(a.e,b-4),a.B=k),a.B!=b>>3&&(a.B=b>>3,c=[0,0,0,a.a(a.p)],a.Z=I(a.t,a.B,c)),B(a,a.b,b+1),a.e[b]^a.Z[b%8]},F=function(a,b,c,d,e){for(a=a.replace(/\\r\\n/g,"\\n"),b=[],d=c=0;d<a.length;d++)e=a.charCodeAt(d),128>e?b[c++]=e:(2048>e?b[c++]=e>>6|192:(b[c++]=e>>12|224,b[c++]=e>>6&63|128),b[c++]=e&63|128);return b},B=function(a,b,c){if(b==a.b||b==a.l)a.c[b]?a.c[b].V(c):a.c[b]=M(c);else if(b!=a.d&&b!=a.f&&b!=a.h||!a.c[b])a.c[b]=K(c,a.a);b==a.p&&(a.t=k,B(a,a.b,a.a(a.b)+4))},I=function(a,b,c,d){try{for(d=0;76138654016!=d;)a+=(b<<4^b>>>5)+b^d+c[d&3],d+=2379332938,b+=(a<<4^a>>>5)+a^d+c[d>>>11&3];return[a>>>24,a>>16&255,a>>8&255,a&255,b>>>24,b>>16&255,b>>8&255,b&255]}catch(e){throw e;}},N=function(a,b){return b<=a.ca?b==a.h||b==a.d||b==a.f||b==a.o?a.n:b==a.P||b==a.H||b==a.I||b==a.k?a.v:b==a.w?a.i:4:[1,2,4,a.n,a.v,a.i][b%a.da]},O=(E.prototype.la=function(a,b){b.push(a[0]<<24|a[1]<<16|a[2]<<8|a[3]),b.push(a[4]<<24|a[5]<<16|a[6]<<8|a[7]),b.push(a[8]<<24|a[9]<<16|a[10]<<8|a[11])},function(a,b,c,d){for(b={},b.N=a.a(L(a)),b.O=L(a),c=L(a)-1,d=L(a),b.self=a.a(d),b.C=[];c--;)d=L(a),b.C.push(a.a(d));return b}),Q=(E.prototype.ja=function(a,b,c,d){if(3==a.length){for(c=0;3>c;c++)b[c]+=a[c];for(d=[13,8,13,12,16,5,3,10,15],c=0;9>c;c++)b[3](b,c%3,d[c])}},function(a,b,c,d){return c=a.a(a.b),a.e&&c<a.e.length?(B(a,a.b,a.e.length),P(a,b)):B(a,a.b,b),d=a.s(),B(a,a.b,c),d}),H=(E.prototype.ka=function(a,b,c,d){d=a[(b+2)%3],a[b]=a[b]-a[(b+1)%3]-d^(1==b?d<<c:d>>>c)},function(a,b,c,d){for(d=b-1,c=[];0<=d;d--)c[b-1-d]=a>>8*d&255;return c}),M=function(a,b,c){return b=function(){return c()},b.V=function(b){a=b},c=function(){return a},b},R=function(a,b,c,d){return function(){if(!d||a.q)return B(a,a.P,arguments),B(a,a.k,c),Q(a,b)}},P=(E.prototype.a=function(a,b){if(b=this.c[a],b===k)throw this.g(this.ea,0,a),this.u;return b()},function(a,b){a.K.push(a.c.slice()),a.c[a.b]=k,B(a,a.b,b)}),J=function(a,b){return a[b]<<24|a[b+1]<<16|a[b+2]<<8|a[b+3]},C=function(a,b){for(b=Array(a);a--;)b[a]=255*Math.random()|0;return b},D=function(a,b){a.m=("E:"+b.message+":"+b.stack).slice(0,2048)};z=E.prototype,z.M=[function(){},function(a,b,c,d,e){b=L(a),c=L(a),d=a.a(b),b=N(a,b),e=N(a,c),e==a.i||e==a.n?d=""+d:0<b&&(1==b?d&=255:2==b?d&=65535:4==b&&(d&=4294967295)),B(a,c,d)},function(a,b,c,d,e,h,l,q,m){if(b=L(a),c=N(a,b),0<c){for(d=0;c--;)d=d<<8|L(a);B(a,b,d)}else if(c!=a.v){if(d=L(a)<<8|L(a),c==a.i)if(c="",a.c[a.w]!=k)for(e=a.a(a.w);d--;)h=e[L(a)<<8|L(a)],c+=h;else{for(c=Array(d),e=0;e<d;e++)c[e]=L(a);for(d=c,c=[],h=e=0;e<d.length;)l=d[e++],128>l?c[h++]=String.fromCharCode(l):191<l&&224>l?(q=d[e++],c[h++]=String.fromCharCode((l&31)<<6|q&63)):(q=d[e++],m=d[e++],c[h++]=String.fromCharCode((l&15)<<12|(q&63)<<6|m&63));c=c.join("")}else for(c=Array(d),e=0;e<d;e++)c[e]=L(a);B(a,b,c)}},function(a){L(a)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),c=a.a(c),b=a.a(b),B(a,d,b[c])},function(a,b,c){b=L(a),c=L(a),b=a.a(b),B(a,c,f(b))},function(a,b,c,d,e){b=L(a),c=L(a),d=N(a,b),e=N(a,c),c!=a.h&&(d==a.i&&e==a.i?(a.c[c]==k&&B(a,c,""),B(a,c,a.a(c)+a.a(b))):e==a.n&&(0>d?(b=a.a(b),d==a.i&&(b=F(""+b)),c!=a.d&&c!=a.f&&c!=a.o||G(a,c,H(b.length,2)),G(a,c,b)):0<d&&G(a,c,H(a.a(b),d))))},function(a,b,c){b=L(a),c=L(a),B(a,c,function(a){return eval(a)}(a.a(b)))},function(a,b,c){b=L(a),c=L(a),B(a,c,a.a(c)-a.a(b))},function(a,b){b=O(a),B(a,b.O,b.N.apply(b.self,b.C))},function(a,b,c){b=L(a),c=L(a),B(a,c,a.a(c)%a.a(b))},function(a,b,c,d,e){b=L(a),c=a.a(L(a)),d=a.a(L(a)),e=a.a(L(a)),a.a(b).addEventListener(c,R(a,d,e,true),false)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),a.a(b)[a.a(c)]=a.a(d)},function(){},function(a,b,c){b=L(a),c=L(a),B(a,c,a.a(c)+a.a(b))},function(a,b,c){b=L(a),c=L(a),0!=a.a(b)&&B(a,a.b,a.a(c))},function(a,b,c,d){b=L(a),c=L(a),d=L(a),a.a(b)==a.a(c)&&B(a,d,a.a(d)+1)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),a.a(b)>a.a(c)&&B(a,d,a.a(d)+1)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),B(a,d,a.a(b)<<c)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),B(a,d,a.a(b)|a.a(c))},function(a,b){b=a.a(L(a)),P(a,b)},function(a,b,c,d){if(b=a.K.pop()){for(c=L(a);0<c;c--)d=L(a),b[d]=a.c[d];a.c=b}else B(a,a.b,a.e.length)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),B(a,d,(a.a(b)in a.a(c))+0)},function(a,b,c,d){b=L(a),c=a.a(L(a)),d=a.a(L(a)),B(a,b,R(a,c,d))},function(a,b,c){b=L(a),c=L(a),B(a,c,a.a(c)*a.a(b))},function(a,b,c,d){b=L(a),c=L(a),d=L(a),B(a,d,a.a(b)>>c)},function(a,b,c,d){b=L(a),c=L(a),d=L(a),B(a,d,a.a(b)||a.a(c))},function(a,b,c,d,e){b=O(a),c=b.C,d=b.self,e=b.N;switch(c.length){case 0:c=new d[e];break;case 1:c=new d[e](c[0]);break;case 2:c=new d[e](c[0],c[1]);break;case 3:c=new d[e](c[0],c[1],c[2]);break;case 4:c=new d[e](c[0],c[1],c[2],c[3]);break;default:a.g(a.A);return}B(a,b.O,c)},function(a,b,c,d,e,h){if(b=L(a),c=L(a),d=L(a),e=L(a),b=a.a(b),c=a.a(c),d=a.a(d),a=a.a(e),"object"==f(b)){for(h in e=[],b)e.push(h);b=e}for(h=b.length,e=0;e<h;e+=d)c(b.slice(e,e+d),a)}],z.b=0,z.p=1,z.h=2,z.l=3,z.d=4,z.w=5,z.P=6,z.L=8,z.H=9,z.I=10,z.r=11,z.F=12,z.G=13,z.f=14,z.o=15,z.k=16,z.ca=17,z.R=253,z.$=254,z.S=248,z.T=216,z.da=6,z.i=-1,z.n=-2,z.v=-3,z.U=17,z.W=21,z.A=22,z.ea=30,z.Y=31,z.X=33,z.u={},z.D="caller",z.J="toString",z.ga=34,z.fa=36,E.prototype.ia=function(a){return(a=window.performance)&&a.now?function(){return a.now()|0}:function(){return+new Date}}(),E.prototype.Q=function(a,b,c,d,e,h,l,q,m,y,s){if(this.m)return this.m;try{if(this.q=false,b=this.a(this.d).length,c=this.a(this.f).length,d=this.j,this.c[this.L]&&Q(this,this.a(this.L)),e=this.a(this.h),0<e.length&&G(this,this.d,H(e.length,2).concat(e),this.R),h=this.a(this.F)&255,h-=this.a(this.d).length+4,l=this.a(this.f),4<l.length&&(h-=l.length+3),0<h&&G(this,this.d,H(h,2).concat(C(h)),this.S),4<l.length&&G(this,this.d,H(l.length,2).concat(l),this.T),q=[241].concat(this.a(this.d)),window.btoa?(y=window.btoa(String.fromCharCode.apply(null,q)),m=y=y.replace(/\\+/g,"-").replace(/\\//g,"_").replace(/=/g,"")):m=k,m)m=","+m;else for(m="",e=0;e<q.length;e++)s=q[e][this.J](16),1==s.length&&(s="0"+s),m+=s;this.a(this.d).length=b,this.a(this.f).length=c,this.j=d,this.q=true,a=m}catch(v){D(this,v),a=this.m}return a},E.prototype.s=function(a,b,c,d,e,h){try{for(a=this.e.length,b=2001,c=k,d=0;--b&&(d=this.a(this.b))<a;)try{B(this,this.l,d),e=L(this)%this.M.length,(c=this.M[e])?c(this):this.g(this.W,0,e)}catch(l){l!=this.u&&((h=this.a(this.r))?(B(this,h,l),B(this,this.r,0)):this.g(this.A,l))}b||this.g(this.X)}catch(q){try{this.g(this.A,q)}catch(m){D(this,m)}}return this.a(this.k)},E.prototype.ha=function(a,b){return b=this.Q(),a&&a(b),b};try{window.addEventListener("unload",function(){},false)}catch(S){}n("thintinel.th",E),n("thintinel.th.prototype.exec",E.prototype.ha);')})() ``` I spent an hour trying to deobfuscate this, but gave up. I then tried Googling for information about this, via words from the first comment line above, and the URL of the .js file, but nothing too relevant came up. Then I tried other sites that use ReCaptcha and checked if they were pulling something similar. Finding sites that use ReCaptcha isn't as easy as I thought (I'm sure there are many, it's just not an easy search). The few I found did pull a similarly-named file from the google.com/js/th path, but they tended to have far less code in it than mine. If this is a legitimate part of ReCaptcha, it seems they could do a much better job of not making it look suspicious. There's no indication of what the hell it is or that it even has anything to do with ReCaptcha. Right now I'm not too worried, as I'm assuming it IS legitimate. I mainly wanted to get this up someplace for others who may have noticed it and gotten worried. If there are no answers I might just answer it myself with a "yeah it's probably fine".
2014/04/23
[ "https://Stackoverflow.com/questions/23246560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2066896/" ]
It creates an object called `thintinel`, in the global scope, and this object is referenced directly by `/recaptcha/api/js/recaptha_ajax.js`. It's almost certainly legitimate and my best guess is that it checks for a traditional, interactive browser rather than a thin bot-controlled client.
Giving the level of obfuscation this code has, and the fact it is binding something to 'unload' event, I'd say it is not good thing. Usually legit code justifies itself somehow, this code is a mystery.. The code can be read at <http://pastebin.com/AQxkh7E0> (new paste, easier to read) Edit: I created a post on <https://reverseengineering.stackexchange.com/questions/4129/suspicios-obfuscated-javascript-file>
1,639,706
On my linux (ubuntu 20.04) workstation i usually have a virtualbox VM with windows 10 running, to get access to some work-related things. If I accidentally leave the virtualbox window focused it prevents the screen saver from locking the screen. Is there a setting, either in ubuntu or in virtualbox, that allows the screen saver to lock the screen when the virtualbox windows is focused?
2021/04/06
[ "https://superuser.com/questions/1639706", "https://superuser.com", "https://superuser.com/users/1294422/" ]
Assuming a different Windows license (old Windows license, new machine with new Windows License), there is not any issue. Still, for clarity for you and for the longer term, install, get your data in a reasonable time and then remove the drive or format it. The reason is (a) the old license may not run properly on the new machine and (b) if it was OEM, the license is not portable anyway. You should not have any issue.
UEFI, like BIOS, allows the user to choose which drive is the primary boot device. The boot partition on the 2nd device will be ignored. You can easily transfer data from the 2nd device to the new boot drive. Be aware that Windows on the 2nd device will freak when you open the folders containing user data. It will know you are not the registered user and will attempt to block you from access to it. Your new administrator account will supersede the old one but will make the old account unusable if you decide to reuse the device as a boot drive. This will occur whether you install the drive internally or externally.
1,639,706
On my linux (ubuntu 20.04) workstation i usually have a virtualbox VM with windows 10 running, to get access to some work-related things. If I accidentally leave the virtualbox window focused it prevents the screen saver from locking the screen. Is there a setting, either in ubuntu or in virtualbox, that allows the screen saver to lock the screen when the virtualbox windows is focused?
2021/04/06
[ "https://superuser.com/questions/1639706", "https://superuser.com", "https://superuser.com/users/1294422/" ]
Assuming a different Windows license (old Windows license, new machine with new Windows License), there is not any issue. Still, for clarity for you and for the longer term, install, get your data in a reasonable time and then remove the drive or format it. The reason is (a) the old license may not run properly on the new machine and (b) if it was OEM, the license is not portable anyway. You should not have any issue.
As long as you still boot from your current drive and only access to the second to read/write data, you shouldn't be annoyed. Be advised that booting from the second drive might not work ; I experienced difficulties with my new desktop when using my old drive (not booting or blue screen) and had to format/reinstall Win10 to get it to work properly.
1,639,706
On my linux (ubuntu 20.04) workstation i usually have a virtualbox VM with windows 10 running, to get access to some work-related things. If I accidentally leave the virtualbox window focused it prevents the screen saver from locking the screen. Is there a setting, either in ubuntu or in virtualbox, that allows the screen saver to lock the screen when the virtualbox windows is focused?
2021/04/06
[ "https://superuser.com/questions/1639706", "https://superuser.com", "https://superuser.com/users/1294422/" ]
You will not have any issues. UEFI is set to boot from the first m.2 SSD. The computer will not attempt to boot from the new drive. Windows will boot from the original drive, it will see the new drive and assign it the next free drive letter. You will then be able to copy any data you need from it. Of course, all of this is assuming you didnt use any sort of encryption on the drive or its files. Alternatively, you could put the m.2 drive in a USB enclosure like [this](https://www.newegg.com/sabrent-ec-m2mc-enclosure/p/0J2-0066-000Y4?item=0J2-0066-000Y4&source=region&nm_mc=knc-googleadwords-pc&cm_mmc=knc-googleadwords-pc-_-pla-_-external%20enclosure-_-0J2-0066-000Y4&gclid=CjwKCAjw6qqDBhB-EiwACBs6x_dmiQSNs6_3ysf0SWv_659Y4qrvN3nPaLIHnX4SmhfFWulEJ2WW7BoC4F8QAvD_BwE&gclsrc=aw.ds).
UEFI, like BIOS, allows the user to choose which drive is the primary boot device. The boot partition on the 2nd device will be ignored. You can easily transfer data from the 2nd device to the new boot drive. Be aware that Windows on the 2nd device will freak when you open the folders containing user data. It will know you are not the registered user and will attempt to block you from access to it. Your new administrator account will supersede the old one but will make the old account unusable if you decide to reuse the device as a boot drive. This will occur whether you install the drive internally or externally.
1,639,706
On my linux (ubuntu 20.04) workstation i usually have a virtualbox VM with windows 10 running, to get access to some work-related things. If I accidentally leave the virtualbox window focused it prevents the screen saver from locking the screen. Is there a setting, either in ubuntu or in virtualbox, that allows the screen saver to lock the screen when the virtualbox windows is focused?
2021/04/06
[ "https://superuser.com/questions/1639706", "https://superuser.com", "https://superuser.com/users/1294422/" ]
You will not have any issues. UEFI is set to boot from the first m.2 SSD. The computer will not attempt to boot from the new drive. Windows will boot from the original drive, it will see the new drive and assign it the next free drive letter. You will then be able to copy any data you need from it. Of course, all of this is assuming you didnt use any sort of encryption on the drive or its files. Alternatively, you could put the m.2 drive in a USB enclosure like [this](https://www.newegg.com/sabrent-ec-m2mc-enclosure/p/0J2-0066-000Y4?item=0J2-0066-000Y4&source=region&nm_mc=knc-googleadwords-pc&cm_mmc=knc-googleadwords-pc-_-pla-_-external%20enclosure-_-0J2-0066-000Y4&gclid=CjwKCAjw6qqDBhB-EiwACBs6x_dmiQSNs6_3ysf0SWv_659Y4qrvN3nPaLIHnX4SmhfFWulEJ2WW7BoC4F8QAvD_BwE&gclsrc=aw.ds).
As long as you still boot from your current drive and only access to the second to read/write data, you shouldn't be annoyed. Be advised that booting from the second drive might not work ; I experienced difficulties with my new desktop when using my old drive (not booting or blue screen) and had to format/reinstall Win10 to get it to work properly.
1,639,706
On my linux (ubuntu 20.04) workstation i usually have a virtualbox VM with windows 10 running, to get access to some work-related things. If I accidentally leave the virtualbox window focused it prevents the screen saver from locking the screen. Is there a setting, either in ubuntu or in virtualbox, that allows the screen saver to lock the screen when the virtualbox windows is focused?
2021/04/06
[ "https://superuser.com/questions/1639706", "https://superuser.com", "https://superuser.com/users/1294422/" ]
UEFI, like BIOS, allows the user to choose which drive is the primary boot device. The boot partition on the 2nd device will be ignored. You can easily transfer data from the 2nd device to the new boot drive. Be aware that Windows on the 2nd device will freak when you open the folders containing user data. It will know you are not the registered user and will attempt to block you from access to it. Your new administrator account will supersede the old one but will make the old account unusable if you decide to reuse the device as a boot drive. This will occur whether you install the drive internally or externally.
As long as you still boot from your current drive and only access to the second to read/write data, you shouldn't be annoyed. Be advised that booting from the second drive might not work ; I experienced difficulties with my new desktop when using my old drive (not booting or blue screen) and had to format/reinstall Win10 to get it to work properly.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Without knowing the amount of RAM or processor speed, it's hard to make specific recommendations, but Lightroom will perform significantly better with more RAM and a faster processor. It also doesn't hurt to occasionally optimize the Lightroom catalog, which helps increase the efficiency of operations. On a PC it's under Edit->Catalog Settings, on a Mac It's under Lightroom->Catalog Settings. Click the "Relaunch and Optimize" button. Lightroom will do just that. It can take a while depending on the size of your catalog.
I'm not sure how well Lightroom performs when your catalog grows too large. I'd recommend improving general system performance by addressing the following areas: * faster & more system memory (limited by the 32-bit XP in this case but max out at 3GB if you can) * faster disk (at least 7200 RPM spindle, striped as RAID-0 or RAID-1+0 if you can afford it) * faster processor (the more cores the merrier, Lightroom might not make use of them directly, but the system is a multi-tasking OS and will make use of them nonetheless) * upgrade to Windows 7 (huge improvements in I/O (memory & disk) as well as processor core usage) In terms of Lightroom itself, I can only suggest creating smaller catalogs.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Something that hasn't been mentioned yet: in 'Catalog Settings' turn off 'Automatically write changes into XMP'. This will prevent LR from automatically dumping its catalog metadata, keywords, rating, labels and develop settings back to your photo files. By doing so you will reduce the number of disk operations performed by LR. You can still write your metadata back manually, as [I describe in this other question](https://photo.stackexchange.com/questions/2680/lightroom-data-storage/2953#2953). I have 8GB of RAM and I process 21MP RAW files out of a Canon 5DMII. Increasing disk performance is how I made it run faster. I replaced a pair of fairly zippy Hitachi SATA 15,000 RPM drives by a pair of 160GB Intel X25G2 SSD. Be careful with your choice of SSD drives, they are not born equal. Most of them read really fast, but many are slow on write. Pair your SSD with a modern operating system like Windows 7, one that supports the [TRIM](http://en.wikipedia.org/wiki/TRIM) command. What should you put on a SSD and what should you leave on a standard drive? Opinions differ, but here is what I would recommend: * your LR catalog file (Lightroom 3 Catalog.lrcat), which is where LR stores its metadata, keywords, rating, labels and develop settings * your Previews directory (Lightroom 3 Catalog Previews.lrdata), which is where LR stores intermediate representation of your photos for faster viewing (1:1, low res, thumbnails, etc) * your Adobe Camera RAW Cache (ACR Cache) * your RAW files, or at least a subset of them What is the Camera RAW Cache? Quoting Jeff Schewe via Luminous Landscape Forum > > Every time you open an image in Camera > Raw the full resolution of the image > must be loaded into Camera Raw… as you > can imagine, this can be pretty > processor intensive… the Camera Raw > cache will cache recently opened > images to make re-opening them faster. > There’s a preference limit to > determine the size and the cache will > remain constant in size by flushing > out older cache files when newer > images are loaded into Camera Raw. > > > You can change the default location of your catalog, previews and Camera RAW Cache from the Preferences and group them on the same SSD. I would definitely recommend increasing the size of your ACR Cache, if you can afford it. RAW files are big. You don't need to have all of them on a SSD, but what about the past 6 months worth of photos? Move older photos back to a standard drive every month or so (do it from LR of course). Do you need to put LR or the whole Operating System on a SSD? If you can, sure, it will start faster and feel a bit more responsive, but I don't think it's critical. If you don't have a lot of RAM though, try to put your page file and TEMP directories on the SSD. Should you go RAID0? I really recommend against it, unless you have really strong backup habits and monitor your RAID controller regularly. Remember, RAID0 uses 2 drives: if one dies, you lose the data on both. Don't risk it. I personally like RAID1 a lot for this very reason and from past experience. Finally, you will "feel" LR run faster if you let it generate your 1:1 photo previews during import. I usually do something else during import anyway, run some errands or whatnot. In any case LR has to generate your 1:1 previews sooner or later when you go to the Develop module, right? So you might as well let this happen during import.
Without knowing the amount of RAM or processor speed, it's hard to make specific recommendations, but Lightroom will perform significantly better with more RAM and a faster processor. It also doesn't hurt to occasionally optimize the Lightroom catalog, which helps increase the efficiency of operations. On a PC it's under Edit->Catalog Settings, on a Mac It's under Lightroom->Catalog Settings. Click the "Relaunch and Optimize" button. Lightroom will do just that. It can take a while depending on the size of your catalog.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Upgrade. LR 3 is a fair amount faster for me. I also have found that RAM seems to matter more than raw processor speed, at least for me.
I'm not sure how well Lightroom performs when your catalog grows too large. I'd recommend improving general system performance by addressing the following areas: * faster & more system memory (limited by the 32-bit XP in this case but max out at 3GB if you can) * faster disk (at least 7200 RPM spindle, striped as RAID-0 or RAID-1+0 if you can afford it) * faster processor (the more cores the merrier, Lightroom might not make use of them directly, but the system is a multi-tasking OS and will make use of them nonetheless) * upgrade to Windows 7 (huge improvements in I/O (memory & disk) as well as processor core usage) In terms of Lightroom itself, I can only suggest creating smaller catalogs.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Something that hasn't been mentioned yet: in 'Catalog Settings' turn off 'Automatically write changes into XMP'. This will prevent LR from automatically dumping its catalog metadata, keywords, rating, labels and develop settings back to your photo files. By doing so you will reduce the number of disk operations performed by LR. You can still write your metadata back manually, as [I describe in this other question](https://photo.stackexchange.com/questions/2680/lightroom-data-storage/2953#2953). I have 8GB of RAM and I process 21MP RAW files out of a Canon 5DMII. Increasing disk performance is how I made it run faster. I replaced a pair of fairly zippy Hitachi SATA 15,000 RPM drives by a pair of 160GB Intel X25G2 SSD. Be careful with your choice of SSD drives, they are not born equal. Most of them read really fast, but many are slow on write. Pair your SSD with a modern operating system like Windows 7, one that supports the [TRIM](http://en.wikipedia.org/wiki/TRIM) command. What should you put on a SSD and what should you leave on a standard drive? Opinions differ, but here is what I would recommend: * your LR catalog file (Lightroom 3 Catalog.lrcat), which is where LR stores its metadata, keywords, rating, labels and develop settings * your Previews directory (Lightroom 3 Catalog Previews.lrdata), which is where LR stores intermediate representation of your photos for faster viewing (1:1, low res, thumbnails, etc) * your Adobe Camera RAW Cache (ACR Cache) * your RAW files, or at least a subset of them What is the Camera RAW Cache? Quoting Jeff Schewe via Luminous Landscape Forum > > Every time you open an image in Camera > Raw the full resolution of the image > must be loaded into Camera Raw… as you > can imagine, this can be pretty > processor intensive… the Camera Raw > cache will cache recently opened > images to make re-opening them faster. > There’s a preference limit to > determine the size and the cache will > remain constant in size by flushing > out older cache files when newer > images are loaded into Camera Raw. > > > You can change the default location of your catalog, previews and Camera RAW Cache from the Preferences and group them on the same SSD. I would definitely recommend increasing the size of your ACR Cache, if you can afford it. RAW files are big. You don't need to have all of them on a SSD, but what about the past 6 months worth of photos? Move older photos back to a standard drive every month or so (do it from LR of course). Do you need to put LR or the whole Operating System on a SSD? If you can, sure, it will start faster and feel a bit more responsive, but I don't think it's critical. If you don't have a lot of RAM though, try to put your page file and TEMP directories on the SSD. Should you go RAID0? I really recommend against it, unless you have really strong backup habits and monitor your RAID controller regularly. Remember, RAID0 uses 2 drives: if one dies, you lose the data on both. Don't risk it. I personally like RAID1 a lot for this very reason and from past experience. Finally, you will "feel" LR run faster if you let it generate your 1:1 photo previews during import. I usually do something else during import anyway, run some errands or whatnot. In any case LR has to generate your 1:1 previews sooner or later when you go to the Develop module, right? So you might as well let this happen during import.
Upgrade. LR 3 is a fair amount faster for me. I also have found that RAM seems to matter more than raw processor speed, at least for me.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Don't let the catalogue grow too large. Separating your pictures into several catalogues can bring a lot of speed. For me the main waiting point is waiting for Lightroom to render the 1:1 previews - if I let Lightroom render those on import I can usually work faster. Of course putting the catalogue on a fast hard disk (SSD) helps, too.
I'm not sure how well Lightroom performs when your catalog grows too large. I'd recommend improving general system performance by addressing the following areas: * faster & more system memory (limited by the 32-bit XP in this case but max out at 3GB if you can) * faster disk (at least 7200 RPM spindle, striped as RAID-0 or RAID-1+0 if you can afford it) * faster processor (the more cores the merrier, Lightroom might not make use of them directly, but the system is a multi-tasking OS and will make use of them nonetheless) * upgrade to Windows 7 (huge improvements in I/O (memory & disk) as well as processor core usage) In terms of Lightroom itself, I can only suggest creating smaller catalogs.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Upgrading to Lightroom 3.2 is cheap and easy. You'll find version 3 a lot more responsive than 2.6, and version 3.2 even more so. In most situations where Lightroom 2 makes you wait, Lightroom 3 will do its processing in the background, so you can continue to interact with the program. You didn't say what hardware you're running, but if you're using Windows XP, it's probably an older system. Lightroom really taxes PC hardware. Getting the fastest PC you can afford is definitely a good idea. I'd recommend a 64-bit system with lots of RAM and an SSD drive. If you can't afford an SSD big enough to store your images, use an SSD for the operating system and your Lightroom catalogs, and a normal hard disk to store your RAW files. Lightroom doesn't benefit from multi-core CPUs as much as I'd like. If you tend to have Lightroom run multiple background tasks (import, export, render previews) as the same time, your computer will stay more responsive with a quad core CPU. If you don't run multiple background tasks, then a dual core may be a better choice. For the same money, the individual cores on a dual core CPU are faster than those on a quad core. Lightroom does not make use of GPU acceleration at all. So don't spend money on a graphics card unless you need it for other purposes.
I'm not sure how well Lightroom performs when your catalog grows too large. I'd recommend improving general system performance by addressing the following areas: * faster & more system memory (limited by the 32-bit XP in this case but max out at 3GB if you can) * faster disk (at least 7200 RPM spindle, striped as RAID-0 or RAID-1+0 if you can afford it) * faster processor (the more cores the merrier, Lightroom might not make use of them directly, but the system is a multi-tasking OS and will make use of them nonetheless) * upgrade to Windows 7 (huge improvements in I/O (memory & disk) as well as processor core usage) In terms of Lightroom itself, I can only suggest creating smaller catalogs.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Something that hasn't been mentioned yet: in 'Catalog Settings' turn off 'Automatically write changes into XMP'. This will prevent LR from automatically dumping its catalog metadata, keywords, rating, labels and develop settings back to your photo files. By doing so you will reduce the number of disk operations performed by LR. You can still write your metadata back manually, as [I describe in this other question](https://photo.stackexchange.com/questions/2680/lightroom-data-storage/2953#2953). I have 8GB of RAM and I process 21MP RAW files out of a Canon 5DMII. Increasing disk performance is how I made it run faster. I replaced a pair of fairly zippy Hitachi SATA 15,000 RPM drives by a pair of 160GB Intel X25G2 SSD. Be careful with your choice of SSD drives, they are not born equal. Most of them read really fast, but many are slow on write. Pair your SSD with a modern operating system like Windows 7, one that supports the [TRIM](http://en.wikipedia.org/wiki/TRIM) command. What should you put on a SSD and what should you leave on a standard drive? Opinions differ, but here is what I would recommend: * your LR catalog file (Lightroom 3 Catalog.lrcat), which is where LR stores its metadata, keywords, rating, labels and develop settings * your Previews directory (Lightroom 3 Catalog Previews.lrdata), which is where LR stores intermediate representation of your photos for faster viewing (1:1, low res, thumbnails, etc) * your Adobe Camera RAW Cache (ACR Cache) * your RAW files, or at least a subset of them What is the Camera RAW Cache? Quoting Jeff Schewe via Luminous Landscape Forum > > Every time you open an image in Camera > Raw the full resolution of the image > must be loaded into Camera Raw… as you > can imagine, this can be pretty > processor intensive… the Camera Raw > cache will cache recently opened > images to make re-opening them faster. > There’s a preference limit to > determine the size and the cache will > remain constant in size by flushing > out older cache files when newer > images are loaded into Camera Raw. > > > You can change the default location of your catalog, previews and Camera RAW Cache from the Preferences and group them on the same SSD. I would definitely recommend increasing the size of your ACR Cache, if you can afford it. RAW files are big. You don't need to have all of them on a SSD, but what about the past 6 months worth of photos? Move older photos back to a standard drive every month or so (do it from LR of course). Do you need to put LR or the whole Operating System on a SSD? If you can, sure, it will start faster and feel a bit more responsive, but I don't think it's critical. If you don't have a lot of RAM though, try to put your page file and TEMP directories on the SSD. Should you go RAID0? I really recommend against it, unless you have really strong backup habits and monitor your RAID controller regularly. Remember, RAID0 uses 2 drives: if one dies, you lose the data on both. Don't risk it. I personally like RAID1 a lot for this very reason and from past experience. Finally, you will "feel" LR run faster if you let it generate your 1:1 photo previews during import. I usually do something else during import anyway, run some errands or whatnot. In any case LR has to generate your 1:1 previews sooner or later when you go to the Develop module, right? So you might as well let this happen during import.
I'm not sure how well Lightroom performs when your catalog grows too large. I'd recommend improving general system performance by addressing the following areas: * faster & more system memory (limited by the 32-bit XP in this case but max out at 3GB if you can) * faster disk (at least 7200 RPM spindle, striped as RAID-0 or RAID-1+0 if you can afford it) * faster processor (the more cores the merrier, Lightroom might not make use of them directly, but the system is a multi-tasking OS and will make use of them nonetheless) * upgrade to Windows 7 (huge improvements in I/O (memory & disk) as well as processor core usage) In terms of Lightroom itself, I can only suggest creating smaller catalogs.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Something that hasn't been mentioned yet: in 'Catalog Settings' turn off 'Automatically write changes into XMP'. This will prevent LR from automatically dumping its catalog metadata, keywords, rating, labels and develop settings back to your photo files. By doing so you will reduce the number of disk operations performed by LR. You can still write your metadata back manually, as [I describe in this other question](https://photo.stackexchange.com/questions/2680/lightroom-data-storage/2953#2953). I have 8GB of RAM and I process 21MP RAW files out of a Canon 5DMII. Increasing disk performance is how I made it run faster. I replaced a pair of fairly zippy Hitachi SATA 15,000 RPM drives by a pair of 160GB Intel X25G2 SSD. Be careful with your choice of SSD drives, they are not born equal. Most of them read really fast, but many are slow on write. Pair your SSD with a modern operating system like Windows 7, one that supports the [TRIM](http://en.wikipedia.org/wiki/TRIM) command. What should you put on a SSD and what should you leave on a standard drive? Opinions differ, but here is what I would recommend: * your LR catalog file (Lightroom 3 Catalog.lrcat), which is where LR stores its metadata, keywords, rating, labels and develop settings * your Previews directory (Lightroom 3 Catalog Previews.lrdata), which is where LR stores intermediate representation of your photos for faster viewing (1:1, low res, thumbnails, etc) * your Adobe Camera RAW Cache (ACR Cache) * your RAW files, or at least a subset of them What is the Camera RAW Cache? Quoting Jeff Schewe via Luminous Landscape Forum > > Every time you open an image in Camera > Raw the full resolution of the image > must be loaded into Camera Raw… as you > can imagine, this can be pretty > processor intensive… the Camera Raw > cache will cache recently opened > images to make re-opening them faster. > There’s a preference limit to > determine the size and the cache will > remain constant in size by flushing > out older cache files when newer > images are loaded into Camera Raw. > > > You can change the default location of your catalog, previews and Camera RAW Cache from the Preferences and group them on the same SSD. I would definitely recommend increasing the size of your ACR Cache, if you can afford it. RAW files are big. You don't need to have all of them on a SSD, but what about the past 6 months worth of photos? Move older photos back to a standard drive every month or so (do it from LR of course). Do you need to put LR or the whole Operating System on a SSD? If you can, sure, it will start faster and feel a bit more responsive, but I don't think it's critical. If you don't have a lot of RAM though, try to put your page file and TEMP directories on the SSD. Should you go RAID0? I really recommend against it, unless you have really strong backup habits and monitor your RAID controller regularly. Remember, RAID0 uses 2 drives: if one dies, you lose the data on both. Don't risk it. I personally like RAID1 a lot for this very reason and from past experience. Finally, you will "feel" LR run faster if you let it generate your 1:1 photo previews during import. I usually do something else during import anyway, run some errands or whatnot. In any case LR has to generate your 1:1 previews sooner or later when you go to the Develop module, right? So you might as well let this happen during import.
Don't let the catalogue grow too large. Separating your pictures into several catalogues can bring a lot of speed. For me the main waiting point is waiting for Lightroom to render the 1:1 previews - if I let Lightroom render those on import I can usually work faster. Of course putting the catalogue on a fast hard disk (SSD) helps, too.
694
I'm running Lightroom 2.6 on Windows XP and it runs painfully slow. Just navigating from one image to the next takes a few seconds. What can I do to speed it up?
2010/07/16
[ "https://photo.stackexchange.com/questions/694", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/190/" ]
Something that hasn't been mentioned yet: in 'Catalog Settings' turn off 'Automatically write changes into XMP'. This will prevent LR from automatically dumping its catalog metadata, keywords, rating, labels and develop settings back to your photo files. By doing so you will reduce the number of disk operations performed by LR. You can still write your metadata back manually, as [I describe in this other question](https://photo.stackexchange.com/questions/2680/lightroom-data-storage/2953#2953). I have 8GB of RAM and I process 21MP RAW files out of a Canon 5DMII. Increasing disk performance is how I made it run faster. I replaced a pair of fairly zippy Hitachi SATA 15,000 RPM drives by a pair of 160GB Intel X25G2 SSD. Be careful with your choice of SSD drives, they are not born equal. Most of them read really fast, but many are slow on write. Pair your SSD with a modern operating system like Windows 7, one that supports the [TRIM](http://en.wikipedia.org/wiki/TRIM) command. What should you put on a SSD and what should you leave on a standard drive? Opinions differ, but here is what I would recommend: * your LR catalog file (Lightroom 3 Catalog.lrcat), which is where LR stores its metadata, keywords, rating, labels and develop settings * your Previews directory (Lightroom 3 Catalog Previews.lrdata), which is where LR stores intermediate representation of your photos for faster viewing (1:1, low res, thumbnails, etc) * your Adobe Camera RAW Cache (ACR Cache) * your RAW files, or at least a subset of them What is the Camera RAW Cache? Quoting Jeff Schewe via Luminous Landscape Forum > > Every time you open an image in Camera > Raw the full resolution of the image > must be loaded into Camera Raw… as you > can imagine, this can be pretty > processor intensive… the Camera Raw > cache will cache recently opened > images to make re-opening them faster. > There’s a preference limit to > determine the size and the cache will > remain constant in size by flushing > out older cache files when newer > images are loaded into Camera Raw. > > > You can change the default location of your catalog, previews and Camera RAW Cache from the Preferences and group them on the same SSD. I would definitely recommend increasing the size of your ACR Cache, if you can afford it. RAW files are big. You don't need to have all of them on a SSD, but what about the past 6 months worth of photos? Move older photos back to a standard drive every month or so (do it from LR of course). Do you need to put LR or the whole Operating System on a SSD? If you can, sure, it will start faster and feel a bit more responsive, but I don't think it's critical. If you don't have a lot of RAM though, try to put your page file and TEMP directories on the SSD. Should you go RAID0? I really recommend against it, unless you have really strong backup habits and monitor your RAID controller regularly. Remember, RAID0 uses 2 drives: if one dies, you lose the data on both. Don't risk it. I personally like RAID1 a lot for this very reason and from past experience. Finally, you will "feel" LR run faster if you let it generate your 1:1 photo previews during import. I usually do something else during import anyway, run some errands or whatnot. In any case LR has to generate your 1:1 previews sooner or later when you go to the Develop module, right? So you might as well let this happen during import.
Upgrading to Lightroom 3.2 is cheap and easy. You'll find version 3 a lot more responsive than 2.6, and version 3.2 even more so. In most situations where Lightroom 2 makes you wait, Lightroom 3 will do its processing in the background, so you can continue to interact with the program. You didn't say what hardware you're running, but if you're using Windows XP, it's probably an older system. Lightroom really taxes PC hardware. Getting the fastest PC you can afford is definitely a good idea. I'd recommend a 64-bit system with lots of RAM and an SSD drive. If you can't afford an SSD big enough to store your images, use an SSD for the operating system and your Lightroom catalogs, and a normal hard disk to store your RAW files. Lightroom doesn't benefit from multi-core CPUs as much as I'd like. If you tend to have Lightroom run multiple background tasks (import, export, render previews) as the same time, your computer will stay more responsive with a quad core CPU. If you don't run multiple background tasks, then a dual core may be a better choice. For the same money, the individual cores on a dual core CPU are faster than those on a quad core. Lightroom does not make use of GPU acceleration at all. So don't spend money on a graphics card unless you need it for other purposes.
32,187,934
I am trying to make a Python script which counts the amount of letters in a randomly chosen word for my Hangman game. I already looked around on the web, but most thing I could find was count specific letters in a word. After more looking around I ended up with this, which does not work for some reason. If someone could point out the errors, that'd be greatly appreciated. ``` wordList = ["Tree", "Fish", "Monkey"] wordChosen = random.choice(wordList) wordCounter = wordChosen.lower().count['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] print(wordCounter) ```
2015/08/24
[ "https://Stackoverflow.com/questions/32187934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5246668/" ]
Are you looking for `collections.Counter`? ``` >>> import collections >>> print(collections.Counter("Monkey")) Counter({'M': 1, 'y': 1, 'k': 1, 'o': 1, 'n': 1, 'e': 1}) >>> print(collections.Counter("Tree")) Counter({'e': 2, 'T': 1, 'r': 1}) >>> c = collections.Counter("Tree") >>> print("The word 'Tree' has {} distinct letters".format(len(c))) The word 'Tree' has 3 distinct letters >>> print("The word 'Tree' has {} instances of the letter 'e'".format(c['e'])) The word 'Tree' has 2 instances of the letter 'e' ```
**Problem:** The count method only takes in one argument and you are trying to pass a whole list. **Solution:** Simply iterate over all the letters, then test if they are in the string before you print them and their amount. ``` import random wordList = ["Tree", "Fish", "Monkey"] wordChosen = random.choice(wordList) letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for letter in letters: if letter in wordChosen.lower(): amount = str(wordChosen.lower().count(letter)) print(letter + " : " + amount) ``` **Result:** If the random word chosen is "Tree": ``` e : 2 r : 1 t : 1 ``` **Conclusion:** Using collections is definitely a more effective method, but I believe the way I have shown above creates more of the output you were looking for.
32,187,934
I am trying to make a Python script which counts the amount of letters in a randomly chosen word for my Hangman game. I already looked around on the web, but most thing I could find was count specific letters in a word. After more looking around I ended up with this, which does not work for some reason. If someone could point out the errors, that'd be greatly appreciated. ``` wordList = ["Tree", "Fish", "Monkey"] wordChosen = random.choice(wordList) wordCounter = wordChosen.lower().count['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] print(wordCounter) ```
2015/08/24
[ "https://Stackoverflow.com/questions/32187934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5246668/" ]
Are you looking for `collections.Counter`? ``` >>> import collections >>> print(collections.Counter("Monkey")) Counter({'M': 1, 'y': 1, 'k': 1, 'o': 1, 'n': 1, 'e': 1}) >>> print(collections.Counter("Tree")) Counter({'e': 2, 'T': 1, 'r': 1}) >>> c = collections.Counter("Tree") >>> print("The word 'Tree' has {} distinct letters".format(len(c))) The word 'Tree' has 3 distinct letters >>> print("The word 'Tree' has {} instances of the letter 'e'".format(c['e'])) The word 'Tree' has 2 instances of the letter 'e' ```
First off, your code contains an error that is rather important to understand: ``` wordChosen.lower().count['a', 'b'] #... ``` `count` is a *function* and so it requires you to surround its parameters with parentheses and not square brackets! Next you should try to refer to *[Python Documentation](https://docs.python.org/2/library/string.html#string.count)* when using a function for the first time. That should help you understand why your approach will not work. Now to address your problem. If you want to count the number of letters in your string use `len(wordChosen)` which counts the total number of characters in the string. If you want to count the frequencies of each letter a few methods have already been suggested. Here is one more using a dictionary: ``` import string LetterFreq={} for letter in string.ascii_lowercase: LetterFreq[letter] = 0 for letter in wordChosen.lower(): LetterFreq[letter] += 1 ``` This has the nice perk of defaulting all letters not present in the word to a frequency of 0 :) Hope this helps!
32,187,934
I am trying to make a Python script which counts the amount of letters in a randomly chosen word for my Hangman game. I already looked around on the web, but most thing I could find was count specific letters in a word. After more looking around I ended up with this, which does not work for some reason. If someone could point out the errors, that'd be greatly appreciated. ``` wordList = ["Tree", "Fish", "Monkey"] wordChosen = random.choice(wordList) wordCounter = wordChosen.lower().count['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] print(wordCounter) ```
2015/08/24
[ "https://Stackoverflow.com/questions/32187934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5246668/" ]
First off, your code contains an error that is rather important to understand: ``` wordChosen.lower().count['a', 'b'] #... ``` `count` is a *function* and so it requires you to surround its parameters with parentheses and not square brackets! Next you should try to refer to *[Python Documentation](https://docs.python.org/2/library/string.html#string.count)* when using a function for the first time. That should help you understand why your approach will not work. Now to address your problem. If you want to count the number of letters in your string use `len(wordChosen)` which counts the total number of characters in the string. If you want to count the frequencies of each letter a few methods have already been suggested. Here is one more using a dictionary: ``` import string LetterFreq={} for letter in string.ascii_lowercase: LetterFreq[letter] = 0 for letter in wordChosen.lower(): LetterFreq[letter] += 1 ``` This has the nice perk of defaulting all letters not present in the word to a frequency of 0 :) Hope this helps!
**Problem:** The count method only takes in one argument and you are trying to pass a whole list. **Solution:** Simply iterate over all the letters, then test if they are in the string before you print them and their amount. ``` import random wordList = ["Tree", "Fish", "Monkey"] wordChosen = random.choice(wordList) letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for letter in letters: if letter in wordChosen.lower(): amount = str(wordChosen.lower().count(letter)) print(letter + " : " + amount) ``` **Result:** If the random word chosen is "Tree": ``` e : 2 r : 1 t : 1 ``` **Conclusion:** Using collections is definitely a more effective method, but I believe the way I have shown above creates more of the output you were looking for.
33,264,005
This Nuspec reference explains the description and summary text fields: <https://docs.nuget.org/create/nuspec-reference> In regards to the summary it says it is > > A short description of the package. If specified, this shows up in the middle pane of the Add Package Dialog. If not specified, a truncated version of the description is used instead. > > > Does anyone know the max length of the summary, description, and how many characters from the description will be used if the summary is not provided?
2015/10/21
[ "https://Stackoverflow.com/questions/33264005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68905/" ]
There is no maximum length of the summary or description. If no summary is used then all of the description is used. However what gets displayed is based on the size of the Manage Packages dialog, the size of characters used in the text, whether the row is selected and the Install button is showing, whether you are using Visual Studio 2015 or an older version. So there is not a defined number of characters defined as the maximum length.
It seems to be client implementation specific. For example, I just got an error from nuget.org's Web API while uploading some packages with long descriptions. Tags and descriptions cannot be longer than 4000 chars for nuget.org. [![enter image description here](https://i.stack.imgur.com/FIjIa.png)](https://i.stack.imgur.com/FIjIa.png) [![enter image description here](https://i.stack.imgur.com/yOjXA.png)](https://i.stack.imgur.com/yOjXA.png) Summaries vary on the client as well. For example, the package manager console in Visual Studio uses the width of the console window to determine the length of the summary, while the Visual Studio 2017 Package Manager is about 197 chars. Nuget.org uses 297 chars at the moment.
296,402
Are there any synonyms for the word "high-concept"? Here is the sentence:"The same goes for some of the high concept scenes in the film – I was often creating a new mix down nearly every single day with new ideas and sounds for him and the picture editors to review and reflect on". According to dictionary it means "a simple and often striking idea or premise, as of a story or film, that lends itself to easy promotion and marketing" but I couldn't find an appropriate synonym of it.
2015/12/28
[ "https://english.stackexchange.com/questions/296402", "https://english.stackexchange.com", "https://english.stackexchange.com/users/142638/" ]
***Devotement*** is an outdated, less common variant of devotion: > > * The action of devoting, or fact of being devoted; devotion, dedication. > + **1604** Shakes. Oth. ii. iii. 322 *He hath deuoted, and giuen vp himselfe to the Contemplation, marke, and deuotement of her parts and Graces.* > + ***1852*** Wayland Mem. Judson (1853) i 29 *His own personal devotement to the missionary cause.* > > > OED [Ngram](https://books.google.com/ngrams/graph?content=devotement%2C%20devotion%20&year_start=1800&year_end=2008&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cdevotement%3B%2Cc0%3B.t1%3B%2Cdevotion%3B%2Cc0): *devotement vs devotion.* [Ngram](https://books.google.com/ngrams/graph?content=devotement&year_start=1800&year_end=2008&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cdevotement%3B%2Cc0): *devotement.* It origin is probably due to the practice of adding the suffix -ment to verbs to form nouns which starred from the 16th century: ***[-ment](http://www.etymonline.com/index.php?term=-ment&allowed_in_frame=0)*** : > > * ***suffix forming nouns, originally from French and representing Latin -mentum, which was added to verb stems sometimes to represent the result or product of the action.*** French inserts an -e- between the verbal root and the suffix (as in commenc-e-ment from commenc-er; with verbs in ir, -i- is inserted instead (as in sent-i-ment from sentir). > * ***Used with English verb stems from 16c.*** for example merriment, which also illustrates the habit of turning -y to -i- before this suffix). > > > (Etymonline) ***[Devotion](http://www.etymonline.com/index.php?term=devotion&allowed_in_frame=0)*** (n.) has an older origin:. > > * ***early 13c., from Old French devocion "devotion, piety," from Latin devotionem*** (nominative devotio), noun of action from past participle stem of devovere "dedicate by a vow, sacrifice oneself, promise solemnly," > > > From which ***[devote](http://www.etymonline.com/index.php?term=devote&allowed_in_frame=0)*** (verb) > > * ***1580s, from Latin devotus,*** past participle of devovere (see devotion). Second and third meanings in Johnson's Dictionary (1755) are "to addict, to give up to ill" and "to curse, to execrate; to doom to destruction." > > > and later (17th century) ***"devotement".***
Many nouns that end with **-tion** has a French root and devotion is not an exception. According to Online Etymology Dictionary: > > early 13c., from **Old French devocion** "devotion, piety," from Latin > devotionem (nominative devotio), noun of action from past participle > stem of devovere "dedicate by a vow, sacrifice oneself, promise > solemnly," from de- "down, away" (see de-) + vovere "to vow," from > votum "vow" (see vow (n.)). > > > There are not many verbs which have 2 different noun forms. But a verb like **abolish** has two noun forms. > > [Abolition](http://www.merriam-webster.com/dictionary/abolition): the > act of officially ending or stopping something : the act of abolishing > something; specifically : the act of abolishing slavery > > > [Abolishment](http://www.merriam-webster.com/dictionary/abolishment) > (My Chrom Spell-checker doesn't like it, either) is listed under the > verb **abolish**. [Merriam-Webster] > > > If you look at the linked [Ngram Viewer](https://books.google.com/ngrams/graph?content=abolition%2C+abolishment&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cabolition%3B%2Cc0%3B.t1%3B%2Cabolishment%3B%2Cc0), abolishment is so rarely used that it's graph is at the bottom compared with abolition. The word [abolition](http://www.etymonline.com/index.php?allowed_in_frame=0&search=abolition) is also from Middle French *abolition* according to Online Etymology Dictionary. I am not trying to say that you have to choose devotion over devotement since abolition has been chosen over abolishment by people. My point is words do compete for survival and only the fittest that is chosen by majority of people will survive. The word devotement didn't survive and the [Ngram Viewer](https://books.google.com/ngrams/graph?content=devoteness%2C+devotion&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cdevotion%3B%2Cc0) supports it. Unless there is any difference in meanings, shorter nouns with easier pronunciation might have survived more often than longer ones as the survival of devotion and abolition indicates. Regarding your last two questions: Nobody will choose *devotement* over *devotion* unless any special meaning that can differentiate the former from the latter is attached to *devotement*.
296,402
Are there any synonyms for the word "high-concept"? Here is the sentence:"The same goes for some of the high concept scenes in the film – I was often creating a new mix down nearly every single day with new ideas and sounds for him and the picture editors to review and reflect on". According to dictionary it means "a simple and often striking idea or premise, as of a story or film, that lends itself to easy promotion and marketing" but I couldn't find an appropriate synonym of it.
2015/12/28
[ "https://english.stackexchange.com/questions/296402", "https://english.stackexchange.com", "https://english.stackexchange.com/users/142638/" ]
***Devotement*** is an outdated, less common variant of devotion: > > * The action of devoting, or fact of being devoted; devotion, dedication. > + **1604** Shakes. Oth. ii. iii. 322 *He hath deuoted, and giuen vp himselfe to the Contemplation, marke, and deuotement of her parts and Graces.* > + ***1852*** Wayland Mem. Judson (1853) i 29 *His own personal devotement to the missionary cause.* > > > OED [Ngram](https://books.google.com/ngrams/graph?content=devotement%2C%20devotion%20&year_start=1800&year_end=2008&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cdevotement%3B%2Cc0%3B.t1%3B%2Cdevotion%3B%2Cc0): *devotement vs devotion.* [Ngram](https://books.google.com/ngrams/graph?content=devotement&year_start=1800&year_end=2008&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cdevotement%3B%2Cc0): *devotement.* It origin is probably due to the practice of adding the suffix -ment to verbs to form nouns which starred from the 16th century: ***[-ment](http://www.etymonline.com/index.php?term=-ment&allowed_in_frame=0)*** : > > * ***suffix forming nouns, originally from French and representing Latin -mentum, which was added to verb stems sometimes to represent the result or product of the action.*** French inserts an -e- between the verbal root and the suffix (as in commenc-e-ment from commenc-er; with verbs in ir, -i- is inserted instead (as in sent-i-ment from sentir). > * ***Used with English verb stems from 16c.*** for example merriment, which also illustrates the habit of turning -y to -i- before this suffix). > > > (Etymonline) ***[Devotion](http://www.etymonline.com/index.php?term=devotion&allowed_in_frame=0)*** (n.) has an older origin:. > > * ***early 13c., from Old French devocion "devotion, piety," from Latin devotionem*** (nominative devotio), noun of action from past participle stem of devovere "dedicate by a vow, sacrifice oneself, promise solemnly," > > > From which ***[devote](http://www.etymonline.com/index.php?term=devote&allowed_in_frame=0)*** (verb) > > * ***1580s, from Latin devotus,*** past participle of devovere (see devotion). Second and third meanings in Johnson's Dictionary (1755) are "to addict, to give up to ill" and "to curse, to execrate; to doom to destruction." > > > and later (17th century) ***"devotement".***
It is simply impossible to know why some words survive and others don't, but let's examine the history of these synonyms, which we can do courtesy of the *OED*. *Devotion* is an old word, coming to us from the Old French *devocion*, ultimately from the Latin *devotio*. The *OED* records several senses of he word, the first from 1225, having the connotation of religious devoutness. This follows the Latin meanings which were about religious ceremonies or the taking of vows to devote oneself to virtue. (Latin had others words -- *dedere*, *devovere*, *dedicare* -- to apply to situations of dedicating oneself to things other than the sacred.) In the 16th century, influenced by more modern Italian and French, *devotion* started to be used for people, causes, hobbies, and so on. The *OED* finds 1530 the first use in the sense. In 1604, Shakespeare uses the word *devotement* in *Othello* (Act II, Scene iii) where Iago talks about Desdemona: > > ... Our general's wife is now the general: may say so in this respect, > for > that he hath devoted and given up himself to the > > contemplation, mark, and **devotement** of her parts > and graces.... > > > (Well, maybe. That's the First Folio. The Second has *denotement*. If you won't accept *Othello*, then the next cite is from 1621.) There's also another synonym, *devoteness*, first recorded in 1606. So the 1600s saw authors turning from *devotion* and its history of religious connotation to new words useful for secular circumstances as well. With multiple words for both contexts, at some point, people decided to remain devoted to *devotion*.
296,402
Are there any synonyms for the word "high-concept"? Here is the sentence:"The same goes for some of the high concept scenes in the film – I was often creating a new mix down nearly every single day with new ideas and sounds for him and the picture editors to review and reflect on". According to dictionary it means "a simple and often striking idea or premise, as of a story or film, that lends itself to easy promotion and marketing" but I couldn't find an appropriate synonym of it.
2015/12/28
[ "https://english.stackexchange.com/questions/296402", "https://english.stackexchange.com", "https://english.stackexchange.com/users/142638/" ]
It is simply impossible to know why some words survive and others don't, but let's examine the history of these synonyms, which we can do courtesy of the *OED*. *Devotion* is an old word, coming to us from the Old French *devocion*, ultimately from the Latin *devotio*. The *OED* records several senses of he word, the first from 1225, having the connotation of religious devoutness. This follows the Latin meanings which were about religious ceremonies or the taking of vows to devote oneself to virtue. (Latin had others words -- *dedere*, *devovere*, *dedicare* -- to apply to situations of dedicating oneself to things other than the sacred.) In the 16th century, influenced by more modern Italian and French, *devotion* started to be used for people, causes, hobbies, and so on. The *OED* finds 1530 the first use in the sense. In 1604, Shakespeare uses the word *devotement* in *Othello* (Act II, Scene iii) where Iago talks about Desdemona: > > ... Our general's wife is now the general: may say so in this respect, > for > that he hath devoted and given up himself to the > > contemplation, mark, and **devotement** of her parts > and graces.... > > > (Well, maybe. That's the First Folio. The Second has *denotement*. If you won't accept *Othello*, then the next cite is from 1621.) There's also another synonym, *devoteness*, first recorded in 1606. So the 1600s saw authors turning from *devotion* and its history of religious connotation to new words useful for secular circumstances as well. With multiple words for both contexts, at some point, people decided to remain devoted to *devotion*.
Many nouns that end with **-tion** has a French root and devotion is not an exception. According to Online Etymology Dictionary: > > early 13c., from **Old French devocion** "devotion, piety," from Latin > devotionem (nominative devotio), noun of action from past participle > stem of devovere "dedicate by a vow, sacrifice oneself, promise > solemnly," from de- "down, away" (see de-) + vovere "to vow," from > votum "vow" (see vow (n.)). > > > There are not many verbs which have 2 different noun forms. But a verb like **abolish** has two noun forms. > > [Abolition](http://www.merriam-webster.com/dictionary/abolition): the > act of officially ending or stopping something : the act of abolishing > something; specifically : the act of abolishing slavery > > > [Abolishment](http://www.merriam-webster.com/dictionary/abolishment) > (My Chrom Spell-checker doesn't like it, either) is listed under the > verb **abolish**. [Merriam-Webster] > > > If you look at the linked [Ngram Viewer](https://books.google.com/ngrams/graph?content=abolition%2C+abolishment&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cabolition%3B%2Cc0%3B.t1%3B%2Cabolishment%3B%2Cc0), abolishment is so rarely used that it's graph is at the bottom compared with abolition. The word [abolition](http://www.etymonline.com/index.php?allowed_in_frame=0&search=abolition) is also from Middle French *abolition* according to Online Etymology Dictionary. I am not trying to say that you have to choose devotion over devotement since abolition has been chosen over abolishment by people. My point is words do compete for survival and only the fittest that is chosen by majority of people will survive. The word devotement didn't survive and the [Ngram Viewer](https://books.google.com/ngrams/graph?content=devoteness%2C+devotion&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cdevotion%3B%2Cc0) supports it. Unless there is any difference in meanings, shorter nouns with easier pronunciation might have survived more often than longer ones as the survival of devotion and abolition indicates. Regarding your last two questions: Nobody will choose *devotement* over *devotion* unless any special meaning that can differentiate the former from the latter is attached to *devotement*.
579,665
Look at these two questions: Has your brother graduated from college? Did your brother graduate from college? Now, both of these questions seem fine to me, but I obviously know they are a little different. However, I can’t seem to explain what the slight difference is between these grammatical sentences. I know that when I use the present perfect, I am expecting an answer of “yes, he has” or “no he hasn’t “ with no specific details of exactly when in the past. But with the simple past, usually there is a specific time in the past and it conveys finality and that it is completely finished at a specific point that the speaker knows the time reference when he/she asks that question. Is there anything else I am missing? Edit: Both are acceptable to my ear but what would people assume differently if they hear one or the other? Or is it the same? Edit: Are both acceptable to use depending on the circumstances?
2021/12/05
[ "https://english.stackexchange.com/questions/579665", "https://english.stackexchange.com", "https://english.stackexchange.com/users/389274/" ]
I will answer for US English (not sure if this will hold in UK English). If I don't have any prior knowledge about the brother, I'd ask, "Did your brother go to college?" (Depending on where the conversation went from there, I might ask, "Did he get his degree?".) I would probably only ask, "Has your brother graduated from college?" if I happen to know that the brother has some college studies under his belt. Otherwise, I'd ask, "Does your brother have a college degree?" or "Did your brother go to college?" or possibly "Did your brother graduate from college?". The latter form doesn't sound very conversational, though. If you want to get more authentic you'll want to take into account that nowadays the person might stop after a two-year degree (Associates) -- it's complicated! If that doesn't address your question, please clarify.
I will mostly focus on American English, since the expression *graduated from college* is not used in the same sense in the UK. I doubt there are any contexts where, in American English, one of the sentences [1]  i  *Has your brother graduated from college?*       ii  *Did your brother graduate from college?* would be acceptable but the other would not. Having said that, one or the other may be *preferred.* In brief, the simple preterite [1ii] is used in practice much more frequently. Having said that, there may be some circumstances, namely those where 'the focus is on the present' (in an appropriate sense), where the present perfect is more likely than in other circumstances. This is discussed in the section 'A general consideration', below. Evidence from various corpora ----------------------------- **Evidence from the Google Books Ngram Viewer and COCA** Interestingly, if you search [Hoogle Ngram Viewer](https://books.google.com/ngrams/graph?content=did+you+graduate+from+college%2Chave+you+graduated+from+college&year_start=1800&year_end=2019&corpus=26&smoothing=3&direct_url=t1%3B%2Cdid%20you%20graduate%20from%20college%3B%2Cc0), you will find that [1i] has no hits at all. Similarly, on the [*Corpus of Contemporary American English*](https://www.english-corpora.org/coca/) (COCA) there are zero hits for 'have you graduated', but 8 hits for 'did you graduate', including entries such as *Have you ever had a job? Did you graduate from high school?* *Did you graduate from Paseo, Miss Bloom?* *"So did you graduate?" I ask.* **Evidence from Google Books** If one searches google books, one does find a number of hits for both 'have you graduated from' and 'did you graduate from', though the latter are more numerous. Apart from the overall higher number of hits for the simple preterite 'did you graduate from', there is one other tendency that seem to be discernable.: if a *specific* institution is named (as in, *Did you graduate from **Gibbs High School?***), then the simple preterite is strongly preferred. (Obviously, if a specific **time** is indicted or asked for, then the simple preterite is basically obligatory, as in ***What year** did you graduate from college?*) A general consideration ----------------------- It is not easy, when searching on Google Books, to precisely specify the context for an expression, and so I will add something that comes close to being a mere opinion. However, this opinion is at least consistent with the general analysis from [CGEL](https://rads.stackoverflow.com/amzn/click/com/0521431468) reproduced below. The general observation is that the present perfect (as in [1i]) is used when 'the focus is on the present'. This focusing may take several forms. Perhaps we are focusing on the fact that the graduation is recent; one way to emphasize that focus even more would be to add *yet* (*Has your brother graduated from college **yet?***).1 . Or, perhaps we are focusing on the fact that the graduation had a specific result—your brother becoming a college graduate—which persists through and is relevant now. 1In some varieties of American English, even the presence of *yet* wouldn't exclude the use of the preterite: *%Did your brother graduate from college yet?* (Here ' % ' in front of a sentence signifies that what follows is grammatical only in some dialects.) On the other hand, if the focus is on the past, then the simple preterite is more likely. This helps explain the observation, noted above, that the simple preterite is preferred when a particular institution is specified. Note that if the institution is famous, so that becoming a graduate of that particular institution is itself a well-recognized change in status, then the present perfect becomes more acceptable. For example, it is easier to imagine contexts where *Have you graduated from Harvard?* is acceptable2 than it is to imagine contexts where *Have you graduated from Lincoln High School?*3 is acceptable. 2One example would be the contexts where what you're really asking is *Have you graduated from an **elite** university?* 3*Lincoln* is one of the more frequent names of high schools. So suppose the institution itself is not famous, and the graduation did not happen recently. Then the fact that one graduated from a *specific* high school or college is not connected to the present in a way that would warrant the present perfect. This is arguably so even when the identity of the institution is actually relevant to the present situation in some other way. An example: *You seem very familiar. Did you attend Lincoln High School?* Here it does matter right now whether the person attended that specific high school. But since the relevance concerns neither recency nor change in status, we are more likely to stick with the simple preterite. (The present perfect is also possible, but is less likely.) General analysis from CGEL -------------------------- For completeness, it will be helpful to recall the main uses of the present perfect. This discussion follows (and quotes) that in CGEL, pp. 143–146. In the first place, there is a reasonably sharp distinction between **continuative** and **non-continuative** uses. A useful criterion is whether the expression in question is compatible with *ever since*: if it is, the use is continuative; otherwise, it is non-continuative. In your example, we clearly couldn't add *ever since* (as in *\*Has your brother graduated from college **ever since?***, where the ' \* ' in front of a sentence signifies that what follows is not acceptable English). Thus your sentence is an example of non-continuative use. Further, within the category of non-continuative use, traditionally there are three further subdivisions: the **experiential** (or 'existential') perfect, the **resultative** perfect, and the perfect of **recent past**. These three are not as sharply delineated, and many examples of use belong to more than one subdivision. Nevertheless, grammarians consider the distinctions useful. Let's consider how they might apply to [1i]. **The experiential perfect** This subdivision has to do with 'the occurrence of situations within the time-span up to now'. CGEL gives three types of use that belong to this subdivision, of which the most relevant for us is exemplified by > > [11]  iii  *His sister has been up Mont Blanc > twice.* > > > The connection with now is less direct in [11iii]: the ascents could > be quite a long time in the past. The focus, however, is not on their > occurrence at some particular time in the past but on the existence of > the situation within the time-span. The connection with now is the > potential for occurrence, or recurrence, of the situation at any time > within the time-span up to now. Thus [iii] implicates that his sister > is still alive, while *I haven't been to the market yet* implicates > that the possibility of my going to the market still exists (it hasn't > closed down).37 > > > 37The implicature may be weaker: that the same kind of > situation is still possible. *Nixon has been impeached,* for example, > can still be acceptable even though Nixon has since died, given a > context where the issue is the occurrence within the time-span of > situations of the kind 'impeachment of a president'. > > > Given that one graduation from college is usually a one-time thing, this subdivision seems to not fit very well with [1i]. I'm not saying it's impossible to interpret [1i] as an experiential/existential perfect, but only that it is less likely than the alternatives. **The experiential/existential perfect vs. the simple preterite** The experiential/existential perfect can be usefully contrasted with the simple preterite in the following situations (and unlike some other cases, this contrast is present in all varieties of English). This will be useful to review, despite the fact that we decided that [1i] is less likely to be interpreted as experiential/existential perfect. > > [12]  i  a.  *It is better than it has > ever > been.*       b.  *It's > better than it was.* > >         ii  a.  *Have > you seen > Jim?*                              b.  *Did > you see Jim?* > > > In [ia] the comparison is between its quality now and its quality at > any time within the time-span – clearly the potential for it to be of > such and such a quality still exists. In [ib] the comparison is between > now and then; the past is contrasted with the present, the 'then' > situation is over and excludes now. > > > Example [i2iia] brings out the point that there may be limits to the > time-span beyond those inherent in the situation itself. The inherent > limit is that Jim (and you) must be alive, but in the salient > interpretation I will have in mind a much shorter span than this: the > time of his current visit to our vicinity, today, the period since we > were last together, or whatever it might be. It would not be > acceptable for you to answer yes on the strength of having seen him > before this time-span. Whatever the limits on its beginning, however, > the time-span stretches up to now. But [iib] is very different. > Assuming again that you know Jim and have seen him perhaps many times, > you need to determine more specifically what I am asking. This time, > however, it is not a matter of placing limits on the start of the > time-span up to now, but of finding which particular, definite past > time I am asking about - your visit to Jim's sister last month, or > whatever it might be, but a time that is over, exclusive of now. > > > **The resultative perfect** CGEL again lists three types of use that belong to this subdivision. The most relevant for us seems this one: > > [14]  i  *She has broken her > leg.    He has closed the > door.    They've gone away.* > > > The clearest cases of the resultative perfect are illustrated in [i], > where the situation is one that inherently involves a specific change > of state: breaking a leg yields a resultant state where the leg is > broken, closing the door leads to the door's being closed, going away > (from place *x*) results in a state where one is no longer at place > *x,* and so on. The connection with the present in this resultative use is that the resultant state still obtains now. *She has broken her > leg* does not **mean** "Her leg is broken", but this is the likely > implicature unless the context selects an experiential interpretation. > Cases like [i] are known more specifically as the perfect of > **continuing result:** the resultant state begins at the time of occurrence of the past situation itself and continues through into the > present. > > > This fits quite well with [1i]: the resultant state is 'being a college graduate' (or 'having a college degree'), which begins at the time of occurrence of the past situation itself (at the time of graduation) and continues through into the present. **The perfect of recent past** > > [15]  i  *It has been a bad start to the year with > two fatal road accidents overnight.* > >          ii  *I've > discovered how to mend the fuse.* > >         iii  *She > has recently/just been to Paris.* > > > One respect in which a past situation may be connected with now is > that it is close in time to now. It is clear from examples like > [11iii] (*His sister has been up Mont Blanc twice*) that it does not > have to be recent, but there is nevertheless a significant correlation > between the present perfect and recency, whereas the simple preterite > is quite indifferent as to the distance between Tr and > To. [Here Tr is the 'time referred-to', the time when the action is taking place, e.g. the time of graduation in [1i]. To is the 'time of orientation', the time relative to which we are positioning Tr as being before, simultaneous, or after it; in [1i], To is the time of utterance, 'now'.] The present perfect is therefore the one most > frequently used in news announcements, as in the radio bulletin > example [15i]. It is arguable that the experiential and resultative > categories are broad enough to cover all non-continuative uses, but > recency adds an important component to the account. For example, > [15ii] has a continuing result interpretation: the discovery resulted > in my knowing how to mend the fuse and this knowledge persists. Such > knowledge can persist for a long time, so there is nothing in the idea > of continuing result itself to exclude my having made the discovery > years ago. But in fact the normal interpretation involves a recent > discovery. We have noted that experiential perfects like [i2iia] (*Have you > seen Jim?*) impose limitations on the time-span up to now beyond those > inherent to the situation, and these additional limitations also > involve recency. > > > Thus, [1i] is likely to be interpreted as asking whether the brother has graduated from college *recently.* The addition of *yet* would further emphasize this connotation.
579,665
Look at these two questions: Has your brother graduated from college? Did your brother graduate from college? Now, both of these questions seem fine to me, but I obviously know they are a little different. However, I can’t seem to explain what the slight difference is between these grammatical sentences. I know that when I use the present perfect, I am expecting an answer of “yes, he has” or “no he hasn’t “ with no specific details of exactly when in the past. But with the simple past, usually there is a specific time in the past and it conveys finality and that it is completely finished at a specific point that the speaker knows the time reference when he/she asks that question. Is there anything else I am missing? Edit: Both are acceptable to my ear but what would people assume differently if they hear one or the other? Or is it the same? Edit: Are both acceptable to use depending on the circumstances?
2021/12/05
[ "https://english.stackexchange.com/questions/579665", "https://english.stackexchange.com", "https://english.stackexchange.com/users/389274/" ]
I will answer for US English (not sure if this will hold in UK English). If I don't have any prior knowledge about the brother, I'd ask, "Did your brother go to college?" (Depending on where the conversation went from there, I might ask, "Did he get his degree?".) I would probably only ask, "Has your brother graduated from college?" if I happen to know that the brother has some college studies under his belt. Otherwise, I'd ask, "Does your brother have a college degree?" or "Did your brother go to college?" or possibly "Did your brother graduate from college?". The latter form doesn't sound very conversational, though. If you want to get more authentic you'll want to take into account that nowadays the person might stop after a two-year degree (Associates) -- it's complicated! If that doesn't address your question, please clarify.
The past tense is used to report past events or states and is preferred in any context that does not call for a "present perfect". The present tense of the Perfect construction (aka "the present perfect tense") is formed by the present tense of *have,* followed by the past participle of the main verb. [McCawley distinguishes](https://english.stackexchange.com/a/69335/15299) four such contexts, which occur with different kinds of predicates: > > (a) The ***Universal*** sense of the Perfect, used to indicate that a state of affairs prevailed throughout some interval stretching from the past into the present > > > * *I've known Max since 1960.* > > > Universal perfects require stative or continuous predicates. Anything else will be interpreted as generic if it's possible. * *I've eaten here/walked a bit/\*hit Max/\*graduated from college since 1960.* but graduating from college is something you only do once, so you need a different type of Perfect > > (b) The ***Existential*** sense of the Perfect, used to indicate the existence of past events > > > * *I have read* Bridge of Birds *five times*. > > > Existential Perfects work with punctual predicates like *graduate from college*. The Perfect and the past tense both can describe the same event or state, but with the Perfect the emphasis is on the fact that it happened, whereas in the past it's just ordinary past notation. The next question to ask, of course, is why the speaker was concerned with its occurrence.
24,560,942
I am attempting to model an existing MSSQL table in SailsJS. Unsurprisingly the tables in the existing database have a createdAt and updatedAt column similar to what is generated by the SailsJS framework. **Is there a way to assign the value of the property generated by the SailsJS framework to an attribute that I have defined?** For example: ``` attributes: { ... creationDate:{ columnName:'cre_dt', type:'datetime', defaultsTo: this.createdAt } ... } ```
2014/07/03
[ "https://Stackoverflow.com/questions/24560942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2418179/" ]
No, but you can turn off the auto-generated property entirely and use your own: ``` autoCreatedAt: false, autoUpdatedAt: false, attributes: { creationDate: { columnName: 'cre_dt', type: 'datetime', defaultsTo: function() {return new Date();} }, updateDate: { columnName: 'upd_dt', type: 'datetime', defaultsTo: function() {return new Date();} } }, //Resonsible for actually updating the 'updateDate' property. beforeValidate:function(values,next) { values.updateDate= new Date(); next(); } ``` See the [Waterline options doc](https://github.com/balderdashy/waterline#options).
You could remap the following way: ``` attributes: { createdAt: { type: 'datetime', columnName: 'cre_dt' }, updatedAt: { type: 'datetime', columnName: 'upd_dt' }, // your other columns } ```
24,560,942
I am attempting to model an existing MSSQL table in SailsJS. Unsurprisingly the tables in the existing database have a createdAt and updatedAt column similar to what is generated by the SailsJS framework. **Is there a way to assign the value of the property generated by the SailsJS framework to an attribute that I have defined?** For example: ``` attributes: { ... creationDate:{ columnName:'cre_dt', type:'datetime', defaultsTo: this.createdAt } ... } ```
2014/07/03
[ "https://Stackoverflow.com/questions/24560942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2418179/" ]
No, but you can turn off the auto-generated property entirely and use your own: ``` autoCreatedAt: false, autoUpdatedAt: false, attributes: { creationDate: { columnName: 'cre_dt', type: 'datetime', defaultsTo: function() {return new Date();} }, updateDate: { columnName: 'upd_dt', type: 'datetime', defaultsTo: function() {return new Date();} } }, //Resonsible for actually updating the 'updateDate' property. beforeValidate:function(values,next) { values.updateDate= new Date(); next(); } ``` See the [Waterline options doc](https://github.com/balderdashy/waterline#options).
Now it's possible to use the `autoCreatedAt` and `autoUpdatedAt` to set a custom name for these fields as described at <http://sailsjs.com/documentation/concepts/models-and-orm/model-settings#?autocreatedat> > > If set to a string, that string will be used as the custom > field/column name for the createdAt attribute. > > >
24,560,942
I am attempting to model an existing MSSQL table in SailsJS. Unsurprisingly the tables in the existing database have a createdAt and updatedAt column similar to what is generated by the SailsJS framework. **Is there a way to assign the value of the property generated by the SailsJS framework to an attribute that I have defined?** For example: ``` attributes: { ... creationDate:{ columnName:'cre_dt', type:'datetime', defaultsTo: this.createdAt } ... } ```
2014/07/03
[ "https://Stackoverflow.com/questions/24560942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2418179/" ]
You could remap the following way: ``` attributes: { createdAt: { type: 'datetime', columnName: 'cre_dt' }, updatedAt: { type: 'datetime', columnName: 'upd_dt' }, // your other columns } ```
Now it's possible to use the `autoCreatedAt` and `autoUpdatedAt` to set a custom name for these fields as described at <http://sailsjs.com/documentation/concepts/models-and-orm/model-settings#?autocreatedat> > > If set to a string, that string will be used as the custom > field/column name for the createdAt attribute. > > >
446,390
I'm modeling credit fraud, where I have a small number of samples that result in fraud (1), and most samples that are not fraud (0). I am creating a models for detecting fraud based on new data. I'm using the following models: logistic regression, K-nn, Support Vector Classifier and decision tree. The dataset is very similar to this: kaggle.com/mlg-ulb/creditcardfraud I performed random undersampling on the data to get a 1:1 ratio. This made my models perform a lot better, but since the undersampling is performed randomly every time, I get a slightly different result because of the chosen samples. Is there a way to find out which of the 8200 majority class samples are best to use in the undersampled data? I was hoping to figure out which these are and only use them with the 800 positive samples on my undersampled dataset.
2020/01/25
[ "https://stats.stackexchange.com/questions/446390", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/265242/" ]
You say (but in comments, it should be in the Q proper!) that you evaluated the models by *precision, recall and f1 score*. Those measure all depends on you making a hard decision, which in the case of say logistic regression needs a probability threshold. You didn't say how you did choose that threshold, so assuming you did use the "default" of one half. There is in general no convincing reason to always use that default. Now, using undersampling of the majority class, you effectively changed the threshold (in terms of the complete data.) If you just used a different threshold with the complete data, you probably would have seen similar results. It would be better for you to see the problem as one of *risk estimation*, and then evaluate the models using some *proper scoring rule*. Then you do not need to make a hard decision. Please read carefully [Why isn't Logistic Regression called Logistic Classification?](https://stats.stackexchange.com/questions/127042/why-isnt-logistic-regression-called-logistic-classification/127044#127044) (including its links and references.)
I have found some undersampling algorithms which can be used to find out which of the majority class samples are closest to the minority ones. Some of these algorithms are Near Miss Undersampling, Condensed Nearest Neighbor Rule for Undersampling,... Using near miss data in undersampling causes massive overfitting in my model so this approach isn't viable though. Source with reproducible examples: <https://machinelearningmastery.com/undersampling-algorithms-for-imbalanced-classification/>
446,390
I'm modeling credit fraud, where I have a small number of samples that result in fraud (1), and most samples that are not fraud (0). I am creating a models for detecting fraud based on new data. I'm using the following models: logistic regression, K-nn, Support Vector Classifier and decision tree. The dataset is very similar to this: kaggle.com/mlg-ulb/creditcardfraud I performed random undersampling on the data to get a 1:1 ratio. This made my models perform a lot better, but since the undersampling is performed randomly every time, I get a slightly different result because of the chosen samples. Is there a way to find out which of the 8200 majority class samples are best to use in the undersampled data? I was hoping to figure out which these are and only use them with the 800 positive samples on my undersampled dataset.
2020/01/25
[ "https://stats.stackexchange.com/questions/446390", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/265242/" ]
The methods you list in the question are discriminative (i.e. you do not indicate that you used the one-class variety e.g. of SVM). Have you considered [one-class classification](https://en.wikipedia.org/wiki/One-class_classification)? One class classification is probably better suited for credit fraud detection than discriminative classification and as a side effect it does (by construction) not have any difficulties with class imbalance. One-class classification is good for situatione where * a\* well-defined ("positive") class is to be separated from cases that do not belong to this class. + well-defined means that the data points of this class form a (or maybe few separate) clouds, but we need not expect "surprises" in future cases (this is really not different from how we think of classes in discriminative settings) + and there are sufficient cases available from this class + \* there can be several such classes, they are treated separately. * cases that do not belong to the positive class (aka the negative class) are ill-defined: + We cannot (or need not be able to) describe those cases better than saying they do not belong to the positive class. + There may be many reasons (classes) of cases that do not belong to the positive class + any new case that does not belong to the positive class may not belong there for an entirely new reason. + Side note: specific known classes within the negatives can be modeled as their own class - this does not affect the performance of the recognition of the positive class in any way. * In one-class classification, a case can belong to more than one class (consider medical diagnosis: a patient may have several diseases that are independent of each other). Your task sounds to me as if the no-fraud cases are a prime example for a positive class. In addition, if you have examples of specific known types of fraud, you can also model them as their own class. If only few cases are available, recognition of that that (sub)class of fraud will of course be uncertain. But this will not disturb the performance of recognizing no-fraud cases.
You say (but in comments, it should be in the Q proper!) that you evaluated the models by *precision, recall and f1 score*. Those measure all depends on you making a hard decision, which in the case of say logistic regression needs a probability threshold. You didn't say how you did choose that threshold, so assuming you did use the "default" of one half. There is in general no convincing reason to always use that default. Now, using undersampling of the majority class, you effectively changed the threshold (in terms of the complete data.) If you just used a different threshold with the complete data, you probably would have seen similar results. It would be better for you to see the problem as one of *risk estimation*, and then evaluate the models using some *proper scoring rule*. Then you do not need to make a hard decision. Please read carefully [Why isn't Logistic Regression called Logistic Classification?](https://stats.stackexchange.com/questions/127042/why-isnt-logistic-regression-called-logistic-classification/127044#127044) (including its links and references.)
446,390
I'm modeling credit fraud, where I have a small number of samples that result in fraud (1), and most samples that are not fraud (0). I am creating a models for detecting fraud based on new data. I'm using the following models: logistic regression, K-nn, Support Vector Classifier and decision tree. The dataset is very similar to this: kaggle.com/mlg-ulb/creditcardfraud I performed random undersampling on the data to get a 1:1 ratio. This made my models perform a lot better, but since the undersampling is performed randomly every time, I get a slightly different result because of the chosen samples. Is there a way to find out which of the 8200 majority class samples are best to use in the undersampled data? I was hoping to figure out which these are and only use them with the 800 positive samples on my undersampled dataset.
2020/01/25
[ "https://stats.stackexchange.com/questions/446390", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/265242/" ]
The methods you list in the question are discriminative (i.e. you do not indicate that you used the one-class variety e.g. of SVM). Have you considered [one-class classification](https://en.wikipedia.org/wiki/One-class_classification)? One class classification is probably better suited for credit fraud detection than discriminative classification and as a side effect it does (by construction) not have any difficulties with class imbalance. One-class classification is good for situatione where * a\* well-defined ("positive") class is to be separated from cases that do not belong to this class. + well-defined means that the data points of this class form a (or maybe few separate) clouds, but we need not expect "surprises" in future cases (this is really not different from how we think of classes in discriminative settings) + and there are sufficient cases available from this class + \* there can be several such classes, they are treated separately. * cases that do not belong to the positive class (aka the negative class) are ill-defined: + We cannot (or need not be able to) describe those cases better than saying they do not belong to the positive class. + There may be many reasons (classes) of cases that do not belong to the positive class + any new case that does not belong to the positive class may not belong there for an entirely new reason. + Side note: specific known classes within the negatives can be modeled as their own class - this does not affect the performance of the recognition of the positive class in any way. * In one-class classification, a case can belong to more than one class (consider medical diagnosis: a patient may have several diseases that are independent of each other). Your task sounds to me as if the no-fraud cases are a prime example for a positive class. In addition, if you have examples of specific known types of fraud, you can also model them as their own class. If only few cases are available, recognition of that that (sub)class of fraud will of course be uncertain. But this will not disturb the performance of recognizing no-fraud cases.
I have found some undersampling algorithms which can be used to find out which of the majority class samples are closest to the minority ones. Some of these algorithms are Near Miss Undersampling, Condensed Nearest Neighbor Rule for Undersampling,... Using near miss data in undersampling causes massive overfitting in my model so this approach isn't viable though. Source with reproducible examples: <https://machinelearningmastery.com/undersampling-algorithms-for-imbalanced-classification/>
5,558
I often run into various licenses for commercial software, and large part of that software has a different text saying the same thing. With license proliferation being a known thing in OSS, are/were there any attempts to fight it in commercial sphere? If not, **what are the unique concerns within the FLOSS community** that made deproliferation desirable there, but not in the domain of proprietary software? (Or if there has been such an effort that I haven't heard of, what distinguishes FLOSS such that the FLOSS deproliferation effort been so much more visible?)
2017/06/02
[ "https://opensource.stackexchange.com/questions/5558", "https://opensource.stackexchange.com", "https://opensource.stackexchange.com/users/5636/" ]
There are attempts to create some standard or templates in other areas, but none that I know in commercial licenses agreements. If there were, not every contract would end up being different! An example of related effort is [common form](https://github.com/commonform) for contract [standardization](https://commonform.org/) and it may contain some licensing-related terms. Now the thing is that proliferation is rather small in the FOSS world... there are about a 1000 significant license variations (and 5 to 10 times more variations on notices..) .... whereas there are likely 10 or 100 times more variants of commercial license contracts. That's the price to pay to paying: each license you pay for is also likely to be a whole new shiny thing. You later asked: > > what are the unique concerns within the FLOSS community that made deproliferation desirable there [...]? > > > With FLOSS, one goal is to facilitate and foster reuse. Yet every package is also licensed and there are subtle license compatibility issues. If every package had a different license building complex system from FLOSS would be a nightmare (it is hard enough as it is) so naturally communities around a programming language, platform or framework have evolved to use similar or the same licensing: this makes reuse much simpler. For instance a lot of Perl project use the "Same as Perl" license, several C/C++-based userland utilities use a combo of LGPL for the library and GPL for the command line tools, several Java-based packages built on or reusing Apache-provided packages use the Apache license, some foundations or larger orgs even enforce this for simplicity and sanity such as the Apache or the Eclipse Foundations. Also FLOSS license terms are not negotiable: you either take it or pass. So there is usually no possibility of per-user variation. In contrast, the goal of commercial software is not only to maximize usage but to maximize the financial gain. Since every contract needs some transaction (e.g. some signature or agreement and some money transfer) there is not much incentive per se to facilitate these transactions across vendors. Furthermore, each contract is eventually negotiable and customers may want special terms which further increase the number of variations. Yet, some vendors (such as Atlassian at least historically) have always used very standard, non-negotiable licensing terms that apply across all their product lines to avoid license proliferation across their customers.
While I can't directly answer your question 1. In the commercial sphere I'm not sure there's an economic motivation to fight license proliferation. Most people don't read software licenses (and don't understand what's in them). It seems like this can only benefit companies (they can slip things past their users). I certainly don't see it hurting companies. 2. I would argue that, when viewing the Open Source Initiative's website, one can see an active effort on their part to curb OSS license proliferation. Specifically, the way the licenses are grouped, [listing some as redundant](https://opensource.org/licenses/category), as well as their choice to only list popular licenses on the [main Licenses Page](https://opensource.org/licenses), will both have the effect of guiding people towards a smaller subset of popular OSS licenses (and hence helps curb license proliferation).
5,558
I often run into various licenses for commercial software, and large part of that software has a different text saying the same thing. With license proliferation being a known thing in OSS, are/were there any attempts to fight it in commercial sphere? If not, **what are the unique concerns within the FLOSS community** that made deproliferation desirable there, but not in the domain of proprietary software? (Or if there has been such an effort that I haven't heard of, what distinguishes FLOSS such that the FLOSS deproliferation effort been so much more visible?)
2017/06/02
[ "https://opensource.stackexchange.com/questions/5558", "https://opensource.stackexchange.com", "https://opensource.stackexchange.com/users/5636/" ]
There are attempts to create some standard or templates in other areas, but none that I know in commercial licenses agreements. If there were, not every contract would end up being different! An example of related effort is [common form](https://github.com/commonform) for contract [standardization](https://commonform.org/) and it may contain some licensing-related terms. Now the thing is that proliferation is rather small in the FOSS world... there are about a 1000 significant license variations (and 5 to 10 times more variations on notices..) .... whereas there are likely 10 or 100 times more variants of commercial license contracts. That's the price to pay to paying: each license you pay for is also likely to be a whole new shiny thing. You later asked: > > what are the unique concerns within the FLOSS community that made deproliferation desirable there [...]? > > > With FLOSS, one goal is to facilitate and foster reuse. Yet every package is also licensed and there are subtle license compatibility issues. If every package had a different license building complex system from FLOSS would be a nightmare (it is hard enough as it is) so naturally communities around a programming language, platform or framework have evolved to use similar or the same licensing: this makes reuse much simpler. For instance a lot of Perl project use the "Same as Perl" license, several C/C++-based userland utilities use a combo of LGPL for the library and GPL for the command line tools, several Java-based packages built on or reusing Apache-provided packages use the Apache license, some foundations or larger orgs even enforce this for simplicity and sanity such as the Apache or the Eclipse Foundations. Also FLOSS license terms are not negotiable: you either take it or pass. So there is usually no possibility of per-user variation. In contrast, the goal of commercial software is not only to maximize usage but to maximize the financial gain. Since every contract needs some transaction (e.g. some signature or agreement and some money transfer) there is not much incentive per se to facilitate these transactions across vendors. Furthermore, each contract is eventually negotiable and customers may want special terms which further increase the number of variations. Yet, some vendors (such as Atlassian at least historically) have always used very standard, non-negotiable licensing terms that apply across all their product lines to avoid license proliferation across their customers.
In the FOSS world, the main incentive for license deproliferation is the ability to reuse code. If one project wants to use another project’s code, it is bound by the license under which the other project released its code. If the project later wants to incorporate code from another source with an incompatible license (i.e. such that both licenses cannot be satisfied at the same time), it cannot do so. Of course every license is issued at the sole discretion of the copyright holder, who can then choose to re-license or dual-license their code. This is “only” a matter of negotiation if the copyright holder is a single person or organization, which is why some projects have Contributor License Agreements (CLAs) under which contributors transfer copyright for their contributions to the maintainer. If a project has no such agreement in place (plenty of projects don’t), its copyright is distributed across its contributors, and the license terms can only be changed if all of them agree—which is usually impractical. None of this is an issue if all projects involved are under the same license (or at least compatible license): they can be freely combined, and the resulting code stays under the same license (or the sum of all requirements from all licenses involved). Therefore most FOSS projects choose one of the standard licenses to make their life easier. In the commercial world, things are a bit different: The code is usually works-for-hire, with the copyright holders being companies rather than individuals, and there are hardly any practical barriers to an interested client company negotiating individual license terms with the vendor of a particular piece of software. Shared copyright usually happens because of one company licensing a piece of software from another and incorporating it into their own. Here the borders tend to be clearer than in the FOSS world (one copyright holder per component), and parties to the contract usually have each other’s contact information. In short: Because individual negotiation of license terms is easier in the commercial world, there is less incentive to have standardized licenses.
15,245,767
I have just merged two branches 'branch1' and 'branch2'. The problem is that it is now a mess with a lot of conflicts, with sometimes duplicate contents (is it possible ??). What I want to do is to force for some files from 'branch1' to be merged against 'branch2' and conversely to force some files from 'branch2' to be merged against 'branch1', knowing I am now on 'branch1'. Is it possible ? Update : there seems to be problem with git-merge ? Suppose I keep the branch1 version, then ``` echo $this->fetch('prehome.html'); die; ``` would appear two times, see : ``` protected function prehomepage() { $var = 'myvar'; echo $this->fetch('prehome.html'); die; } <<<<<<< HEAD $this->mySmarty->assign('title', 'Primagora'); echo $this->fetch('prehome.html'); die; } /** * Generate the campaign block for the general sidebar, called through AJAX. */ protected function getCampaignBlock() { $from = Utils::fromGet('from'); echo $this->getCampaignSidebarBlock($from); die(); } ======= /** * Generate the campaign block for the general sidebar, called through AJAX. */ protected function getCampaignBlock() { $from = Utils::fromGet('from'); echo $this->getCampaignSidebarBlock($from); die(); } >>>>>>> branch2 ```
2013/03/06
[ "https://Stackoverflow.com/questions/15245767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1275959/" ]
On a merge with conflicts (if `git config merge.conflictstyle diff3` is set) , you can: * ignore that merge and keep your original version (from `branch1`): ``` git show :2:full_path > file # or git checkout-index --stage=2 -- file ``` * ignore that merge and keep the other version (from `branch2`): ``` git show :3:full_path > file # or git checkout-index --stage=3 -- file ``` From there, `git add` and `git commit`.
You should always try to resolve conflicts. They tell you a lot about what is going on. Netbeans can work with git which makes resolving conflicts a fairly simple task. You can resolve conflicts one by one ore choose the version you want to keep. What do you mean by duplicate contents? It's not possible to have something marked as change if it's identical in both files.
15,245,767
I have just merged two branches 'branch1' and 'branch2'. The problem is that it is now a mess with a lot of conflicts, with sometimes duplicate contents (is it possible ??). What I want to do is to force for some files from 'branch1' to be merged against 'branch2' and conversely to force some files from 'branch2' to be merged against 'branch1', knowing I am now on 'branch1'. Is it possible ? Update : there seems to be problem with git-merge ? Suppose I keep the branch1 version, then ``` echo $this->fetch('prehome.html'); die; ``` would appear two times, see : ``` protected function prehomepage() { $var = 'myvar'; echo $this->fetch('prehome.html'); die; } <<<<<<< HEAD $this->mySmarty->assign('title', 'Primagora'); echo $this->fetch('prehome.html'); die; } /** * Generate the campaign block for the general sidebar, called through AJAX. */ protected function getCampaignBlock() { $from = Utils::fromGet('from'); echo $this->getCampaignSidebarBlock($from); die(); } ======= /** * Generate the campaign block for the general sidebar, called through AJAX. */ protected function getCampaignBlock() { $from = Utils::fromGet('from'); echo $this->getCampaignSidebarBlock($from); die(); } >>>>>>> branch2 ```
2013/03/06
[ "https://Stackoverflow.com/questions/15245767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1275959/" ]
On a merge with conflicts (if `git config merge.conflictstyle diff3` is set) , you can: * ignore that merge and keep your original version (from `branch1`): ``` git show :2:full_path > file # or git checkout-index --stage=2 -- file ``` * ignore that merge and keep the other version (from `branch2`): ``` git show :3:full_path > file # or git checkout-index --stage=3 -- file ``` From there, `git add` and `git commit`.
The file you are showing is the intermediate file in an ongoing git merge whit conflicts. The lines from ``` <<<<<<< HEAD ``` to ``` ======= ``` is one version and from ``` ======== ``` to ``` >>>>>branch1 ``` is the other. You can then either edit the file by hand and pick the version to use or run a tool to help you resolve the conflicts. The git command mergetool will guide you in the process of resolving all the conflicts <https://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html> ``` git mergetool ``` git mergetool will most likely have to be configured to use your favorite conflict resolution program. I have found meld to be very helpful and intuitive. [Git mergetool with Meld on Windows](https://stackoverflow.com/questions/14821358/git-mergetool-with-meld-on-windows) or [How to set Meld as git mergetool](https://stackoverflow.com/questions/12956509/how-to-set-meld-as-git-mergetool)
1,526,510
What Is the difference between how the char datatype is stored or represented in 32bit vs 64bit in C?
2009/10/06
[ "https://Stackoverflow.com/questions/1526510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184503/" ]
There is no difference. One char occupies one byte. One byte has CHAR\_BIT bits. ``` #include <limits.h> #include <stdio.h> int main(void) { printf("a char occupies 1 byte of %d bits.\n", CHAR_BIT); return 0; } ```
One possible difference is that chars might be aligned on 64bit rather than 32bit boundaries. ``` struct { char a; char b; } ``` Might take up 2 \* 4 bytes on 32bit and 2 \* 8 bytes on 64bit. edit -actually it wouldn't. Any sane complier would repack a struct with only chars on byte boundary. However if you added a 'long c;' in the end anything could happen. That's why a) you have sizeof() and b) you should be careful doing manual pointer stuff in c.
32,176,761
Not much familiar with JQuery; I want to get id of form element in jquery which is located in following location ``` <body> <div id="boxDialog"> </div> <div class="container"> <div class="header"> Many Tables and divs </div> </div> <form id="approval"></form> Jquery: : : alert($("body.form").attr("id")); ``` Fiddle: <https://jsfiddle.net/j32f9128/>
2015/08/24
[ "https://Stackoverflow.com/questions/32176761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
**Problem:** `body.form` will select the `body` element having class of `form`, which doesn't exists so returns `undefined`. **Solution:** Use space between the `body` and `form` and remove `.`. Using space, the `form` element will be searched in `body`. ``` alert($("body form").attr("id")); ``` You can also ommit `body` here as all the `forms` are nested inside `body`. ``` alert($("form").attr("id")); ``` If you want to get the `id` of **first** form element, you can use `first()`. ``` alert($("form").first().attr("id")); ``` Or you can also ``` alert($("form:first").attr("id")); ``` [**Demo**](https://jsfiddle.net/tusharj/j32f9128/1/)
You have used `form` as classname. your selector tries to find element body that has class `form` You should rather use space that indicate matching against descendants or find selector along with tagname selectors for both body and form: ``` $("body form").attr("id"); ``` which is equivalent to ``` $("body").find("form").attr("id"); ``` **[Demo](https://jsfiddle.net/cLv2sj8k/)**
32,176,761
Not much familiar with JQuery; I want to get id of form element in jquery which is located in following location ``` <body> <div id="boxDialog"> </div> <div class="container"> <div class="header"> Many Tables and divs </div> </div> <form id="approval"></form> Jquery: : : alert($("body.form").attr("id")); ``` Fiddle: <https://jsfiddle.net/j32f9128/>
2015/08/24
[ "https://Stackoverflow.com/questions/32176761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
You have used `form` as classname. your selector tries to find element body that has class `form` You should rather use space that indicate matching against descendants or find selector along with tagname selectors for both body and form: ``` $("body form").attr("id"); ``` which is equivalent to ``` $("body").find("form").attr("id"); ``` **[Demo](https://jsfiddle.net/cLv2sj8k/)**
> > How to get id of first element (form) in body using JQuery? > > > This will get you the first form element's id in the body ``` $('body').find('form').eq(0).attr('id'); ``` [Demo](https://jsfiddle.net/j32f9128/2/)
32,176,761
Not much familiar with JQuery; I want to get id of form element in jquery which is located in following location ``` <body> <div id="boxDialog"> </div> <div class="container"> <div class="header"> Many Tables and divs </div> </div> <form id="approval"></form> Jquery: : : alert($("body.form").attr("id")); ``` Fiddle: <https://jsfiddle.net/j32f9128/>
2015/08/24
[ "https://Stackoverflow.com/questions/32176761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
**Problem:** `body.form` will select the `body` element having class of `form`, which doesn't exists so returns `undefined`. **Solution:** Use space between the `body` and `form` and remove `.`. Using space, the `form` element will be searched in `body`. ``` alert($("body form").attr("id")); ``` You can also ommit `body` here as all the `forms` are nested inside `body`. ``` alert($("form").attr("id")); ``` If you want to get the `id` of **first** form element, you can use `first()`. ``` alert($("form").first().attr("id")); ``` Or you can also ``` alert($("form:first").attr("id")); ``` [**Demo**](https://jsfiddle.net/tusharj/j32f9128/1/)
> > How to get id of first element (form) in body using JQuery? > > > This will get you the first form element's id in the body ``` $('body').find('form').eq(0).attr('id'); ``` [Demo](https://jsfiddle.net/j32f9128/2/)
32,176,761
Not much familiar with JQuery; I want to get id of form element in jquery which is located in following location ``` <body> <div id="boxDialog"> </div> <div class="container"> <div class="header"> Many Tables and divs </div> </div> <form id="approval"></form> Jquery: : : alert($("body.form").attr("id")); ``` Fiddle: <https://jsfiddle.net/j32f9128/>
2015/08/24
[ "https://Stackoverflow.com/questions/32176761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
**Problem:** `body.form` will select the `body` element having class of `form`, which doesn't exists so returns `undefined`. **Solution:** Use space between the `body` and `form` and remove `.`. Using space, the `form` element will be searched in `body`. ``` alert($("body form").attr("id")); ``` You can also ommit `body` here as all the `forms` are nested inside `body`. ``` alert($("form").attr("id")); ``` If you want to get the `id` of **first** form element, you can use `first()`. ``` alert($("form").first().attr("id")); ``` Or you can also ``` alert($("form:first").attr("id")); ``` [**Demo**](https://jsfiddle.net/tusharj/j32f9128/1/)
You can try this: `$('form').attr('id')`
32,176,761
Not much familiar with JQuery; I want to get id of form element in jquery which is located in following location ``` <body> <div id="boxDialog"> </div> <div class="container"> <div class="header"> Many Tables and divs </div> </div> <form id="approval"></form> Jquery: : : alert($("body.form").attr("id")); ``` Fiddle: <https://jsfiddle.net/j32f9128/>
2015/08/24
[ "https://Stackoverflow.com/questions/32176761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
You can try this: `$('form').attr('id')`
> > How to get id of first element (form) in body using JQuery? > > > This will get you the first form element's id in the body ``` $('body').find('form').eq(0).attr('id'); ``` [Demo](https://jsfiddle.net/j32f9128/2/)
71,698,080
I have a screen like this: [![enter image description here](https://i.stack.imgur.com/TbgZK.png)](https://i.stack.imgur.com/TbgZK.png) There is a `checkBox` right above the button. When I click on the `checkBox`, it is ticked; If it's already ticked, I want it unticked. I wrote the following code for this: ``` Checkbox( checkColor: Colors.white, value: isChecked, onChanged: (bool value) { setState(() { isChecked = value; }); }, ), ``` --- I put the checkBox here inside the `showModalBottomSheet`. When I click the checkbox, it ticks but does not appear. I tried to close and open the `showModalBottomSheet` if it is ticked. I clicked it while `showModalBottomSheet` was open, then I closed and reopened `showModalBottomSheet` and saw that it was ticked. I saw that when `showModalBottomSheet` is open, it does not click, I need to close it. `showModalBottomSheet` codes: ``` FlatButton( child: Text("Hesap Oluştur", style: TextStyle(color: Colors.blue[400], fontSize: 18, fontFamily: "Roboto-Thin"),), onPressed: () async { await showModalBottomSheet( isScrollControlled: true, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)), ), context: context, builder: (context) { return FractionallySizedBox( heightFactor: 0.75, child: Column( children: [ Padding( padding: EdgeInsets.all(15), child: Column( children: [ Text("Hesap Oluştur", style: TextStyle(fontSize: 25, fontFamily: "Roboto-Bold"),), SizedBox(height: 8), Text("Hesap oluşturmak oldukça basittir. Bilgilerini gir, hesabını oluştur.",style: TextStyle(fontSize: 18, fontFamily: "Roboto-Thin"), textAlign: TextAlign.center,), SizedBox(height: 10), Divider(thickness: 1,), SizedBox(height: 10), TextFormField( decoration: InputDecoration( hintText: "E-posta", prefixIcon: Icon(Icons.mail) ), style: TextStyle(fontSize: 18), ), SizedBox(height: 15), TextFormField( decoration: InputDecoration( hintText: "Ad-soyad", prefixIcon: Icon(Icons.person) ), style: TextStyle(fontSize: 18), ), SizedBox(height: 15), TextFormField( obscureText: true, decoration: InputDecoration( hintText: "Şifre", prefixIcon: Icon(Icons.lock) ), style: TextStyle(fontSize: 18), ), SizedBox(height: 15), TextFormField( obscureText: true, decoration: InputDecoration( hintText: "Şifreyi doğrula", prefixIcon: Icon(Icons.lock) ), style: TextStyle(fontSize: 18), ), Checkbox( checkColor: Colors.white, value: isChecked, onChanged: (bool value) { setState(() { isChecked = value; }); }, ), RaisedButton( child: Padding( padding: const EdgeInsets.only(right: 85, left: 85, top: 12, bottom: 12), child: Text("Create account", style: TextStyle(color: Colors.white, fontSize: 20, fontFamily: "Roboto-Thin"),), ), color: Colors.blue[400], textColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.0), ), onPressed: () { //Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage())); }, ), ], ), ) ], ), ); } ); }, ), ``` How can I solve this problem? I appreciate the help in advance.
2022/03/31
[ "https://Stackoverflow.com/questions/71698080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18003111/" ]
Hi Emir Bolat you need to wrap your "FractionallySizedBox" with "statefulBuilder" and that's it. Thanks
I was doing something similiar, in the return for the modal I created a seperate stateful widget ie ``` showModalBottomSheet( context: context, builder: (BuildContext context) { return ListView.builder( itemCount: 3, itemBuilder: (context, index) { return RadioListBuilder(); }, ); }); ``` and then a seperate stateful class ``` class RadioListBuilderState extends State<RadioListBuilder> { var isChecked = false; @override Widget build(BuildContext context) { return CheckboxListTile( value: Provider.of<ListValueNotifier>(context).isChecked, onChanged: (bool) => Provider.of<ListValueNotifier>(context, listen: false).setValue(), // (newValue) { // setState(() { // isChecked = newValue!; // if (isChecked == true && value <= 2) { // value++; // } else { // value--; // } // print(value); // }); // }, controlAffinity: ListTileControlAffinity.leading, ); } } ``` and that solved the issue for me of not being able to check it
53,655,563
I'm trying to parse an XML file using "lxml" module in Python. My xml is: ``` <?xml version="1.0"?> <root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <GEOMdata> <numEL>2</numEL> <EL> <isEMPTY>true</isEMPTY> <SECdata> <SEC> <Z>10.00</Z> <A>20.00</A> <P>30.00</P> </SEC> <SEC> <Z>40.00</Z> <A>50.00</A> <P>60.00</P> </SEC> </SECdata> </EL> <EL> <isEMPTY>false</isEMPTY> <SECdata> <SEC> <Z>15.00</Z> <A>25.00</A> <P>35.00</P> </SEC> <SEC> <Z>45.00</Z> <A>55.00</A> <P>65.00</P> </SEC> </SECdata> </EL> </GEOMdata> </root> ``` I want to write a text file for each "EL" reporting isEMPTY value and a list of Z,A,P values. Despite the I/O I don't understand how to access this file. For the moment I wrote that code: ``` from lxml import etree parser = etree.XMLParser(encoding='UTF-8') tree = etree.parse("TEST.xml", parser=parser) for ELtest in tree.xpath('/root/GEOMdata/EL'): print (ELtest.findtext('isEMPTY')) ``` and the output is correct: ``` true false ``` Now I don't know how to access the children element Z,A,P "inside" ELtest. Thanks for your kind help. EDIT: The desired output is a formatted file like this: ``` 1 true # Z A P # 10 20 30 40 50 60 2 false # Z A P # 15 25 35 45 55 65 ```
2018/12/06
[ "https://Stackoverflow.com/questions/53655563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7252497/" ]
[Date Functions](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions): Use `datediff` and `case` ``` select Name,startdate,enddate, case when datediff(enddate,startdate) < 60 then 1 else 0 end flag from table ``` If you are comparing the previous row's enddate, use `lag()` ``` select Name,startdate,enddate, case when datediff(startdate,prev_enddate) < 60 then 1 else 0 end flag from ( select Name,startdate,enddate, lag(endate) over(partition by Name order by startdate,enddate) as prev_enddate from table ) t ```
Use `lag` to get the enddate of the previous row (per name). After this the `flag` can be set per name using `max` window function with a `case` expression that checks to see if the 60 day diff is satisfied at least once per name. ``` select name ,startdate ,enddate ,max(case when datediff(startdate,prev_end_dt) < 60 then 1 else 0 end) over(partition by name) as flag from (select t.* ,lag(enddate) over(partition by name order by startdate) as prev_end_dt from table t ) t ```
66,457,672
I came across one issue that I cannot create SSRS databases on Azure SQL Database, netiher I can use the migrated databases of report server in the SSRS Config manager, can anyone explain why is this a limitation and something like Managed Instance or Azure SQL VM is needed in this case? Is there no other way of configuring Azure SQL Database with SSRS?
2021/03/03
[ "https://Stackoverflow.com/questions/66457672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7790172/" ]
Azure SQL database didn't explain why SSRS is not supported in Azure SQL database. I think the reason the that [Azure SQL database](https://learn.microsoft.com/en-us/azure/azure-sql/azure-sql-iaas-vs-paas-what-is-overview) is PAAS and different between IAAS: Azure MI and SQL server in VMS: [![enter image description here](https://i.stack.imgur.com/y5scJ.png)](https://i.stack.imgur.com/y5scJ.png) And for now, there is no way to configure SSRS for Azure SQL database. SQL database product team confirmed this. Ref this [feedback](https://feedback.azure.com/forums/217321-sql-database/suggestions/7955331-support-sql-server-reporting-service): * "**Thanks for your feedback here. You can do SSRS today in an Azure VM. I’m closing this as we have no plans in SQL DB to significantly grow it’s scope to SSRS.**" If you still want to SSRS, you need to choose Azure SQL managed instance or SQL Server in VMs. HTH. [![enter image description here](https://i.stack.imgur.com/Q6Gl4.png)](https://i.stack.imgur.com/Q6Gl4.png)
I think that you can pick a Azure Virtual Machine and then get things done by yourself, from scratch. Or you can create RDLC and run them inside a web application, using Azure Database as data source.
38,846,292
I have set up a search form for my database. When I search and results are found a message is echoed below the search form. For instance, 10 records found, 0 records found. How can I get that message to disappear if the search form field is blank/empty. Currently it displays **15 records found** for a blank/empty search field. Which is all the database records. Thanks for any help. **Form:** ``` <form action="" method="post"> <input type="text" name="search_box" value="<?php if (isset($_POST['search_box'])) echo $_POST['search_box']; ?>" placeholder="Search here ..."/> <input value="Search" name="search" type="submit" /><br> </form> ``` **PHP:** ``` <?php $count = mysqli_num_rows($result); if($count > 0){ echo $count . " Records Found"; }if($count == 0){ echo "0 Records Found"; }if($count == ""){ echo ""; } ?> ``` **Query:** ``` //Retrieve the practice posts from the database table $query = "SELECT * FROM practice"; //check if search... button clicked, if so query fields if(isset($_POST['search'])){ $search_term = trim($_POST['search_box']); $query .= " WHERE title = '{$search_term}'"; $query .= " or subject LIKE '%{$search_term}%'";} ```
2016/08/09
[ "https://Stackoverflow.com/questions/38846292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2494593/" ]
``` <?php //Retrieve the practice posts from the database table $query = "SELECT * FROM practice"; //check if search... button clicked, if so query fields if(isset($_POST['search'])){ $search_term = trim($_POST['search_box']); $query .= " WHERE title = '{$search_term}'"; $query .= " or subject LIKE '%{$search_term}%'"; //execute your query $result = $dbconnect->query($query); $count = mysqli_num_rows($result); if($count > 0){ echo $count . " Records Found"; } if($count == 0){ echo "0 Records Found"; } } else { // it is mean your search box value($_POST['search']) is empty, so it will echo null value echo $_POST['search']; } ?> ``` please try, hope will save your day :D
Please replace PHP code with these one :- ``` <?php if(isset($_REQUEST['search_box'])){ $count = mysqli_num_rows($result); } else { $count = ''; } if($count > 0){ echo $count . " Records Found"; }if($count == 0){ echo "0 Records Found"; }if($count == ""){ echo ""; } ?> ```
38,846,292
I have set up a search form for my database. When I search and results are found a message is echoed below the search form. For instance, 10 records found, 0 records found. How can I get that message to disappear if the search form field is blank/empty. Currently it displays **15 records found** for a blank/empty search field. Which is all the database records. Thanks for any help. **Form:** ``` <form action="" method="post"> <input type="text" name="search_box" value="<?php if (isset($_POST['search_box'])) echo $_POST['search_box']; ?>" placeholder="Search here ..."/> <input value="Search" name="search" type="submit" /><br> </form> ``` **PHP:** ``` <?php $count = mysqli_num_rows($result); if($count > 0){ echo $count . " Records Found"; }if($count == 0){ echo "0 Records Found"; }if($count == ""){ echo ""; } ?> ``` **Query:** ``` //Retrieve the practice posts from the database table $query = "SELECT * FROM practice"; //check if search... button clicked, if so query fields if(isset($_POST['search'])){ $search_term = trim($_POST['search_box']); $query .= " WHERE title = '{$search_term}'"; $query .= " or subject LIKE '%{$search_term}%'";} ```
2016/08/09
[ "https://Stackoverflow.com/questions/38846292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2494593/" ]
``` <?php //Retrieve the practice posts from the database table $query = "SELECT * FROM practice"; //check if search... button clicked, if so query fields if(isset($_POST['search'])){ $search_term = trim($_POST['search_box']); $query .= " WHERE title = '{$search_term}'"; $query .= " or subject LIKE '%{$search_term}%'"; //execute your query $result = $dbconnect->query($query); $count = mysqli_num_rows($result); if($count > 0){ echo $count . " Records Found"; } if($count == 0){ echo "0 Records Found"; } } else { // it is mean your search box value($_POST['search']) is empty, so it will echo null value echo $_POST['search']; } ?> ``` please try, hope will save your day :D
Just put your code in the post method ``` if ((isset($_POST['search_box'])) && ($_POST['search_box']!="")) { $count = mysqli_num_rows($result); if($count > 0){ echo $count . " Records Found"; }if($count == 0){ echo "0 Records Found"; }if($count == ""){ echo ""; } } ```
20,024,531
I need this file for tutorials, but I can't find it anywhere on the internet. Help somebody?
2013/11/16
[ "https://Stackoverflow.com/questions/20024531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2943202/" ]
Any tutorial that uses `iostream.h` is twenty years out of date; that header was used in pre-standard C++, but has never been part of the ISO standard. Find a newer tutorial; one that uses `iostream`.
The iostream library is usually called just `iostream` in most IDE's. Just `#include <iostream>` should do.
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
If the purpose is satellite communication between Earth and the Moon, here's my ranking of the options, from simple and cheap to exotic and expensive: 1. **No satellites**, a set of **laser ground stations** operates from the Earth surface to one or two sites on the Moon. The Moon's Earth-facing side always has line-of-sight with Earth, it's a lot cheaper to create a ground-based laser network, and they don't have to be put on the end of a huge firework either. [Moon bounce](http://en.wikipedia.org/wiki/Earth-Moon-Earth_communication) [wikipedia] 2. Earth-Moon **L4/L5** Lagrange point satellite. One satellite, always has visibility of Earth and Moon. Pros are that you only needed one thing on a huge firework, and these points are stable so it should stay there without needing fuel for course correction. The downsides are that you still need an Earth-based network of ground stations or satellites to link to as the Earth turns, and data will be completing 2 sides of a triangle, so the already bad latency (1300ms) will be made worse (~2300ms). [E-M L-points](http://hyperphysics.phy-astr.gsu.edu/hbase/mechanics/lagpt.html) [hyperphysics] 3. 1 Earth sat in a **wide polar orbit**. By synchronizing the orbit with that of the Moon, you could ensure that the Earth never blocks line of sight. However, this would require both a wide orbit to minimise the angular size of the Earth and a long period to permit the Moon to transit the angular size of the Earth during a fraction of its orbit. Helpfully long periods and large orbital radii go hand in hand. I think an odd fraction of the Moon orbital period (1/3, 1/5, 1/7) would permit an arrangement which prevented direct alignment of the Earth between them. I don't know if the Sun would drag this out of line, so occasional propulsion might be needed. 4. Earth-Moon **L1**. Again one satellite, so one giant rocket, but this time it will need propulsion as L1 is not a stable point (when it drifts away from L1, it will need to propel itself back). This should be doable with ion thrusters though, so only a moderately enlarged firework. Being directly between Earth and the Moon would have 2 Pros - easy to find, and the lowest latency. 5. **2+ Earth sats**, orthogonal Polar orbits or same orbit 180 degrees apart. One or other satellite can always see the Moon, as when one is obscured by the Earth, the other is not. Same requirement for a ground-based network. Lather, rinse repeat for more satellites. 6. 1 Earth sat in polar orbit (as per the question), but with a matter-scoop fuelled ion thruster performing **continuous course correction**. Making the satellite and putting it up there is straightforward, but the propulsion would be entirely experimental. It would be worth putting up a sister satellite with nuclear fuel so that you could spend a bit longer refining the technology when the first one seizes up.
Yes, it's possible .. A polar orbit that has a longitudinal transition of the exact amount of speed the moon circles the Earth would allow such a thing.
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
<http://en.wikipedia.org/wiki/Lagrangian_point> A satellite orbiting at the L1 point or L2 point would be in constant contact with the moon. Unfortunately, neither of these are particularly useful for keeping in contact with a lunar mission. The L1 point is between the earth and the moon, and would offer no advantages over just putting the reciever on earth. The L2 point is on the far side of the moon, and would therefore not be able to communicate with earth. <http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19680015886.pdf> This article seems to be exactly what you want. They conclude that a satellite near L2 would work.
If the purpose is satellite communication between Earth and the Moon, here's my ranking of the options, from simple and cheap to exotic and expensive: 1. **No satellites**, a set of **laser ground stations** operates from the Earth surface to one or two sites on the Moon. The Moon's Earth-facing side always has line-of-sight with Earth, it's a lot cheaper to create a ground-based laser network, and they don't have to be put on the end of a huge firework either. [Moon bounce](http://en.wikipedia.org/wiki/Earth-Moon-Earth_communication) [wikipedia] 2. Earth-Moon **L4/L5** Lagrange point satellite. One satellite, always has visibility of Earth and Moon. Pros are that you only needed one thing on a huge firework, and these points are stable so it should stay there without needing fuel for course correction. The downsides are that you still need an Earth-based network of ground stations or satellites to link to as the Earth turns, and data will be completing 2 sides of a triangle, so the already bad latency (1300ms) will be made worse (~2300ms). [E-M L-points](http://hyperphysics.phy-astr.gsu.edu/hbase/mechanics/lagpt.html) [hyperphysics] 3. 1 Earth sat in a **wide polar orbit**. By synchronizing the orbit with that of the Moon, you could ensure that the Earth never blocks line of sight. However, this would require both a wide orbit to minimise the angular size of the Earth and a long period to permit the Moon to transit the angular size of the Earth during a fraction of its orbit. Helpfully long periods and large orbital radii go hand in hand. I think an odd fraction of the Moon orbital period (1/3, 1/5, 1/7) would permit an arrangement which prevented direct alignment of the Earth between them. I don't know if the Sun would drag this out of line, so occasional propulsion might be needed. 4. Earth-Moon **L1**. Again one satellite, so one giant rocket, but this time it will need propulsion as L1 is not a stable point (when it drifts away from L1, it will need to propel itself back). This should be doable with ion thrusters though, so only a moderately enlarged firework. Being directly between Earth and the Moon would have 2 Pros - easy to find, and the lowest latency. 5. **2+ Earth sats**, orthogonal Polar orbits or same orbit 180 degrees apart. One or other satellite can always see the Moon, as when one is obscured by the Earth, the other is not. Same requirement for a ground-based network. Lather, rinse repeat for more satellites. 6. 1 Earth sat in polar orbit (as per the question), but with a matter-scoop fuelled ion thruster performing **continuous course correction**. Making the satellite and putting it up there is straightforward, but the propulsion would be entirely experimental. It would be worth putting up a sister satellite with nuclear fuel so that you could spend a bit longer refining the technology when the first one seizes up.
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
<http://en.wikipedia.org/wiki/Lagrangian_point> A satellite orbiting at the L1 point or L2 point would be in constant contact with the moon. Unfortunately, neither of these are particularly useful for keeping in contact with a lunar mission. The L1 point is between the earth and the moon, and would offer no advantages over just putting the reciever on earth. The L2 point is on the far side of the moon, and would therefore not be able to communicate with earth. <http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19680015886.pdf> This article seems to be exactly what you want. They conclude that a satellite near L2 would work.
Yes, it's possible .. A polar orbit that has a longitudinal transition of the exact amount of speed the moon circles the Earth would allow such a thing.
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
It is possible in several ways. Let's get the dumb ones out the way first. 1. As I commented, you can orbit the moon itself. Technically correct, since anything orbiting the moon is also orbiting the Earth. 2. You can make your satellite big enough so that it always has a line-of-sight. A giant pole somewhat longer than the Earth's diameter can be arranged to orbit so as have a point with in line-of-sight. 3. Similarly, you can make your satellite encircle the Earth (a Niven ring or Dyson sphere) Not outside-the-box answers: 4. You can orbit at a Lagrange Point. As this diagram of exactly your situation shows, any except $L\_3$ are fine: ![enter image description here](https://i.stack.imgur.com/lHq1z.gif) 5. I haven't run the numbers on this, but it should be possible to make a synchronized polar orbit with the moon. I thought up a simple example: > > Say the orbital inclination of the moon were $0^{\circ}$ and circular. Set up your satellite in the same orbit but at inclination $90^{\circ}$ and behind by a quarter orbit. It might be a little hard to visualize, but in this configuration the line of sight never passes through the Earth. > > >
Yes, it's possible .. A polar orbit that has a longitudinal transition of the exact amount of speed the moon circles the Earth would allow such a thing.
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
It is possible in several ways. Let's get the dumb ones out the way first. 1. As I commented, you can orbit the moon itself. Technically correct, since anything orbiting the moon is also orbiting the Earth. 2. You can make your satellite big enough so that it always has a line-of-sight. A giant pole somewhat longer than the Earth's diameter can be arranged to orbit so as have a point with in line-of-sight. 3. Similarly, you can make your satellite encircle the Earth (a Niven ring or Dyson sphere) Not outside-the-box answers: 4. You can orbit at a Lagrange Point. As this diagram of exactly your situation shows, any except $L\_3$ are fine: ![enter image description here](https://i.stack.imgur.com/lHq1z.gif) 5. I haven't run the numbers on this, but it should be possible to make a synchronized polar orbit with the moon. I thought up a simple example: > > Say the orbital inclination of the moon were $0^{\circ}$ and circular. Set up your satellite in the same orbit but at inclination $90^{\circ}$ and behind by a quarter orbit. It might be a little hard to visualize, but in this configuration the line of sight never passes through the Earth. > > >
Besides of orbiting Lagrangian points, orbiting around Earth or Moon of 90 degrees with respect to Earth-moon plane inclination can be a solution. There is a simple image I made. First one (orbiting around Earth) can be the cheapest solution of all because it is low-orbit. ![enter image description here](https://i.stack.imgur.com/rafgk.png)
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
<http://en.wikipedia.org/wiki/Lagrangian_point> A satellite orbiting at the L1 point or L2 point would be in constant contact with the moon. Unfortunately, neither of these are particularly useful for keeping in contact with a lunar mission. The L1 point is between the earth and the moon, and would offer no advantages over just putting the reciever on earth. The L2 point is on the far side of the moon, and would therefore not be able to communicate with earth. <http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19680015886.pdf> This article seems to be exactly what you want. They conclude that a satellite near L2 would work.
Yes. You could place it at any of the Lagrange points that have LOS to the Moon. The first solution I would explore would be to place it in orbit about the Moon itself on a route that is generally perpendicular to the Earth. There should be a number of acceptable orbital solutions to this problem, and dealing with larger bodies farther out will cost the least fuel for maintenance (but a larger amount for launch).
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
It is possible in several ways. Let's get the dumb ones out the way first. 1. As I commented, you can orbit the moon itself. Technically correct, since anything orbiting the moon is also orbiting the Earth. 2. You can make your satellite big enough so that it always has a line-of-sight. A giant pole somewhat longer than the Earth's diameter can be arranged to orbit so as have a point with in line-of-sight. 3. Similarly, you can make your satellite encircle the Earth (a Niven ring or Dyson sphere) Not outside-the-box answers: 4. You can orbit at a Lagrange Point. As this diagram of exactly your situation shows, any except $L\_3$ are fine: ![enter image description here](https://i.stack.imgur.com/lHq1z.gif) 5. I haven't run the numbers on this, but it should be possible to make a synchronized polar orbit with the moon. I thought up a simple example: > > Say the orbital inclination of the moon were $0^{\circ}$ and circular. Set up your satellite in the same orbit but at inclination $90^{\circ}$ and behind by a quarter orbit. It might be a little hard to visualize, but in this configuration the line of sight never passes through the Earth. > > >
One more option--not in orbit at all. You can use solar sails to hover a satellite over the north or south pole or Earth. The patent on this has expired, you're free to do it. Note that such a satellite must be far out, the lag going through the satellite will be considerably greater than the Earth-Moon lag. On the flip side, it will retain communication with a equatorial-orbit satellite when it goes "behind" the moon so long as it's not in too low an orbit. <http://en.wikipedia.org/wiki/Statite>
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
If I understand your edited question, then no. While the Earth's J2 (oblateness) produces enough torque to rotate a Sun-synchronous orbit once a year, it does not produce enough torque to rotate a "Moon-synchronous orbit" once a month. So there is no such orbit. I am not clear on what the utility of such an orbit would be, even if it did exist. If you're going to point antennas at the Moon from the near vicinity of Earth, you can have many more antennas and much larger antennas on the surface of the Earth than what you would be able to put into Earth orbit for an equal amount of money. You would only need to divide your total aperture by three to account for the downside of not always being able to see the Moon.
Yes. You could place it at any of the Lagrange points that have LOS to the Moon. The first solution I would explore would be to place it in orbit about the Moon itself on a route that is generally perpendicular to the Earth. There should be a number of acceptable orbital solutions to this problem, and dealing with larger bodies farther out will cost the least fuel for maintenance (but a larger amount for launch).
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
It is possible in several ways. Let's get the dumb ones out the way first. 1. As I commented, you can orbit the moon itself. Technically correct, since anything orbiting the moon is also orbiting the Earth. 2. You can make your satellite big enough so that it always has a line-of-sight. A giant pole somewhat longer than the Earth's diameter can be arranged to orbit so as have a point with in line-of-sight. 3. Similarly, you can make your satellite encircle the Earth (a Niven ring or Dyson sphere) Not outside-the-box answers: 4. You can orbit at a Lagrange Point. As this diagram of exactly your situation shows, any except $L\_3$ are fine: ![enter image description here](https://i.stack.imgur.com/lHq1z.gif) 5. I haven't run the numbers on this, but it should be possible to make a synchronized polar orbit with the moon. I thought up a simple example: > > Say the orbital inclination of the moon were $0^{\circ}$ and circular. Set up your satellite in the same orbit but at inclination $90^{\circ}$ and behind by a quarter orbit. It might be a little hard to visualize, but in this configuration the line of sight never passes through the Earth. > > >
Yes. You could place it at any of the Lagrange points that have LOS to the Moon. The first solution I would explore would be to place it in orbit about the Moon itself on a route that is generally perpendicular to the Earth. There should be a number of acceptable orbital solutions to this problem, and dealing with larger bodies farther out will cost the least fuel for maintenance (but a larger amount for launch).
5,649
Could a satellite, without too much fuel consumption for station keeping, orbit the Earth so that it always has a line of sight to the Moon? It would need a near polar orbit which precesses in tandem with the Moon's orbit around Earth. Wouldn't that be the perfect communication satellite orbit for constantly staying in touch with Lunar missions? Have any satellites used such an orbit and does that type of orbit have a three letter name? EDIT: I'm looking for the possibility of a satellite orbiting Earth's poles so that it can always have contact with the Earth facing side of the Moon, and with satellites in lunar polar orbit which precess so that they remain in line of sight with this satellite (and the rotating Earth). A potential use for this would be that such a polar Earth satellite would have a relatively small altitude and be able to relay data to Earth more easily than having to use something like the Deep Space Network spread across the equator.
2014/10/20
[ "https://space.stackexchange.com/questions/5649", "https://space.stackexchange.com", "https://space.stackexchange.com/users/1457/" ]
<http://en.wikipedia.org/wiki/Lagrangian_point> A satellite orbiting at the L1 point or L2 point would be in constant contact with the moon. Unfortunately, neither of these are particularly useful for keeping in contact with a lunar mission. The L1 point is between the earth and the moon, and would offer no advantages over just putting the reciever on earth. The L2 point is on the far side of the moon, and would therefore not be able to communicate with earth. <http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19680015886.pdf> This article seems to be exactly what you want. They conclude that a satellite near L2 would work.
It is possible in several ways. Let's get the dumb ones out the way first. 1. As I commented, you can orbit the moon itself. Technically correct, since anything orbiting the moon is also orbiting the Earth. 2. You can make your satellite big enough so that it always has a line-of-sight. A giant pole somewhat longer than the Earth's diameter can be arranged to orbit so as have a point with in line-of-sight. 3. Similarly, you can make your satellite encircle the Earth (a Niven ring or Dyson sphere) Not outside-the-box answers: 4. You can orbit at a Lagrange Point. As this diagram of exactly your situation shows, any except $L\_3$ are fine: ![enter image description here](https://i.stack.imgur.com/lHq1z.gif) 5. I haven't run the numbers on this, but it should be possible to make a synchronized polar orbit with the moon. I thought up a simple example: > > Say the orbital inclination of the moon were $0^{\circ}$ and circular. Set up your satellite in the same orbit but at inclination $90^{\circ}$ and behind by a quarter orbit. It might be a little hard to visualize, but in this configuration the line of sight never passes through the Earth. > > >
46,580,981
I have a requirement to do the following: 1. Get a list of "lines" by calling an internal function (getLines()). 2. Select the first line, perform an action 3. After the previous action finishes, select the next line and do the same action 4. Repeat for all lines (3-20 depending on user) I have the following code in place: ``` App.Lines = response.data; for (var _i = 0; _i < App.Lines.length; _i++) { var makeCallPromise = new Promise( function(resolve, reject) { Session.connection.ol.makeCall(App.Lines[_i], callBackFunction(response) { //this can take up to 30 seconds to respond... resolve(response.data); }, errorCallBackFunction(message) { reject(message.error); }, bareJid); } ) makeCallPromise.then(function(fulfilled) { console.log("PROMISE WORKED!!!!!", fulfilled); }) .catch(function(error) { console.log("PROMISE FAILED!!!!!", error); }); } ``` My hope was that the loop would wait to resolve the promise before it continued the loop, however, that's not the case. My question is whether or not it's possible to halt the loop until the resolution is complete. Note - I am using the bluebird JS library for promises. Thank you! Kind Regards, Gary
2017/10/05
[ "https://Stackoverflow.com/questions/46580981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2265237/" ]
I don't know about bluebird, but you can do something like that to create some kind of for loop that waits for each promise to end before the next iteration. Here is a generic example, it could certainly be optimized, it's just a quick attempt: ``` var i = 0; var performAsyncOperation = function(operationNumber) { return new Promise(function(resolve, reject){ console.log('Operation number', operationNumber); resolve(); }); } var chainAsyncOperations = function() { if(++i < 10) { return performAsyncOperation(i).then(chainAsyncOperations); } }; performAsyncOperation(i).then(chainAsyncOperations); ``` Hoping this will help you ;)
You can use [Promise.each()](http://bluebirdjs.com/docs/api/promise.each.html) provided by bluebird, It would traverse an array serially and wait for them to resolve before moving to the next element in the array
46,580,981
I have a requirement to do the following: 1. Get a list of "lines" by calling an internal function (getLines()). 2. Select the first line, perform an action 3. After the previous action finishes, select the next line and do the same action 4. Repeat for all lines (3-20 depending on user) I have the following code in place: ``` App.Lines = response.data; for (var _i = 0; _i < App.Lines.length; _i++) { var makeCallPromise = new Promise( function(resolve, reject) { Session.connection.ol.makeCall(App.Lines[_i], callBackFunction(response) { //this can take up to 30 seconds to respond... resolve(response.data); }, errorCallBackFunction(message) { reject(message.error); }, bareJid); } ) makeCallPromise.then(function(fulfilled) { console.log("PROMISE WORKED!!!!!", fulfilled); }) .catch(function(error) { console.log("PROMISE FAILED!!!!!", error); }); } ``` My hope was that the loop would wait to resolve the promise before it continued the loop, however, that's not the case. My question is whether or not it's possible to halt the loop until the resolution is complete. Note - I am using the bluebird JS library for promises. Thank you! Kind Regards, Gary
2017/10/05
[ "https://Stackoverflow.com/questions/46580981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2265237/" ]
I don't know about bluebird, but you can do something like that to create some kind of for loop that waits for each promise to end before the next iteration. Here is a generic example, it could certainly be optimized, it's just a quick attempt: ``` var i = 0; var performAsyncOperation = function(operationNumber) { return new Promise(function(resolve, reject){ console.log('Operation number', operationNumber); resolve(); }); } var chainAsyncOperations = function() { if(++i < 10) { return performAsyncOperation(i).then(chainAsyncOperations); } }; performAsyncOperation(i).then(chainAsyncOperations); ``` Hoping this will help you ;)
This Use Case perfectly matches the ES7 feature `async await`, If you have the possibility to transpile your code using babeljs, you could refactor your function like this : ``` function createPromise(line) { return new Promise( function(resolve, reject) { Session.connection.ol.makeCall(line, callBackFunction(response) { //this can take up to 30 seconds to respond... resolve(response.data); }, errorCallBackFunction(message) { reject(message.error); }, bareJid); } ); } App.Lines = response.data; async function main() { for (var _i = 0; _i < App.Lines.length; _i++) { try { var result = await createPromise(App.Lines[_i]); console.log(result); } catch (err) { console.log(err); } } } main().then(function() { console.log('finished'); }); ```
46,580,981
I have a requirement to do the following: 1. Get a list of "lines" by calling an internal function (getLines()). 2. Select the first line, perform an action 3. After the previous action finishes, select the next line and do the same action 4. Repeat for all lines (3-20 depending on user) I have the following code in place: ``` App.Lines = response.data; for (var _i = 0; _i < App.Lines.length; _i++) { var makeCallPromise = new Promise( function(resolve, reject) { Session.connection.ol.makeCall(App.Lines[_i], callBackFunction(response) { //this can take up to 30 seconds to respond... resolve(response.data); }, errorCallBackFunction(message) { reject(message.error); }, bareJid); } ) makeCallPromise.then(function(fulfilled) { console.log("PROMISE WORKED!!!!!", fulfilled); }) .catch(function(error) { console.log("PROMISE FAILED!!!!!", error); }); } ``` My hope was that the loop would wait to resolve the promise before it continued the loop, however, that's not the case. My question is whether or not it's possible to halt the loop until the resolution is complete. Note - I am using the bluebird JS library for promises. Thank you! Kind Regards, Gary
2017/10/05
[ "https://Stackoverflow.com/questions/46580981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2265237/" ]
I don't know about bluebird, but you can do something like that to create some kind of for loop that waits for each promise to end before the next iteration. Here is a generic example, it could certainly be optimized, it's just a quick attempt: ``` var i = 0; var performAsyncOperation = function(operationNumber) { return new Promise(function(resolve, reject){ console.log('Operation number', operationNumber); resolve(); }); } var chainAsyncOperations = function() { if(++i < 10) { return performAsyncOperation(i).then(chainAsyncOperations); } }; performAsyncOperation(i).then(chainAsyncOperations); ``` Hoping this will help you ;)
You should use `Bluebird#each` method: > > .each(function(any item, int index, int length) iterator) -> Promise > > > Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (value, index, length) where value is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. > > > ``` Promise.each(App.Lines, line => { return new Promise((resolve, reject) => { Session.connection.ol.makeCall(line, callBackFunction(response) { resolve(response.data); }, errorCallBackFunction(message) { reject(message.error); }, bareJid); }) .then(fulfilled => console.log("PROMISE WORKED!!!!!", fulfilled)) .catch(err => onsole.log("PROMISE FAILED!!!!!", err)); }); ```
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
Are you running on a Linux 2.4 kernel? From VMware KB article #1420 (<http://kb.vmware.com/kb/1420>). > > Linux guest operating systems keep > time by counting timer interrupts. > Unpatched 2.4 and earlier kernels > program the virtual system timer to > request clock interrupts at 100Hz (100 > interrupts per second). 2.6 kernels, > on the other hand, request interrupts > at 1000Hz - ten times as often. Some > 2.4 kernels modified by distribution vendors to contain 2.6 features also > request 1000Hz interrupts, or in some > cases, interrupts at other rates, such > as 512Hz. > > >
Can you at least use nanosleep in your loop to sleep for 1ms? Or is that a glibc thing? **Update:** Never mind, I see from the man page "it can take up to 10 ms longer than specified until the process becomes runnable again"
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
I think you'll have trouble achieving 1 ms precision with standard Linux even with constant querying in the main loop, because the kernel does not ensure your application will get CPU all the time. For example, you can be put to sleep for dozens of milliseconds because of preemptive multitasking and there's little you can do about it. You might want to look into [Real-Time Linux](http://rt.wiki.kernel.org/index.php/Main_Page).
Are you running on a Linux 2.4 kernel? From VMware KB article #1420 (<http://kb.vmware.com/kb/1420>). > > Linux guest operating systems keep > time by counting timer interrupts. > Unpatched 2.4 and earlier kernels > program the virtual system timer to > request clock interrupts at 100Hz (100 > interrupts per second). 2.6 kernels, > on the other hand, request interrupts > at 1000Hz - ten times as often. Some > 2.4 kernels modified by distribution vendors to contain 2.6 features also > request 1000Hz interrupts, or in some > cases, interrupts at other rates, such > as 512Hz. > > >
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
Polling in the main loop isn't an answer either - your process might not get much CPU time, so more than 10ms will elapse before your code gets to run, rendering it moot. 10ms is about the standard timer resolution for most non-[realtime operating systems](http://en.wikipedia.org/wiki/Real-time_operating_system) (RTOS). But it is moot in a non-RTOS - the behaviour of the scheduler and dispatcher is going to greatly influence how quickly you can respond to a timer expiring. For example even suppose you had a sub 10ms resolution timer, you can't respond to the timer expiring if your code isn't running. Since you can't predict when your code is going to run, you can't respond to timer expiration accurately. There is of course realtime linux kernels, see <http://www.linuxdevices.com/articles/AT8073314981.html> for a list. A RTOS offers facilities whereby you can get soft or hard guarantees about when your code is going to run. This is about the only way to reliably and accurately respond to timers expiring etc.
First, get the kernel source and compile it with an adjusted HZ parameter. * If `HZ=1000`, timer interrupts 1000 times per seconds. It is ok to use `HZ=1000` for an i386 machine. * On an embedded machine, HZ might be limited to 100 or 200. For good operation, PREEMPT\_KERNEL option should be on. There are kernels which does not support this option properly. You can check them out by searching. Recent kernels, i.e. 2.6.35.10, supports NO\_HZ options, which turns on dynamic ticks. This means that there will be no timer ticks when in idle, but a timer tick will be generated at the specified moment. There is a RT patch to the kernel, but hardware support is very limited. Generally RTAI is an all killer solution to your problem, but its hardware support is very limited. However, good CNC controllers, like emc2, use RTAI for their clocking, maybe 5000 Hz, but it can be hard work to install it. If you can, you could add hardware to generate pulses. That would make a system which can be adapted to any OS version.
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
There is ktimer patch for linux kernel: <http://lwn.net/Articles/167897/> <http://www.kernel.org/pub/linux/kernel/projects/rt/> HTH
What about using "/dev/rtc0" (or "/dev/rtc") device and its related ioctl() interface? I think it offers an accurate timer counter. It is not possible to set the rate just to 1 ms, but to a close value or 1/1024sec (1024Hz), or to a higher frequency, like 8192Hz.
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
To get 1ms resolution timers do what [libevent](http://monkey.org/~provos/libevent/) does. Organize your timers into a [min-heap](http://en.wikipedia.org/wiki/Min-heap), that is, the top of the heap is the timer with the earliest expiry (absolute) time (a rb-tree would also work but with more overhead). Before calling `select()` or `epoll()` in your main event loop calculate the delta in milliseconds between the expiry time of the earliest timer and now. Use this delta as the timeout to `select()`. `select()` and `epoll()` timeouts have 1ms resolution. I've got a timer resolution test that uses the mechanism explained above (but not libevent). The test measures the difference between the desired timer expiry time and its actual expiry of 1ms, 5ms and 10ms timers: ``` 1000 deviation samples of 1msec timer: min= -246115nsec max= 1143471nsec median= -70775nsec avg= 901nsec stddev= 45570nsec 1000 deviation samples of 5msec timer: min= -265280nsec max= 256260nsec median= -252363nsec avg= -195nsec stddev= 30933nsec 1000 deviation samples of 10msec timer: min= -273119nsec max= 274045nsec median= 103471nsec avg= -179nsec stddev= 31228nsec 1000 deviation samples of 1msec timer: min= -144930nsec max= 1052379nsec median= -109322nsec avg= 1000nsec stddev= 43545nsec 1000 deviation samples of 5msec timer: min= -1229446nsec max= 1230399nsec median= 1222761nsec avg= 724nsec stddev= 254466nsec 1000 deviation samples of 10msec timer: min= -1227580nsec max= 1227734nsec median= 47328nsec avg= 745nsec stddev= 173834nsec 1000 deviation samples of 1msec timer: min= -222672nsec max= 228907nsec median= 63635nsec avg= 22nsec stddev= 29410nsec 1000 deviation samples of 5msec timer: min= -1302808nsec max= 1270006nsec median= 1251949nsec avg= -222nsec stddev= 345944nsec 1000 deviation samples of 10msec timer: min= -1297724nsec max= 1298269nsec median= 1254351nsec avg= -225nsec stddev= 374717nsec ``` The test ran as a real-time process on Fedora 13 kernel 2.6.34, the best achieved precision of 1ms timer was avg=22nsec stddev=29410nsec.
You don't need an RTOS for a simple real time application. All modern processors have General Purpose timers. Get a datasheet for whatever target CPU you are working on. Look in the kernel source, under the arch directory you will find processor specific source how to handle these timers. There are two approaches you can take with this: 1) Your application is ONLY running your state machine, and nothing else. Linux is simply your "boot loader." Create a kernel object which installs a character device. On insertion into the kernel, set up your GP Timer to run continuously. You know the frequency it's operating at. Now, in the kernel, explicitly disable your watchdog. Now disable interrupts (hardware AND software) On a single-cpu Linux kernel, calling spin\_lock() will accomplish this (never let go of it.) The CPU is YOURS. Busy loop, checking the value of the GPT until the required # of ticks have passed, when they have, set a value for the next timeout and enter your processing loop. Just make sure that the burst time for your code is under 1ms 2) A 2nd option. This assumes you are running a preemptive Linux kernel. Set up an unused a GPT along side your running OS. Now, set up an interrupt to fire some configurable margin BEFORE your 1ms timeout happens (say 50-75 uSec.) When the interrupt fires, you will immediately disable interrupts and spin waiting for 1ms window to occur, then entering your state machine and subsequently enabling interrupts on your wait OUT. This accounts for the fact that you are cooperating with OTHER things in the kernel which disable interrupts. This ASSUMES that there is no other kernel activity which locks out interrupts for a long time (more than 100us.) Now, you can MEASURE the accuracy of your firing event and make the window larger until it meets your need. If instead you are trying to learn how RTOS's work...or if you are trying to solve a control problem with more than one real-time responsibility...then use an RTOS.
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
To get 1ms resolution timers do what [libevent](http://monkey.org/~provos/libevent/) does. Organize your timers into a [min-heap](http://en.wikipedia.org/wiki/Min-heap), that is, the top of the heap is the timer with the earliest expiry (absolute) time (a rb-tree would also work but with more overhead). Before calling `select()` or `epoll()` in your main event loop calculate the delta in milliseconds between the expiry time of the earliest timer and now. Use this delta as the timeout to `select()`. `select()` and `epoll()` timeouts have 1ms resolution. I've got a timer resolution test that uses the mechanism explained above (but not libevent). The test measures the difference between the desired timer expiry time and its actual expiry of 1ms, 5ms and 10ms timers: ``` 1000 deviation samples of 1msec timer: min= -246115nsec max= 1143471nsec median= -70775nsec avg= 901nsec stddev= 45570nsec 1000 deviation samples of 5msec timer: min= -265280nsec max= 256260nsec median= -252363nsec avg= -195nsec stddev= 30933nsec 1000 deviation samples of 10msec timer: min= -273119nsec max= 274045nsec median= 103471nsec avg= -179nsec stddev= 31228nsec 1000 deviation samples of 1msec timer: min= -144930nsec max= 1052379nsec median= -109322nsec avg= 1000nsec stddev= 43545nsec 1000 deviation samples of 5msec timer: min= -1229446nsec max= 1230399nsec median= 1222761nsec avg= 724nsec stddev= 254466nsec 1000 deviation samples of 10msec timer: min= -1227580nsec max= 1227734nsec median= 47328nsec avg= 745nsec stddev= 173834nsec 1000 deviation samples of 1msec timer: min= -222672nsec max= 228907nsec median= 63635nsec avg= 22nsec stddev= 29410nsec 1000 deviation samples of 5msec timer: min= -1302808nsec max= 1270006nsec median= 1251949nsec avg= -222nsec stddev= 345944nsec 1000 deviation samples of 10msec timer: min= -1297724nsec max= 1298269nsec median= 1254351nsec avg= -225nsec stddev= 374717nsec ``` The test ran as a real-time process on Fedora 13 kernel 2.6.34, the best achieved precision of 1ms timer was avg=22nsec stddev=29410nsec.
There is ktimer patch for linux kernel: <http://lwn.net/Articles/167897/> <http://www.kernel.org/pub/linux/kernel/projects/rt/> HTH
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
I seem to recall getting ok results with gettimeofday/usleep based polling -- I wasn't needing 1000 timers a second or anything, but I was needing good accuracy with the timing for ticks I did need -- my app was a MIDI drum machine controller, and I seem to remember getting sub-millisecond accuracy, which you need for a drum machine if you don't want it to sound like a very bad drummer (esp. counting MIDI's built-in latencies) -- iirc (it was 2005 so my memory is a bit fuzzy) I was getting within 200 microseconds of target times with usleep. However, I was not running much else on the system. If you have a controlled environment you might be able to get away with a solution like that. If there's more going on the system (watch cron firing up updatedb, etc.) then things may fall apart.
Can you at least use nanosleep in your loop to sleep for 1ms? Or is that a glibc thing? **Update:** Never mind, I see from the man page "it can take up to 10 ms longer than specified until the process becomes runnable again"
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
I seem to recall getting ok results with gettimeofday/usleep based polling -- I wasn't needing 1000 timers a second or anything, but I was needing good accuracy with the timing for ticks I did need -- my app was a MIDI drum machine controller, and I seem to remember getting sub-millisecond accuracy, which you need for a drum machine if you don't want it to sound like a very bad drummer (esp. counting MIDI's built-in latencies) -- iirc (it was 2005 so my memory is a bit fuzzy) I was getting within 200 microseconds of target times with usleep. However, I was not running much else on the system. If you have a controlled environment you might be able to get away with a solution like that. If there's more going on the system (watch cron firing up updatedb, etc.) then things may fall apart.
You don't need an RTOS for a simple real time application. All modern processors have General Purpose timers. Get a datasheet for whatever target CPU you are working on. Look in the kernel source, under the arch directory you will find processor specific source how to handle these timers. There are two approaches you can take with this: 1) Your application is ONLY running your state machine, and nothing else. Linux is simply your "boot loader." Create a kernel object which installs a character device. On insertion into the kernel, set up your GP Timer to run continuously. You know the frequency it's operating at. Now, in the kernel, explicitly disable your watchdog. Now disable interrupts (hardware AND software) On a single-cpu Linux kernel, calling spin\_lock() will accomplish this (never let go of it.) The CPU is YOURS. Busy loop, checking the value of the GPT until the required # of ticks have passed, when they have, set a value for the next timeout and enter your processing loop. Just make sure that the burst time for your code is under 1ms 2) A 2nd option. This assumes you are running a preemptive Linux kernel. Set up an unused a GPT along side your running OS. Now, set up an interrupt to fire some configurable margin BEFORE your 1ms timeout happens (say 50-75 uSec.) When the interrupt fires, you will immediately disable interrupts and spin waiting for 1ms window to occur, then entering your state machine and subsequently enabling interrupts on your wait OUT. This accounts for the fact that you are cooperating with OTHER things in the kernel which disable interrupts. This ASSUMES that there is no other kernel activity which locks out interrupts for a long time (more than 100us.) Now, you can MEASURE the accuracy of your firing event and make the window larger until it meets your need. If instead you are trying to learn how RTOS's work...or if you are trying to solve a control problem with more than one real-time responsibility...then use an RTOS.
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
You don't need an RTOS for a simple real time application. All modern processors have General Purpose timers. Get a datasheet for whatever target CPU you are working on. Look in the kernel source, under the arch directory you will find processor specific source how to handle these timers. There are two approaches you can take with this: 1) Your application is ONLY running your state machine, and nothing else. Linux is simply your "boot loader." Create a kernel object which installs a character device. On insertion into the kernel, set up your GP Timer to run continuously. You know the frequency it's operating at. Now, in the kernel, explicitly disable your watchdog. Now disable interrupts (hardware AND software) On a single-cpu Linux kernel, calling spin\_lock() will accomplish this (never let go of it.) The CPU is YOURS. Busy loop, checking the value of the GPT until the required # of ticks have passed, when they have, set a value for the next timeout and enter your processing loop. Just make sure that the burst time for your code is under 1ms 2) A 2nd option. This assumes you are running a preemptive Linux kernel. Set up an unused a GPT along side your running OS. Now, set up an interrupt to fire some configurable margin BEFORE your 1ms timeout happens (say 50-75 uSec.) When the interrupt fires, you will immediately disable interrupts and spin waiting for 1ms window to occur, then entering your state machine and subsequently enabling interrupts on your wait OUT. This accounts for the fact that you are cooperating with OTHER things in the kernel which disable interrupts. This ASSUMES that there is no other kernel activity which locks out interrupts for a long time (more than 100us.) Now, you can MEASURE the accuracy of your firing event and make the window larger until it meets your need. If instead you are trying to learn how RTOS's work...or if you are trying to solve a control problem with more than one real-time responsibility...then use an RTOS.
Can you at least use nanosleep in your loop to sleep for 1ms? Or is that a glibc thing? **Update:** Never mind, I see from the man page "it can take up to 10 ms longer than specified until the process becomes runnable again"
240,058
I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd\_create is not an option because of the glibc requirement. I tried timer\_create and timer\_settimer, but the best I get from them is a 10ms resolution, smaller values seem to default to 10ms resolution. Getittimer and setitimer have a 10 ms resolution according to the manpage. The only way to do this timer I can currently think of is to use clock\_gettime with CLOCK\_MONOTONIC in my main loop an test if a ms has passed, and if so to increase the counter (and then check if the various Events should fire). Is there a better way to do this than to constantly query in the main loop? What is the recommended solution to this? The language I am using is plain old c **Update** I am using a 2.6.26 Kernel. I know you can have it interrupt at 1kHz, and the POSIX timer\_\* functions then can be programmed to up to 1ms but that seems not to be reliable and I don't want to use that, because it may need a new kernel on some Systems. Some stock Kernel seem to still have the 100Hz configured. And I would need to detect that. The application may be run on something else than my System :) I can not sleep for 1ms because there may be network events I have to react to. **How I resolved it** Since it is not that important I simply declared that the global timer has a 100ms resolution. All events using their own timer have to set at least 100ms for timer expiration. I was more or less wondering if there would be a better way, hence the question. **Why I accepted the answer** I think the answer from freespace best described why it is not really possible without a realtime Linux System.
2008/10/27
[ "https://Stackoverflow.com/questions/240058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510/" ]
If you are targeting x86 platform you should check HPET timers. This is hardware timer with large precision. It must be supported by your motherbord (right now all of them support it) and your kernel should contains driver for it as well. I have used it few times without any problems and was able to achieve much better resolution than 1ms. Here is some documentation and examples: * <http://www.kernel.org/doc/Documentation/timers/hpet.txt> * <http://www.kernel.org/doc/Documentation/timers/hpet_example.c> * <http://fpmurphy.blogspot.com/2009/07/linux-hpet-support.html>
First, get the kernel source and compile it with an adjusted HZ parameter. * If `HZ=1000`, timer interrupts 1000 times per seconds. It is ok to use `HZ=1000` for an i386 machine. * On an embedded machine, HZ might be limited to 100 or 200. For good operation, PREEMPT\_KERNEL option should be on. There are kernels which does not support this option properly. You can check them out by searching. Recent kernels, i.e. 2.6.35.10, supports NO\_HZ options, which turns on dynamic ticks. This means that there will be no timer ticks when in idle, but a timer tick will be generated at the specified moment. There is a RT patch to the kernel, but hardware support is very limited. Generally RTAI is an all killer solution to your problem, but its hardware support is very limited. However, good CNC controllers, like emc2, use RTAI for their clocking, maybe 5000 Hz, but it can be hard work to install it. If you can, you could add hardware to generate pulses. That would make a system which can be adapted to any OS version.
8,114,131
concerning android development, I'm simply trying to create an SQL database when the activity is launched for the first time (using preferences). The second time the activity is launched it should retrieve the data from the database and output a log message. Ive managed to launch the activity for the first time (im assuming the database was created here) but the second time i get an IllegalStateException error: get field slot from row 0 to col -1 failed. Not really sure where i went wrong here. can someone please check? Thanks Main class ``` public class MainMenu extends Activity implements OnClickListener{ private ModulesDbAdapter mpDbHelper; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //create database here SharedPreferences initialPref = getSharedPreferences("INITIAL", 0); boolean firsttimer = initialPref.getBoolean("INITIAL", false); if (!firsttimer){ //create database here mpDbHelper = new ModulesDbAdapter(this); mpDbHelper.open(); long id1 = mpDbHelper.createReminder("Hello1", "Test 1", "Date1"); long id2 = mpDbHelper.createReminder("Hello2", "Test 2", "Date2"); long id3 = mpDbHelper.createReminder("Hello3", "Test 3", "Date3"); /*Cursor c = mpDbHelper.fetchModules((String)"CS118"); Log.d("TESTING",c.getString(c.getColumnIndex("KEY_MOD_NAME")));*/ //get boolean preference to true SharedPreferences.Editor editorPref = initialPref.edit(); editorPref.putBoolean("INITIAL", true); editorPref.commit(); }else { fetchData(); } } private void fetchData(){ mpDbHelper = new ModulesDbAdapter(this); mpDbHelper.open(); long input = 2; Cursor c = mpDbHelper.fetchReminder(input); startManagingCursor(c); Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); } /*@Override protected void onPause() { super.onPause(); mpDbHelper.close(); } @Override protected void onStop() { super.onPause(); mpDbHelper.close(); }*/ } } ``` Adapter class ``` public class ModulesDbAdapter { private static final String DATABASE_NAME = "data"; private static final String DATABASE_TABLE = "reminders"; private static final int DATABASE_VERSION = 1; public static final String KEY_TITLE = "title"; public static final String KEY_BODY = "body"; public static final String KEY_DATE_TIME = "reminder_date_time"; public static final String KEY_ROWID = "_id"; private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; //defines the create script for the database private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE + " (" + KEY_ROWID + " integer primary key autoincrement, " + KEY_TITLE + " text not null, " + KEY_BODY + " text not null, " + KEY_DATE_TIME + " text not null);"; //Context object that will be associated with the SQLite database object private final Context mCtx; //The Context object is set via the constructor of the class public ModulesDbAdapter(Context ctx) { this.mCtx = ctx; } //helps with the creation and version management of the SQLite database. private static class DatabaseHelper extends SQLiteOpenHelper { //call made to the base SQLiteOpenHelper constructor. This call creates, opens, and/or manages a database DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion) { // Not used, but you could upgrade the database with ALTER // Scripts } } //now create the database by calling the getReadableDatabase() public ModulesDbAdapter open() throws android.database.SQLException { mDbHelper = new DatabaseHelper(mCtx); mDb = mDbHelper.getWritableDatabase(); return this; } //close the database public void close() { mDbHelper.close(); } public long createReminder(String title, String body, String reminderDateTime) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_TITLE, title); initialValues.put(KEY_BODY, body); initialValues.put(KEY_DATE_TIME, reminderDateTime); //insert row into database return mDb.insert(DATABASE_TABLE, null, initialValues); } public boolean deleteReminder(long rowId) { return mDb.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0; } //utilizes the query() method on the SQLite database to find all the reminders in the system public Cursor fetchAllReminders() { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, null, null, null, null, null); } public Cursor fetchReminder(long rowId) throws SQLException { Cursor mCursor = mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } public boolean updateReminder(long rowId, String title, String body, String reminderDateTime) { ContentValues args = new ContentValues(); args.put(KEY_TITLE, title); args.put(KEY_BODY, body); args.put(KEY_DATE_TIME, reminderDateTime); return mDb.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0; } // The SQLiteOpenHelper class was omitted for brevity // That code goes here. ``` }
2011/11/13
[ "https://Stackoverflow.com/questions/8114131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044502/" ]
The error is simple. You've defined KEY\_BODY as a static string constant value in the DbAdapter class, but you've used the string literal "KEY\_BODY" in your access code. ``` Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); ``` should be ``` Log.d("TESTING",c.getString(c.getColumnIndex(ModulesDbAdapter.KEY_BODY))); ```
I believe your issue is in your log line. Change the string to a literal: ``` Log.d("TESTING",c.getString(c.getColumnIndex(KEY_BODY))); ```
8,114,131
concerning android development, I'm simply trying to create an SQL database when the activity is launched for the first time (using preferences). The second time the activity is launched it should retrieve the data from the database and output a log message. Ive managed to launch the activity for the first time (im assuming the database was created here) but the second time i get an IllegalStateException error: get field slot from row 0 to col -1 failed. Not really sure where i went wrong here. can someone please check? Thanks Main class ``` public class MainMenu extends Activity implements OnClickListener{ private ModulesDbAdapter mpDbHelper; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //create database here SharedPreferences initialPref = getSharedPreferences("INITIAL", 0); boolean firsttimer = initialPref.getBoolean("INITIAL", false); if (!firsttimer){ //create database here mpDbHelper = new ModulesDbAdapter(this); mpDbHelper.open(); long id1 = mpDbHelper.createReminder("Hello1", "Test 1", "Date1"); long id2 = mpDbHelper.createReminder("Hello2", "Test 2", "Date2"); long id3 = mpDbHelper.createReminder("Hello3", "Test 3", "Date3"); /*Cursor c = mpDbHelper.fetchModules((String)"CS118"); Log.d("TESTING",c.getString(c.getColumnIndex("KEY_MOD_NAME")));*/ //get boolean preference to true SharedPreferences.Editor editorPref = initialPref.edit(); editorPref.putBoolean("INITIAL", true); editorPref.commit(); }else { fetchData(); } } private void fetchData(){ mpDbHelper = new ModulesDbAdapter(this); mpDbHelper.open(); long input = 2; Cursor c = mpDbHelper.fetchReminder(input); startManagingCursor(c); Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); } /*@Override protected void onPause() { super.onPause(); mpDbHelper.close(); } @Override protected void onStop() { super.onPause(); mpDbHelper.close(); }*/ } } ``` Adapter class ``` public class ModulesDbAdapter { private static final String DATABASE_NAME = "data"; private static final String DATABASE_TABLE = "reminders"; private static final int DATABASE_VERSION = 1; public static final String KEY_TITLE = "title"; public static final String KEY_BODY = "body"; public static final String KEY_DATE_TIME = "reminder_date_time"; public static final String KEY_ROWID = "_id"; private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; //defines the create script for the database private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE + " (" + KEY_ROWID + " integer primary key autoincrement, " + KEY_TITLE + " text not null, " + KEY_BODY + " text not null, " + KEY_DATE_TIME + " text not null);"; //Context object that will be associated with the SQLite database object private final Context mCtx; //The Context object is set via the constructor of the class public ModulesDbAdapter(Context ctx) { this.mCtx = ctx; } //helps with the creation and version management of the SQLite database. private static class DatabaseHelper extends SQLiteOpenHelper { //call made to the base SQLiteOpenHelper constructor. This call creates, opens, and/or manages a database DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion) { // Not used, but you could upgrade the database with ALTER // Scripts } } //now create the database by calling the getReadableDatabase() public ModulesDbAdapter open() throws android.database.SQLException { mDbHelper = new DatabaseHelper(mCtx); mDb = mDbHelper.getWritableDatabase(); return this; } //close the database public void close() { mDbHelper.close(); } public long createReminder(String title, String body, String reminderDateTime) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_TITLE, title); initialValues.put(KEY_BODY, body); initialValues.put(KEY_DATE_TIME, reminderDateTime); //insert row into database return mDb.insert(DATABASE_TABLE, null, initialValues); } public boolean deleteReminder(long rowId) { return mDb.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0; } //utilizes the query() method on the SQLite database to find all the reminders in the system public Cursor fetchAllReminders() { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, null, null, null, null, null); } public Cursor fetchReminder(long rowId) throws SQLException { Cursor mCursor = mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } public boolean updateReminder(long rowId, String title, String body, String reminderDateTime) { ContentValues args = new ContentValues(); args.put(KEY_TITLE, title); args.put(KEY_BODY, body); args.put(KEY_DATE_TIME, reminderDateTime); return mDb.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0; } // The SQLiteOpenHelper class was omitted for brevity // That code goes here. ``` }
2011/11/13
[ "https://Stackoverflow.com/questions/8114131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044502/" ]
You don't have to explicitly check if your database was created. If you create a subclass of SQLiteOpenHelper implementing onCreate(SQLiteDatabase), onUpgrade(SQLiteDatabase, int, int) it will "know" not to created the database, if it already exists. Otherwise your error is caused in the line: ``` Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); ``` because you're using as column index the String "KEY\_BODY" and not the value of your static String variable KEY\_BODY.
I believe your issue is in your log line. Change the string to a literal: ``` Log.d("TESTING",c.getString(c.getColumnIndex(KEY_BODY))); ```
8,114,131
concerning android development, I'm simply trying to create an SQL database when the activity is launched for the first time (using preferences). The second time the activity is launched it should retrieve the data from the database and output a log message. Ive managed to launch the activity for the first time (im assuming the database was created here) but the second time i get an IllegalStateException error: get field slot from row 0 to col -1 failed. Not really sure where i went wrong here. can someone please check? Thanks Main class ``` public class MainMenu extends Activity implements OnClickListener{ private ModulesDbAdapter mpDbHelper; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //create database here SharedPreferences initialPref = getSharedPreferences("INITIAL", 0); boolean firsttimer = initialPref.getBoolean("INITIAL", false); if (!firsttimer){ //create database here mpDbHelper = new ModulesDbAdapter(this); mpDbHelper.open(); long id1 = mpDbHelper.createReminder("Hello1", "Test 1", "Date1"); long id2 = mpDbHelper.createReminder("Hello2", "Test 2", "Date2"); long id3 = mpDbHelper.createReminder("Hello3", "Test 3", "Date3"); /*Cursor c = mpDbHelper.fetchModules((String)"CS118"); Log.d("TESTING",c.getString(c.getColumnIndex("KEY_MOD_NAME")));*/ //get boolean preference to true SharedPreferences.Editor editorPref = initialPref.edit(); editorPref.putBoolean("INITIAL", true); editorPref.commit(); }else { fetchData(); } } private void fetchData(){ mpDbHelper = new ModulesDbAdapter(this); mpDbHelper.open(); long input = 2; Cursor c = mpDbHelper.fetchReminder(input); startManagingCursor(c); Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); } /*@Override protected void onPause() { super.onPause(); mpDbHelper.close(); } @Override protected void onStop() { super.onPause(); mpDbHelper.close(); }*/ } } ``` Adapter class ``` public class ModulesDbAdapter { private static final String DATABASE_NAME = "data"; private static final String DATABASE_TABLE = "reminders"; private static final int DATABASE_VERSION = 1; public static final String KEY_TITLE = "title"; public static final String KEY_BODY = "body"; public static final String KEY_DATE_TIME = "reminder_date_time"; public static final String KEY_ROWID = "_id"; private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; //defines the create script for the database private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE + " (" + KEY_ROWID + " integer primary key autoincrement, " + KEY_TITLE + " text not null, " + KEY_BODY + " text not null, " + KEY_DATE_TIME + " text not null);"; //Context object that will be associated with the SQLite database object private final Context mCtx; //The Context object is set via the constructor of the class public ModulesDbAdapter(Context ctx) { this.mCtx = ctx; } //helps with the creation and version management of the SQLite database. private static class DatabaseHelper extends SQLiteOpenHelper { //call made to the base SQLiteOpenHelper constructor. This call creates, opens, and/or manages a database DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion) { // Not used, but you could upgrade the database with ALTER // Scripts } } //now create the database by calling the getReadableDatabase() public ModulesDbAdapter open() throws android.database.SQLException { mDbHelper = new DatabaseHelper(mCtx); mDb = mDbHelper.getWritableDatabase(); return this; } //close the database public void close() { mDbHelper.close(); } public long createReminder(String title, String body, String reminderDateTime) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_TITLE, title); initialValues.put(KEY_BODY, body); initialValues.put(KEY_DATE_TIME, reminderDateTime); //insert row into database return mDb.insert(DATABASE_TABLE, null, initialValues); } public boolean deleteReminder(long rowId) { return mDb.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0; } //utilizes the query() method on the SQLite database to find all the reminders in the system public Cursor fetchAllReminders() { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, null, null, null, null, null); } public Cursor fetchReminder(long rowId) throws SQLException { Cursor mCursor = mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } public boolean updateReminder(long rowId, String title, String body, String reminderDateTime) { ContentValues args = new ContentValues(); args.put(KEY_TITLE, title); args.put(KEY_BODY, body); args.put(KEY_DATE_TIME, reminderDateTime); return mDb.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0; } // The SQLiteOpenHelper class was omitted for brevity // That code goes here. ``` }
2011/11/13
[ "https://Stackoverflow.com/questions/8114131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1044502/" ]
The error is simple. You've defined KEY\_BODY as a static string constant value in the DbAdapter class, but you've used the string literal "KEY\_BODY" in your access code. ``` Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); ``` should be ``` Log.d("TESTING",c.getString(c.getColumnIndex(ModulesDbAdapter.KEY_BODY))); ```
You don't have to explicitly check if your database was created. If you create a subclass of SQLiteOpenHelper implementing onCreate(SQLiteDatabase), onUpgrade(SQLiteDatabase, int, int) it will "know" not to created the database, if it already exists. Otherwise your error is caused in the line: ``` Log.d("TESTING",c.getString(c.getColumnIndex("KEY_BODY"))); ``` because you're using as column index the String "KEY\_BODY" and not the value of your static String variable KEY\_BODY.
41,539
I'm writing a book largely based on a OASIS open standard. I assume this would constitute derivative work. I wondering about the following phrasing in the copyright. > > The document(s) and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works... > > > If I do a derivative work it says the copy right notice and paragraph needs to be included. Does that mean that I just add this as a attribution att the end, or will this copyright then cover the entirety of the book and allow others to copy it freely? Copyright notice in full <https://www.oasis-open.org/committees/ciq/copyright.shtml>
2019/05/29
[ "https://law.stackexchange.com/questions/41539", "https://law.stackexchange.com", "https://law.stackexchange.com/users/25931/" ]
Whoever wrote this standard didn't write your book and therefore has no copyright on it, except for the parts derived from the standard. So it doesn't make sense that a copyright notice would claim copyright on your book. Just including the copyright notice would only cause confusion, because a copyright needs to be formally transferred. (Even with the notice, you would still be copyright holder. But if anyone creates a derived work assuming the notice - which you put there - refers to the whole book, you'd have a very hard time claiming damages. So it's a bad idea to include it). I would write "This book is based on the so-and-so standard" followed by the copyright notice and license, which makes it clear that the copyright notice and license refer to the standard, not your book. Do the wording a bit more careful then I did, perhaps consult a lawyer who is better than me and you at finding the exact right words.
You must include the notice and it allows others to copy your work and distribute it freely. Alternatively, you can contact the copyright holder and attempt to negotiate a different licence or ensure your work stays firmly within the fair use/dealing exemptions to copyright law.
33,158
How do I search files, some of which might be directories (in this case recursively) for a given string? I'd like to search source files for a class definition, so it would also be great if there was the name of the containing file before each output string.
2009/06/29
[ "https://serverfault.com/questions/33158", "https://serverfault.com", "https://serverfault.com/users/3320/" ]
All the above answers will work perfectly well, but may cause false positives if you've got the string in more than just source code. Say you are looking for where you use the FooBar class in a java project, you can search for all files named \*.java and grep just those. ``` # grep "FooBar" -Hn $(find -name "*.java") ``` The section in between the $() will expand to the output of that command. The -H prints out the filename. It's the default where there is more than one file name, but we explicitly add it here in case the expansion only returns one file name. The -n prints the line number of the match. This will work for small projects, but if you're dealing with a larger project, there the potential for the find to expand to a string longer than the command line limit. It's therefore safer to use: ``` # find -name "*.java" -print0 | xargs -0 grep "FooBar" -Hn ``` xargs will take input from standard in and split it up so it fits on the command line, running the command multiple times if necessary. The -print0 and -0 are required to deal with files with spaces in their name. You can also look for all the filesnames with a match in using: ``` # find -name "*.java" -print0 | xargs -0 grep "FooBar" -l ``` The -l will just display the file name and stop looking in a particular file as soon as it finds a match. If you're going to be doing this sort of thing frequently, you may want to look at a tool like ctags or exuberant tags, which maintain a search index of your source code and can answer these sorts of questions quickly. Both vim and emacs have support for these tools. You may also like to look at an IDE like eclipse, which can do cross referencing very well. (I know you were looking for a class definition, but in Java a class will be defined in a file with the same name as the class. If you were doing cpp, you could do something like: ``` # find -name "*.cpp" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" -print0 | \ xargs -0 egrep "class\s+FooBar" -Hn ```
this is something I find myself using alot so I have put two bash functions in my `.bashrc` First one does a recursive search for *text* in filenames. Second one will do a recursive search for *text* inside of files returning the filenames of the files that match. ``` ff () { find . -name "*$@*" -print; } fff () { find . -type f -print0 | xargs -0 grep -l $@ } ``` example usage: ``` [lunix@godzilla ~/tmp]$ ff foo ./slideshow/foo ./slideshow/velocity_puppet_workshop_2009/repo/modules/foo [lunix@godzilla ~/tmp/test]$ fff commodo ./file2 [lunix@godzilla ~/tmp/test]$ ll total 16K drwxr-xr-x 2 lunix lunix 4.0K 2009-06-29 23:01 . drwxr-xr-x 4 lunix lunix 4.0K 2009-06-29 22:57 .. -rw-r--r-- 1 lunix lunix 1.3K 2009-06-29 22:59 file1 -rw-r--r-- 1 lunix lunix 1.7K 2009-06-29 23:00 file2 ```
33,158
How do I search files, some of which might be directories (in this case recursively) for a given string? I'd like to search source files for a class definition, so it would also be great if there was the name of the containing file before each output string.
2009/06/29
[ "https://serverfault.com/questions/33158", "https://serverfault.com", "https://serverfault.com/users/3320/" ]
You could use grep: ``` grep -rn 'classname' /path/to/source ``` This will also print the line number next to each match. Case insensitive: ``` grep -rin 'classname' /path/to/source ``` Search non-recursively in all cpp files: ``` grep -n 'classname' /path/to/source/*.cpp ```
All the above answers will work perfectly well, but may cause false positives if you've got the string in more than just source code. Say you are looking for where you use the FooBar class in a java project, you can search for all files named \*.java and grep just those. ``` # grep "FooBar" -Hn $(find -name "*.java") ``` The section in between the $() will expand to the output of that command. The -H prints out the filename. It's the default where there is more than one file name, but we explicitly add it here in case the expansion only returns one file name. The -n prints the line number of the match. This will work for small projects, but if you're dealing with a larger project, there the potential for the find to expand to a string longer than the command line limit. It's therefore safer to use: ``` # find -name "*.java" -print0 | xargs -0 grep "FooBar" -Hn ``` xargs will take input from standard in and split it up so it fits on the command line, running the command multiple times if necessary. The -print0 and -0 are required to deal with files with spaces in their name. You can also look for all the filesnames with a match in using: ``` # find -name "*.java" -print0 | xargs -0 grep "FooBar" -l ``` The -l will just display the file name and stop looking in a particular file as soon as it finds a match. If you're going to be doing this sort of thing frequently, you may want to look at a tool like ctags or exuberant tags, which maintain a search index of your source code and can answer these sorts of questions quickly. Both vim and emacs have support for these tools. You may also like to look at an IDE like eclipse, which can do cross referencing very well. (I know you were looking for a class definition, but in Java a class will be defined in a file with the same name as the class. If you were doing cpp, you could do something like: ``` # find -name "*.cpp" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" -print0 | \ xargs -0 egrep "class\s+FooBar" -Hn ```
33,158
How do I search files, some of which might be directories (in this case recursively) for a given string? I'd like to search source files for a class definition, so it would also be great if there was the name of the containing file before each output string.
2009/06/29
[ "https://serverfault.com/questions/33158", "https://serverfault.com", "https://serverfault.com/users/3320/" ]
[ack](http://betterthangrep.com/) is better for searching source codes as it already recognize some of the most popular file extension (c, perl, etc). It's as fast as grep and by default ignoring all your version control artifact. For example if you want to search some pattern perl source code you could use ``` ack --perl pattern ``` instead of ``` grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn) ```
This classical find + exec could also be handy: ``` find /path/to/ -type f -exec grep -i 'string' {} \; ```