How can I diagnose a bridging (ethernet) loop?

Question: Given that spanning tree has failed (or you don't have any spanning tree) and get an ethernet loop, what's the best way to diagnose where the problem is?
Which switch?, which cable? and so on.
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
Answer: OK, so assume you have a topology like:
          SW1
         /   \
        /     \
       /       \
PC A--SW2-----SW3--PC B

For some reason there is a bridging loop, STP is disabled or someone applied a filter in the wrong place or such.
PC A wants to communicate with PC B. It first ARPs for the MAC of PC B, the destination is a broadcast with MAC ffff.ffff.ffff. So the frame goes to both SW1 and SW3. The SRC MAC is PC A. SW1 then floods the frame towards SW3 and SW3 will flood the frame coming from SW2 to SW1.
SW1 and SW3 learned the MAC of PC A when the first frame came in. When the second one comes in from the opposite direction it has to relearn it. Because these events occur so fast and repeatedly you will see log messages complaining about MAC flapping. Something like "MAC FLAP 0000.0000.0001 is flapping between Gi0/24 and Gi0/23". This is a good sign that you have a loop.
What you could do then is to try to trace this MAC. Try looking in the ARP cache of a device in the same subnet and see what IP this device has. So with the MAC you could try to trace it with sh mac-address-table or with the IP maybe you have a list with all IPs and where they are connected.
If the host gets a IP address from a DHCP server you could also try there to find where the host is coming from. If you have option 82 enabled that would be a great help.
Other signs are that the CLI will be very sluggish. CPU load will be very high. Switches do almost everything in ASICs so if a switch has a CPU load over 50% it's probably not good. You should implement SNMP monitoring and watch for high CPU load. Also look for the MAC flap messages. If the switches have a loop the LEDs will probably be blinking like crazy.
Things you could do to protect against loops:

Enable STP! (duh)
SNMP monitoring of CPU load
Enable SNMP traps for certain events like STP topology changes
Enable storm control on the ports to limit broadcast
Don't span your VLANs too much in your L2 topology
Enable port security and limit number of MAC addresses per port
Enable Option82 if you run DHCP
Comment: Yeah - kind of weird.  I would have thought all of those things (except the switch IP issue) would be in silicon...
Comment: I have to say the CPU load item surprises me a bit.  I haven't seen this before during bridging loops at all, although all my experience in dealing with them is on ProCurve gear.  On them the CLI never seemed to be sluggish.
Comment: Interesting. Maybe HP does something differently than Cisco. some things that could affect it would be speed of interfaces involved in loop. If it's unicast or broadcast. If the switch has a SVI in the vlan or not.
Comment: Actually, now that i think about it, i'm almost sure that we never had a switch IP in an affected VLAN.  All of our switch-to-switch links on that site were untagged on a transit VLAN which didn't have any management IPs on it.
Answer: One of my users recently borrowed a desktop switch from someone's desk. Upon returning the switch, they plugged in all of the loose ethernet ends that were nearby. One of those cables went to the network and another was two ends of the same cable. The desktop switch was plugged into the network and also plugged into itself. The switch had no STP, so broadcasts that came in from the network would loop on the other cable in both directions. Of course, each time a broadcast was received on the looped ports it gets replicated back into the network. It drove HSRP absolutely mad and--due to poor design--it also resulted in OSPF adjacency failures across the campus.
The first indication of the problem was a macflap forwarded to my email. This immediately led us to the correct wiring closet. From there, it was a process of elimination based on port LEDs, interface pps and logs. Needless to say, I have since rearchitected the entire campus. The best preventative measure is probably bpduguard. I have since deployed the feature and it was quite simple. Getting that errdisable syslog in my email is nothing short of bliss.
Comment: Unfortunately, MAC Flaps log messages are useless if you have any WIFI access points connected to various switches, as users roaming from one AP to the next will cause such message.

BPDU Guard (or mecanisms like it) is a MUST on access switches.  If you're lazy, you can also put the "errdisable recovery cause bpduguard" statement, which cause ports put in error-disable to be automatically put in forwarding state after 5 minutes, so no need to reset the port in config after having disconnected the offending cable
Comment: > From there, it was a process of elimination based on port LEDs...

Ahh, Das Blinkenlichten.
Answer: With most equipment, the CPU shoots to 100% and the only thing you can do is break the redundant physical connections.  Once the CPU calms down you can plug the links back in one by one and see which one re-causes the loop.
For big chassis (like a 6500) I've had to pull out all of the blades and plug them back in one at a time.  Once I figured out which blade, then I had to pull all of the individual links (16 GBICs) and put them back in one at a time as well.  Never fun.
Some more modern equipment has a protected CPU which should make this easier to deal with - you can still interact with the box.  At that point looking at traffic counters and such to determine the malfunctioning link becomes possible.
Answer: I recently started at a company where they use broadcast limits on each port.  If a port passes >5% of it's capacity as broadcasts the switch puts it into ERRDISABLE.
 storm-control broadcast level 5.00
 storm-control action shutdown

This has been a life saver when one group tends to plug in devices that bridge the wireless networks onto the LAN.
Though for your actual question, I've always found it to be manual.
Answer: for IOS:
You will probably have MAC addresses flapping between ports.. look for MAC_MOVE_NOTIFICATION (or similar) errors in:
sh logg

Now to find the port:
sh int g0/1 controller

look for out of ordinary Multicast and Broadcast numbers. Any collisions are a bad sign.
Last but not least, you can't log in, because the CPU is pwned :)
sh proc cpu

How is the switch doing here? If it's an L2 switch only, you don't want anything above ~10%
Answer: In the case you have unmanaged, or the equivalence of unmanaged (lacking login details, or knowledge of the switch operating system, etc), switches and a bridge loop, I describe how I'd go about finding the loop manually.
This also addresses the fundamental bottom of the original question, "you don't have STP".
The basic algorithm for fault-locating this loop is similar to STP except you don't readily have access to sending out BPDU's with port ID's in them.

First, connect a packet dumping/sniffing-capable device to a port in
one of the switches.  This device has now become your tree's root device.

If you have to fault-locate in multiple locations, e.g. over a "campus" or similar, you stand to gain by being able to remotely login with a portable ssh client to the packet dumping machine.

I'd personally use my Linux laptop with an Internet connection with tcpdump in a screen and ssh into it from for example ipad or phone.

If you are unable to login yourself remotely, use a friend to visually monitor the tcpdump, which is probably flooding at link speed making it easy to notice a difference whenever the path towards the loop source device is disconnected.

Next, you're going to have to essentially recreate a tree, starting from your root switch.

And because you can have the scenario where you have multiple looping links feeding into your root device, you must start by removing all connected ports simultaneously at once.
Reconnect the ports one by one and if at any time the packet burst re-appears, follow this port to the connected switch in the other end.
Repeat step 1, until you find the looped port(s) and can't iterate further down in your manual tree.
Having resolved the loop situation in this switch, return to the switch above in the tree and resume step 2.  This recursion continues all the way back until the final cable has been re-connected in your root switch.

This is a completely exhaustive manual search for looped ports.
Typically there will just be one pair of ports that are looped, meaning the exhaustive and safe search with first removing all connected (link) ports and then reconnecting them one by one is unnecessary. If just one port pair down the 'tree' is looped, you can find it by simply disconnecting one port at a time.
Nevertheless, the general, "foul-proof", method, or algorithm, becomes what I described above.
Answer: Ouch. But ok, I can think of two ways I'd go at this...
Eyeball it: If the switches have port indicators, you should be able to eyeball which ports are the most active. Those are the ones to start looking at first. Hopefully the cables are labeled so you can search for the low hanging fruit of finding two busy ports, on two switches with the same cable.
SNMP monitoring: If you've got SNMP (or similar) usage stats, look for the busiest switch and the busiest ports. Then go looking at cables.
...if you have unlabeled cables, start tracing and labeling as part of your checking out the busiest ports.
Comment: An SNMP trap would be better than SNMP polling which typically is done only once every 300 seconds.  A flood and subsequent meltdown might happen so fast that nothing gets monitored by SNMP.  Still helpful though, the SNMP monitors that are not getting data back from switches that can't keep up might give a starting point.
Answer: To be honest, if you remotely connected (or via console cable) onto the device, you'd notice its very sluggish, there will be a delay from when you type to the letters coming up on the CLI.
If its a Cisco switch, 2 easy ones are to look at the interface statistics, it'll be on 100% (or 255/255) usage, constantly. In my years of dealing with switches, I've yet to see a port legitimatly hit 100% usage. Other than that, check the CPU usage (usually "show process cpu history"), looped interfaces will usually hit your CPU pretty hard unless you're running a high end switch.
STP should really be enabled though!
Answer: I am going to answer this question based on the understanding that there is a full outage for the layer 2 domain in question, and that you have no management access because the CPU's are all pegged.
The best way to troubleshoot a bridging loop is to start unplugging uplinks until it goes away. Say you have a standard switched access layer with all the access switches connecting into a pair of distribution switches. Go to the first access switch, and unplug the uplinks, if the LED's for the switchports stop going mental, it's not that switch, plug it back in and go to the next one. Repeat until you get to a switch where you have unplugged the uplinks and the LED's are continuing to blink rapidly, this is your switch with the loop.
Now start the unplugging process on the end user ports until the LED's calm down, when they do, the last on you unplugged was the problem port, trace the cable and chastise the user appropriately.
Answer: I had this issue occur on a network on the other end of the US and had to remotely help some level one analysts via the phone and my wan link to their site. The issue was complicated further by the fact that they had several brands of switches which they had slowly added to the network over the years. When they moved the office, they marked where each port went then re-attached everything the exact same way at the new office and started everything up. Needless to say that the handful of switches that did have working spanning tree didn't converge the same way and they had all kinds of loops and issues. By the time I was done fixing everything no less than three unmanaged switches were discovered to have been connected in loops with the rest of the infrastructure.
The way I was able to track down each of the unmanaged switches was by using a tool called nedi (on the switches which were able to be managed I enabled lldp/cdp). I first generated maps with nedi. Then in areas where the map showed connections from one switch to another then back around to the same switch again I had the network technician on site trace the line manually. I either manually shutdown the interfaces involved with the loop or had the onsite person unplug cables. In the end I was able to get the network working as it should, despite all the crazy off brand switches.
Answer: One thing that can be done here, is to see what machines are connected to the switch using the commands show cdp neighbor or show lldp neighbor.
If the BPDU guard command is not being used, and someone connects a rogue switch with lower priority (or older mac-address), the new device will negotiate as Spanning Tree root which will surely cause a problem.
Answer: In my experience it's always been the cable that I just plugged in, or no shut, or added to the port-channel.  Tougher is when someone else did it and doesn't immediately fess up.
Answer: Determining a loop really depends on the brand of switch that you have. For example, on an Extreme switch, I can run elrp-client on a VLAN and the switch will basically send out a broadcast frame on all ports for that VLAN and see if it returns by any of them, if so, it tells me which port(s) the frame was received back on, thereby revealing the loop candidates.
On a Cisco, you can enable storm control, which is a bit more of a blunt instrument since it will basically block the port for a period of time until the status clears (or you clear the errdisable state) - generally speaking however, this sort of thing is only relevant when you're using Cisco switches in a mixed topology of devices that do not do spanning tree nor forward BPDUs.
Answer: Without a doubt the fastest approach I have found is by monitoring the packet/sec rates of interfaces.  A quick show interfaces with appropriate CLI filter will list each interface and the packet/sec rate.  To find the source of the loop look for the only interface with a crazy high packet/sec INPUT rate.  Within a typical enterprise environment, with typical utilisation profiles, it works everytime without fail. On a 6500 with many interfaces it doesn't take very long to spot the source...
Answer: During loop, for a large number of broadcast traffic (eg ARP Request) at the end station may also increase the load on the CPU (for example if you are using cheap 100Mbit/s realtek card that calculate a checksum on CPU).
As physically possible to find a loop if the cable is disconnected, the link lost immediately on 2 ports.


How are the parts of GPT connected?

Question: Reading Stephen Wolfram's explanation of ChatGPT, it sounds as if first you train a very powerful "autocomplete" function that doesn't know anything specifically about chatbots, and then you create a corpus of chatbot-dialogs on top of that model to show it how to be a chatbot specifically. I'm curious if anyone can explain in a bit more detail how this process works technically, ie taking an already-trained model and "specializing" it with a second training corpus. How are the two neural networks related to one another?
Comment: It's just more training. There's no "end of training process" that stops you from doing any more training after that; you can just keep doing even more training. There's probably some kind of secret sauce in ChatGPT, but this isn't it
Comment: ChatGPT is a decoder-only transformer model. For a full on (hopefully not too technical explanation), please [read this extensive post](https://ai.stackexchange.com/questions/40179/how-does-the-decoder-only-transformer-architecture-work). It also goes into how the transformer is trained (in two stages).
Answer: ChatGPT derives also from InstructGPT that is subject to a reinforcement learning training with human feedback (called RLHF) in order to enble it for instruction following.
Basically, to get a chatGPT you take a GPT model, pre-train it to predict the next token in a sentence (so that it learns the structure of the language), and then RLHF is applied to enable it to follow instructions specified in a prompt. Otherwise it will give you just random (but plausible) complexions of sentences.
The power of chatGPT is the combination of a very large model (billions of parameters), a huge dataset, and a large collection of human annotated prompts and results for the instruction follwing thing.

How are the parts of GPT connected?


turn data off, on android Samsung note 4

Question: what should I do,not to use up my data limit on my Samsung note 4,
what steps I need to know to do that?
Answer: To turn off mobile data:

Pull down the notifications bar, Find the Mobile data icon in
Notification bar.
Toggle OFF Mobile Data icon so that it is no longer green.

To set a limit:

Settings → Data Usage → Set Mobile Data Limit
Also on the same Data Usage screen you may want to press the action overflow icon on the top right and choose Restrict Background Data


QGIS 1.8.0 Mac where is measure window or measure area symbol?

Question: Just trying to measure the area of a selected polygon (a few km2) but can't find out where the measure symbol is (mentioned in some posts here) or how to get the measure window shown in the manual. How?
Answer: The measure tool is in the Attributes Tool Bar. If it isn't visible you can bring it up using  View > Toolbars and check the Attributes Toolbar.
The measuring tool icon is a blue rule with a line above it.  It has a drop down menu to chose measurement type, Length, Area or Angle.
Hope this helps.
Comment: Found it, but I can't get it to measure an existing polygon, it only seems to measure the area of something drawn on the map live. Do I really have to retrace the 100+ points of a polygon I want to measure the area of when it's already created in a layer?
Comment: John. I've only ever used it to measure area by plotting round an existing polygon. It drags the measured area out as you have probably seen. I don't know if you can use it to just specify an existing polygon to work on and have it give you the area. I suspect there must be a way to do this but I'm afraid I don't know the method.
Comment: I've submitted it as a feature request, with a note that if QGIS already does it, to answer here. cross fingers!
Comment: I hope you get a result John.


TeXShop: disabling auto bracketing?

Question: Whenever I used an underscore it automatically adds those curly brackets to it. Now sometimes thats nice, but sometimes you really dont need this. Is there a way to disable that feature? I roamed through the options several times now but can't find the one regarding my problem.
Comment: Though `_{1}` and `_1` are equivalent, I believe it's best to stick to the braces. A well known counterexample is `_\in` which might surprise the beginner; writing `_{\in}` it won't break.
Comment: Actually, while some (like George Gratzer, in his book More Math into LaTeX) advocate the uniform use of braces to delimit materials in subscripts and superscripts, I find that it does decidedly *not enhance* the legibility of the LaTeX/TeX code that contains lots of expressions with sub- and superscripts. In fact, a thicket of `_{t}`, `^{n}` etc terms, rather than the simpler `_t` and `^n` terms, can make it harder to decipher the code. To improve legibility, it's far more important to leave adequate whitespace, to break up long lines judiciously, and to indent as appropriate.
Comment: Can't you simply use a backslash? `\_`
Answer: There are two ways you can control this behaviour in TeXShop: permanently or temporarily.
Temporarily
At the top of each source window there should be a check box called Key Bindings. (If it's not there, you can add it by choosing the Customize Toolbar item from the Window Menu and dragging it to the toolbar.)

If you unclick the checkbox, you can turn off all automatic substitutions temporarily.
Permanently
If you want to change just the behaviour of the underscore or caret, you can permanently change them by choosing the Key Bindings menu item from the Source menu. This will give you the Key Bindings editor and you can change any key binding you like:

TeXShop: disabling auto bracketing?


Small AC Transformer

Question: Came across these small Zwave controllers here .These are small enough to fit inside the electrical switch housing in the wall. Just wondering how is this device so small as the AC->DC transformer is usually pretty big. Are they using some special kind of smaller transformers that are there?
Answer: It's probably a switched-mode power supply which tend to need smaller transformers. If you pull apart a small AC adapter / wall wart you'll often find it contains a lot of empty space and the AC pins take up a substational amount of the total size.
Here's an example photo taken from Ken Shirriff's blog - although maybe it's a fraction smaller than it should be because it's a page describing an unsafe model:
Comment: thanks for the link. I need to incorporate a 220v AC to 5v DC with minimal footprint in my project. This is to power a microcontroller. Any ideas on how to get started?
Comment: Designing one that is safe from scratch is fairly complex and lots of things could go badly. If this is a one-off (or small qty) I'd probably just find a suitable adapter and pull it apart, still being careful about insulation etc. For a commercial product there are so many approval and safety implications you'd want a professional to do it, even for large companies it's one reason they often use wall warts instead of trying to embed the AC supply to save them having to worry about it.

Small AC Transformer


Generating samples from kernels other than Epanechnikov's

Question: Generating samples from kernel densities with Gaussian kernel is very simple, the same with uniform, or triangular kernels. There is also a smart algorithm for generating samples from Epanchenikov kernel, however is it possible to generate samples from other kernels (e.g. biweight, cosine, optcosine) in more efficient way than by using than accept-reject algorithm?
Answer: I suggest the inverse cdf method. For the biweight kernel,
$$
\begin{align}F(x)&=\int_{-1}^x \frac{15}{16}(1-u^2)^2\text{d}u\\ &= \int_{-1}^x \frac{15}{16}(1-2u^2+u^4)\text{d}u\\
&=\frac{15}{16}\left\{ x+1-2\frac{x^3+1}{3}+\frac{x^5+1}{5}\right\}\\\end{align}
$$
which can be inverted numerically, while, for the cosine kernel,
$$
\begin{align}F(x)&=\int_{-1}^x \frac{\pi}{4}\cos(\pi u/2)\text{d}u\\ &= \frac{1}{2}\{\sin(\pi x/2)+1\}\end{align}$$
which produces
$$F^{-1}(u)=2\arcsin(2u-1)/\pi$$
Note that the biweight cdf looks very similar to the logistic cdf
$$G(x)=\dfrac{1}{1+\exp\{-4x^2+3\text{sign}(x)x^2/2\}}$$which helps with the inversion:
Comment: +1 This is a general answer because most kernels are developed to have mathematically tractable expressions for their PDFs and CDFs.
Answer: My answer is maybe as much a question related to Xi'an's +1 answer.
I took up the idea of numerically inverting the biweight cdf, using this code:
<code>library(MASS)

inverse  <-  function (f, lower = -1, upper = 1) {
  function (y) uniroot((function (x) f(x) - y), lower = lower, upper = upper)[1]
}

biweight_inverse <- inverse(function (x) (abs(x)<=1)*15/16*(x+1-2*(x^3+1)/3+(x^5+1)/5))

reps <- 1e6
biweight_realizations <- matrix(NA,reps)
for (i in 1:reps){
  biweight_realizations[i] <- biweight_inverse(runif(1))$root
}
truehist(biweight_realizations)
</code>
Sure enough, it works:

I however suspect that OP wants to avoid rejection sampling for efficiency considerations. Now, my code is awfully slow in view of the need to perform numerical inversion.
So I wonder whether (a) the inverse cdf method is really a good idea when the quantile function needs to be found numerically or (b) my code is just bad. (I am sure the loop could be avoided, but I doubt this is what slows down the simulation.)
Comment: I believe you can use `rbeta` to speed this up considerably.  The parameters are $3$ and $3$.  Just double the result and subtract $1$.  Look at this: `hist(rbeta(1e6, 3, 3)*2 - 1, freq=FALSE)` (about $0.2$ seconds).


Using a copyrighted figure for an article posted to a non-commercial preprint server

Question: I need to use a figure from a published paper that is non open access, and copyrighted. What is the general advice for going about this? Do people tend to pay the fee for access to reproduce it? Or do you just not insert it into your preprint article? It would be difficult for me to not have it in my article, since it's the central framework I am using
Comment: "Do people tend to pay the fee for access to reproduce it?" Paying for legitimate access to an article is a separate issue entirely from having rights to reproduce figures from an article.  You'll have to ask the copyright holder about reproducing their figure regardless of whether you bought access personally, viewed/downloaded it through a library with access, saw it on the researcher's personal website, etc.
Comment: Are you *sure* you need the figure? Can you not just cite it?
Comment: @BryanKrause the figure represents the theoretical framework I am using, it would be difficult to have the paper without it, as the whole paper is based on using this particular framework.
Answer: If you're determined to include the figure from this paper in your article, you'll have to get permission from the copyright holder to reproduce it. Some journals allow free licensing through the copyright clearance center marketplace - you should check that first. If that doesn't pan out, large publishers typically have a licensing, reprints, and copyright department that you may be able to contact with your request.
If you can't secure a reprint license through those methods, you can always make your own figure based on the same data or concepts.
Answer: The copyright holder of the figure has exclusive rights to reproduce (reprint in exactly the same form) or adapt (reprint a version with elements added/removed) the figure. Paying the fee to access the article does not confer copyright. If you want to reproduce or adapt the figure, you need to get permission from the copyright holder, or else you can't legally do so.
What you can do is redraw the figure. Copyright covers the particular expression of an idea, but not the idea itself. You can take the original figure of a schematic or workflow or whatever it may be, and produce a new figure from scratch that represents the same information.


How do interactive CLIs work?

Question: How do command-line applications like Vim work? Specifically, how do they take control of the terminal in the manner they do? Also, for future reference, is there a specific term for applications that take control of the terminal the way Vim does?
Comment: I've seen "TUI" used for such [text-based user interfaces](https://en.wikipedia.org/wiki/Text-based_user_interface) (to distinguish it from a pixel-based GUI).
Comment: In my mind, you're asking about an interactive opposite-of-a-CLI!  A hallmark of a CLI is that you type a command line, and when you're happy with it, you hit RETURN.  But I think what you're asking about is programs that process each key immediately as you hit it.  They do that (under Unix/Linux, anyway) by putting the terminal driver into "raw" or "cbreak" mode.
Comment: A term I've seen used for such programs is `full-screen terminal applications`.  The word `terminal` tries to indicate it's a text display rather than GUI, and `full-screen` indicates the program moves the terminal's cursor around the screen rather than merely writing one line at a time (and depending on the terminal to scroll the accumulated lines).
Answer: vim and other semi-graphical (the capability to display semi-graphic characters such as corners, full crosses…) applications control the terminal (manage the position of the cursor, the position of displayable characters, color settings…) by sending dedicated escape sequences, control codes that the terminal will translate into some dedicated action it will execute.
Because it would be just a nightmare for any programmer to echo the escape sequences to the stdout, not to say implying non portable code since there have always been many different terminals with different capabilities and different escape sequences,
a library abstracting all that work was created : curses. Nowadays named ncurses which also provides higher level functions such as window management.
ncurses relies on the terminfo database for acquiring the appropriate terminal description of capabilities.
It is thanks to this library of functions that vim, iptraf-ng, alsa amixer, less, gdb, the primary kernel configuration utility and many other control the terminal.

Note that these apps are typically not called "command-line" utilities which generally handle a single line of input with basic cursor management and editing facilities thanks to the readline library.
Per contrast and as you can read in the ncurses man page linked hereabove, these programs can be called : Interactive, Screen Oriented. vim is typically named a screen-oriented editor per contrast to ed the line-oriented editor.

Note following suggestion in comments :
When started, the application will inherit the tty driver settings from the shell that launched it which are likely to be very similar to those initially set by the original agetty.
This including buffering of input until catching a newline charater, echoing of input keys at instant cursor's position… all sort of features whatever screen oriented application is not likely to want
When initializing, the program will save current tty driver settings and force those according to the programmer wishes.
Before quitting… the programmer is strongly invited to restore the initial settings… unless facing the risk of coming back to the calling shell in rather unpredictable but certainly messy conditions…
Comment: Or at the shell level, `stty raw`, `stty cooked`, and similar operations
Comment: Another piece of the puzzle is how the application turns off the tty driver's pre-processing (of keystroke input from the terminal) and post-processing (of display output to the terminal).  And, of course, remembers the original tty driver settings in order to restore them when the application quits.
Comment: @SottoVoce : Do you mean what def/reset_prog_mode() achieve behind the scene ?
Comment: @MC68020 I'm not familiar with the routine you mentioned.  I was thinking of the calls to do the equivalents of the `stty` commands as @roaima said, though I think for a C/C++ program like `vim` they're `ioctl()` calls to get and set the tty line disiplines.
Comment: If I am not mistaken, I think the name of the interactive terminal applications that the OP and others here are looking for is in the tags for the question:
`console application` - Am I right?
Answer: One character at a time goes into a buffer.
When the carriage return is entered, the buffer is examined ("parsed") one character at a time looking for tokens arranged in a given syntax.
Then, if possible, some command is executed accordingly. If the input can't be parsed, then an error message is given showing what the command interpreter couldn't figure out how to handle.
Rinse and repeat, until the command line interpreter is halted and/or the computer is shut down.
Basically, it's like any other computer program. Inputs, IF and ELSE statements, data manipulation (doing calculations and moving data around in memory), and outputs.

How do interactive CLIs work?


Nokia HTTP_REFERER issue

Question: We've developing mobile application using CodeIgniter PHP framework. App was tested on several hardware phones and emulators. Everything works fine everywhere - except Nokia S40 built-in browser.
When browsing via thatbrowser, it reveals that $_SERVER['HTTP_REFERER'] is not set at all - even using straight PHP with no frameworks.
Specifically, app was tested on Nokia 3500 Classic and 6300.
Also, when using Opera Mini on the same phones, all worked like a charm.
Server is Apache2 with PHP5, CodeIgniter 1.7, but I don't think it's a framework issue.
Strange thing is, it seems that only a few people in the world got, or mentioned, this issue, with no answer.
Well, the question is -  do we missing something? Does Nokia S40 built-in browser really strips out HTTP_REFERER, or is it server issue? What could be done to fix or mitigate it?
Answer: Referers are not required to be sent by any browser.  Do not build anything assuming you will be getting them from a browser; there are other things that can block their appearance (browser plugins, security software, etc.)
Answer: In order for HTTP_REFERER to exist, there needs to be a
HTTP_REFERER header.  This header does not exist if someone types in
the URL directly (ie: does not follow a link to the page).  It only
exists when someone clicks on a link from another page.  And, some
browsers don't send them.
Answer: Yes, HTTP_REFERER are optional http headers. Some carrier, or his transcoders (proxies), are deleting HTTP_REFERER header.

Nokia HTTP_REFERER issue


One word to describe the concept of two counteracting factors

Question: Suppose there are two important factors to a beneficial objective. Bigger values of both factors lead to higher achievement in the objective. However when one of the two factors increases, the other has to decrease. There is a point at which the optimality is achieved. What would be the best word to describe this kind of duality,  and accurately capture the abstract concept of achieving optimality through compromise?
Answer: trade-off

a situation in which you must choose between or balance two things that are opposite or cannot be had at the same time
Answer: Balance suggests an optimal state where one factor does not dominate the other. Balance is both a noun and a verb.
Equilibrium is another possibility, but can only be used as a noun.
Comment: Balance and equilibirum indicate that a stable status is maintanined, but they don't convey the concept that an optimal objective is achieved.
Answer: It sounds like a zero-sum game. As described in Wikipedia, that is

In game theory and economic theory, a zero-sum game is a mathematical representation of a situation in which a participant's gain (or loss) of utility is exactly balanced by the losses (or gains) of the utility of the other participant(s). If the total gains of the participants are added up and the total losses are subtracted, they will sum to zero. Thus cutting a cake, where taking a larger piece reduces the amount of cake available for others, is a zero-sum game if all participants value each unit of cake equally (see marginal utility).


Why may I accept and downvote the same answer?

Question: What is the reasoning behind me being able to downvote an answer but still accept it as correct?
Comment: This is necessary, if only for meta. Use it for staff responses that you dislike.
Comment: @Laurel that's worthy of a new answer.
Comment: see discussions here (not quite dupes, but similar ground): http://meta.stackexchange.com/questions/686/accepting-answer-without-upvoting http://meta.stackexchange.com/questions/40627/should-accepting-an-answer-automatically-up-vote-it http://meta.stackexchange.com/questions/21258/asking-upvote-for-accepted-answer
Comment: I can think of one situation where this could happen inadvertently: the OP didn't understand and downvoted an answer that was then explained in comments; it could be accepted at that point while getting the vote-too-old error when reversing the vote.  But even that sounds better handled by social convention ("Hey, could you edit this so I can change my vote?"), and it's likely the answer would've been edited in that process anyway.
Answer: This situation is 1) incredibly rare and 2) perfectly valid from a data integrity standpoint.  Adding a feature to prevent this is unnecessary feature creep.  This is the kind of complexity that you don't need in your system increasing your fault rates.
I'm sure there are plenty of other situations that "don't make sense" from a holistic, human point of view.  Just because some of them are easier to implement than others doesn't mean we should implement them.  The distinction between can easily implement and should implement is subtle but important.  Further discussion is material for SO proper, not meta. :)
Answer: Because it probably requires extra code to prevent you from doing it, and no one thinks to do it, so it's usually never a problem.
Comment: And if they did think to do it, they probably have a valid reason.
Comment: You haven't changed your meta name in awhile, isn't your 30 days up, and isn't changing your meta name still cool?
Comment: @Pollyanna - I changed my name to this before there was a 30-day limit. I'm at a loss as to where I can go from here, as my current name hits the length limit. Otherwise, I would change it to "I Was Changing my Name on Meta Before Changing Names on Meta was Cool."
Comment: @Cha - IWCMNOMBCNOMWC has a certain ring to it.
Comment: @Pol - That would fit, but I've decided to take on a different issue. Fortunately, my recent responses is still registering @Cha for a while.
Comment: @Length Limits on Names are Stu: I was going to say something witty about your name, but I hit the comment length limit.
Comment: @mmyers - I find it funny that you indirectly said something witty about my name in a comment well under the length limit, thereby invalidating your own witty remark.
Comment: @Len: Confuse 'em until they upvote you, that's my motto. (Unless it was Welbog's -- I forget.)
Answer: Because sometimes an answer is "right" but still "wrong".  Like, maybe it's nearly incomprehensible, but after staring at it for a while you finally tease out the hidden clue which leads you to the solution.  Accept for truth, downvote for style.
Comment: Or maybe the question was "How does I parse this HTML with regex?" and the answer provides a regex that works for that specific HTML requirement, but is an unreadable beast.
Answer:
what is the reasoning behind being able to downvote a post yet still accept it as correct answer to my question?

"I already knew about this solution and I hate it.  I was hoping for something better from the SO hivemind, but technically it is correct, and people who come on this question in the future may not have known about this correct (but horrible) answer, so it's best to implement it, mark it as accepted, and move on with my life."
It's also useful for those really hard bounty questions - you may have to accept an answer, even if it's not one you like or really agree completely with.


Any Appexchange app which can perform address validation on custom object address fields?

Question: Looking for appexchange solution which can do real-time or on-demand address validation on custom object address fields.  Already looked at address doctor, which validates the address on Leads, Accounts and Contacts only.  We have a custom Address object on which we would like this service to run.
Answer: There is a proven works product address validation and country complete.Have used in past ,works well.
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000002zt9uEAA
Comment: This works like a charm - on custom objects.Thanks!
Answer: I have used the Address Verification tool in DemandTools.  It works well.  DemandTools is listed in Appexchange, but be aware that it is a standalone application for Windows.  Account, contact, and lead are the only object types this tool lists for checking.
If nobody shares a way to validate an address in a custom object, you could consider copying your custom object data to contact records.  Use a new record type for these special contact records and keep them hidden from most users.  Keep the ID of the custom object record in these special contacts records so you can easily move the changes back to the custom object records.
Note: Address verification in DemandTools requires a purchase from StrikeIron of some number of address validations in addition to purchasing DemandTools.
I have no connection to DemandTools, CrmFusion, or StrikeIron.  I'm a satisfied customer.


Change standard behaviour of pasted text?

Question: Word 365 has a useful option, which allows you to change the standard behaviour of pasting text, meaning you can set the pasting mode to "Text Only" by default:

I have lots of notes on Google Keep, which I usually want to transfer to Scrivener. However, I always have to remove the text formatting manually, either by pasting it into regular notepad first, which gets tiring because you have to copy-paste everything twice everytime, or use the shortcut CTRL-SHIFT-V shortcut, which is too close to CTRL-SHIFT-C, meaning I'll accidently hit that shortcut at some point instead...
I want to know if Scrivener has a similair option, allowing me to have all text formatting automatically removed whenever I paste something into Scrivener.
Comment: Workaround: When you have to perform repetitive operations in a GUI, a keyboard automation application may be just the thing. You may want to take a look at AutoHotKey for Windows or Automator for Mac. These apps will allow you to do things as simple as replacing text similar to an autocorrect function or arbitrarily complex multi-step operations. They make it look like their actions are coming from the keyboard and mouse, so they will work with almost any application without the application even knowing they are there. Each macro is usually bound to a hotkey or trigger phrase. ...
Comment: ... Getting one macro to work with multiple applications can be a bit tricky, but is certainly doable. (I use AutoKey on Linux.) In your case, you could do something as simple as taking some unassigned key code such as Super+P and have it emit a Ctrl+Shift+V - with no chance of typing something else unfortunate. Or, you could just get both apps open with your mouse cursor on the note to transfer and then have a macro do the whole thing.
Comment: @Joe Thanks for that. I hoped I wouldn't have to use another software for this, especially when it comes to pasting text, but if this question remains unanswered for even longer, I guess this will have to do.
Comment: Adding another piece to the puzzle is never ideal, but once you start using one of these tools, you'll wonder how you ever got by without it. You could also look into remapping one or more keys on your keyboard to do what you want. I know a little about doing that in Linux, but not in Windows.
Answer: Try using a clipboard manager like flycut for mac osx (similar tools exist for other platforms). What these programs do, is save everything you copy to a list. You can configure what hotkey you want to use to paste from such a program, or in the case of flycut, simply select your text from it's list in the notification area when you are ready to paste into scrivener. The nice thing about doing it this way is you are always sure of what you are about to paste, and can paste something you copied in the past if the most recent "copy" wasn't what you want.
It's a little easier than setting up a macro, and will work for any program you want to paste into, not just scrivener.


Generate a sine wave with MCU

Question: I want to generate a sine wave without an offset voltage. I generated a sine wave from 0 to 3.3 V and it has a 1.65 V offset. I need a sine wave from -1.65 V to 1.65 V using an MCU. How can I do that?
Comment: DC-block it with a cap?
Comment: connect the CPU to +1.65 and -1.65 supplies
Comment: DC shift with an opamp?
Comment: Buy a function generator on Ebay for $20
Comment: Generate the complement on another GPIO pin and read the voltage between pins.
Answer:
I generated sine wave from 0 to 3.3V and its has a 1.65V offset value. I need a sine wave from -1.65V to 1.65V using MCU.

Use a coupling capacitor (a.k.a. DC blocking capacitor):

simulate this circuit – Schematic created using CircuitLab
RL represents the input impedance of the load. For technical explanation purposes I put 10k but can be anything depending on the application. CX is the coupling capacitor.
Note that this RC network forms a high-pass filter with a cut-off frequency of
$$
f_c=\frac{1}{2\pi \ R_L \ C_X}
$$
So, CX should be selected such that the frequency of the waveform that MCU generates stays in pass band. To guarantee this, I personally recommend you to select a cut-off frequency of less than half the minimum frequency of the sine that MCU generates. For example, if the minimum frequency will be 50 Hz then a cut-off frequency of 20 Hz should be enough. This makes CX = 800 nF but 1 uF can be used.
One thing worth to note here is the value of RL. I chose it low enough so that some other equipment (e.g. AC voltmeter or oscilloscope) can be connected. If you put higher values then the CX can be reduced accordingly but anything connected in parallel with RL will reduce the effective load resistance which results in distortion or amplitude reduction on the waveform. So anything between 1k to 10k should be alright.
Comment: Actually it's a pretty simple idea. A series capacitor block a dc voltage. Output of the capacitor is a pure sine wave. Thank you very much Mr. Rohat Kılıç.
Comment: @AliBuğraÇETİN never ignore what comes after DC blocking capacitor.

Generate a sine wave with MCU


How many Vaults are there in Fallout game universe?

Question: In the Fallout lore, I have gathered information that there are 112 vaults. But is that all of them or just the vaults that have been released as in-game content? Wouldn't there be other vaults in the other countries across the Atlantic?
So overall, how many Vaults are there?
Comment: If you consider the new Fallout Shelter mobile game canon, 1000 ;)
Answer: As far as I know, there are a total of 122 Vaults in the US in the Fallout Universe.

Commissioned by the U.S. government in 2054 as part of "Project: Safehouse", the Vault-Tec Corporation constructed 122 Vaults across the country

6 are available to explore in Fallout 3, listed here on the official Fallout 3 wiki in the Vaults section.
7 are available to explore in New Vegas, listed here on the official New Vegas wiki in the Vaults section.
And I can't comment for sure about Vaults outside the US. The Vaults were an American initiative, other countries probably did something similar but I don't think it's ever mentioned in-game.
Comment: Also [Vault 77](http://fallout.wikia.com/wiki/Vault_77), which was populated only by one man and a crate of puppets.
Answer: Vault Tech Corporation was only capable of constructing a maximum of 112 vaults. Unfortunately, due to the size of the population and the overall effects the Wars had- had on the  economy; Vault Tech was not able to afford to build more vaults. Although, that being said. There were a number of 'Private Vaults' constructed; but unfortunately  the contents and whereabouts of those vaults are relatively unknown.
Aside from a few control vaults, whose functionality mirrored the official promise. Most of the vaults were testing grounds for social experiments. The types of experiments could vary from Subliminal messaging, Controlled Genetic Mutation, Isolation and even Sexual Predatory Instinct (Speculation based on Vault 68 and 69).
Answer: There were about 122 vaults constructed as Vault-Tec wasn't interested in preserving the human race, rather doing ion them, with the exception with "control" vaults like Vault 101 and Vault 76.
Each state had at maximum two vaults, (with the exeption of vaults in the Capital Wasteland, Commonwealth, Mojave Wasteland, and New California).
If Vault-Tec wanted to preserve most of the human race, Vault-Tec would need to build at least 1,000,000 vaults.
Answer: Here is a list of all the American Vaults.
I don't think that there are 112 vaults, probably much less than that.
as you see in the American vaults list the numbers don't come after each other. That might be intentional or it might mean that the "missing" numbers are vaults made in Europe, Africa etc...
Comment: That's just a list of vaults that were already mentioned by number - doesn't suggest that there couldn't be more, not yet seen in game.
Answer: To correct many of the false answers, I believe only around 240 vaults were made, in approx. The vaults were not going to be used as protective shelters for the way, but to preform social experiments. Each vault has their own experiment with the exception of a few "control" vaults, actually designed to do as the people were told. The "cry wolf effect" happened when the bombs actually fell, and people used them as shelters. They did not build enough vaults for every American citizen, as they had not nearly enough money for it all. According to know game lure, Vault-tec, the creators of the vaults, was only in the US, and no vaults were build a anywhere else. I hope this covers it all, thank you!
Comment: Could you add references to where that information comes from please?


How to handle multiple job offers by a new grad?

Question: This is the situation of myself and many of my friends. Since I am an immigrant and I just passed out of college, the burden of getting a job offer as soon as possible is heavy. Finally I get one and then what happens is that they don't give enough time and I sign up the offer and send it. Later I get a very good offer from another company. Naturally because of the debts and job security from the new company, I am inclined to join that. But I get a guilt feeling of saying no to the old company which I got offer from. The old company is a start up with 4-6 people while the new company is well established and the salary too is higher than old company. How do I handle this situation as professionally as possible?
Comment: I took, "I just passed out of college" in a completely different way.
Comment: Do you feel you can ask for more time?
Comment: I don't think. I signed up and sent it. It's not a contract. The only thing I worry is ethics.
Answer: Every contract has its escape clauses including your employment contract. If all you did was say "yes" to the startup and you haven't started work with them yet, then notify them that you can't start work with them because of personal reasons. If you just started with them, give them the two-week notice and hopefully they do you the favor of getting themselves rid of you the same day. It's not an ideal situation for the startup but they'll recover quickly. Especially if they had the good sense not to send a rejection email to the next best candidate on their list.
A close friend of mine asked me for advice 30 years ago. We were both PhD grad students. He was on an HB1 visa and after sending 600 resumes, he got an offer from an outfit where the pay was anything but hot and he was told that he would have to sort out the immigration paperwork by himself, without any support from the company. He said "yes" to the other. Then comes along IBM with a much better offer - he is a very talented and smart individual - and IBM would handle all immigration issues for him.
He asked me for advice on what to do. I told him to tell the outfit with the cheesy offer and that was trying to get him on the cheap that IBM was making him a much better offer and that he was turning the outfit down. Cold and fast. Which he did. The outfit ranted and whined "What did we ever do to you?" I got a scolding from another PhD grad student whose attitude was that once you accept an offer, you follow through on that offer even if it's a lousy offer. But my eyes were pretty cold back then, and they still are.
At the end of the day, you have to take care of yourself and it's not a good idea to take a job that you know is lousy before you even started working. As Lord Buddha says, happiness and unhappiness are temporary - The outfit will get over it and so will you, should you choose to go with the better offer.
Comment: This is a pretty good answer. My only additional comment would be that if you(thefragmenter) have accepted any bonuses(signing, relocation, etc) or assistant from the first company read your contract very carefully to understand what your liabilities are. Many companies have in place that any bonuses you receive for signing require 1 year of employment at the company, you may be required to return any such money/perks.
Comment: Be aware that while I still think this is the best course of action, that going back on your acceptance may burn bridges with the company.  Chances are you won't care though, if their standard offer isn't really up to what you could be getting.  While it might be considered rude to go back on a promise, that's a small downside compared to the huge advantage of getting a much better job.
Comment: @Kai - I agree with you to a point. It's a little disingenuous to put a very short time-frame on recent graduates. They're desperate for a job, so I think they need a little longer time to make a decision. A lot of industries set a single offer date for internships, so students get all of their offers on the same day without fear of a better offer.
Comment: @Nahkki There are no signing bonuses, no relocation and no year end bonuses. My only worry is about the ethics. But I am in a situation to see what's in best interest for me. They sure can find talent and it wont be a financial loss on their part, but to me since its the start of my career I need to look in to those.


How do I restore itunes library onto another computer

Question: I followed all the steps as suggested for backing up and restore iTunes library in the apple support website: http://support.apple.com/kb/HT1751 but I have problems with the 'choose library' part in the last step. I clicked it and located my iTunes Media folder but all that happened was that it just opened the folder and showed me what I have inside and not restore it.
Comment: Which specific support document are you referring to? You have to select the folder from inside iTunes of course.
Comment: Hey Lily, have a look at my answer below. When you open the itunes media folder, you then need to **select the `iTunes Library.itl` file**. This file will then restore your library
Answer: I'm just echoing the Apple KB article for anyone else who comes across this answer. I have used this process many times when moving or reformatting my computer:

Process for restoring an iTunes library:

Quit iTunes.
Copy your iTunes folder from your external hard drive to whatever location you desire on your internal hard drive.
Open iTunes while holding down the Option key (Mac) or Shift key (Windows).
In the resulting dialog, click the Choose Library button.

Navigate to the new iTunes folder you just copied and locate the iTunes Library.itl file
Click Choose (Mac OS X) or Open (Windows)
iTunes will open and your iTunes Library will be restored.
Comment: Thank you very much, that just made my life a lot simpler!
Answer: You have to select the iTunes folder you just moved to the internal hard drive, not the iTunes folder currently on your computer.
If you were backing up to a disc, you have to follow these instructions.


Allowed latest update. System froze. Reboot to contiuous login loop and what do you mean?

Question: Yesterday it said there was an update available, and would I like to install it. Since previously I had issues and an update corrected them, I figured this would help fix the quirky idiosyncrasies and freezes we were experiencing. Wrong. It froze the installation at a prompt to allow Windows fonts. I couldn't select "OK", and I couldn't cancel the install. Everything else was still working, but I couldn't get rid of that update window. I finally decide to power down, but it would not. You could select it from the menu, then you could select power down from the log-out option, but in no instance would it power down. It only kept repeating the cycle. I finally select log-out, which only brought me to the log-in screen, which would not allow me to log in. I powered it down by holding the power button  and re-booted. I am now in perpetual log-in loop. I cannot even log in as guest.
I searched "Ubuntu continuous log-in loop" on my XP desktop and began reading results. This is when I find that every remedy is geared to those familiar with Ubuntu. Each one requires typing a line of code in SOMEWHERE. What good is telling someone to type a line of code without telling them how to get where you are supposed to type it in?
"In the grub menu". GRUB menu? What the heck is a grub menu? If I find a grub I feed it to my chickens!
"Look at your dmxp" (Or some such thing. I can't remember now) What the heck is that? Where do I find it? When I do, what the heck am I looking for?
"Look at the logs and xsession errors"  ????????!!!!
There are several more such recommendations, all of which have absolutely no meaning to someone who just came on the scene. I was, however, able to glean a few things along the path. First, if you hold the shift key while booting, it will come to GNU GRUB (2.02~beta 2-9ubuntu1.4) I now have 4 options, NONE of which were ever discussed in any of the remedies. I found that if I go to "Advanced Options" I can go into recovery mode. (Which was mentioned in one remedy, but never how to get there!) OK, Recovery mode does not work, so the rest of that remedy is moot. Recovery does not work, period.
PLUS, nobody ever mentioned anywhere at any time about selecting e' to edit the commands before booting or c for a command line". Which one do I need, and what do I do when I get there?
THEN  I find ctrlaltf1 somewhere in the quagmire of fixes. AH! This must be where they say to type in the selected codes! What the heck is sudo? Why does it tell me that the line I tired has to be entered manually?
I have now spent more time trying to repair and get this laptop working than I have in actual use. Does it get better from here? All I want to do is get out of continuous log-in loop and have a stable, operating machine.
Do you think that I need to be lead by the hand down the file path of repair? Let me tell you most assuredly, YES!!!!
PLEASE when you give an answer on these forums, give each step, and possibly some explanation of what is happening in said step. I want to understand just what it is I am doing, or about to do.
Do NOT tell me that I need to do a complete install and lose all of the email my wife has saved. If you do, then YOU come HERE and tell her yourself! SURELY there has to be a remedy somewhere to at least get back in, get the emails backed up or off, and then re-install.
Comment: Ok! Calm down first and then please edit your answer by sharing a picture or video of the login loop. Also, by login loop did you mean, it gets to the screen where you enter your password and it restarts or is your password not accepted?
Comment: @Raphael you look confused after reading his question ;) He has not posted any "answer" yet.
Answer: ha, ha. Question of the day.
I'll give you a possible tip on how to get the emails.
If the /home directory is not encrypted, boot up a live session. This means starting the operating system from a DVD or USB. There you will see the disk with the installed instance of Ubuntu. Enter the /home directory and then the directory of your wife. There you will have to tell the file browser to show you hidden files. In the image below it's at the bottom of the menu with the down arrow.

Depending on what e-mail client your wifes' using, the mails will be at:

default - .local/share/evolution/mail (This means you need to enter the directory ".local", then "share", and so on).
thunderbird - .thunderbird - and then it may be in different places and you may need to look for it, but by dafault it will be in a directory with a name ending in ".default", then "Mail", possibly also "ImapMail" if she uses the IMAP protocol.
some other client - .someOtherClient - and then an appropriate subdirectory path

From her home directory you she may also want some other things like photos, music, documents, etc. Good news is that if the system was not configured by a creative IT genius, everything should be in her home subdirectory. I strongly advise you backup the whole home directory, ie. the one which has the name of your wife.
Now, if the /home directory is encrypted, you should be able to enter it from a live session (same as with me first tip for non-encrypted one) after entering the encryption password, which most likely is the root password of the Ubuntu instance, if the /home directory was created at the same time. If you have problems with that, you'll surely come back with feedback.
That's all the tips I can give you. I hope they help. But first of all, I hope you manage to fix your Ubuntu.


Are Ramshorn Snails edible?

Question: I find websites telling me that many but not all sea snails are edible. I'm wondering if the Ramshorn variety is edible?
Answer: My understanding is that "edible" snails are those with substantial enough muscles in their foot to make them worth eating as a delicacy.  There are a few sea snails that are poisonous, such as Cone Snails, but I do not think any land snails are.  Therefore all land snails are technically edible.
The primary risk when preparing and eating land snails is parasites, particularly nematodes. These will be killed by cooking so make sure the whole snail is well heated through.  The gut contents may include poisonous plants, but you do not want to eat that anyway.
Comment: How do you go from "There are a few sea snails that are poisonous" to "The primary risk is parasites"? The ramshorn snail is, after all, not a land snail.
Comment: @npst I meant of land snails.  I shall edit, thanks.
Comment: Ramshorn snails are neither land nor sea snails, though; they're freshwater snails. Do freshwater snails have a similarly low rate of being poisonous?

Are Ramshorn Snails edible?


Updated to PHP version 8.1.22 and one of my Craft 3 sites is getting a critical error

Question: I upgraded my server to PHP 8.1.22 in order to start a new Craft 4 site, and one (but not all) of my existing Craft 3 (3.6.17) sites is giving me the following error. How do I resolve this error? See error screenshot below:
Answer: Craft version 3.6.17 was released in June 2021, while PHP 8.1 had its first stable release in November 2021. The latest PHP version Craft could support at that point was 8.0, so you're running this version of Craft on an unsupported PHP version. That's why your getting errors.
To fix this issue and prepare for the Craft 4 update, first update to the last stable 3.x version, as mentioned in the update guide. This one will support newer PHP versions.
If you can't use the Craft binary (php craft update all) because it's giving you errors as well, you can use Composer to update the library instead. Then run php craft up to execute any required migrations. However, the better approach is to do the update first, and then bump your PHP version.
Comment: @JustinKendall The specific error is coming from ImageMagick, maybe the other sites are using GD? Anyway, updating the Craft version is recommended in either case, there could be other errors that you are not seeing due to the version mismatch. And it's required before you update to Craft 4 anyway.
Comment: Thanks for the answer, I will give it a shot. The weird thing is though I have two other sites that are both running 3.6.17 and still work fine after updating the PHP.


How much work experience should be included in Statement of Purpose for Master program?

Question: I'm wondering how I should put my internship experiences in my Statement of Purpose for Master program. The internship experiences (mainly building java web applications) are not quite related to my research interests like distributed systems, real-time computing, etc.
Answer: Well It really doesn't matter much whether your research subjects are related to what you have done internships in!
To make it more clear. Internships depicts that you are inclined and willing to work along with your regular curriculum. I would suggest you to relate your  internship with research subjects. As we all know that all subjects in Computer Science are inter- related so try to find out any open source concept that you can relate to or willing to work for it. This much is enough. No doubt Research is most important aspect for admissions but you should know to combine it with your life. Give small Instances (backed with Proofs) where you can prove your point. Speaking about Number of years to show for experience is all depends on your profile, show max possible and make sure that you have salary slips.
Answer: Any relevant experience is valid subject matter for an application for a program of study.
In your case, your internship experiences are well within the same field of endeavour and I would include them, if space allows.
A researcher who has a particular interest in developing a java web application to interface with a real-time computing solution, might therefore be very interested in your particular skill set.
Answer: While I think that any relevant work experience should definitely be included in your resume or cv, I am not sure if its place is in the statement of purpose.
If your internship in some way inspired you to get your master's degree or to pursue a certain area of interest, then I would include it; however, mentioning it for the sake of mentioning it doesn't make sense to me.


Why would spending money on a tile lower my score?

Question: I was playing Civilization 5 as the Arabian empire, and one of my warriors found some Ruins and earned me about 70 coins. My score was 14 at the time, and didn't go up due to the increased amount of money. I spent them on a tile nearby my city, and my score went from 14 to 13. Could someone please explain? How does money effect score, and number of tiles not?
Comment: Related: [How is score calculated in Civilization 5?](http://gaming.stackexchange.com/questions/9104/how-is-the-score-calculated-in-civilization-5) Based on what they found in that question, I don't actually see how this is possible, and should actually have been the reverse. I wonder if there's something else going on.
Comment: I agree, there must be another factor effecting my score that I did not notice. I'm playing on a large map as well, so I don't believe tiles effect your score at all, either.
Comment: Yah, this sounds like a bug, you should've gone from 14 to 15.
Answer: I have tried replicating this, with exact same conditions (map size, civ ect) but unless you play with some 3rd party mods, I will have to call this one a bug.
There was one version where the point system calculation was completely off. Can't remember which one.
Alternatively, someone might have messed with your GlobalDefines.xml, or if you were playing multiplayer, the game maker might have been messing with his GlobalDefines.xml. (You could do this in the early games and have messed up cheating / point calculation.)
But unless you get beaten militantly, it's rather hard to drop in score.


How to use arduino uno to as timer

Question: I am trying to use an Arduino Uno as a timer so that when current passes through an input pin it will only continue out of the output pin for a certain amount of time and then the current will stop flowing. Does anyone know how to achieve this and the code necessary? Any help is appreciated.
Comment: Also check that you have yhe basics right. Arduino inputs work with voltage levels, not currents. A current flowing into Arduino pin means there is something wrong in the circuit.
Comment: Take a relay breakout board, connect it to the Arduino and program a simple delay timer (for example with the `delay()` command but there are also more advanced/flexible ways of building a timer). If you've succeeded in making that work, you can make it fancier. This is, apart from blinking an LED, one of the easiest things to build with an Arduino and there are literally zillions of sites that describe how to do this.
Answer: The most simple way would be to check if there is voltage at an input pin. If yes, the Arduino waits xyz seconds and then checks again. If there is again a voltage at the input pin, you can assume that there was a voltage at the pin for at least xyz seconds. After that you could turn on a digital pin and use it to switch something (if your load is over 40mA you should use a transistor or a relay to not damage your Arduino board. There a dozens of tutorials out there...). Since we all were beginners once, I will add a basic code snippet for you:
if (digitalRead(pin) == HIGH) { //check if there is a voltage at the pin
    delay(amountOfTime); // wait xyz seconds

    if (digitalRead(pin) == HIGH) { //check again
      //put your code here...
    }
}

The problem with this code is that you can't be sure if there is an interruption of the current flow during the delay(amountOfTime) part because if you use amountOfTime = 2000 for example, there could be a voltage interruption during those 2 seconds.
So a more advances way of programming it would be to create a while loop and wait as long as there is a voltage at the input pin. If there is no voltage anymore, you can check how long it took the Arduino to run the loop (and so how long the input was HIGH). After that you can simple compare the time that it took to run the loop with a threshold.
I prepared a piece of code for this scenario as well:
int starttime = millis(); //maybe change "int" to "long" because you can store larger numbers in a long
while (digitalRead(pin) == HIGH) {
    //just wait and do nothing
}
int buttonPressedTime = millis() - starttime; //again, you may change "int" to "long"
//check how long the button was pressed:
if (buttonPressedTime > xyz) {
    //the button was pressed for over xyz seconds
}

(if you don't know what the millis()-funktion is you can simply google it or browse the forum)

****EDIT****

I think I got your question a bit wrong, but I won't delete my old answer because it might be heplful for others
If you just want to check if there is a voltage at an input pin and if yes just wait xyz amount of time and afterwards switch another pin of the Arduino to HIGH, you can use the delay-function.
Code:

if (digitalRead(inputPin) == HIGH) { delay(amountOfTimeInMilliseconds); digitalWrite(outputPin, HIGH); }
(sorry, but the code tags aren't working as they're supposed to)

How to use arduino uno to as timer


What does っす at the end of a sentence mean?

Question: I saw a sentence like:

「それ使{つか}ってるっす。」

and none of my dictionaries have an entry for just "っす". Is it a verb form, gobi, or something else?
Answer: It's a contraction of です. It's not quite as polite as that though - it's always sounded a bit like "thinking that one needs to be polite but not bothering to do it properly" to me. I guess it comes somewhere between teineigo-level polite and casual in the politeness spectrum.
Answer: It is a contraction of です, but you will also hear (mostly younger guys) putting it (without the っ) on greetings. こんにちはす!こんばんはす!Here's a real example (written like it's spoken).
っす Is not normal polite Japanese. Think of it as almost using a です when the situation is uncertain; for example, a group of young guys who've met fairly recently. です・ます are rather stilted, but they don't know each other well enough to use complete casual style. The contraction っす is a nice halfway point.
In the context that you saw it, it could be expanded to これを使っているのです. Then then の turns into ん and then disappears. The "のです" construction is used a lot more often than regular old ます. Technically the first one is considered an explanation of something, but it is also less stiff than the latter.
Comment: っす is quite masculine speech. It's mostly a polite dialect from what my wife told me. It could be contraction of both です and ーます
Comment: Is this [っす] etymology real? A halfway point between formal and informal? I'm curious, bcuz if so, that is quite interesting. Since when [っす] emerge in spoken Japanese?
Comment: Is it used in questions? There was a scene in an anime, where a girl is talking to a boy who heavily uses っす and probably other derivatives (っすよう from what I gather). At some point the girl mistakenly switches to this half-polite level, saying: そうっす. But then corrects herself: そうですか. Are these interchangeable? Or she didn't finish the first phrase? Like, そうっすか?
Comment: Why don't I just show you?
https://vimeo.com/315016429 (ichiemon ssu)
https://vimeo.com/315016438 (niemon ssu)
https://vimeo.com/315016418 (mon ssu, director's cut)
don't forget to turn on the subtitles and read the description
Answer: It's lazy polite form.  Dropped for ease of use and to add a level of casual feel.  Used nationwide.
When I worked in bars and a few host clubs this style commonly used in place of normal 敬語 as it is too stiff for young women, who are the majority of our customers.  However, we always reverted back to normal 敬語 when an older male, female(ママさん) or couple was the customer.
I suppose you can also think of this as a slightly flirtatious polite form.
Answer: It is a contraction of です--though as you'll note in your example sentence, it is often used in places where です would not be grammatically correct.  It indicates politeness, but shows the (often young) speaker's ignorance of the proper polite forms. :)
Comment: "It indicates politeness, but shows the (often young) speaker's ignorance of the proper polite forms." Is this an opinion or a fact? I am curious
Comment: Opinion, and a tongue-in-cheek one at that.  It indicates politeness and it's not a grammatically-correct polite form, but that doesn't necessarily mean that someone who uses it is ignorant. :)
Answer: As others have noted, it's a corrupted form of ーです. It's usually found in social situations where both humility and some roughness are apropos, like in yakuza movies, when a lower-level thug is talking to the boss. Another example is when addressing sempai in after-school clubs, particularly athletics. おはようございます -> おはようーっす!, お疲れさまです -> おつかれっす, etc.
Answer: Similar to English, you can abbreviate common words with slang. I've heard おはよう become おっす, and similar. There isn't even a す in おはよう.
Comment: I thought it was a contraction of おはようございます but actually it seems that it can be written 押忍 so it might be a different ending?
Comment: おっす / 押忍 is not a variation on おはようございます; it's a completely different greeting. It's like a macho "hi", often specific to martial arts clubs and other bastions of testosterone. The ーっす version of おはようございます is おはようっす.
Comment: That's true, but it's also worth noting that the etymology of おっす is almost certainly from a contraction of おはようございます (gogen ascribes it to pre-war martial art schools in Kyoto). One shouldn't confuse etymology with current usage, of course.


Embedded padding/margin in fonts

Question: It seems that all fonts have some sort of embedded padding or margin. By setting:
margin: 0px;
padding: 0px;

You never get what you want. Does anybody know why this is?
Comment: You mean like the space between the letters?
Comment: If you're talking about  tag, in that case, it is not advised to use it because it is deprecated in HTML. I'd ask you to elaborate your code
Comment: Example to what you are referring to would be able to help better so we can see what it is you are talking about an see how it is coded.
Comment: No, I never use  thats pretty deprecated hehe. What I am talking about is it always seem to be a built in padding on the top and bottom of fonts.
Comment: Aside from the line-heights and letter-spacing stuff. Please note that the actual font-size (even if you define it in CSS) differs between browsers.
Answer: It sounds like the issue you are having is not with the CSS but the font itself. Most fonts define a baseline, x-height and line-height out-of-the-box. Your specific issue is likely with the font's leading, the space between lines. Sometimes these values can be wildly inconsistent. If you are really trying to get a specific font to line up correctly, I would recommend taking a look at FontLab and editing the glyphs/baseline/line-height for the specific font you are working with.
You can also look at a web-safe version of the font. These types of fonts usually have been specifically spaced to render best on the web. This isn't always the case, but it might get you the results you are looking for. Check out Google's library of web fonts here.
Update
This answer has received enough attention that I decided to add the first comment below to the answer and expound on it.
Browser Reset: Every browser will set default states for many of the reserved HTML tags like a and strong. There are other things defined by default including fonts, line-heights, weights and sizes. This could have an affect on the rendering of a font. Generally this is localized to specific browsers. So, by using a CSS reset, you can eliminate default rendering issues in browsers. Eric Meyers Reset is a good reset, but there are definitely others. Try using different ones to see which works best for you.
However, CSS resets work by targeting all browsers and setting them to all be the same. Some people prefer to use something that, instead, targets only the issues with each browser. That is were Normalize will be better.
There are also issues that a CSS reset will not fix. Such as font aliasing (making the fonts seem smooth rather than jagged). Since some browsers and operating systems do not add anti-aliasing to fonts, you will also see glyph width differences. This, unfortunately, is unavoidable in most cases. Some people go the route of using a flash font replacement tool like Cufon or Sifr. This too has it's own list of issues (such as the FOUC).
Another Update
One other issue that is still out there is the problem with kerning, or the space between glyphs. There is a CSS property letter-spacing that will allow you to do a global kern on a block of text, but it lacks the ability to target individual glyphs like Photoshop or InDesign. The kerning is also based on whole-pixels, so you are limited by what you can achieve. It also has issues with IE and is not as reliable as one would hope. There is a javascript called kerningjs that is pretty decent but it, too, is whole-pixel based and therefore not as accurate as rasterized text.
On the whole, fonts on the web have gotten better over the past few years. Sadly, we are still dealing with issues from the past, when fonts were only intended to be printed or rasterized. There is hope on the horizon for us font enthusiasts, though. As @allcaps said, the CSS3 specification for linebox is out there, so it's only a matter of time until it is widely accepted!
Comment: Second that. To be certain that this is an issue with a specific font, and not a browser interpretation, be sure to always use a CSS reset in your code, like Eric Meyers Reset (http://meyerweb.com/eric/tools/css/reset/). Alternatively, look into Normalize.css (http://necolas.github.io/normalize.css/).
Comment: you should have left your answer as it was: kerning is completely off-topic based on what the user asked.
Comment: @Francesco Kerning is absolutely on-topic. The original question was vague so the answer is to address other people that may have this issue and help resolve their problems. As an accepted answer this question was no longer useful for the OP. So the update was to address the others that find this response useful. We shouldn't discourage overcommunication in answers since the site is also used as a resource for people.
Answer: The reasons of this pecularity of the computer fonts are mostly historical. In the past, fonts were the sets of small metal blocks with one character on each, and the height of these blocks had to be enough to contain all the elements of any character, including descendants, ascendants and diacritical marks. The typographic tradition has defined the font size as the height of such metal blocks. That's why almost all actual characters are usually much smaller visually than the font size set for the text and there is some white space above and below them.
Here is a good article explaining the historical roots of the main typographic measurements: http://www.dev-archive.net/articles/typograph1-en.html#Ch22
Answer: x ov gjqpy bdfhklt CAPS ÂÊÁËÈ
A glyph is designed on a two dimensional canvas. For the latin writing system the height of this canvas is consistent and width may vary. Glyphs are placed on a baseline. x is on the baseline and the top of x defines x-height. Round and pointy shapes appear smaller so are optically corrected. Descenders extend below the baseline. Ascenders, capitals go above x-height. Browsers align text with different fonts (in the same paragraph) by baseline.
So why is the build in margin? Glyphs need whitespace around to be aligned to each other.
What can we do to influence these margins?

Choose your fonts wisely.
Specify line-height p { line-height:0.5EM;}.
Baseline shift .shift { top:-.5em; position:relative; }
And wait for CSS3 module: line.

General advice: do not adjust a font yourself unless you are absolutely sure what you are doing. One of the many things you'll encounter is hinting. Windows needs hinted fonts and hinting is hard to get right. Also the way fonts are loaded (@font-face) will load a local copy if it exists. You can disable local fonts by a hack. Your mileage may vary.
Answer: you can use line-height and letter-spacing padding/margin in fonts...
otherwise use custom css for each heading........
/*use line-height*/
.font{
line-height: 1px;
letter-spacing: 1px;
}

or use custom css......
  h1{margin:1px 0;}
    h2{margin:1px 0;}
    h3{margin:1px 0;}
    h4{margin:1px 0;}

using these css before use reset css .......
Answer: If you want use space between lines in a paragraph, you can use:
line-height: 3px; /*3px is an example*/

Or, if you use space between letters, you can use:
letter-spacing: -2px;

Comment: Thanks Vin, but thats not what I have a problem with. To get a paragraph to be pixel perfect at the same hight as for instance a floating div I have to set a negative margin on the paragraph.
Answer: The "padding" at the top and bottom of fonts is essentially reserved space for diacritics (https://en.wikipedia.org/wiki/Diacritic). Some scripts stack multiple diacritics on some letters, including capitals (for example, Vietnamese https://en.wikipedia.org/wiki/Vietnamese_alphabet) so a font designer that forgets to reserve some place for them won't be able to extend his font later. Also, horizontal scripts require some separation (leading) between lines to be readable.
Only very specific glyphs like box drawing elements extend to the limits of a glyph box
http://www.unicode.org/charts/PDF/U2500.pdf
That's also why the "padding" is built-in each glyph. If it was an external property it would not be possible to differentiate between glyphs intended to be jointive and glyphs that need some separation (in other words the amount of padding is a glyph property no a whole-font property).
The following example requires a good font with decent Unicode coverage (http://dejavu-fonts.org/ works)
Jointive box drawing elements
↓
┃ÇŖŞ
┃ẤỄǛȰ┃U  ← You really need to include the "padding" to align with box drawings
  ↑
 Latin capitals with multiple diacritics (really crowded)
Lastly fonts stem from very old technology (movable type), and the conventions used to describe them still refer to fifteenth century habits, which makes them quite un-obvious to laymen.
(See also http://www.webfonts.info/node/330 for info on complications added by computer font formats)
fonts opentype text-rendering
Answer: Its not a problem with the font as such. Yes, as @matthew said, the font design itself has some character built in. For example, check out difference between say "Segoe" family and "Verdana" family. You will keep on resetting your css if you need to use both. One style just won't work.
The larger part of the problem lies in the way different browsers render even on the same OS. Heck, even different versions of IE render differently. ClearType, Anti-aliasing, font smoothing, software rendering instead of GPU rendering, rendering engine itself, etc. etc. all play their role to make sure you don't end up with pixel-perfect design across all browsers across all OSs.
ClearType tries to align with pixel-grid causing another set of problems with subtle differences in height.
This link is very old, but still very relevant: http://www.joelonsoftware.com/items/2007/06/12.html
See Also: http://www.codinghorror.com/blog/2007/06/whats-wrong-with-apples-font-rendering.html
See Also: https://webmasters.stackexchange.com/questions/9972/how-can-i-make-fonts-render-the-same-way-across-different-web-browsers
See Also: CSS font differences between browsers
Your best bet would be to keep tinkering with css until you get close enough.
Comment: Thanks @Matthew for the unexpected bounty. :) It took me by surprise! Thanks again.
Answer: The native margins for text elements are as follows (at least in Firefox and Chrome):
Working Example
 p{margin:16px 0;}
h1{margin:21px 0;}
h2{margin:19px 0;}
h3{margin:18px 0;}
h4{margin:21px 0;}
h5{margin:22px 0;}
h5{margin:24px 0;}

To remove them you'll have to re-set the margin like so:
p, h1, h2, h3, h4, h5, h6{margin:0;}

Answer: I think is kerning what you intend to describe
take a look to this library
http://kerningjs.com/

CSS, meet kerning. Kerning, meet CSS. Kern, style, transform, and
  scale your web type with real CSS rules, automatically.
Print designers have had it easy for way too long. This is 2012; the
  web has been around for over two decades, yet web designers don't get
  full control over their typography? Forget that, use Kerning.js!

it's free
Answer: The fonts itself has problems it seems. CSS can be used as shown above to solve the problem but still it should be said that it is better in your scenario to fix up the font files itself.
Check out this page as it will give you better insight on how to edit a font:
http://mashable.com/2011/11/17/free-font-creation-tools/
Comment: Will this work in a web environment? Even if you load a font with @font-face, won't a local copy take precedence?
Answer: After looking at the html source of a html document found out that after the normal margin/padding added by all the browsers, chrome by default adds its own webkit's margin/padding properties.
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;

Solution is instead of normal
*{
margin:0;
padding:0;
}

Append the style with
*{
margin:0;
padding:0;
-webkit-margin-before:0;
-webkit-margin-after:0;
}

As -webkit-margin-start and -webkit-margin-end are already set to 0px, there is no use of setting them in here.
Tell me if that works! :)
Answer: Here is my Opinion

The margin is the distance from each side to the neighboring element and the margin property can be set for the top, left, right and bottom of an element
padding is the distance between the border of an HTML element and the content within it.

But in your case you dont really need these both you , as you are interested in font spacing , there is one css property called letter-spacing

The letter-spacing property increases or decreases the space between characters in a text

Try
 h2 {letter-spacing:-3px}

The letter-spacing property is supported in all major browsers.
Note: The value "inherit" is not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 supports "inherit".
Answer: I have run into this pain a couple of times when using some webfonts for icons and gained better control by placing them in an absolute positioned container.
HTML

&#10004

CSS
 .relative { position:relative; }
 .webfont {  position: absolute;

             top: -5px;
             left: -5px; /* easier control with these values */
           }

This felt like a better way to control things cross browser, rather than say, using positive/negative margins and paddings.
Giving the text block a container and class we have much more cleaner ability to tweak it's position cross browser. ( IMO ).
Might be something there.
Cheers,
Rob
Answer: I often run into the same issue, especially when trying to get text to top-align with something beside it that isn't text, such as an image.
Here's a technique I've had some success with. Select a portion of the text so that a colored background appears behind it. The top of the selection highlight will reveal what the font considers the "top" and "bottom" of the letter. Take screenshots of the font at various sizes and across multiple browsers. Zoom in on the screen capture in Photoshop and count the number of pixels from what you believe "should" be the top and the actual top. Calculate the percentage that number of pixels represents within the entire selection height.
Then set a negative top margin on the text in ems that is equal to the percentage of the "overflow." So if the text should be 10px tall and it's actually 12px tall, then give it a negative top margin of -0.2em.
Then wherever you assign the font-family that's causing the problem, also include this negative top margin as well. You can use the same technique for bottom and side overflow as well, but I typically find it's the top that causes the biggest headaches.
Answer: What's about resetting the margin and padding value to zero in all
*{
  margin: 0;
  padding: 0;
}

Answer: You can do it with line-height
I know it's not too common in HTML5, and is more HTML4.1, but...

and if it's really that important:
L
o/font>
r
e
m

Embedded padding/margin in fonts


My fishing pole won't cast in terraria mobile

Question: So I have worms and other bait but my pole won't cast i tried making a new one and even restarting my phone
But still it won't work please help
Answer: Well, first off you should make sure you have at least 75 tiles of water (a tile being as big as one block), then you should try using the right on-screen joystick, as that usually puts your bobber in front of you in the water, and if that doesn't work try tapping randomly on the screen which usually puts your bobber pretty far out, and if that doesn't work i don't know what will. To reduce the amount of junk fished, you need 200 tiles of water.
Answer: Part of this would require personal troubleshooting, I don't know how far you are but an uninstall would do the trick. I would suggest that you also report the incident to the developers (re-logic). The final option is you could just wait and hope that a patch/update that fixes your problem. I would have no other ideas beside those on this subject.