I have a string variable which is receiving a Guid. I need to convert this string back to Guid as the database field is of type Guid.  I tried using:    Guid myGuid = Guid.Empty;; myGuid = Guid.Parse(myId);   But keep getting Format Exception; Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).  Below is my code:   public string addVehicleDetails(string vname, string vtype, string regNumber, string ftype, string fefficiency, string insby, DateTime datecreated, string myId)         {              string result = string.Empty;             tblVehicleDetail myVehicleDetails = new tblVehicleDetail();           //  Guid myGuid = Guid.Empty;             System.Guid myGuid = new Guid(myId);            // myGuid = Guid.Parse(myId);             try {                 // Add details into vehicle details                 myVehicleDetails.VehicleName = vname;                 myVehicleDetails.VehicleType = vtype;                 myVehicleDetails.RegistrationNumber = regNumber;                 myVehicleDetails.FuelType = ftype;                 myVehicleDetails.FuelEfficiency = fefficiency;                 myVehicleDetails.InsuranceBy = insby;                  myVehicleDetails.DateCreated = datecreated;                 myVehicleDetails.Guid = myGuid;                  dc.tblVehicleDetails.InsertOnSubmit(myVehicleDetails);                  dc.SubmitChanges();                  return result = vname;              }             catch(Exception exp)             {                 exp.ToString();                 return result = "Error in Adding Vehicle Details.";             }         }   Any solution for this?
I want to try to convert a string to a Guid, but I don't want to rely on catching exceptions (   for performance reasons - exceptions are expensive for usability reasons - the debugger pops up  for design reasons - the expected is not exceptional   In other words the code:  public static Boolean TryStrToGuid(String s, out Guid value) {     try     {         value = new Guid(s);         return true;     }     catch (FormatException)     {         value = Guid.Empty;         return false;     } }   is not suitable.  I would try using RegEx, but since the guid can be parenthesis wrapped, brace wrapped, none wrapped, makes it hard.   Additionally, I thought certain Guid values are invalid(?)    Update 1   had a good idea to catch only FormatException, rather than all. Changed the question's code sample to include suggestion.    Update 2  Why worry about thrown exceptions? Am I really expecting invalid GUIDs all that often?   The answer is yes. That is why I am using TryStrToGuid - I am expecting bad data.  Example 1 . I might be parsing folder names, checking to see if the text after the final . is a GUID.  c:\Program Files c:\Program Files.old c:\Users c:\Users.old c:\UserManager.{CE7F5AA5-6832-43FE-BAE1-80D14CD8F666} c:\Windows c:\Windows.old   Example 2 I might be running a heavily used web-server wants to check the validity of some posted back data. I don't want invalid data tying up resources 2-3 orders of magnitude higher than it needs to be.  Example 3 I might be parsing a search expression entered by a user.     If they enter GUID's I want to process them specially (such as specifically searching for that object, or highlight and format that specific search term in the response text.)    Update 3 - Performance benchmarks  Test converting 10,000 good Guids, and 10,000 bad Guids.  Catch FormatException:    10,000 good:     63,668 ticks    10,000 bad:   6,435,609 ticks  Regex Pre-Screen with try-catch:    10,000 good:    637,633 ticks    10,000 bad:     717,894 ticks  COM Interop CLSIDFromString    10,000 good:    126,120 ticks    10,000 bad:      23,134 ticks   p.s. I shouldn't have to justify a question.
What is a word for someone that only does something to benefit them? Take this paragraph for example: I am a follower, not a leader. Hell, I'm not even that good of a follower either, just someone who will do your bidding for the right price. Even then, if it doesn't benefit me -- or put you in debt to me -- I won't do it. Difference between DispatchQueue.main.async and DispatchQueue.main.sync I am trying to burn a shapefile to a raster using GDAL's RasterizeLayer. I pre-create an area of interest raster from a different shapefile, given a specific pixel size. This AOI then serves as a base for all following rasterizations (same number of collumns and rows, same projection and geotransform).  The issue occurs, however, when I go to burn the shapes to their own raster, based on the same pixel size and projections. The link below (don't have enough rep to post the image), shows the original shapefile in tan, and the dark pink where RasterizeLayer has burned data. The light pink is nodata values for the dark pink raster data. The grey is the AOI based on which the shapefile burn was completed.  Given the extents of the shapefile polygons, I would expect to see burn values in the bottom two corners, as well as the two pixels underneath the data that does show. Obviously, however, this is not the case.    As follows is the code that I used to generate these. All of the shapes were created using QGIS, and were all created in the same projection.  (It should be noted that the gridding in the picture shown was just to give an idea of the pixel size I was using.)  from osgeo import ogr from osgeo import gdal  aoi_uri = 'AOI_Raster.tif' aoi_raster = gdal.Open(aoi_uri)  def new_raster_from_base(base, outputURI, format, nodata, datatype):      cols = base.RasterXSize     rows = base.RasterYSize     projection = base.GetProjection()     geotransform = base.GetGeoTransform()     bands = base.RasterCount      driver = gdal.GetDriverByName(format)      new_raster = driver.Create(str(outputURI), cols, rows, bands, datatype)     new_raster.SetProjection(projection)     new_raster.SetGeoTransform(geotransform)      for i in range(bands):         new_raster.GetRasterBand(i + 1).SetNoDataValue(nodata)         new_raster.GetRasterBand(i + 1).Fill(nodata)      return new_raster  shape_uri = 'activity_3.shp' shape_datasource = ogr.Open(shape_uri) shape_layer = shape_datasource.GetLayer()  raster_out = 'new_raster.tif'  raster_dataset = new_raster_from_base(aoi_raster, raster_out, 'GTiff',                                 -1, gdal.GDT_Int32) band = raster_dataset.GetRasterBand(1) nodata = band.GetNoDataValue()  band.Fill(nodata)  gdal.RasterizeLayer(raster_dataset, [1], shape_layer, burn_values=[1])   Is this a bug in GDAL, or is RasterizeLayer burning data based on something other than just the presence or lack of a polygon within a specified pixel area?  The files that I was using can be found . Can a US citizen leave and enter the US using a foreign passport? I am a dual citizen. I have both a US passport and a non-US passport. I live in the US. My US passport is currently being processed for renewal. I am unsure whether I will receive my passport in time for a trip that I have scheduled. Could I use my non-US passport to leave the US and return? I have never entered the US with my non-US passport. There is no immigration leaving the US but I still need to scan my passport for ticketing. Will the airline refuse me a ticket? I know that in this situation returning with a non-US passport can be problematic as well, but will I be able to leave at all? Note that I am traveling to a country which neither of my passports are from. Which infinity is meant in limits? For example, when we write $\lim_{x\rightarrow \infty} f(x)$ - which infinity is meant and why? Countable? If uncountable - which and why? What is rank deficiency, and how to deal with it? Fitting a logistic regression using  ends with   Error in mer_finalize(ans) : Downdated X'X is not positive definite.    A likely cause of this error is apparently rank deficiency. What is rank deficiency, and how should I address it? Close vote review audit is broken - displays "on hold" while reviewing I just reviewed this:    But while reviewing, it already displays the "put on hold as not a real question" section, and it asked:     Should this question be closed as: ?   So as it stands, the audits are broken, since we already know that the question is "on hold" while reviewing, and it is incredibly hard to miss the huge grey box at the bottom.  Another with screenshot: Which story is true at end of the movie "Life of Pi"? At the end of the movie  Pi tells us two stories. One with the tiger (unrealistic) and one without the tiger (realistic).  I believe that he was metaphorically referring himself as the tiger who enters the forest (world) after being rescued.  Is my thinking correct? can you explain me the ending?  At the end did Irfan Khan (older Pi/narrator) say that "even God chose the first story"? Does it mean that the first story was indeed real? Run TTY script every time I open a GUI terminal When I log in to a TTY I get the following nice text:  Ubuntu 16.04.03 LTS Log-in: username Password: Last log-in date/time Welcome to Ubuntu 16.04.03 LTS   * Documentation:  * Management:  * Support:  9 packages to update 4 updates are security updates   I would like the last 2 lines repeated every time I open a GUI terminal for all users in the adm group (but will settle for having the entire thing displayed each and every time I open a GUI Terminal for all users)  I tried the obvious:  fab-root@fab-ux-predator:~ $ cd /etc/update-motd.d/ fab-root@fab-ux-predator:/etc/update-motd.d $ ./90-updates-available  fab-root@fab-ux-predator:/etc/update-motd.d $ cat /var/lib/update-notifier/updates-available cat: /var/lib/update-notifier/updates-available: Permission denied fab-root@fab-ux-predator:/etc/update-motd.d $   What am I missing?  P.S. Obviously I can chmod o+r the file, but how future-proof would that be? The external Flash is not showing up in the configuration Menu when using Pixel TF-321 hot shoe. Is this the wrong adapter for that camera, as there is no X connection? I want to trigger a studio flash via sync connection. Can you recommend me a working hot shoe? Thanks! When we canonically quantize the scalar field in QFT, we use a Lorentz invariant integration measure given by $$\widetilde{dk} \equiv \frac{d^3k}{(2\pi)^3 2\omega(\textbf{k})}.$$  How can I show that it is Lorentz invariant? Server only reachable over VPN I have an Apache server running on a Raspberry P and it works just fine in the local network. And after forwarding port 80 and trying to connect using the public IP, Chrome says ERR_CONNECTION_REFUSED. But the strange thing is that I CAN reach the server when using VPN and using the same IP. What can I do?     -telnet 80.***.***.78 80      Trying 80.***.***.78...     telnet: connect to address 80.***.***.78: Connection refused     telnet: Unable to connect to remote host     -route -n      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface     0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0     192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0      -sudo netstat -lapute:              Active Internet connections (servers and established)     Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode       PID/Program name     tcp        0      0 *:http                  *:*                     LISTEN      root       6137        2051/apache2     tcp        0      0 *:ssh                   *:*                     LISTEN      root       6367        2249/sshd     tcp        0      0 pi.local:ssh            nmb.local:65535         ESTABLISHED root       8669        2565/sshd: pi [priv     udp        0      0 *:9949                  *:*                                 root       5918        1809/dhclient     udp        0      0 *:mdns                  *:*                                 avahi      6293        2184/avahi-daemon:     udp        0      0 *:54070                 *:*                                 avahi      6295        2184/avahi-daemon:     udp        0      0 *:bootpc                *:*                                 root       5946        1809/dhclient     udp        0      0 pi.local:ntp            *:*                                 root       6310        2200/ntpd     udp        0      0 localhost:ntp           *:*                                 root       6309        2200/ntpd     udp        0      0 *:ntp                   *:*                                 root       6304        2200/ntpd How to tell the difference between linear and non-linear regression models? I was reading the following link on non linear regression . My understanding from reading the first section "Nonlinear Regression vs. Linear Regression" was that the equation below is actually a linear regression, is that correct? If so why?  $$y = b_1x^3 + b_2x^2 + b_3x + c$$  Am I also to understand that in non linear regression multicollinearity isn't an issue? I know that multicollinearity can be an issue in linear regression so surely if the model above is in fact a linear regression there would be multicollinearity? If $R$ is an integral domain and a subring $S$ has identity $1_S$, how would you show that $1_S=1_R$ (here $1_R$ is the identity of the ring $R$)? I am unsure about what an integral domain really is and how the subring comes into play here. Just recently, the right-click context menus in Windows 7 have been acting in a kind of left-handed way. That is, when possible, the initial menu appears to the left of the mouse pointer. When I hover over a submenu option, the next level of context menu appears to the left of the first and so-on.  Basically, what normally happens when you're right at the right-hand edge of the screen is happening all the time - except when I'm at the left-hand edge. Perhaps it's some kind of left-handed users option, but that doesn't seem likely - more like a right-to-left language option, except that I've never even tried to use a right-to-left language.  I haven't checked every app. for the issue - probably only Windows Explorer, definitely not in Firefox, for the moment that's as far as I've checked.  Scratch that - this affects menu bars as well as context menus. The menus dangle down to the left of the menu-bar item instead of the right, and submenus open to the left too. This seems to apply to most applications, but not too Firefox or Thunderbird.  I find this extremely annoying.  I have no idea how this occurred, though it isn't the only weird glitch I've had in Windows 7 in the last few days - see   I assume there's a setting somewhere that has got changed, but I can't find anything. There's also a chance that I've suffered some kind of registry corruption, so I might need to apply a fix in the registry - not something that scares me, but I need to know what to fix and how.  So - does anyone know what setting has been changed, and how I can fix it?  Also, beyond CCleaner (which I already have), are there any tips on making sure that the registry stays clean and sane?  Finally, both Microsoft Security Essentials and Malwarebytes Antimalware seem happy that I don't have a malware problem. Should my recent glitches make me doubt that? Installing IE8 in wine - error rename/sha1sum mismatch winetest.cat Please note, this is an informative QA post rather than a question specific, due to this issue popping up many a time.  QUESTION / ISSUE  How to solve the issue of installing IE8 (Internet Explorer) in wine (any version - to my knowledge).  Related Wine Errors:  Terminal install method  Installing IE8:  winetricks -q ie8   should give you a similar error:  Executing w_do_call ie8 Executing load_ie8 Executing wine iexplore -unregserver Executing w_do_call msls31 msls31 already installed, skipping Using native,builtin override for following DLLs: iexplore.exe itircl itss jscript msctf mshtml shdoclc shdocvw shlwapi urlmon wininet xmllite Executing winetricks_early_wine regedit /S C:\windows\Temp\_ie8\override-dll.reg Using builtin override for following DLLs: updspapi Executing winetricks_early_wine regedit /S C:\windows\Temp\_ie8\override-dll.reg Downloading http://winezeug.googlecode.com/svn/trunk/winetricks_files/winetest.cat to /home/user/.cache/winetricks/ie8 --2016-09-08 23:03:12--  http://winezeug.googlecode.com/svn/trunk/winetricks_files/winetest.cat Resolving winezeug.googlecode.com (winezeug.googlecode.com)... 66.102.1.82, 2a00:1450:400c:c06::52 Connecting to winezeug.googlecode.com (winezeug.googlecode.com)|66.102.1.82|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2016-09-08 23:03:13 ERROR 404: Not Found.  ------------------------------------------------------ Downloading http://winezeug.googlecode.com/svn/trunk/winetricks_files/winetest.cat failed ------------------------------------------------------   GUI Install via Winetricks GUI method  or using the GUI method, you should see a error dialog similar to this: I want to talk to someone about the house that my wife and I own.  Saying, for example, "My wife's and my house is awesome," sounds a bit funny to me.  What's the best way to express this?  Clarification  I'm asking specifically about the grammar of multiple nouns in possessive form.  I'm particularly curious if it's possible to do this with a first-person pronoun (me).  I am capable of rephrasing this in other ways - my question is not how to express the idea, but about this particular grammatical construction, if it is even legal. Why does change in speed of a wave make it refract? When a light wave enters a medium with a higher refractive index (e.g. from air to standard glass) and its speed decreases, why does that make it refract/bend?  I understand that wavelength decreases and frequency stays the same and therefore its speed decreases, but I can't find anywhere whatsoever why the speed decrease cause the wave to refract. So could someone please explain this? How to configure lightdm to allow manual logins in Ubuntu 14.04 I used to modify /etc/lightdm/lightdm.conf, adding the line greeter-show-manual-login=true, in order to allow login for hidden users and root.  Now I've just installed the new Ubuntu 14.04 and the file lightdm.conf is no longer located in /etc/lightdm. It's in /etc/init and has been totally modified.  How can I force lightdm login screen to show a field to input a login name? I just realized I can't unrar .rar files on my Ubuntu machine!  What's the easiest way to accomplish this fundamental task? If possible I'd love something like 7Zip that I can just right Click, and extract and have the program worry about how to do it regardless if it's a .zip, a .rar or a .foo compressed file.