Where are Custom Menus saved in the Database for Wordpress 3.0?

Question: I've been searching and searching my sql database in phpmyadmin but I can't seem to find where custom menus are stored in the database. Anyone know where it's stored? I have a large menu basically that takes forever to create. I'm in development now and rather than recreating it in production I want to try and copy the sql over to see if it works. Thanks!
Answer: When new custom menu is added, its entry is added into several tables.

table: _term_taxonomy with a column taxonomy and value nav_menu.
from 1) term_id is also in table:_terms with the title of menu which is shown in admin panel
table:_term_relationship will contain term_texonomy_id from 1) and connection to all object_id which will be linked to all _post table having sub_menu and below level menu.
table:_postmeta will contain all the details related to menu and submenu for each object_id from _posts table.
Comment: I don't understand how this isn't upvoted. I was looking for a way to export and import the menus. I know my answer. Don't. I ll do it manually.
Comment: Should clarify step 3 to say that the object_id from term_relationships is equal to the id field from wp_post
Comment: I have uninstalled WP Fastest Cache and after finishing the uninstall process left an entry on the left menu and I cannot find it anywhere on the tables you say...
Answer: Navigation menu items are stored in the wp_posts table with post_type = 'nav_menu_item'.
Comment: how wrong is this, wordpress bloats the _posts and _options tables throwing all kinds of things in there that should be placed in a seperate table for better database management and loading speed
Comment: But what custom post type?
Comment: Yes, the database is very poorly normalized and this answer is only partially correct. It identifies the objects that comprise the menu but doesn't provide the values (e.g. menu text) associated with the menu. I am still digging to try to find that data.
Answer: The actual menu titles, IDs, and names are stored in the wp_terms table.
Comment: This query returns only the menu ID. What query returns each menu item with enough information to regenerate the menu?
Comment: `$menu_list = get_terms('nav_menu');` will return all menus.
Comment: Once you have the menu ID, you can run
`$wp_menu_items  = wp_get_nav_menu_items( $id );`
Answer: I hate to bump a old thread. But if anyone runs into this like I did searching for the answer, as of WP 3.2 the post_type for menu is now called nav_menu_item  in the wp_posts table. They didn't have that on the wp page, they just had nav_menu. Which I couldn't find.
Answer: The custom menu links are in the wp_postmeta table under "meta_value"
    meta_key = _menu_item_url
Comment: Check out [WordPress Answers](http://wordpress.stackexchange.com/), Stack Exchange's WordPress question and answer site.  It would be great if you could share some of your expertise.  BTW WordCamp Phoenix was great!
Comment: @Chris_O Hey man! thanks.. I've seen it I just rarely get on stack..... sites. I should try and hang out there more often :/  #toobusy
Comment: @Chris_O fyi, I do have an account there: http://wordpress.stackexchange.com/users/2173/ryno
Answer: I wanted to provide a more complete and up to date answer for people who stumble upon this post like I did. There are several places in the database that need to be checked/updated if you're wanting to manually insert or update menu items.
The first step is finding your main menu container. This is stored in wp_terms. Just search by name for the name of your menu. Take note of the ID. In my example this will be 33. Likewise, you could insert a new row here to create a new menu. The slug can't have spaces in it. Just substitute in - instead.
Now we'll get to finding items in that menu. Those are stored in wp_posts with a post_type of nav_menu_item. There's nothing in this table that ties it to your ID above, so you'll have to go by post_title. If the goal is inserting a new menu item, with phpMyAdmin you can just click Copy on an existing item in any menu and change post_title and post_name. Now take note of the ID of the item you inserted. Mine is 9179. It will also be nice to take note of the ID of the item you copied (even better if it was from the same menu) as we'll be using that in the next step.
Now go to wp_postmeta and search on the post_id field for the item we just copied. This will bring up all of the fields that need to be filled in to get the info for our new menu item. Using phpMyAdmin copy each of those entries and change as needed. _menu_item_menu_item_parent, _menu_item_target, and _menu_item_classes are the fields that will most likely need changing. And make sure you're putting the ID of your new item (9179) in _menu_item_object_id.
After those are all created we can now tie that menu item to our menu. We need to get the term_taxonomy_id from wp_term_taxonomy. Just search term_id using the ID from the first step, 33 for me. The term_taxonomy_id happens to be 33 for me as well. No we need to insert a new row into wp_term_relationships. object_id will be your post id (9179) and term_taxonomy_id is what we just looked up (33).
Now your new item should be in your menu.
Comment: Hideous schema. Thanks though.
Answer: Here are the SQL scripts I used:
Get the menus from the wp_term table:
SELECT * FROM wp_terms AS t LEFT JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'nav_menu'

Use the term_id to get get all of the menu titles / links from all the other connected tables. In my opinion this is a terrible relational database.  Just replace the tt.term_id with yours from the query above, below is 11.
SELECT p.post_title, p.post_name, p.menu_order, pm.meta_value FROM wp_posts AS p LEFT JOIN wp_term_relationships AS tr ON tr.object_id = p.ID LEFT JOIN wp_term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id INNER JOIN wp_postmeta AS pm ON p.Id = pm.post_id WHERE p.post_type = 'nav_menu_item' AND tt.term_id = 11 AND pm.meta_key = '_menu_item_url'

Answer: Each menu item are saved in posts table and menu hierarchy/options/urls etc. belonging to these items are stored in postmeta table. In postmeta table you can see post_id column belonging to posts table items.
Answer: $postId = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM `wp_postmeta` WHERE meta_key='_menu_item_object_id' AND `meta_value`='$id'"));
$postIdc = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM `wp_postmeta` WHERE meta_key='_menu_item_object_id' AND `meta_value`='$a[1]'"));
$sql2 = "SELECT * FROM `wp_postmeta` WHERE meta_key='_menu_item_menu_item_parent' AND `meta_value`='$postId'";
$sql2c = "SELECT * FROM `wp_postmeta` WHERE meta_key='_menu_item_menu_item_parent' AND `meta_value`='$postIdc'";

Comment: Try to put a little more information into your answer.  "Just code" doesn't help us understand the why or the how this addresses the question.
Comment: @GeorgeStocker how is this an answer at all?


Bypass read-only SD card with missing 'Lock' slider

Question: I have an SD card, that is broken, the slider for the "Lock" is gone. When I put it into my computer it turned out to be in read-only, How can I override this with software? I need to format the SD card. I am using Ubuntu and Windows 7
Comment: After reading the unsuccessful answers so far, one question comes up: where does this card from? Specifically: was it writable *before*? If the file system on the disk says "you can't read me", you have **two** things to fix.
Comment: yes it was write-able. It is a San Disk Extreme SD card, The file system is FAT32, My computer can read it fine.
Answer: From sd card reader not working :

I found that unlocked, my Eye-Fi card should only be inserted 20-22mm
  into the card reader (not all the way).  Locked, it seemed to work
  fine inserted all the way.

Another solution from Repair missing SD-card lock :

Get a piece of aluminum foil and stick it onto a piece of tape then put it on SD  :

Cut a straw into pieces that can fit into the hole of the Lock
and fill the hole with them
and cover with the other end of a scotch-tape. Use 2-3 pieces of straw :

Insert into the card-reader :
Comment: I tried this, it does not work, thats why I am asking for a software way of bypassing it
Comment: Try using the card with another reader, computer or operating system. Try a Linux live CD as [described here](http://answers.yahoo.com/question/index?qid=20120420080704AAKaUCV). If nothing works then the card is defective and is a lost cause.
Comment: this is the closest thing to an answer that I am going to get.
Comment: This works because the slider/tab doesn't do anything to the card.  The slider itself is just a piece of plastic, but it doesn't alter the card at all when it's moved.  The Read Only state comes from the SD Card Reader.  It has a sensor that detects the position of the slider and based upon that, allows Read/Write or just ReadOnly.  So, if you can glue, tape or somehow add back the small piece to the SD Card to fool the SD Card reader to think the tab is still there and in the UP position, it will no longer be read only.
Answer: I'm fairly certain that the lock is a physical mechanism, and therefore all you need to do is put a piece of scotch tape over the SD card. Be very precise in placing the tape over the notch, but not over the brass connector on the opposite side.

The notch forces the read-only to work with camera's, PDA's, MP3 players, etc, however they are not guaranteed to work on all SD readers (apparently it works on your reader). It's simply a physical thing, therefore the tape will trick the SD card reader into thinking the SD card is unlocked.
Comment: DOes not work, fiel system is still read only
Comment: I think it is more sophisticated than a light blocker.
Comment: Just tried with a SD card with lost lock pin. Precisely taped a harder plastic there and voilá. It writes!
Comment: Just want to say @CC Inc, that this solution worked perfectly and saved me a camera; the camera had broken lock sensor. You have to put a few pieces of tape (I used 3 clear scotch) and it works perfectly...thank you so much!
Answer: The write protection tells the computer to reject all write requests, which normally prevents writing to the SD card. Unlike the floppy disk, this is done at the software level. Although the card reader can detect the position of the read-only switch, the switch itself doesn't physically hinder writing. This means that although it's theoretically possible to write onto a read-only card, it would have to be at a low level. Barring direct manipulation of the output bits, the only permanent solution would be to format your card at a low level, thus removing the card-side write protection.
This is not the same as a normal formatting. It wipes the card completely, including the protected areas, where the write-protection securities would be held. Theoretically, this would erase the card's write protection, but it may also come with unforeseen complications if done incorrectly. I would suggest that you only use a low-level format if you know exactly what you're doing. There is a free low-level format tool compatible with SD cards available at this link: http://hddguru.com/software/HDD-LLF-Low-Level-Format-Tool/
It should be noted that this needs to be done in conjunction with one of the hardware solutions posted here. Again, SD card readers are designed so that they can detect the position of the switch. If the hardware solution doesn't work (as is the case here), then the card must also have a built-in write protection.
Answer: If I'm not mistaken - its the same kind of thing as the old floppy disk.  The lock blocks a lightbeam if it is in the correct position.  There's no electrical component to it - just that if the switch is in a certain spot, the lightbeam gets broken and you can read and write.  Otherwise it is write only.  I'd try and tape over the switch area with something like scotch tape and darkening it with a sharpie.  Really, though, they're so cheap it would be better to just replace the card.  I'd worry about the tape pealing off inside the SD card slot and then you might end up really screwed.
Comment: I don't believe that the lock mechanism for SD cards is a literal lightbeam, but it could certainly be something that was implemented in hardware. At best it might be overridden at the driver level. I'd advise against continuing to use an sd card that has been physically damaged.
Comment: @Fopedush The switch **is** purely mechanical and should (by the standard) not affect what the card itself chooses to do. It's up to the reader to decide how the detection of the switch is made. Some might use a small IR LED and sensor, whereas other use a mechanical switch in the slot. [here](http://blog.tynemouthsoftware.co.uk/2014/01/raspberry-pi-sd-card-socket-repair.html) is a look inside an SD card slot component which  shows an example of how the reading can be implemented using a spring contact. As long as you can replicate the effect of the switch, it should work.
Comment: I do not see a whole in which the light could enter.
Comment: Put card on the table.  Align it so the part you insert is facing away from you and the gold fingers face the table.  The switch should have been on the left edge of the card.  There may be a notch on the left side towards the edge you insert.  Tape that area and darken it.  If you are confused, you can search youtube - there should be a couple of examples.
Answer: TRICK DOESN'T WORK ON APPLE MACBOOK or iMAC and technically, it shouldn't work on any SD slot, there's no such thing as a "light beam", it's a very simple metal pins mechanism. I had the same issue, tried the tape, tinfoil and mid-position tricks to no avail so I looked it up:

(source: engineersgarage.com)
I used a led light to see inside the slot and it was all in fact, pins. a pin is pushed when the card slider is in "lock" position preventing the OS from writing. I used tweezers to scrub inside the lock recess in the iMac slot, plugged the SD afterwards and it worked. might have been jammed with dirt and dust.
Answer: there is no light beam in an sd card reader.  the lock is a little switch
which CLOSES when the plastic sliding lock is forwards (towards the contacts).
tape over the slot only with scotch tape and the switch may be weak enough
to activate, thus closing the circuit and allowing the card to write.
i am finding a way of taping a little piece of wood to fill the slot
( a thin sliver of wood such as that off a matchstick )
as the switch in my camera requires a lot of pressure to activate it. its not working in my camera because the tape gives a little under pressure and doesnt push the switch closed.   it needs something in the slot to be taped there.
method 2:  i am now using some semi-hardened gorilla glue and building it
up thus removing the indentation on the side of the card completely.
leave the glue for a while to become mostly hard, perhaps an hour or more, and then using a sharp hobby knife ensure its
a flat surface by scraping the excess off with the knife.
i allowed the gorilla glue to become opaque and thick before trying to apply
it to the card, that way it becomes thick enough to stay put and not run out of the groove.  in 18C temperature that took about 10 minutes to go opaque and get thick enough to paste it into the groove.
note:  test the glue is stuck firmly to the card when its cured.
if the glue drops off into your electronic equipment, it may cause havoc !!!
if you are unsure of this method or unsure of the bond between the glue and the card, DON'T DO IT this way as i won't be responsible for the loss of your equipment - do it at your own risk.    (but gorilla glue is good stuff.  if the card is not greasy it should stick well).


Newton's third law of motion when moving between two surfaces

Question: If for every action there is an equal but opposite reaction, then why doesn't a ball keep on moving when made to move between two surfaces, should elasticity of surface, gravity and friction be mentioned in this theory?
Answer:
You are talking about Newton's first law, i.e, inertia (ball should keep moving)
This has absolutely nothing to do with the current group-theory tag.
The first law doesn't need to explicitly mention friction, it already says "when no force is applied". It's upto you to keep track of external forces.
This has been voted for migration to Physics but I doubt they will accpet such poorly formulated questions. You should probably read more on Newton's laws of motion.
Comment: actually I am talking about 3rd law not 1st.if every action has equal reaction then why magnitude of force goes on decreasing?
Comment: @dipendra I highly suggest you read the link provided. You have a serious misconception it seems. The magnitude of the force doesn't necessarily decrease, also the third law doesn't say anything about it. The third law is instantaneous. It talks about a particular *instant* of time.
Answer: The answer is that there is friction. Friction is a dissipative force, meaning that friction will cause energy losses. This causes the ball to stop rolling: in a vacuum that would not happen! These things can be taken into account when doing calculations.
Answer: I think Sir Issac Newton's laws works fine here.
1st law
Object will continue to be in rest or move in straight line
until a external force applied on it.

the ball starts/stops moving only when an external force applied on it.
2nd law
 F=ma

The ball uses the force 'F' applied on it to move in acceleration 'a' on direction of force.
3rd law
Every action has an equal and opposite reaction

the ball is stopped if an equal force applied on opposite direction of
  ball's movement.

But usually it stops due to friction/gravity/other obstructions which does not come into action exact opposite direction or exact force needed to stop ball. so it will move as long the above condition satisfies.
also the friction reacts on exact force and direction opposite to ball's movement (same for all the obstructions ) and when these forces sums upto the force 'F' which used to made the ball move, ball will be stopped !


Shouldn't we be cleaning up these porn links?

Question: There are currently 1,140 references to a porn site on Stack Overflow. I'm planning on going on an edit spree to change them to something more appropriate (that is, example.org, net, or .com). I might do them all myself, but 1,140 is rather a lot, so some help would be appreciated. (Please also vote up that feature request I've linked to.)
Comment: In any case, if this is something that really needs to be done, it needs to be done by an SE developer.  They can probably run a script that does a find/replace and be done with it in 5 minutes.
Comment: Is this really a problem?  I'm quite sure that any reasonable person would look at those and interpret them as "example.com".  Anyone that clicks on one of those  deserves what they get.
Comment: I'm pretty sure the vast majority of those didn't intend to link to a porn site...
Comment: @TRiGisTimothyRichardGreen The problem is that serial minor edits not only take up a lot of user time, but spam the front pages with updates that people don't need to pay attention to, contribute to posts going CW, draws extra attention to the links, etc.  It really is best, if this should be cleaned up, for it to be done in a script.
Comment: Except that if the link is in a post by a reasonably high reputation user, we're sending it a lot of Google Juice. (Only if they're actually links, of course, and not just a domain name in some text.)
Comment: If you're like me, @RobertHarvey, you find it easier to read with reverse contrast, so you double-click on each paragraph as you're reading it. And sometimes you hit a link by mistake.
Comment: Probably not, which is why I'm editing, not flagging. Either way, though, they should still be cleaned up.
Comment: http://lifehacker.com/5912480/how-to-invert-your-browsers-colors-for-easier-reading-at-night
Comment: We need to avoid smutoverflo
Comment: Someone has to work at those sites. It's not the first time a web dev has used SO to do their job
Comment: Bumping is rarely ever a problem on Stack Overflow, @Stijn. If the edits are useful, great!
Comment: Well, I've done a few and in each case have done a couple of other tidies while I'm at it, so there's that to be said for doing it manually, @RobertHarvey. Working slowly, because it's late. Signing off now.
Comment: I don't know if it's related, but [this user](http://stackoverflow.com/users/2174085/johnny-bones?tab=activity&sort=suggestions) is making suggested edits to change these links. Do we want to have all these questions bumped to the front page?
Comment: Hmm. I probably should have just done these myself. Working slowly, no one would have noticed. However, I generally don't see a problem with bumping. SO moves so fast anyway that it makes little difference. @Stijn.
Comment: Well, my eyesight's not too bad with the glasses, but double-clicking while I read has become a habit. @RobertHarvey.
Comment: Never come across one of these mentioned porn sites.
Comment: In any case, I think a consensus should be reached here on Meta before doing anything.
Comment: @Shog9 Thanks for clearing that up :)
Comment: There are actually ony 347 references: http://stackoverflow.com/search?q=%22xxx.com%22 The rest are posts that have "xxx" and "com" separately but not the combined url.
Answer: If it's easy to do, which I'm sure it is, please change the xxx-links. As Kate points out below - we may make it example.org ( example.com,  example.net work also)
I think it's a good idea. But part of me is tentative, because perhaps the  best way to go about this might just be volunteer effort. 1000 is reasonable if we get a few folks who'll scratch away in their spare time.
Because I'm not sure it's trivial to do this in code without at least a few unintended side-effects. There must be some instance of xxx.com that is literally intended(regex comes to mind), where it throws code off. So that said, I'll do my little part in editing out xxx's.
Comment: The only URL you should ever use as a placeholder is example.com. This is exactly why. Nobody can put a site at example.com so it is safe. If you go to it, you will see that it is reserved. See also http://www.iana.org/domains/reserved
Comment: Or `example.net` or `example.org`.
Comment: In the time that has passed since this question was asked, a filter has been implemented that warns anyone posting a link to xxx.com they should use example.com instead - see http://meta.stackexchange.com/a/207155/147247 @devRicher
Comment: The only "inspiration" new users take to make a good question are the help center and the tour. None of them explain "use example.com" only. A lot of new users will keep using xxx.com as an example domain. Without an explicit filter to pornographic content links that tells the users to change `example-porn-link.com` to `example.com`, there's not much most/most new users will do. @KateGregory
Comment: @KateGregory Apologies, I've never tried to post such a link. ;)
Answer: Have you shown that there is an actual problem? If there is an actual rendered link with a TLD of .xxx then by all means edit it in case it ends up pointing to a real website, but other than that is there any point going through and editing out every instance of xxx that you can find? Before we start witch-hunting 'bad' URLs, keep in mind that porn sites don't necessarily use an .xxx TLD or have xxx anywhere in their URL, cleaning up these example URLs (which in many cases are simply text, not a hyperlink) won't achieve much at all.
As a developer, I didn't stop using xxx as a placeholder just because questionable websites can now use it as a TLD. It might just be the OCD and old habits dieing hard, but as a placeholder xxx is implicitly understandable (i.e. people implicitly realise it's a placeholder), and using substitutes like zzz just doesn't look right.
Edit:
this old question seems to be getting a bit of attention lately. I guess the fact that there are now 1675 usages just of the original xxx.com reference shows that its usage is quite commonplace within the developer community. I guess my original assertion is also correct - some may consider it offensive or inappropriate but there's no real problem with its usage in this context.
If you see things like:
...grant all on server server1.xxx.com to role role_sec_admin_all

(as seen in this example) and you find it inappropriate or offensive then you really need to take a hard look at yourself - maybe your head is in the wrong place or you're over analyzing it?
Comment: Pretty sure he was talking about xxx.com (which has been a registered domain [since 1994](http://www.networksolutions.com/whois/results.jsp?domain=xxx.com)) not *whatever* .xxx (which is a much more recent possibility, albeit one with [some history of use](http://stackoverflow.com/search?q=url%3A%22http%3A%2F%2F*.xxx%22))
Comment: To be specific, `xxx.com` is a porn site. An actual porn site. I checked.
Comment: @TRiGisTimothyRichardGreen I understand that (I did have a mention of `xxx.com` but I took it out before submitting my last edit), but I think there is only an issue if the URL is rendered as a link - if it is not in link form (i.e. in a code block or quoted section) then there is little point in changing it. I'd be surprised if SO didn't already have automated scanning for dodgy links.


Cann't delete the CSV file after imported by Feeds module

Question: We uninstalled the "Feeds" and "Job Scheduler" modules, after a successful imported csv data by Feeds. However, the csv file is still maintained in "media" list. When we try to delete that file, it say "The file xxx.csv is in use and cannot be deleted". Is there a way to delete that, or do we have to delete from FTP?
Comment: Have you run update.php to update the database after removing the module?
Comment: Ya, we did the update database after removed the module. It still unable to delete.
Answer: The "file still in use and cannot be deleted" means Drupal's still managing the file, so don't remove it via FTP because that basically bypasses Drupal and could cause other issues related to Drupal expecting a file to be somewhere and it's suddenly not there. So I'd recommend finding a solution that involves working via the UI and not directly on the file system.
Is the file attached as a field to an item of content somewhere? That would result in "file still in use". If so, delete the item of content, clear cache a few times and check again.
Comment: The only time we used that file was imported by "Feeds" module. And the Feeds module has been uninstalled.
Comment: @H-L uninstalling module does not remove it's usage marks on files. It should probably be used to delete file, if it's the one that uploaded it.
Comment: It may used when to "delete file" when running "Feeds" module. But I already uninstalled the Feeds. There should be a way to delete that, because that csv data already imported into database.
Answer: Just in case, run the file through file_usage_list() to be absolutely sure it's not used anywhere else. You never know.
If only Feeds comes back as a result, you can then always run the file through file_delete(), though you'll have to use the $force parameter.
Comment: The easiest way to do that, would be to install the Devel module. After doing that, you can run PHP by browsing to devel/php, type the required code and press submit.

This should pretty much do it:
`$fid = [file_id];`
`$file = file_load($fid);`
`dpm(file_usage_list($file));`

You'll have to find the file's ID first though, and replace '[file_id]' with that number.
Another option is to access your DB and browse in the `file_usage` table, again using the file's ID and look at the value listed under 'module'
Comment: Sorry Vodde, I'm not a developer. But I really want to know how to run "file_usage_list()"


News Posts on Associated Sites not showing on Hub Site

Question: We have a hub site with web parts for news rollup that should be pulling in news posts from associated sites as they are added ;  it was working fine but now I am not seeing new posts from some sites.  The newest post is there on the associated site but only older 4 posts are showing on the Hub site web part.
Answer: Is it for all users or specific users who are facing this issue?
Please verify - are you able to see the news from the below URL :
sites/vg/_layouts/15/news.aspx?title=All%20news
And you can do the below as well :

Re-indexed the library
Removed the webpart and add back
Check the library permission.

Note :

After re-indexing wait for at least a day for crawl to happen.

If above doesn't fix your issue, you may deassociate and reassociate back the site to the hub site from admin center.
If none of the above fix the issue, raise a ticket to Microsoft from office 365 admin center report.
Similar issue was raised by an user, in the below thread :
News not visible for users at hub site


Custom wordpress Theme and Plugin repository

Question: I am looking for a guide/guidance to create a proper custom wordpress repository for themes and plugins hosted on a website hosting account. I do not want to host it on github.com or anywhere else. I searched in google but without any success so far. Anyone could help?
Answer: Do you want to display the plugins and themes for sale or download or just have them accessible to download for updates?
Comment: I would like to have them available for direct install and/or download.
Answer: I suppose it all depends on what you are actually looking for, but you can use composer as your installer and use packagist which is the code of packagist.org to install on your server. It is also used by wpackagist.org.
An article on how to set this up on an ubuntu server can be found here.
If you are looking for a marketplace for plugins and themes then that's something different altogether.


How to get the default permissions of a file in linux

Question: If there is a file called new.txt which has permission -rw-r--r--, but when someone use chmod 777 new.txt the permissions are changed. Then how to get back the original permissions of new.txt if I do not know the previous permission.
Answer: The system won't maintain a history of previous file permissions for you. If you have a backup that includes that file with its original permissions, you might get the original permissions information by listing out the contents of that backup.
Depending of what backup solution you use, you might not even have to restore any actual file: just a directory listing of the contents of a backup with the file permissions included might suffice.
If there is no backup, you must use brainpower to deduce what the permissions should have been. As atype said, the user's umask setting determines the default permissions for any files or directories the user creates.
For most regular files, the "starting set" of permissions is 666, and then the umask value is used to mask out some permissions. So if you know that the user's umask value is 022, then the actual default permissions for the new file would be 666 - 022 = 644, or -rw-r--r--.
Note: the permissions numbers are in octal, and the actual operation uses Boolean operators: 666 AND (NOT 022) = 644.
For directories and executable files, the "starting set" of permissions will be 777 instead of 666. So if the user's umask is 022, the actual default permissions for a new directory will be 777 - 022 = 755, or drwxr-xr-x.
Answer: Default permissions are difined by umask. If you want to find default permissions of the newly created file you can just look at it.
If the file for which you want to find permissions on installation was part of a package, you usually can look into it and find out.
Answer: You cannot "get back the original permissions" of a file. What you can do, though, is to set them to whatever the default settings are right now.
touch /tmp/file.$$                  # Create a temporary file with "default" perms
chmod --ref=/tmp/file.$$ new.txt    # "Reset" the file new.txt
rm -f /tmp/file.$$                  # It's always good to tidy up

The default setting is controlled by the shell's umask value. On my system, here is the current setting:
umask
0022

This means that write permission (value 02, binary 010) for group and others is to be removed when a file or directory is created.
Also be aware that most editors will not create a file with the executable bit set (binary value 001) even though this should be allowed by the umask setting. It's up to you as the user to differentiate an ordinary file (without execute permission) and one that is a script (with execute permission):
chmod +x new.txt                    # Add execute permission


Sdk is missing error android studio

Question: I just installed Android Studio on Ubuntu 16.04 and I can't open it.
When the welcome page of android studio opens I click on Start a new Android Studio project and it says Your Android SDK is missing, out of date or corrupted.
I downloaded the last version of SDK Tools from android studio webpage and tried to add it to sdk manager but it says: Target folder is neither empty nor does it point to an existing SDK installation...
I don't know what to do now..! :((
Comment: Have you tried adding SDKs from Android Studio's settings instead of downloading them from a website?
Comment: Yes I tried that one too but it doesn't work
Answer: I had the same problem and I solved it by following these steps:

Go to android studio and then go to configure option on the bottom of the window.
Go to 'project default' option in that option and click on project structure option.
Change the SDK location to your sdk location. (If you get errors such as your location not a platforms you must go to your sdk location and make an empty folder and rename it to 'platforms'. Then you must repeat this steps.)
Note:this error may arise when your sdk folder not a 'platforms' folder and you must make an empty folder and rename it to 'platforms'. platforms folder must be in the sdk folder.

For more information you can watch these videos:
  https://www.youtube.com/watch?v=3XiUavaRwt0
  https://www.youtube.com/watch?v=DuagOiwIbUk
Answer: The current direct link for SDK Tools package is (2018-12-31):  https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip.
But, as others have already said in other responses to similar questions on SO, the best way is to let Android Studio handle the installation, because it will install other useful apps, too (emulator, platform tools, etc).
In my case, I wasn't connected to the internet when I first started Android Studio, so I got stuck at the same error.
After removing the ~/.AndroidStudio3.2 folder and a ./studio.sh restart, it asked me to download all the necessary apps (note: the dowload has ~1GB!) and then Android Studio started flawlessly!

Sdk is missing error android studio


Putting portable air conditioner hose in bucket of water

Question: Does it really work to use the hose to heat water in a bucket?    I do not want to leave my windows open at night for the hose to go outside.   I have heard the hot air from the portable air conditioner can be disposed of in this way.
Comment: No. Would either prevent air from flowing out the hose or would blow water all over. Make room hot and humid.
Comment: If the heat stays inside (whether directly or heating water that then heats the room), you will defeat the purpose of the air conditioner. What is the reason for "do not want to leave my windows open at night"? If it is because the open window leaves open additional space next to the hose, take a piece of thick cardboard or other relatively stiff plastic or other material and cut it to match the size of the window opening and cut a hole in it for the hose.
Comment: You can put a clamp on the window track to keep it from being opened any further from the outside.
Comment: Do you have an exhaust hood over the stove that vents outside, i.e., not just recirculates?
Answer: This won't work in that simplified form. Even if the water did absorb a bit of heat as the air passed through, the water would heat up fairly quickly, at which point it would stop absorbing heat from the air. "Dissipation" doesn't mean "disappeared". The heat still exists somewhere. You'd have to change the water regularly. Also, you'd be adding moisture to the air via evaporation and possibly effervescence, countering the cooling effect of the air conditioner.
Now, if you wanted to split the airflow into many tiny tubes, provide a large quantity of cold water, and change the water regularly, it could work. Maybe. But probably not very well.
Comment: Keep in mind that the air conditioner probably does not have enough static pressure to force the air through the water in the first place.
Comment: When the hose is placed in the water, the water will fill the inside of the hose up to the water line. The air pressure will have to displace that height of water, equivalent to about 0.5 psi per foot of submersion.
Comment: Maybe. The vacuum created by the air's buoyancy might just overcome any backpressure.
Comment: >  "vacuum created by the air's buoyancy"
I don't follow?
Comment: I'm no fluid dynamicist, but the backpressure is created by the weight of the water column. Perhaps the buoyancy of the air as it is released from the hose counters that.
Comment: True. I hadn't considered that it's an open circuit.


Can't get Mesh to unwrap properly

Question: I'm trying to get this chair (the back part) mesh
Unwrap smoothly but it keeps coming out like this

which causes extreme distortion when i try to put a texture on it.
i'm trying to get it to unwrap smoothly like this

Can anyone explain to me how i can get my mesh to unwrap like that?
Answer: without an blend file i have to guess, but it seems to me, that you missed some uv marks on one end of each of the objects. A cubic object needs to have 3 UV Marks on each of its ends. I made a picture to explain it futher:  If that does not solve the problem, please upload the blend file.
For getting the top and bottom face separated from the object, mark the howl face:

Can't get Mesh to unwrap properly


Statistical test evaluating consistency

Question: I'm trying to solve a problem and I'm not used to how little data I'm given. I'm trying to compare results from an actual system I've created, and a value given to me. I've found that the value of Model A's mean is 10.871, for instance, and I have also found the standard deviation, sample size, and half width of Model A. I'm supposed to compare Model A's mean to another mean from the "real" mean, which is appx 14. I'm not given the standard deviation, sample size, or any information about the "real" mean, other than it being 14. I need to use the level of significance alpha = 0.05, but none of the t-tests or z-tests seem to work since I don't know standard deviation or sample size for the "real" mean. How can I carry out my test to see whether or not the "real" mean is consistent with the mean I've found from Model A?
Answer: You are comparing one sample (mean = 10.871, sd known) with a specified mean (14). If you really want to do a null hypothesis significance test (many experienced statisticians deprecate them) and can assume [approximate] Normality, then a one-sample Student's t-test is appropriate, you can Google that for more detail but briefly:
The test statistic is $ t = \frac{m-μ}{s/\sqrt n } $
where
m = sample mean
μ = hypothesized population mean
s = sample standard deviation
n = sample size
The p-value depends on the alternative hypothesis
$H_1: m > μ$  then    $P(t_{n-1} >= t)$
$H_1: m < μ$  then    $P(t_{n-1} <= t)$
$H_1: m != μ$ then    $2 * P(t_{n-1} >= |t|)$
Answer: This is an unreplicated design question. You cannot use any of those tests and the best you can do is say that the "real mean" falls within x% confidence interval of your model. It is easy to illustrate why such test would be useless: you could model a population with a mean of 14 and a range of e.g. 0-28 and one with the same mean and a range of 13.999-14.001, or much more extreme and skewed cases, so without knowing the underlying distribution of the 'real' population, it is impossible to predict whether and to what degree the two distributions overlap.

Statistical test evaluating consistency


Bayes Nets are acyclic, Markov Nets are cyclic. How does that work?

Question: In Bayes networks it is assumed that directed acyclic graphing makes for simple calculations where there are conditional dependencies between the states. I do not understand what calculations are made easier, would someone please give an example for this? I understand a Markov Net and a Bayes Net can be called a zeroth order Markov Net with no hidden layer. Would someone explain this?
Answer: Bayes Networks represent probability distributions in a very simple manner.  That being said, all models apply simplifying assumptions to the problem, so in that sense they do end up simplifying assumptions.
Important Ideas:

If you really understand the joint distribution of all of the variables you're interested in you're golden.  You can then compute conditionals, marginals (their densities, statistics, means, medians).  So this is a reasonable goal.
Each node in a Bayes Network represents a random variable conditionally distributed on it's parents.
Because of the chain rule, and the fact that the Bayes Network is acyclic, the joint distribution's density can be computed as a product of the individual nodes' densities.
Causation flows along arrows, and correlation travels in both directions.  Then there are important ideas like conditional independence, d-separation, inference.

I think your last sentence should say that Bayes Networks and Markov Random Fields are both examples of Artificial Neural Networks with no hidden layer.
EDIT: Also, I think your title should be changed, Bayes networks are also directed, where as MRF's are undirected.
Comment: To understand the computational simplification, I suggest you study a simple algorithm like the forward algorithm for Hidden Markov models This turns a sum that could involve an exponentially large number of terms into something linear, just as a consequence of the independencies implicit in the model.
Answer: You ask "I am not getting what calculcations it makes easier, can anyone please give an example for this". I cannot give a specific example, as I do not really use either Bayes Nets or Markov Random Fields (at least not explicitly).
However I believe the classical practical difference in calculations is belief propagation. This algorithm can be done exactly for DAGs, but the "loopy" variant is only approximate for graphs with cycles. My understanding, which is crude and may be wrong, is that the basic version essentially proceeds through the network in topological order, so all calculations that can affect a node have been completed prior to reaching that node.)


How to use loadnibnamed to pushviewController

Question: I'm writing a program that uses a NavigationBar.
I am using the project from this website
http://www.edumobile.org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/
Usually, we push view controllers onto the navigationController. In my case, my xib connects to a class which is an object
<code>#import <UIKit/UIKit.h>
@interface PageControlExampleAppDelegate : NSObject  {
UIWindow *window;
IBOutlet UIScrollView *scrollView;
IBOutlet UIPageControl *pageControl;
NSMutableArray *viewControllers;
BOOL pageControlUsed;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIPageControl *pageControl;
@property (nonatomic, retain) NSMutableArray *viewControllers;

- (IBAction)changePage:(id)sender;
</code>
The problem is that because this is not a viewController, I'm unable to push it onto the navigationController.
The view is loaded using loadNibNamed, the object loads with awakeFromNib.
My problem is that when I call the loadNibNamed, it opens this object and I'm unable to come back to my previous view as the navigationBar is gone. This view seems to load itself on top of everything.
I've tried creating a new class which is a viewController and has an object of this ContentController but it would then load the new viewController (which is empty). If i call loadNibNamed from the new viewController, the new view still comes on top of everything.
1- What would be the best way to push this object (which opens up a view) onto my navigationController?
2- How would I make this contentController into a UIViewController instead of an object and would it still look and work the same as being an NSObject?
Thanks in Advance
Answer: i did not understand clearly what u said.
but for navigation controller try this
[self.navigationController setNavigationBarHidden:NO animated:animated];
Comment: The navigation controller is not hidden. Just that when calling the object, it seems that it gets instantiated on top of everything else prior to it rather than pushing onto the navigation controller and still showing the navbar


How can I determine the background color of a site?

Question: How can I determine the background color of a site (so I can use that color in Photoshop)? I looked at the source code, but I don't know code well enough to figure out what's what...
Answer: Right click with your mouse on the web page and then click "Inspect Element". Then look to the right under the "Styles" tab (assuming you're using Chrome), and then under where it says:
.site {
background-color: #f8f3ef;

This is the color (#f8f3ef). For future reference, you may have to do some looking around in the Inspect Element next time and just look for "background-color" and then the color code.
Answer:
View the source code using a tool like Firebug or Chrome Developer Tools will make that easier to do. You can inspect an element, in this case the background, and see the CSS rules that applies to it.
Use a browser extension like Colorzilla to click and tell you what the color is.
Comment: FireFox, right click => Inspect Element on any background area gives you the answer so quick it's not funny. Click the little checkbox to toggle `.site { background-color: }` to verify that's what you're looking at and copy out the hex color code.
Answer: Its a #f8f3ef, somtimes i just make print screen copy to Photoshop then grab color. But this method is the most lazy by Firebug
Answer: In most browsers, you can hit F12 to open a set of developer tools for inspecting the page. From there, you can click the search icon and click the element you want to see the background color of, then look for the background-color css property:

Or alternately, if this is something you do often, you could use a browser extension (like ColorZilla on Chrome) to make finding exact colors on web pages quite a bit easier:
Answer: Look for:
background-color:

That's your dead giveaway that a color (in hexadecimal format) is being set for the background of an element. I looked at the code just now and both values are the same.
#ece7e3

The value is in the format of # and 2 hex characters for amount of red, 2 hex characters for amount of green, and 2 hex characters for amount of blue all together to form one color. individual values must be from 00 to FF.
An easier way to try to match a color in a picture with a color of something on a page is to make use of the print screen button in windows. Simply open up one painting program along with your web browser. MsPaint should work.
Visit the website you mentioned in your browser.
Once its loaded, press the print screen button to take a snapshot of the screen then paste the contents in the painting program. Use the color picking tool to click on the part of the snapshot that you want to know the color of.
Answer: There is a color picker tool in Firefox which you can use easily.
Tools> Web Developer > Inspector
It's shown in the picture below. You can point anywhere on the page and you'll have the color.
Answer: Why not simply use a color picker?
You can use this one  and then just go in the area you want to exactly copy the color. You will have it in hex and RGB so can use in photoshop.


Best fundamental books?

Question: I'm looking for internationally applauded  textbooks on fundamental biology. Books that are a must for a pre-medicine student/high school advanced. Currently, I study Biology by Neil Campbell, Jane Reece(and team) and I really like it. What I'm looking for is 21st century pedagogy and a modern writing style(as opposed to a stiff, unfriendly writing style that reads like a fact presentation pamphlet); books so good you don't need an amazing teacher(which I definitely do not have.) Thanks.
P.S.- If you have come across amazing books in branches of biology like say biochemistry or neuroscience or immunology, even those suggestions are welcome.
P.P.S- My question is distinct from the "Books for beginners" question asked by user31782 because: 1.cost is no bar 2.I am not a beginner in biology, I'm studying pre medicine; and 3.All the resources suggested in the answers, I already know about them/have used them.
Comment: How can one study pre-medicine (note the hyphen)? Or is this an example of the modern writing style you yearn for? And as for 21st century Pedagogy, sounds like a film company or a rock band. I would suggest that you explain yourself more clearly.
Comment: @David, a number of universities require a year of basic biology, biochemistry, calculus, biostatistics and psychology after high school for admission to medicine. That preparatory year is called pre-medicine (hyphen duly noted). Pedagogy means the method of teaching; both an apathetic school teacher and an ivy league professor know that DNA is transcribed into RNA and RNA is translated to protein, but their methods of presenting that to a student is what creates the difference. That's where pedagogy comes in.
Comment: My criticism of your use of words is because the lack of precision makes your request unclear, so that all that happens is people express opinions about books they like or use, which is both off-topic here and does not answer your question. Pre-clinical medical courses differ throughout the world and within countries (and in some '21st centurary pedagogy' has replaced them completely by 'problem-based learning' — although this is clearly not what you mean by the term). The problem is that the adjective you use describe your emotions towards the books, rather than the books themselves.
Comment: To clarify further: What do you find 'amazing"? (Do you really mean this or just good?) How is a book 'unfriendly'? (Author frowning in photo?) What do you consider a 'modern writing style'?  And when you have ceased to be a beginner, biology is not a single subject. Do you want to understand one branch at a less superficial (more chemical and mathematical) level, read something in which the science is related to medicine, or be inspired to do something about the apalling maternity mortality statistics in the US? Or do you, like most students, just want a book to pass an exam? Tell us.
Answer: For fundamental mammalian cell biology, and molecular biology, and fundamental biochemistry: "The Molecular Biology of the Cell" by Bruce Alberts and colleagues.
It is mostly written for first semester students at university and thus summarizes the basics in a very clear way. Moreover they state whenever findings have some ambiguity, and they use many nicely drawn pictures to convey abstract concepts.  Despite its approachability it covers most fundamental topics of many domains (also diseases).
While the ~2,000 pages of the complete edition might seem a bit intimidating they rarely provide unnecessary detail, and the individual chapters are written in a very concise way (even allowing you to skip some of them).
Answer: Best textbook is no textbook. Don't read textbooks. Textbooks are overpriced reviews.
Do a literature search like a scientist. Create a list of keywords from the books you already have. Search PubMed for review papers containing the keywords in the titles or abstracts and read:

titles;
sentences containing the keywords;
entire abstracts;
skim through the papers (look for pictures).

If you collect all papers for each keyword, thousands in some cases, you can learn a lot by reading just the titles. Some programming skills will be useful.

https://www.ncbi.nlm.nih.gov/pubmed
Answer: Biology by Brooker (and now additional authors Widmaier, Graham, and Stiling) 4th edition is one which I used, and I quite liked it. Great presentation of information, in my opinion.
Textbook of Medical Physiology by Guyton and Hall, though not friendly, is a decent book.
I mostly have recommendations in the field of biopsychology, etc.
Neuroscience: Exploring the Brain by Bear, Connors, Paradiso (2016 ver) is colourful, inviting and VERY friendly! Great for high school advanced or pre-med, though I suppose if you want more details in neuroscience, you'll need something like Kandel.
Comment: Have you ever had a chance to compare Neuroscience by Bear, Connors and Paradiso and Neuroscience by Purves, Augustine and Fritzpatrick? Are they the same level or one is more in-depth than the other?
Comment: Both seem to be on more or less on the same level. Presentation of the matter is better in B,C,P. Neuronal signalling is really good in P,A,Z, as in, it goes pretty in-depth. If you're a high-school student, I'd recommend B,C,P as your text book and P,A,Z as a reference book because B,C,P teaches better and that is what you want.
Answer: I really like The Molecules of Life: Physical and Chemical Principles from John Kuriyan. It does a good job of introducing basic to intermediate principles in biochemistry. In particular it is a great introduction to protein biochemistry and pharmacology.
Comment: I just got the book last month, I find it very helpful. Thank you.
Comment: My pleasure. Good luck!

Best fundamental books?


Find a non-principal ideal (if one exists) in $\mathbb Z[x]$ and $\mathbb Q[x,y]$

Question: I know that $\mathbb Z$ is not a field so this doesn't rule out non-principal ideals. I don't know how to find them though besides with guessing, which could take forever.
As for $\mathbb Q[x,y]$ I know $\mathbb Q$ is a field which would mean $\mathbb Q[x]$ is a principal ideal domain, but does this still apply for $\mathbb Q[x,y]$ ?
Comment: $\Bbb Z$ is a principle ideal domain. I don't know about $\Bbb Z[x]$.
Comment: Have you *tried* guessing yet? Yes, sometimes guessing takes forever. However, a lot of the time (especially with homework questions), it solves the problem *very quickly*. And frequently when it doesn't, working through your guesses help you understand the problem better which lets you make your next guess even better, or even gives you ideas for solving the problem!
Answer: Hints:

Consider the polynomials $a_nx^n+\dots+a_1x+a_0\in\mathbb{Z}[x]$ where $a_0$ is even.
For $\mathbb{Q}[x,y]$: you have two indeterminates.
Answer: Here is a general result:

If $D$ is a domain, then $D[X]$ is a PID iff $D$ is a field.

One direction is a classic result. For the other direction, take $a\in D$, consider the ideal $(a,X)$, and prove that it is principal iff $a$ is a unit.
This immediately answers both questions: $(2,X)$ is not principal in $\mathbb Z[X]$ and $(X,Y)$ is not principal in $\mathbb Q[X,Y]=\mathbb Q[X][Y]$.


Hide hidden files and directories in file upload pop-up explorer

Question: How can I hide hidden files and directories in pop-up file explorer when uploading a file via web browsers, e.g. when inserting an email attachment? I checked Firefox 42.0 and Chrome 46.0 on x64 Ubuntu GNOME 15.10; both show hidden items. In this screen-shot I wanted to do a Google image search. And yes, nautilus does not show hidden files when I do day-to-day directory navigation.

Answer: A shortcut key to show/hide hidden 'dot' folders is: Ctrl+H.
This key is part of Nautilus and such (also GNOME I think) to toggle the displaying of hidden files and folders.  Try that shortcut key in that window, see if that helps.
Answer: Right click anywhere in the pop-up file explorer and untick "Show Hidden Files". Poof! It's gone!


802.1x and use Google G Suite Directory as LDAP

Question: Has anyone managed to authenticate yours to the network via 802.1x using Google Directory? I have a case where whole company is using Google Apps and G-Suite with a custom domain and they would like to access wireless network without setting addition LDAP directory. Wireless equipment is aerohive (so radius server is already build-in). Any hints on this topic will be helpful ..
Comment: Welcome to NE, we hope you will both contribute to and learn from this community. I know before Google provided an LDAP service, I used OSC Radiator and Google IMAP over TLS to authenticate. I haven't ever set up the Aerohive RADIUS server so do not know what it is capable of doing.
Comment: I am also trying to use "Cloud ID Secure LDAP" + FreeRadius + Cisco2504 to authenticate user in 802.1x. But until now it is not working.
Answer: Google have just released Secure LDAP which does what you want. Note you'll need to set add Cloud Identity to your G-Suite domain. I don't know if you'll be able to get Aerohive to talk directly to it, or if you'll need to put FreeRADIUS in between.
Other existing paid options include JumpCloud and Foxpass.
Comment: Yeah, I can Image there is a need for radius in between. Aerohive devices already include buildin FreeRADIUS.
Answer: This feature is available in G Suite Enterprise, Cloud Identity Premium and G Suite for Education. If you have G Suite Basic or Business, you can add Cloud Identity Premium on top of existing license or upgrade to G Suite Enterprise
Answer: Yes, I managed to authenticate the network via 802.1x using Cloud ID Secure LDAP.
It was Cisco2504 + FreeRADIUS + Cloud ID Premium.
At the end, Authentication Protocol I used in Android was 802.1x EAP-TTLS/PAP.
I think that because Cloud ID Secure LDAP doesn't provide ntPassword attribute, only way to authenticate is using PAP not CHAP, MSCHAPv2.


Insert third partition in previous 2-partition setup

Question: I've read a few of the articles around, browsed the net for a while, but was unable to find a solution to my problem.
I have an MBP with 1TB Flash which is split by 50% into two partitions. One contains OS X, the other is used for raw data storage.
Now what i would like to do, is create a third partition from some of the remaining space on the 1st (OS X) partition. Essentially, i need to "fill in" a third partition in between the two existing, but without affecting the capacity of partition #2.
I remember that back in the days when i installed Bootcamp it seemed no problem to change my main partition size and add an extra partition, but for whatever reasons, i cannot do that. Disk Utility has completely greyed out all the controls:

I also tried rebooting from a Mavericks USB-Installer Stick and then going to Disk Utility in there, but the result is the same. I hoped it would work there because OS X was not in use - but no.
Why is that? Has it become impossible to repartition a drive in use? Or have i generally misunderstood something here?
(MBP Mid 2014 | 1TB | Yosemite OS X)
Answer: 1 TB? I presume that's a Fusion drive. Fusion drive can at most have 2 partitions.
Comment: Fusion? Never heard of it. What is that? Hardware Info says it is an *APPLE SSD SM1024F Media* and states **Revertible: Yes** on the Logical Volume.


Who killed Sauron?

Question: Is it correct to state that Frodo killed Sauron? Which is the role of Gollum/Smeagol? Frodo was the one in charge of destroying the Ring in the flames of Mount Doom (Amon Amarth of Mordor), but Gollum actually bit Frodo's finger and fell into the flames.
Comment: [Did Sauron survive?](http://scifi.stackexchange.com/questions/12038/did-sauron-survive/12042#12042) - "*"If it [The One Ring] is destroyed, then he [Sauron] will fall; and his fall will be so low that none can foresee his arising ever again. For he will lose the best part of the strength that was native to him in his beginning, and all that was made or begun with that power will crumble, and he will be maimed for ever, becoming a mere spirit of malice that gnaws itself in the shadows, but cannot again grow or take shape.*" - The Return of the King
Comment: Nobody, he wasn't killed.
Comment: Nope. He was *diminished*
Comment: I'm sorry, what does it mean?
Comment: Don't think he's dead, he's a maia, but his spirit is so weak he cannot even cause as much harm as a light headache.
Comment: So it is correct to state that the diminishing of Sauron was caused by Eru Ilúvatar?
Comment: @lupod It's most correct, yes. That's arguably the moral of the *Lord of the Rings*: we incarnate creatures can struggle against Evil, but ultimately it can only be truly defeated by the Divine
Answer: Frodo did not kill Sauron
Sauron did not die. It was said he put most of his power into the Ring, and thus when it perished, he was vanquished, but he did not actually die.

He concentrated within the Ring a great part of his own fëa (soul). In this way, Sauron's fate became bound to that of the One Ring. If it were damaged or destroyed, so too would be Sauron's strength and power.
- From the LOTR wikia.

Notice, nothing was ever said of him being destroyed or killed. I can't find the exact quote in the books yet, but there was a particular passage by one of the Wise Ones that said, if Sauron regains the Ring, he will have power to cover all the land in a second darkness, the ending of which cannot be forseen by anyone. But if the Ring is destroyed, he will lose most of his strength and power, and will diminish and his rising again can never be foreseen.
So no, it is not correct to say Frodo killed Sauron, because Sauron did not die. He was Maia before his corruption, and even at the end of the Third Age, he was still considered a being not of the lower order (the Elves, Men and Dwarves we see). He is still 'alive' as far as we know.
Gollum, aka Smeagol helped (though unwillingly) to destroy the Ring, and was one of those to find it in the first place)
It was Smeagol's friend, Deagol who fell into the river while the two were fishing at least 500 years before the events of The Fellowship of the Ring. He saw the Ring and retrieved it, and Smeagol, enamoured by the gold, strangled his friend to death and hid the body, taking the Ring for his own. After being kicked out of his home, he went to the Misty Mountains, where the Ring abandoned him just in time to meet Bilbo, who took it out. Smeagol (Gollum, by then) accused him of stealing the Ring, his Precious, as he called it.
After the Fellowship broke at Parth Galen, Frodo and Sam went through Emyn Muil, where they met him, Gollum having stalked the Fellowship since Moria. Partly out of fear of being beheaded by Sting (Frodo's sword), he agreed to help the hobbits to Mordor. Along the way, he betrayed them and turned up again in the end at Mount Doom. Frodo did not want to destroy the Ring at the very end, but Gollum attacked him and bit his finger (with the Ring) off. At that point, (in the books) Eru Illuvatar intervened and Gollum tripped of the ledge, taking the Ring down into the Cracks of Doom and getting it destroyed, along with himself. In the movie, Frodo fought him and he fell. Doesn't really matter. Point is, without him, the Ring would not have been destroyed in the end.
Comment: @Neeshka, no I'm saying that Eru would not have intervened unless there was no other option. When Frodo claimed the Ring, there still were options: either Sam or Gollum could have still gotten the Ring into the Fire. But when Gollum had the Ring, noone else could have done anything anymore, so Eru did.
Comment: Why not? If it was divine intervention anyway then wouldn't Eru trip Frodo as well? Or make him sneeze so the ring would fall off?
Comment: I think Tolkien's idea was that Eru almost never intervened. If ur going by the book, he only stepped in right at the end veeery subtly after Frodo did almost everything humanly possible to get the ring destroyed, and there was nothing more anyone on Middle Earth could have done. Only then did he step in. If ur going by the movie, Frodo did trip and go off the edge, but he held on and Sam saved him. Gollum was so obsessed with the Ring, he didn't even care he was falling to his death.
Comment: Quote required has been provided by Valorum in comments section :)
Comment: @Neeshka Frodo was a reasonably good person still and had not yet been fully corrupted so maybe Eru didn't want to kill him. Golum had been utterly corrupted so Eru was being merciful killing him.
Comment: @bellerophon &ASH so you guys say even though Frodo (and many others) would have died anyways as Sauron already dispatched his servants to collect the ring Eru wouldn't push anyone else if Gollum wasn't conveniently available?
Comment: @Neeksha No, I am saying Eru would rather kill Gollum than Frodo so he waited till Gollum had taken the Ring before tripping them into the fire.

Who killed Sauron?


Should a group keep the same GM, or choose different GMs for every new campaign/system?

Question: The title is mostly the question. Is it good to give everyone in the group the chance to be the GM, or should the best do the job always for best play experience?
Comment: Warning - this is a pretty subjective, discussiony question.  Take care in answering, if this turns into a big list of random thoughts it'll get closed. Remember Good Subjective, Bad Subjective - http://blog.stackoverflow.com/2010/09/good-subjective-bad-subjective/
Comment: I've created the [tag:gm-rotation] tag, since I've seen a few questions floating around here about people rotating between gamemasters.
Comment: @Emracool a tag already exists, [tag:round-robin].
Answer: The GM/Player roles are not symmetrical
In my experience, not everyone is suited, desires, or even likes to GM. The work required to show-up and play your character is almost always less than preparing to GM - reviewing rules [changes], creating worlds/encounters, prepping session materials, cross-checking player-submissions, etc. Even "lazy GMs" usually do more prep than their players - it is a side effect of the many-to-one nature of the game.
It's not for the timid.  - so no one should be compelled to take on the role.
Finding out requires trying out
On the other hand, there are many folks who might be great GMs, if they only get the chance.
Earth Needs More GMs! Watching a great GM can be intimidating to prospective ones. Offering the rotation to everyone at the table is an excellent means to encourage trying the role on for size. And, as suggested by the question - allowing other game systems to be introduced as well can help with the fear of being compared to other GMs stigma.
"Hey! I don't know if I can do it justice, but I just read about this new system: XXX - and if you guys want, I'll try to run it for a one-shot next week..."
Comment: There is a symmetry you missed: Not everyone is suited, desires, or even likes to be a (non-GM) player.
Answer: I think this is really up to each individual group. From what I have seen on this site some groups share GM load by campaign and other groups play different simultaneous campaigns with different GMs.
My group has kept to one consistent GM for our main campaign. However, myself and one other member of our group have started our own campaigns with the same group of people. We still play in our usual time and just give our regular GM time off to be a normal player.
This has the advantage of giving the main adventure the consistency of a single GM, but it also gives the GM a break and allows him to step into the player role. It also gives the players who want it the opportunity to get behind the screen and GM.
Answer: A gaming group is like a sports team. Like that team, you have a variety of concerns you need to balance.
Is everyone having fun/are we excelling?
If everyone's having fun, that's good. Sometimes GMs get burned out and don't want to GM, which means everyone's not having fun.  Sometimes one or more of the GMs suck, in which case everyone's not having fun. Sometimes someone wants to GM but they are getting told "no, this other person is the GM," in which case they're not having fun.  These factors vary from group to group and vary over time within the group, so you need to know how much people are enjoying the game(s) and their role(s).  Talk about it.
But "are we having fun right this minute" isn't the only gauge...
Are we planning for the future; is our group healthy?
Having one GM, like just having one pitcher, can be a problem when that one GM leaves/graduates/has a falling out/burns out/gets married/etc.  You want a deeper roster. So in many cases, you will want to let the person who's not your "best" GM do the job so that they get better. You will want to let valued members GM, even if they're not the best, because they are happy and will stay with the group if they get to GM once in a blue moon.
You have to plan for long term happiness, too.
GM Rotation Example
In my old gaming group in Memphis, TN, we had me as primary GM for years and one other guy who GMed some. When D&D 3e came out we all bought the books and I bought the first crop of 6 adventures that came out (mostly third party - hooray OGL!).  I said, "I'll run the first one, but I'm as new to this game as anyone.  I know some of you have GMed and some never have.  But what do you all think about everyone taking a turn GMing in this initial round?" They all agreed and so inside the same campaign with the same characters, we rotated GMing from adventure to adventure. Some folks had never GMed; others had.  The experience was extremely positive for everyone.

The people who had never GMed got additional appreciation for those who do.  At least one guy was of the opinion that "GMing is easy" and had a bit of a sense of self-gratification about gaming; after he realized how much work goes into running a game he was a lot more appreciative of the GMs after that.
The people who had never/seldom GMed got a chance to, and with at least one they decided they really had a taste for it and wanted to do it more.
We learned from everyone.  People would say to me "Oh, you're the best GM," but seeing all six of us back to back we realized everyone has strengths and weaknesses.  One guy, he really was bad at a lot of the parts of GMing, and some parts of his adventure were painful I'll be honest, but he did NPC characterization great and kept the game momentum up way, way better than anyone else!

Once we had done that, we were very happy we had, and though some people went back to just being players, more chipped in to GM over time and even started side groups to run other campaigns; it helped turn the group into one gaming group into a network of related gaming groups.  My group here in Austin is the same kind of way; nearly everyone GMs sometimes and as a result it's not one six person group, it's a group of maybe 4 or more loosely affiliated games. This provides a lot of flexibility in terms of player recruitment, game choice, etc.
Answer: I've played in a longterm campaign with 1 DM, and another group where everyone DMs.
Benefits of many DMs:

More variety in storytelling.  Sometimes you want to play a deep chronicle that has subtext and subtlety, lots of intra-party back-stabbing, and plots of world-impacting importance; other times you just want to have a bit of harmless escapist fun.  Run a "fluff" campaign.
If one DM gets a little overworked due to outside factors, another DM can prepare an adventure for the night.

Benefits of a single DM:

You can really explore a character and do some really in depth plot-arcs that can develop characters much more than a simple level or 2 adventure
If you are playing an area as a low level character, you can then come back much later in the campaign and get a sense on how far you have progressed.

Disadvantages of Multiple DMs:

My group tends to have to maintain a list of who is in line to run something in the near future.
If you have something you want to run and is ready for characters, you can end up waiting a year or more to run it.

Disadvantages of Single DM:

If the DM has to work late and can't plan that week's adventuring, then you end up playing board games during the weekly session (or calling it off entirely).
If you are reaching your fill-line on a type of plot arc (serious or frivolous), you may have to continue playing a long-term plot arc that is very undesirable to you.  Sure, you could have a "palate cleaner" night and play something against the tone of the campaign, but that will only help in the short-term.

In the final analysis, I think it comes down to a Coke/Pepsi kind of thing.  I personally really like the many-DM approach my current group uses, but I do miss some of the long-term character development that single DM campaigns allow for.  It is also somewhat frustrating when you've thought up some sort of wonderful campaign and are amped up about it, only to find it sit on a shelf for a year while you wait in line.
Answer: Our group has one primary DM who "owns" the campaign, but other people take turns as well running story arcs that are a part of the overall campaign.  Basically, the primary plot belongs to our main DM, but from time to time, others of us have run arcs which belong to the same world, but which usually occur in other parts of the campaign world and only have a minor to moderate interaction or influence on the main campaign plotline.  It's worked quite well for us.  We've been playing the same campaign for nearly 15 years now.
When we do one-offs with other rules, such as an annual Call of Cthulhu session or two around Halloween and occasional runs with other rules systems then it's usually run by someone other than the primary DM.
Answer: I've been a DM for as long as I've been role playing.  More often then not, I'm the DM for our games.  The reasons vary from desire to creativity to just wanting to run the game.  But it gets taxing and tiring and after a while, a DM will burn out.  I'm not saying that the players should have to sit and take a break for a few weeks/months, but it helps a lot if you have different people to run games.  This way, you don't get a DM to burn out or run out a material.  I know I have more than once in the last 12 years.  I think it's a very good idea, but note that it's not for everyone.


random testing sqlite

Question: For one of my testing project, I am working on sqlite testing. I see that they have have a regression test suite. Is it an open source test suite I can use? I am either planning to use a test suite available or design a test suite..My aim is to design a huge number of tests (so using random values adn assigning them is the best call)
Any help and views wil be appreciated:-)
Answer: Saying they have a regression test suite is a little bit of an understatement.  The SQLite engine itself has 73,000 lines of code.  The test suite has 91,378,600 lines of test code.  Besides that, the library is C and tests are TCL, so a lot more bang for your buck in each line of test code.
You can read about SQLite's regression test suite here:
http://www.sqlite.org/testing.html
And you can browse and download the source from the public repository (requires anonymous login):
http://www.sqlite.org/cgi/src/dir?name=test

random testing sqlite


Find longest audio common subsequences

Question: In the next days I'm going to receive an audio dataset for a machine learning project at university. The files I'm going to receive are of 2 kinds: one that is the original entire audio audio sequence and the other that is composed of short sequences of the original file cut and put together in a single "summary" file (one summary for each original file). The problem is that I need to know from which point in time every subsequence was cut, but they cannot provide me with this information. Is there a program to deal with this problem?
Answer: Providing they are exact extracts of the audio files you could use python and numpy to load each audio sequence as a numeric array and then search the full audio files, also as a numeric array for the fragment.
Since all of your audio summary sequences are joined together in a single file you will need to find a window size that produces a unique fingerprint to locate in your large file, (I would suggest starting at about 5-10 seconds worth and scan the big file - if you get more than one match increase the sample size. Once you have a unique match you can carry on from that point in both files until they differ - that will give you your position in the full file and the duration of the first clip. You can then take a new fragment from the summary after the end of the match and repeat the process.
Comment: The problem is that I have many subsequences chained in the summary and I don't know where one ends and the other begins, so I need a way to use this approach and separate all of them correctly in the original file (I hope I explained myself correctly)
Comment: @VincenzoScotti - Very clear - answer updated to address this point.

Find longest audio common subsequences


Can `a?bc` be shortened in Javascript?

Question: So I have the situation where I have one boolean value a and, if that one is true and b<c I want it to end up as true, if a is false and b>c I want it to resolve as true as well. If b=c I want it to be always false, no matter the value b and c are both numbers. My best approach so far is a?b<c:b>c or maybe b^c^a^b<c. Is there any shorter approach? I can't stop thinking about it, and want confirmation this is the shortest possible way or find the solution...
Comment: Are `b` and `c` guaranteed to be integers?
Comment: @Arnauld yes they are guaranteed integers
Comment: @thejonymyster no it doesn't matter
Comment: if `a` is `true`, does it matter what is output if `b>c`? same question for `a` being `false` and `b<c`
Answer: Yes, it can be shorter!
c-b<a^a beats a?b<c:b>c by 2 bytes. My tests show that it works for any integer, including negatives. The downside to this formula is that a is repeated twice, which may be unideal depending on your situation.
Comment: Very clever. This works for integers because 1) if `a` is false, `c-b `c-b `b>c`; 2) if `a` is true, `c-b `c-b `c-b<1` is false <=> `c-b>=1` is true <=> `b<c`. But it sometimes fails for non-integers.
Comment: @EricDuminil Yes, you are correct
Comment: I think `c<b+a^a` also works, again for integers.
Comment: What is precedence order for `c-b<a^a`? Is it `((c - b) < a) ^ a`?
Answer: I don't think it can be any shorter, at least in the most general case
See dingledooper's 7-bytes solution that works for integers.
If the target expression were a?b<c:b>=c (note the change on the second comparison), the two conditions are exactly the opposite, and we can get away with comparing b and c only once with a^b>=c or !a^b<c.
But, the target is a?b<c:b>c, and since b<c and b>c cannot be inferred from each other, you either need to

mention b and c twice each, to carry out two separate comparisons, or
somehow use the three states (negative, zero, positive) of b-c.

For the first method, you already have the optimal answer. For the second, the best I can get is (c-b)*(a-.5)>0, 14 bytes (TIO).
Also note that b^c^a^b<c doesn't quite work.
Comment: Javascript numbers are floating point, so have 4 states (negative, zero, positive, NaN).  Similarly, the relation between a pair of numbers can be above, below, equal, or unordered (one or both NaN).  It can still be interesting to golf the case of finite numbers, though, so you can exclude NaN inputs, and the case of `inf-inf` giving `NaN`.

Can `a?bc` be shortened in Javascript?


Can a half-orc's Savage Attacks and a monk's unarmed strike work together?

Question: I want to make a half-orc monk and I was wondering if the racial feature Savage Attacks from the half-orc race and unarmed strikes from the monk's Martial Arts feature work together. Or, is there some reason that unarmed strikes don't apply to this?
Answer: The Savage Attacks trait says:

Savage Attacks. When you score a critical hit with a melee weapon attack, you can roll one of the weapon's damage dice one additional time and add it to the extra damage of the critical hit.

All it requires is that you get a critical hit with a melee weapon attack. An unarmed strike can be used to make a melee weapon attack, so yes, Savage Attacks will work if you get a critical hit with an unarmed strike.
Comment: I initially upvoted this ages ago, but I've since ended up at the opposite conclusion: because it says you roll the "weapon's damage dice" again, it does require the attack to be made with a weapon (as with Divine Smite). I've left my own answer accordingly.
Comment: @JAMalcolmson Sorry, I misunderstood what you were saying: I thought you were disagreeing with the conclusion, rather than pointing out that the answers on that question don't support it. I've added an answer to that question and changed the link to point to it.
Comment: This answer is wrong. The one provided by @V2Blast is right: https://rpg.stackexchange.com/questions/88852/can-a-half-orcs-savage-attacks-and-a-monks-unarmed-strike-work-together/142840#142840
Answer: No, the Savage Attacks trait doesn't benefit unarmed strikes.
The half-orc's Savage Attacks trait says (emphasis mine):

When you score a critical hit with a melee weapon attack, you can roll
one of the weapon's damage dice one additional time and add it to
the extra damage of the critical hit.

Because it does say "the weapon's damage dice", it only applies on attacks made with weapons - not unarmed strikes.
Even though unarmed strikes are considered "melee weapon attacks", they do not involve a weapon, as mentioned in the "Melee Attacks" section of the rules (emphasis mine):

Instead of using a weapon to make a melee weapon attack, you can use
an unarmed strike: a punch, kick, head-butt, or similar forceful blow
(none of which count as weapons).

As such, things that require a weapon don't work with unarmed strikes.

The same is true of the similarly worded (...and very similarly named) Savage Attacker feat. The description of the Savage Attacker feat says (PHB, p. 169; emphasis mine):

Once per turn when you roll damage for a melee weapon attack, you can
reroll the weapon's damage dice and use either total.

Page 8 of the Sage Advice Compendium includes the following official ruling on the Savage Attacker feat's interaction with unarmed strikes:

Does the Savage Attacker feat work with unarmed strikes?
No. Savage Attacker relies on a weapon's damage dice, and an unarmed
strike isn't a weapon (a point that was clarified in the Player's
Handbook errata).

The half-orc's Savage Attacks trait includes the exact same phrase as the Savage Attacker trait: "the weapon's damage dice". Thus, by the same logic, Savage Attacks also requires an attack with a weapon - so unarmed strikes don't count. They're melee weapon attacks, but are not made with a weapon. (This is not changed by anything in the monk's Martial Arts feature either.)
As always, DMs can houserule otherwise.
(It likely does not break anything to allow this; even for monks, the highest damage die they can have on an unarmed strike is 1d10, whereas several weapons can also do 1d10 damage, and greataxes and lances do 1d12 damage. While monks can make more attacks per turn than some other classes, the benefit of the Savage Attacks trait in particular is limited to critical hits, so this does not seem particularly game-breaking to allow.)
Comment: @Josh It does matter a little. For example, a monk can only use its Flurry of Blows feature to make *unarmed strikes* with a bonus action. So whether or not the Savage Attacker feature works with unarmed strikes can change whether the monk has two or four chances to use that feature every turn (at level 5+).
Comment: I'd argue it's ultimately pointless as the monk could just pick up a Monk Weapon, then have the benefit of smite or Savage Attacks with no change in their rolling.
Comment: @Gandalfmeansme not super significant but I do get your point, it continues the trend of the designers discouraging multi-classing
Answer: That is dependent on the DM
A point of contention will always be whether or not unarmed strikes count as melee weapon attacks. A PHB errata and sage advice compendium muddy the answer to this question. This answer tries to assert that unarmed strikes count as a melee weapon attack using this SAC as its proof. However, in that very same compendium, that question is answered outright.

Does the Savage Attacker feat work with unarmed strikes? No. Savage Attacker relies on a weapon's damage dice, and an unarmed strike isn't a weapon (a point that was clarified in the Player's Handbook errata)

Therefore, the operative question is: does Martial Arts override this, and allow unarmed strikes to be considered melee weapon strikes because of the nature of monks?
By definition, the answer is no.
But your DM may decide differently. Firstly, the way it's worded and described is VERY confusing, misleading, and generally uncool. Unarmed strikes are melee weapon attacks until they aren't, because for the above example unarmed strikes do not qualify even though the rule says melee weapon attack and unarmed strikes have been described as a melee weapon attack in that errata despite not involving a weapon and clearly being treated as an unarmed strike, which itself is being treated as separate from a melee weapon attack despite the...well, you get the loop from here. Your DM may choose fun over semantics. Secondly, damage die exist for unarmed strikes for monks, therefore bypassing the objection that damage dice are needed. But then there still comes the matter that unarmed strikes are simply not melee weapons – and even that if having damage dice was enough, then half-orcs with the tavern brawler feat might also qualify their unarmed strikes to work with Savage Attacks. These complications may make for a stronger case that, even for monks, the RAW are also the RAI. Though the quote above addresses Savage Attacker and not Savage Attacks, both rely on damage die and trigger on melee weapon attacks for the added dice, ergo the answer seems to apply for both. So I'd say to be prepared for DMs to staunchly deny the extra crit damage die as there is nothing that supports monk unarmed strikes counting as melee weapon attacks, and everything supporting the RAW – that monk unarmed strikes are still just unarmed strikes, and unarmed strikes are, beyond a shadow of a doubt, not eligible for Savage Attacks. But I know I would absolutely allow it because I wouldn't want to invalidate Half-Orcs as a race choice for my players' monks, nor would I want to restrict their RP/play style by forcing them to use weapons lest they lose out on their racial abilities. And if any exception to this rule should be allowed, it would be for monks and their martial arts.
Comment: Unarmed strikes are not made with weapons, but they are melee weapon attacks. Perhaps more importantly, the Savage Attacker feat is not the same as the half-orc's racial Savage Attacks feature. (They are confusingly named.) And with monks, their unarmed attacks do involve damage dice, so there is indeed something to roll.
Comment: @Miniman and V2Blast While both points are correct enough based on wording in that errata, for the purposes of Savage Attacks and Savage Attacker, this appears to be untrue despite the way it was worded in that very SAC. Both add dice with melee weapon attacks (different circumstances), but it seems that unarmed strikes are melee weapon attacks until dealing with a feature that specifies melee weapon attacks, then they absolutely aren't. So apparently they aren't, even though they are. Safe to say they aren't?

V2, saw your comment after I edited. Thought of that and added a counterpoint.
Comment: You might want to add a paragraph break or two to the last paragraph to improve readability.
Comment: @V2Blast Rather, I should say that I addressed that damage die point before reading your comment on it. Because you're right, but apparently for the RAW it's only half the solution? Regardless, it does rather feel like monk as an exception should be directly addressed.
Comment: Agreed, your answer was spot on and first and v2blasts is nearly identical in information. If you can organize this more clearly, you may get the bounty .


Fork travel on a mtb

Question: I just wanted to ask how much fork travel does this bike have and is it worthy of buying??
Answer: Information about fork travel should be present in marketing materials to a bicycle. If you are looking at a web shop page, such information is usually hidden somewhere in the lower part of a page.
Alternatively, the travel is usually specified somewhere on the fork itself. If you could see the bicycle in person or ask the seller, that would be the most reliable method.
The provided picture is in quite low resolution, which does not allow to recognize the brand of frame, fork, or other essential details. Neither it helps to see any inscriptions on the fork.
Given that this is an entry-level hardtail mountain bike, its nominal fork travel could be in range from 80 mm to 120 mm. Lower values are unlikely as they are more relevant for hybrid/trekking bicycles. Longer travel is unlikely because longer travel hardtails are less popular and typically more high tier. I'd wager it has 100 mm of travel, as it is the most popular value for such machines.
Whether it is not worth buying anything or not is up for the potential buyer to decide. I doubt we can give you an advice here, especially given how little information about anything is given.
Comment: An entry-level hardtail can be very worthwhile, but to me fitting a kickstand as stock is a red flag - what is the bike built for? Trails or shopping?
Comment: Should add that what a low end fork is claims, and what it actually achieved with a rider less than 300lb can be very different.
Comment: @mattz Exactly, that is why I used the words "nominal travel".
Answer: A way to gauge the amount of travel a fork has, in the absence of any other information or clues, is to measure the amount of exposed stanchion.  A stanchion is the upper part of a side of the fork which is very smooth and narrower than the lowers. The stanchions are what the lower fork slides up and down on during compression and rebound.  Most forks have approximately 10mm of exposed stanchion that is unused as far as travel. So if you were to take a measurement of the exposed stanchion from the bottom of the crown to the top of the lip of the lower fork seal and it measures, for example, 110mm, you are likely looking at a fork that has 100mm of travel.
In almost all cases, a suspension fork has travel anywhere from 80 to 200mm in increments of 10mm.  If you have an air spring suspension fork--which can be determined by the presence of a Schraeder valve for air input or removal on top of the left fork leg-- the air can be let out via the valve while fully compressing the fork to bottom out. When the fully compressed, measure the remaining exposed stanchion, subtract this figure from the length of exposed stanchion when fork is pumped up to the recommended pressure for your riding weight. The difference between the measurements is the amount of travel.
Comment: @MaplePanda No. Agree with the facts and your edit is better worded. Thanks
Comment: Made a pretty big edit - feel free to revert if you don't like it.

Fork travel on a mtb


Publishing .NET web service to Jetty web server?

Question: I have created a very simple webservice using C# in VS2008.  I would like to publish this to a server using Jetty-6 as its web server.  Is this possible, or is IIS the only way I can go.
Answer: IIS isn't the only way you can go.  Web Services using WCF (Windows Communication Foundation) can be published in the following ways:

Self-hosting in any managed .NET application
Hosting in a Windows service
Hosting in different versions of IIS

This article breaks down pros and cons of the different options:
http://msdn.microsoft.com/en-us/library/ms730158.aspx
In any case, each one is pretty simple to do.  You should find templates for these options in Visual Studio.
Answer: Jetty is a Java web server, so I doubt you'll be able to use C# code in Jetty itself... you can of course use something like HttpClient in Jetty to communicate with your C# service over HTTP.


Gimp: How to despeckle old scanned document

Question: The sample image below was overly dotted with block spots. How are the spots removed (or at least reduced) using Gimp, please? I have tried the Despeckle filter but it seems to have no effect on the image.
Comment: It's not really a "speckle".. as in dust.. the marks are the same intensity and color as the type. Because there's no real value, intensity, or hue definition between the type and the clumps, I'm afraid *manually* erasing may be the best method.
Answer: The Despeckle filter is a "median blur" with some bells and whistles. I can't make it work either, but it seems to expect gray levels when you image is strictly black and white.
But the plain Median blur filter (Filters ➤ Blur ➤ Median blur) works (radius=3):
Answer: Sorry for working in Krita, but I have a good toolpack installed for it. That toolbox is G'MIC filter collection. It's freeware and it's  also available for GIMP (see NOTE1)
I applied G'MIC filter Inpaint:

It despeckles but as a side product here it fills holes. I guess in reality filling holes is the intended main result and the despeckling is a lucky side product because there's not enough black garbage between the letters and lines. That space is seen as white hole which should be filled.
I have not checked what useful basic GIMP with no extras contains for this, but the previous answer by user xenoid hints that some possibilities exist.
Holes in the letters can be restored by inserting the original as the top layer and setting its blending mode = Lighten. The lighter color is shown:

To get perfect letters you need something which recognizes they are letters and replaces them with perfect ones. That's OCR. Nothing ordinary will work because there's so many distorted letters. To be useful the OCR method should be intelligent enough to utilize the context i.e. what word would be the right one. I skip it.
At least one commentator suggests you to erase the garbage manually. He's right. That method doesn't remove any text, but inserting white between the lines makes reading substantially easier.
In a vector graphics program (for ex. Inkscape) you can prepare a set of white rectangles that you duplicate as needed and drag to the right place with no need to mess with layers.
I guess you can easily prepare as groups good white covers for longer chunks than one line. Export the finished page in the wanted format.
If your text has somehow simple and regular line- and paragraph spacing that idea has a possibility to be productive also with bitmap layers in GIMP.
NOTE1: G'MIC is as well available for Paint.NET and Photoshop.
Comment: A little overwhelmed by the procedure (considering GB of files ahead), but I surely will try this. Thank you :)