Who are the main bosses, in Terraria?

Question: I am attempting to defeat all of the bosses, to beat Terraria. This includes hard mode.
Who are the main bosses, throughout both regular and hard mode? Is there a particular preference I should take in defeating them?
It would definitely be worth considering multiple platforms, and the optional bosses, to make the answer more useful to other users.
Comment: The particular order might be an issue, but I have removed it from the primary question. Asking about the actual bosses should in no way be "too broad" for arqade; We accept questions that have far more diverse and broad answers. Ultimately, I feel that **if this question was too broad, it would not have taken a mere 45 minutes for an accepted answer**.
Comment: @Timelord64 - Took the words out of my mouth. This is a finite collection of characters and definitely not 'too broad', there's precedent of these sorts of questions across the site. voting to reopen.
Comment: What is your question here? Are you asking which boss do you need to beat to reach hardmode?
Comment: @Timelord64 The answer that was accepted at the time this was closed is now at -2 and no longer accepted. I'm not sure "got an accepted answer quickly" is necessarily a sign of a good question. Your cleanup did the trick, though, I'd say.
Comment: @Timelord64 An accepted answer **in no way invalidates closure**.  It means nothing at all.
Comment: @Frank, except for the part where the question can be suitably answered to the content of the asker, of course.
Comment: @Frank, how is that relevant to the question currently being "too broad"?
Comment: and the answer *still addressed* the part I assume made it too broad. And I left the part asking for order in the question..
Comment: There is no set order for most bosses and are interchangeable for when you can fight them. Some are easier/harder depending on what type of playstyle you go with.
Comment: @Timelord64 Except for having to change the question to remove the key part that *made* it too broad to begin with.
Answer: One of the great things about Terraria is that the order of bosses that you defeat is pretty flexible. Some bosses are even completely optional as far as progression goes. That being said, most players will usually beat bosses in the following order:
Main Bosses
Pre-Hardmode

Eye of Cthulhu. Either this boss spawns on its own after a while, or you will spawn it yourself using a Suspicious-Looking Eye. The Eye has the least health of any boss, and has only three distinct attach patterns.

Eater of Worlds/Brain of Cthulhu (depending on Corrupted or Crimson world). Summon this boss by destroying three Shadow Orbs/Crimson Hearts.

Skeletron. He blocks the entrance to the dungeon. If you don't kill Skeletron, a Dungeon Guardian will spawn anytime you try to enter the dungeon. DG will one-shot you even if you have the best armor in the game.

Wall of Flesh. After throwing a voodoo guide doll into lava in the underworld, this boss will spawn. Beating WoF activates hardmode and allows you to summon new bosses.

[These bosses can be beaten in any order, but this is the order I've always done them in. Also, technically Eye of Cthulhu isn't required, but he shares the same ore drop as Eater of Worlds/Brain of Cthulhu, and the ore is required to make one of the better swords in the game.]
Post-Hardmode

The Destroyer. A huge worm type boss, most people face him before any other mechanical boss because of easy access to several piercing weapons that make him really easy to beat (like Nimbus Rod or Daedalus Bow).

The Twins. Somewhat more difficult. Usually requires an aerial arena to beat.

Skeletron Prime. Pretty tough, since he has 4-5 attacks that he performs simultaneously. You better be good at dodging if you want to beat him.

[Note that the mechanical bosses can be beaten in any order.]

Plantera. Once all three mechanical bosses have been beaten at least once, Plantera Bulbs will spawn in the jungle. Break one to spawn this boss. Once Plantera is defeated, it drops a temple key (which can be used to open the Jungle temple) and allows more monster types to spawn in the dungeon.

Golem. This boss is found in the jungle temple and can be summoned by using a solar cell on the altar at the bottom of the temple. Be sure to disable any traps in the room first, otherwise the fight will get quite tough!

Lunatic Cultist. Once the Golem is defeated, several cultists will spawn near the dungeon, praying to some symbol. Kill these cultists to spawn the Lunatic Cultist, who absorbs the symbol's strength and fights you in the air. Beating the Lunatic Cultist will spawn four Lunar Pillars in your world.

Lunar Pillars. Not a boss per se, but still a challenging series of fights. Each pillar has its own set of enemies and obstacles. You'll know you're close to one when the colors on your screen start changing to the color of the pillar you're close to. The pillars do not despawn and remain on the map until destroyed.

Moon Lord. The hardest boss in the game (so far). Destroying the four Lunar Pillars will cause him to spawn after about 30 seconds to 1 minute (don't remember the exact timing). A definite challenge even with the best armor in the game. Getting help from friends is not required but recommended.

Optional Bosses

King Slime. Hard to kill right away, but pretty easy once you've acquired some decent beginner gear. Spawns at the end of a slime rain event if you've killed enough slimes.

Queen Bee. Occasionally in the jungle you'll find bee hives. Inside the hives is a 2x2 block that, once destroyed, spawns the Queen Bee. Drops various bee-related items when defeated.

Goblin Invasion. An event in which a bunch of goblins will attack at once. Has a random chance of happening in the morning once the player has more than 200 health.

Snowman Invasion. An event that happens when the player uses a snowglobe (available from presents that only drop during the annual Christmas event - see this question for more details on how to get it year-round). A bunch of snowmen will attack in waves.

Pirate Invasion. An event where pirates attack in waves. Good source of money and gold furniture drops. Careful of the captain, he packs a punch!

Queen Slime. The hardmode equivalent to the King Slime fight. She spawns a ton of slimes that shoot many, many projectiles. .

Duke Fishron. This boss will only spawn when you fish in the ocean while using a truffle worm as bait. He's fast, tough, and drops some really good gear. An arena is highly encouraged.

Empress of Light. In the Hallow, between 7:30pm to midnight, you'll occasionally see a rainbow butterfly called a Prismatic Lacewing. If you kill it, you'll summon the Empress of Light, a challenging boss with a spectrum of colorful attacks. She drops some of the best gear in the game, but the fight is quite difficult - especially if you're going for the Terraprisma!

Pumpkin Moon. A Halloween-themed invasion event where the player has to beat as many monsters in one night as possible. Getting to higher waves yields greater rewards, but also greater risk of death. The "end boss" of this event is the Pumpking.

Frost Moon. A Christmas-themed invasion event where the player has to beat as many monsters in one night as possible. Getting to higher waves yields greater rewards, but also greater risk of death. The "end boss" of this event is the Frost Queen.

Martian Madness. An invasion event where aliens attack. This event is triggered by letting a martian probe (found in upper atmosphere area) see you and escape.

Old One's Army. A special Dungeon Defenders 2 crossover event that can be started by placing an Eternia crystal in a crystal stand (both purchased from the tavernkeep NPC). The difficulty of the event varies depending on how far in the game you've progressed. The "final boss" of this event is Betsy, though she only appears if you've beaten the Golem.
Comment: NOTE: successfully killing the dungeon guardian will give you a bone key, which can summon a baby skeleton head. One of the hardest to obtain items in the game. Also, the Moon Lord, some consider him/her/it The Cthulhu. Because his eyes are the "real eye of Cthulhu".
Comment: @Alex actually, Cenx (one of the boss people in charge of terraria) stated that the moon lord is his brother [here](https://www.reddit.com/r/Terraria/comments/3bekpz/confirmed/cslmwip?context=3)
Comment: @Alex alright, if I ever see him I'll be sure not to let him know. XD
Comment: Also don't forget the orcram!
Comment: You may want to note that the snowman invasion is christman-exclusive.
Comment: @Gamer3001 well don't tell his brother I called him Cthulhu then. You can summon a snowman invasion with a snow globe
Comment: @Gamer3001 Thanks, I added that now, as well as some related info on how to get the event even when it's not Christmas.
Comment: @MageXy yeah. He does 600-1000 damage I'm pretty sure and 1000-2000 on expert mode, don't take my word on that, though.
Answer: These are all bosses you have to fight, how to spawn them, and what you should do to fight them. Skeletron is not needed because mechanical skulls can rarely drop, although I would recommend defeating him.
Wall of Flesh: Spawned by dropping a guide voodoo doll into lava. You will need a guide to make it work. You should build a bridge across lava and break holes in the obsidian houses.
Destroyer: Spawned by using a mechanical worm. You should make a big box with campfires and maybe a heart lamp.
The Twins: Spawned with the mechanical eye. You should use the same box for all 3 mechanical bosses (Destroyer, Twins, and Skeletron Prime).
Skeletron Prime: Spawned with a mechanical skull.
Plantera: Spawned by breaking bulbs that appear in the jungle after defeating the mechanical bosses. mine out a large space around a bulb and put campfires and a heart lamp in it. Make shure the bulb isn't near the underworld or surface.
Golem: Spawned by using a lizard power cell at the lizard altar. To get there you use the key from plantera to get into the jungle temple. lizard power cells can be dropped by lizards or found in chests. Put walls next to the lizard altar because he can't go through walls. Also break all statues and traps in the room and make a wall so that other lizards can't come inside the room.
Lunatic Cultist: Spawned by killing the enemies that spawn outside the dungeon after defeating Golem. Make a platform at the dungeon or make a box around you because his attacks can't go through blocks except his phantasmal dragon.
Solar Pillar, Vortex Pillar, Stardust Pillar, and Nebula Pillar: These are sometimes not considered bosses, but I put them in my list. They spawn at different places in your world after defeating the Lunatic Cultist. They have a force field that will go away after defeating 100 enemies that spawn near it. A tip for crawltipedes: circle around them and hit their back where they can only take damage.
Moon Lord: Spawns 1 minute after defeating all 4 pillars. Make lines of platforms at your base and make a row a blocks for a shield for his phantasmal deathray. Put lots of healing things around the arena and use potions and food like pumkin pie. When I defeated him, I did it with 2 of my friends. You (and maybe your friends) should use full beetle armor and solar eruptions.
Here are links for how to craft the mechanical boss spawners:
https://terraria.gamepedia.com/Mechanical_Worm
https://terraria.gamepedia.com/Mechanical_Eye
https://terraria.gamepedia.com/Mechanical_Skull

Who are the main bosses, in Terraria?


`preg_match_all()` yields incorrect/null results

Question: The question
Why do I get the wrong results?  How can I get the desired results?
The input file
vulture (wing)
tabulations: one leg; two legs; flying
father; master; patriarch
mat (box)
pedistal; blockade; pilar
animal belly (oval)
old style: naval
jackal's belly; jester    slope of hill (arch)
key; visible; enlightened

The two versions of the code, with issue
Version 1:
<?php
$filename = "fakexample.txt";
$file = fopen($filename, "rb");
$myFile = fread($file, filesize($filename));
//PLEASE NOTE THAT $STARTSAFE IS IN PLACE IN THIS VERSION AND NOT IN THE NEXT
function get_between($startString, $endString, $myFile, $startSafe, $endSafe){
  //CHANGES WILL START HERE
  if($startSafe = 0){
    $startStringSafe = $startString;
  }
  elseif($startSafe = 1){
    $startStringSafe = preg_quote($startString, '/');
  }
  //AND END HERE
  if($endSafe = 0){
    $endStringSafe = $endString;
  }
  elseif($endSafe = 1){
    $endStringSafe = preg_quote($endString, '/');
  }
  //non-greedy match any character between start and end strings.
  //s modifier should make it also match newlines.
  preg_match_all("/$startStringSafe(.*?)$endStringSafe/m", $myFile, $matches);
  return $matches;
}
$list = get_between("^", ")", $myFile, 0, 1);
foreach($list[1] as $list){
  echo $list."\n";
}
?>

This code returns nothing.
Version 2:
<?php
$filename = "fakexample.txt";
$file = fopen($filename, "rb");
$myFile = fread($file, filesize($filename));
//PLEASE NOTE THAT $STARTSAFE IS NOT IN PLACE IN THIS VERSION
function get_between($startString, $endString, $myFile, $startSafe, $endSafe){
  //CHANGES START HERE

    $startStringSafe = $startString;

  //AND END HERE
  if($endSafe = 0){
    $endStringSafe = $endString;
  }
  elseif($endSafe = 1){
    $endStringSafe = preg_quote($endString, '/');
  }
  //non-greedy match any character between start and end strings.
  //s modifier should make it also match newlines.
  preg_match_all("/$startStringSafe(.*?)$endStringSafe/m", $myFile, $matches);
  return $matches;
}
$list = get_between("^", ")", $myFile, 0, 1);
foreach($list[1] as $list){
  echo $list."\n";
}
?>

This returns vulture (wing mat (box animal belly (oval jackal's belly; jester slope of hill (arch.
The desired output
vulture mat animal belly jackal's belly; jester slope of hill
Marked differences
vulture **(wing** mat **(box** animal belly **(oval** jackal's belly; jester slope of hill **(arch**
Comment: You could use http://rubular.com/ to test your regex. Very helpful !
Comment: Maybe because I'm using `file_get_contents()`, there's only one line?
Answer: ^ means start of subject per default. If you want it to mean start of line, then you will have to use the /m modifier in your regex wrapper.
Comment: `get_between("^", ")"` will cut out to the closing parenthesis, not the opening one you assume to use. Still incorrent assignments.
Comment: So I basically have to use `/m` instead of `/s`?  I'm getting null results.
Comment: You can combine both flags. That is `/ms`.
Comment: What's strange is, regardless of whether I use `/m` or `/s`, the I get a null result when I use a paramaterized $startString, and I get `vulture (wing mat (box animal belly (oval jackal's belly; jester slope of hill (arch` when I don't.  Neither are correct.  Correct should be `vulture mat animal belly jackal's belly; jester    slope of hill`.  So, it's breaking at the wrong character.
Comment: Well, I don't know what your cumbersome function is all about, neither have you elaborated on your input. But you might want to review the `if` statements. There are assignment expressions within, not comparisons.
Comment: If you have time, I edited for clarity.  The function isn't very long, but the script is kind of bulky I guess.  Hopefully the edited version will be easier.
Comment: I checked that line like 10 times because it was the only thing I could think of, and it never was )....  Then you told me it was that line, and I looked, and it magically was.  Isn't that so strange?  Any idea why the paramaterized version still returns null? :)


parsing XML from XML string for actionscript 3

Question: I am trying to parse out the nodeName but nothing was return, what is wrong with my script?
import flash.xml.XMLDocument;
import flash.xml.XMLNode;
import flash.xml.XMLNodeType;

var MaintainXML:XML =
<letter><to>senocular</to>Get a life</letter>;

trace("status"+MaintainXML.status); // traces "0" (No error)
trace("nodeName" + MaintainXML.firstChild.nodeName); // traces "letter"
trace("nodeName" + MaintainXML.firstChild.firstChild.nodeName); // traces "to"
trace("nodeValue"+MaintainXML.firstChild.firstChild.firstChild.nodeValue); // traces

Comment: how to accept the answer. I did click the up arrow. Is there somewhere else? lol don't where to accept. I see now. The check mark
Answer: You are trying to use methods or properties on your XML that are not existent: Neither status, nor firstChild, nor nodeName are available for the XML Object.  Flash will interpret those calls as a search query, so it looks for child nodes with the name "status", resp. "firstChild" as in
<root>
   <status />
    <firstChild />
</root>

and returns an empty XMLList, because of course it cannot find such nodes.
Also, your MaintainXMLs root node is <letter>, so the first child would be <to>.
Try this:
var MaintainXML : XML = <letter><to>senocular</to>Get a life</letter>;

trace( "nodeName:" + MaintainXML.to.name() ); // traces "to"
trace( "nodeValue:" + MaintainXML.to.toString() ); // traces "senocular"


Can not download dependencies for SBT (the build tool for Scala) in the first run

Question: As you must known, the first time you run SBT, it starts to download his dependencies:
>sbt sbt-version
Getting org.scala-sbt sbt 0.12.4
downloading repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/main/0.12.4/jars/main.jar ...

The problem is that I'm living in Africa and the ISP is not very good: for some unknown reason, they are some domains from which I can not download any file. For example, if I enter to the site of WAMP and try to download the installer, the download begins but it never ends. Normally I fix this issue by using a proxy (such as HideMyAss or ZendProxy), which servers as an intermediate between the site and the ISP, allowing me of download the file.
typesafe.com seems to be one of the not-work-for-download-in-africa domains, as consequence, SBT can not download his dependencies.
The question is, there is a way of download manually the dependencies? (I have downloaded them using a proxy, but I do not known in which folder put them in order to avoid SBT to try to download them)?
Answer: Create a directory in the root of your sbt project called lib and put the jars there.
Comment: By the moment I have not any project, I'm just executing the sentence "sbt sbt-version" from the command prompt of Windows 8
Comment: Then just pick a directory where you like to begin working. The important part is you have the lib directory in the same directory in which you are executing sbt.
Comment: I created the "lib" folder in the installation directory of SBT and then I picked this directory as the working directory in the command prompt, and it worked! Thanks
Comment: Nice! Have fun with Scala!


Are there any peer-reviewed papers on the maximum waiting time to be considered "user real-time"?

Question: Are there any scientific papers about any study performed on what is considered a maximum waiting time for an activity to be considered "user real-time" (not software real-time).
I was looking at something along the lines of "maximum waiting time for a web page to render" and the user's perception of real-time.
For instance empirically, we can state that waiting 200 ms would be real-time whereas waiting 10 seconds would not, but I was hoping to find some citation for it in scientific literature.
I've tried some resources (eg Google Scholar) but to no avail.
Thank you.
Comment: Hi FrankZappa, welcome to UX.se! This has been answered multiple times here. http://ux.stackexchange.com/questions/2/what-is-an-acceptable-response-time-for-my-ajax-ui http://ux.stackexchange.com/questions/30770/studies-showing-the-impact-of-response-time-variability-on-user-experience All quoting http://www.nngroup.com/articles/response-times-3-important-limits/
Answer: In Chapter 3 of Designing and Engineering Time by S.Seow there are list of standards which consern time and user experience. In average, "user real-time" response is in interval of 0.2-1.0 sec.


Deleted directory doesn't appear at the bin and doesn't give the free space back

Question: I'm using Kubuntu. My disk was full some days ago and the system requested me to delete files.
I deleted a ~17GB directory, but it didn't appear at the bin and didn't released the space.
What could be happening? Thanks!
df -h
<code>~$ df -h
S. fitxers      Mida En ús Lliure  %Ús Muntat a
/dev/sda1       145G  131G   6,4G  96% /
none            4,0K     0   4,0K   0% /sys/fs/cgroup
udev            985M   12K   985M   1% /dev
tmpfs           201M  880K   200M   1% /run
none            5,0M     0   5,0M   0% /run/lock
none           1001M   84K  1001M   1% /run/shm
none            100M   16K   100M   1% /run/user
</code>
Comment: Can you please [click here](http://askubuntu.com/posts/360298/edit) and provide us the output of `df -h`?
Comment: There seems to be some free space there, what makes you think you didn't get the space back?
Comment: I deleted more things because what I deleted didn't give the space, of course :/
Answer: A good program to visualize these types of things is the Disk Usage Analyzer.
Sometimes on drives a .Trash folder is created when these files get "moved" to the bin.
This will at least help you to figure out exactly where the space is going.


Hardware Processor Counters Incorrectly Resetting

Question: I wrote a program which reads the APERF/MPERF counters on an Intel chip (page 2 on http://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-software-developer-vol-3b-part-2-manual.pdf).
These counters are readable/writable via the readmsr/writemsr instructions, and I'm currently simply reading them at a regular interval via a device driver in Windows 7. The counters are 64 bits, and increment approximately with each processor clock, so you'd expect them to overflow in a very long amount of time, but when I read the counters, their value jumps around as if they are being reset by another program.
Is there any way to track down what program would be resetting the counters? Could something else be causing incorrect values to be read? The relevant assembly and corresponding C functions I'm using are attached below. The 64-bit result from rdmsr is saved into eax:edx, so to make sure I wasn't missing any numbers in the r_x registers, I run the command multiple times to check them all.
C:
long long test1, test2, test3, test4;
test1 = TST1();
test2 = TST2();
test3 = TST3();
test4 = TST4();
status = RtlStringCbPrintfA(buffer, sizeof(buffer), "Value: %llu %llu %llu %llu\n", test1, test2, test3, test4);

Assembly:
;;;;;;;;;;;;;;;;;;;
PUBLIC TST1
TST1 proc
    mov ecx, 231 ; 0xE7
    rdmsr
    ret ; returns rax
TST1 endp

;;;;;;;;;;;;;;;;;;;
PUBLIC TST2
TST2 proc
    mov ecx, 231 ; 0xE7
    rdmsr
    mov rax, rbx
    ret ; returns rax
TST2 endp

;;;;;;;;;;;;;;;;;;;
PUBLIC TST3
TST3 proc
    mov ecx, 231 ; 0xE7
    rdmsr
    mov rax, rcx
    ret ; returns rax
TST3 endp

;;;;;;;;;;;;;;;;;;;
PUBLIC TST4
TST4  proc
    mov ecx, 231 ; 0xE7
    rdmsr
    mov rax, rdx
    ret ; returns rax
TST4 endp

The result that prints out is something like below, but the only register which ever changes is the rax register, and it doesn't increase monotonically (can jump around):
Value: 312664 37 231 0
Value: 252576 37 231 0
Value: 1051857 37 231 0

Comment: Are you reading those registers on a specific CPU or on whichever happens to be the current?
Comment: That's a good point, I am running the code on whatever core happens to be current. (I'm using i5 and i7 machines as the test machines). On the other hand, I would expect the rdx register to increment from 0 *eventually* on one of the CPUs, rather than always remaining at zero.
Comment: Also, is be possible to only run the driver off of one specific core?
Comment: You can move the current thread to a specific CPU using `KeSetSystemAffinityThreadEx()`.
Answer: I was not able to figure out what was resetting my counters, but I was able to determine the frequency. The Intel docs state that when one counter overflows, the other counter also will. So even though the counters are constantly resetting, the ratio of aperf and mperf still does represent the processor's frequency.
Answer: It seems that Windows 7 and Windows 8 read and reset the writeable APERF/MPERF counters on AMD processors. So, you want to access the read-only APERF/MPERF counters at registers 0xc00000E7/E8.
But there is a new issue. On some of the latest AMD processors (Family 0x16 processors), those registers are not always supported. To determine if those registers are supported, you have to read the EffFreqRO bit in CPUID Fn8000_0007_EDX. As stated before, all this applies only to AMD processors.


If $f(x-4) = x^3 + 2x^2 + 7x + 1$, determine $f(x)$.

Question: I was faced with a pretty tricky math problem from my school. Here is the question.
If $f(x-4) = x^3 + 2x^2 + 7x + 1$, determine $f(x)$.
My first instinct is to graph the initial equation and shift it $4$ points to the right, I saw the $(x-4)$. Would this be the correct way to start?
All help is appreciated. Thanks in advance.
EDIT: I understand what you guys are saying about replacing the f(x). Just to make sure, you want me to replace f(x) with f(y) and then plug in y + 4 for every single x value in the original equation? (P.S. I am the original poster, I just registered)
Comment: **Hint**  Put $y = x - 4$, that is  $x = y + 4$.  Finally just replace $x$ by $y$ and you will have your answer.
Answer: You are on the right track. Note, however, that $f(x-4)$ is the same thing as $f(x)$ but shifted to the right by 4 units. Thus, to get $f(x)$ you have to shift back to the left. This is a good way to go if you want to visualize geometrically the relationship between $f(x)$ and $f(x-4)$. If you are just looking for an equation, however, there is an easier way.
Come up with some other variable name, such as $y$, and then let $y=x-4$. Solving for $x$ you get $x=y+4$. Now take your equation for $f(x-4)$ and rewrite it in terms of your new variable $y$.
You should have an equation now with $f(y)$ on the left hand side. Since it doesn't matter what name you call your variables by, you can now just replace all occurrences of $y$ with $x$ and you will have your expression for $f(x)$.
Answer: $x = (x+4) - 4$
so $f(x) = f((x + 4) -4) = (x+4)^3 + 2(x+4)^2 + 7(x+4) +1$.


Install Exchange Server 2013 on Windows Server 2012 R2

Question: I am completely new to servers. And I run into a problem that I need to install Exchange Server 2013 on my server.
When I try to install this server it gives me an error
<code>Error:
The Active Directory schema isn't up-to-date, and this user account isn't a member of the 'Schema Admins' and/or 'Enterprise Admins' groups.
</code>
I looked through numerous tutorials and I am pretty sure that I did everything right.
As you can see my account is a member of domain admins and enterprise admins as well.
P.S. I am using Google Compute Engine
Answer: As it says, you need to add your account to Schema Admins. Add it the same way you added Enterprise Admins. Schema Admins is not inherited by Enterprise Admins, they're separate roles.


Does walking distance count if you are also capturing a pokemon?

Question: In pokemon go, it is possible to walk while trying to capture a pokemon. Is it better to walk or to stay still?
Does the distance walked while capturing count towards egg hatching or pokemon buddy?
If you forget to close a pokestop and walk, does that walk distance count as well?
Answer: Yes, walking distance will count even if you are capturing a Pokemon.
Egg progress will also be made in the following scenarios (credit to this Reddit post from theSilphRoad:

Having a pokestop selected on your screen
Having a different egg hatch mid walk. I'm referring to the screen with a picture of an egg that says "Oh?"
Having your menu open while walking. I was on the egg selection screen for testing. What is interesting is that the distance values don't actually update until you close the screen and reopen it, but the distance logged was correct.
CATCHING A POKEMON. I'm very excited to report this as it's been speculated for a long time that catching a pokemon while walking won't log your location correctly. That is wrong. I entered a battle/cutscene whatever you want to call it prior to walking. Didn't interact with it for the entire 1 km. At the end I caught 2 of the pokemon and ran from the other two. All four attempts gave me full distance logging.

From observation, egg and buddy distance progress are calculated the same way (delta vector calculated each minute), so buddy distance should be unaffected by these actions as well, so long as you are walking less than 10.5 km/h.
Comment: how about evolve animation?
Comment: @user55570 I'm going to assume since evolution is done via the menu, it will not affect it either.


Is it possible to declare a method with block as default value?

Question: I want to write a method which takes a block and if no block given it should use a default block. So I want to have something like this:
def say_hello(name, &block = ->(name) { puts "Hi, #{name}" })
  # do something
end

But when I'm trying to do so I'm getting the syntax error.
I know I can deal with my problem using block_given?. But I am interested in first approach.
Am I missing something or this is just not possible?
Answer: Some answers suggest using block_given?, but since there is no possibility that a block would be nil or false when it is given, you can simply use ||=.
def say_hello(name, &block)
  block ||= ->(name){puts "Hi, #{name}"}
  # do something
end

Comment: I'm trying to tell you that this technique of assigning a value to `block` in the event the caller doesn't provide it is not a transparent alternative to providing a default value for `█` (i.e. providing a "default block" to be used in case the caller doesn't provide one). The OP needs to know that if he used `yield` previously, he needs to change his code (i.e. the contents of `# do something`) to use this alternate approach.
Comment: Don't you also have to switch your method of accessing the block to avoid `yield`?
Comment: @PeterAlfvin I don't understand what you mean.
Comment: If a block isn't provided on the call, then `yield` statements will not work. You have invoke it with `block.call(...)` or something equivalent.
Comment: @PeterAlfvin That is right. And, how is `yield` relevant? What are you trying to tell me?
Comment: I said as much in my answer and I'm suggesting you might want to update your answer to include that remark, particularly since it's the accepted one.
Comment: @PeterAlfvin No, I don't want to update my answer to make it less useful by including any unhelpful thing as in your answer. Since the OP is using the variable `block`, the OP should not, (and probably not) be using `yield` within the code; otherwise it is useless to accept the block with a variable. I see no mentioning of `yield` in the OP's question (which is the right thing), nor in my answer. It is you who somehow brought in `yield`, and is struggling over it.
Comment: So in your view, the `█` parameter is only intended to be used when you want to reference `block` in method body? I understood it was also intended as a mechanism for simply documenting that the method was expecting a block.
Comment: See also https://www.ruby-forum.com/topic/50679#19405 as an example of someone else raising this concern.
Comment: @user2422869 Wanted to call your attention to this thread in case you weren't aware of it.
Comment: @PeterAlfvin Accepting a block with a variable and then switching to use `yield` is a bad practice. If you wanted to make clear of the block, then you should use the variable consistently.
Answer: You cannot declare a default block in the method definition, however you can use a little trick to use a custom block if none is given.
def say_hello(name)
  block = block_given? ? Proc.new : ->(name) { puts "Hi, #{name}" }
  block.call(name)
end

# This example uses a custom block
say_hello('weppos') { |name| puts "Hello, #{name}!" }
# => Hello, weppos!

# This example fallbacks to the default
say_hello('weppos')
# => Hi, weppos!

Let me explain it a little bit. Let's start from a more readable version.
def say_hello(name, &block)
  block = block ? block : ->(name) { puts "Hi, #{name}" }
  block.call(name)
end

You define the method to accept a block, then you check if block is defined. If not, you assign a custom block. Finally, you execute the block.
Let's enhance it a little bit. You can use block_given? to check if a block is passed
def say_hello(name, &block)
  block = block_given? ? block : ->(name) { puts "Hi, #{name}" }
  block.call(name)
end

This also allows you to skip the declaration of the block (&block) in the method definition.
def say_hello(name)
  if block_given?
    yield name
  else
    # This is rendundant, but it's for clarity
    block = ->(name) { puts "Hi, #{name}" }
    block.call(name)
  end
end

But, at this point, you can also use the Proc.new to assign the block to a variable.
def say_hello(name)
  block = block_given? ? Proc.new : ->(name) { puts "Hi, #{name}" }
  block.call(name)
end

As a final word, I'm trying to understand when this approach would make sense. In most cases, you can probably wrap the code in a class or module and pass it as argument. It's probably better.
Comment: Didn't see your answer when I posted mine. In the event you use `█` as a parameter, you don't have to define `block` as `Proc.new` if a block isn't passed, because Ruby takes care of that for you. Right?
Comment: I had to write that I know what `block_given?` do. :) Though awesome answer.

I'm currently playing with something that needs to declare a method on `method_missing`. eg `foobar { |x| puts x }` will add a method `foobar(x)` to current objects class.
Answer: You can do it with regular lambdas.
def say_hello(name, block = ->(name) { puts "Hi, #{name}" })
  block.call(name)
end

say_hello("Sergio")
say_hello("Ivan", ->(name) { puts "Where are you from, #{name}?"})
# >> Hi, Sergio
# >> Where are you from, Ivan?

Not sure if you can do this with blocks, though. A block is not an ordinary parameter.
Answer: No, you can't provide a default block value in a method definition. You can, however, achieve the equivalent behavior through the use of block_given? within the body of the method, as follows:
def say_hello(name, &block)
  block = ->(name) { puts "Hi, #{name}" } unless block_given?
  # do something
end

However, in this scenario you can't utilize yield to invoke any block that is passed in, since it won't be there in the default case. You'll have to invoke the block Proc object, as in block.(name).


On an example of an inseparable element in a field extension

Question: Put $F := \mathbb{F}_p(t) = \left\{\frac{f(t)}{g(t)} : f(t), g(t) \in \mathbb{F}_p[t], g(t) \neq 0\right\}$.
Now in one book the author considers the so-called Frobenius homomorphism $\mathcal{F}:F \to F$ defined by $\mathcal{F}(x) = x^p$. Then he proceeds to show that $t$ is not separable over $\text{Im}(\mathcal{F}) =: K$.
However in another set of notes, essentially the same example is given, but the author starts by "considering $\alpha$ s.t. $\alpha^p = t$" and then he shows $\alpha$ is not separable over $F$.
Question: In the book, it is clear that we have the extension $F/K$. However, in the set of notes, in what extension of $F$ does $\alpha$ belong to ? Naively $\alpha$ is a $p$-th root of $t$, so I thought the extension would have to be some field of functions...?
Answer: When $a$ is not a $p$-th power in $F$, we can always define $F[\sqrt[p]{a}] = F[X]/(X^p-a)$.  We can also specify that we are working within an algebraic closure.
In characteristic $p$, $p$-th roots are unique, so this is even somewhat canonical.
Comment: @Guest Sorry, I misspoke.  I meant to say that $a$ is not a $p$-th _power_.  If $a$ is already a $p$-th power, then the formula I wrote down no longer gives you a field.  Instead, you should just take $F[\sqrt[p]{a}]$ to be $F$ itself.
Comment: Thanks for your very enlightening answer. Just to be sure: at the beginning do you mean "When $a$ *has no* $p$-th root"?


std::dec still outputting memory address to hex?

Question: I have:
std::cout << "Start = " << std::dec << (&myObject) << std::endl;

to output an address in decimal. However, the address is still coming out in hex??
(I am outputting one of these for each of ten members, so I don't want to assign each one to a variable and then std::dec the variable separately)
Comment: std::cout << "Start = " << uint32_t((&myObject)) << std::endl;
that work? x86?
Comment: @hanshenrik: Why make assumptions about pointer type sizes when `uintptr_t` was created precisely for this purpose???
Comment: i can't think of any reasons :D i just didn't know about the intptr_t when i wrote it; thanks
Answer: The hex and dec manipulators are for integers, not pointers. Pointers are always rendered in the form that printf's %p formatter would have used on your system (which is, usually, hexadecimal notation).
This helps to emphasise the fact that pointers and numbers are distinct. You may consider it to be one of the rare cases in which number semantics and number representation are, to some degree, coupled.
The best you can do is to cast the pointer to uintptr_t before streaming it:
std::cout << "Start = " << std::dec << uintptr_t(&myObject) << std::endl;

…but please consider whether you really need to do so.
Comment: @LightnessRacesinOrbit  `std::dec` is superfluous in this case
Comment: @vsoftco: You don't know what state the stream is in from previous operations.
Comment: Why the "whether you really need to do so"?
Comment: @user997112: I explained that in the rest of the answer. What makes you think you need to represent pointers in an unconventional manner? That's usually not a good idea.


Core Data custom migration policy with multiple targets

Question: If I want to use a custom migration policy for a given entity, I believe I have to prefix the class name by the product module name, as shown on the following image:

How can I manage to handle multiple targets?
I tried using the following entry: $(PRODUCT_MODULE_NAME).VisitToVisitPolicy but this does not seem to work. I still have the possibility to duplicate the mapping model, one for each target, but that does not feel right.
Answer: Had the same problem trying to share model files between app and test targets. Almost gave up and thought I'll have to use your duplicate hack, but thankfully found a sane way:
// Get mapping model
let mappingModel = NSMappingModel(from: [.main],
                        forSourceModel: sourceModel,
                      destinationModel: destinationModel)!

// Get migration policy class name that also includes the module name
let fullClassName = NSStringFromClass(NSEntityMigrationPolicySubclass.self)

// Set policy here (I have one policy per migration, so this works)
mappingModel.entityMappings.forEach {
    $0.entityMigrationPolicyClassName = fullClassName
}

// Migrate
let manager = NSMigrationManager(sourceModel: sourceModel,
                            destinationModel: destinationModel)

try! manager.migrateStore(from: sourceURL,
                    sourceType: NSSQLiteStoreType,
                       options: nil,
                          with: mappingModel,
              toDestinationURL: destinationURL,
               destinationType: NSSQLiteStoreType,
            destinationOptions: nil)

Comment: can you please share where you put the above code?
Comment: Can you provide more context, such as where and how you use this code?
Answer: I had the same problem. My solution is similar to Alexander's and it should work with multiple migration policies (one per entity). You need to set Custom Policy to class name without any namespace and after obtaining mapping model I do this:
    mapping.entityMappings.forEach {
        if let entityMigrationPolicyClassName = $0.entityMigrationPolicyClassName,
            let namespace = Bundle.main.infoDictionary?["CFBundleExecutable"] as? String {
            $0.entityMigrationPolicyClassName = "\(namespace).\(entityMigrationPolicyClassName)"
        }
    }

Comment: can you please share where you put the above code?
Answer: Based on the snippets from the previous answers, here's a more complete example implementation. In order to do this it seems like you need to do a fully manual migration.
Note: I haven't gotten this to work with the @FetchRequest decorator, but it is working with a basic MVVM setup. The part of the migration where I force update to get around WAL issues was causing issues with entities being loaded twice. Running a fetch request directly on a managed object context seems to work fine.
import CoreData

struct DataLayer {
    static let shared = DataLayer()
    let container: NSPersistentContainer

    // The base directory for you app's documents
    private var documentsUrl: URL {
        let fileManager = FileManager.default

        if let url = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "your.group.here") {
            return url
        } else {
            // Falling back to the regular core data location.
            let urls = fileManager.urls(for: .documentDirectory, in: .userDomainMask)
            return urls.first!
        }
    }

    // The SQLite data store
    private var dataStoreUrl: URL {
        return documentsUrl.appendingPathComponent("YourDataStoreName")
    }

    init() {
        container = NSPersistentContainer(name: "YourDataStoreName")

        migrateIfNeeded()

        // Prevent Core Data from trying to automatically migrate
        container.persistentStoreDescriptions.first!.url = dataStoreUrl
        container.persistentStoreDescriptions.first!.shouldMigrateStoreAutomatically = false
        container.persistentStoreDescriptions.first!.shouldInferMappingModelAutomatically = false

        // Load the new store just like you normally would
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                print("Core Data failed to load: \(error.localizedDescription)")
            }
        })

        container.viewContext.automaticallyMergesChangesFromParent = true
    }

    func getItems() -> [Item] {
        let fetchRequest = NSFetchRequest<Item>(entityName: "Item")
        fetchRequest.sortDescriptors = [NSSortDescriptor(key: "timestamp", ascending: true)]

        do {
            return try container.viewContext.fetch(fetchRequest)
        } catch {
            let nsError = error as NSError
            print("Unresolved error \(nsError), \(nsError.userInfo)")
        }

        return []
    }

    /// Checks if the current data store is up to date and migrates to the newest version if needed
    func migrateIfNeeded() {
        // The managed object model we might need to migrate to
        let finalManagedObjectModel = NSManagedObjectModel(contentsOf: Bundle.main.url(forResource: "Incremental", withExtension: "momd")!)!

        // If the app hasn't ever been launched there might not be a data store at all
        if !FileManager.default.fileExists(atPath: dataStoreUrl.path) {
            print("No store to check")
            return
        }

        // Get metadata from the source data store
        guard let sourceMetadata = try? NSPersistentStoreCoordinator.metadataForPersistentStore(type: .sqlite, at: dataStoreUrl) else {
            fatalError("Could not find metadata for current data store")
        }

        // If the current data store is compatable with the desired object model, no need to do anything
        let compatible = finalManagedObjectModel.isConfiguration(withName: nil, compatibleWithStoreMetadata: sourceMetadata)
        if compatible {
            print("compatible - skipping migration")
            return
        }

        // Get the object model of the current data store
        let sourceModel = NSManagedObjectModel.mergedModel(from: [Bundle.main], forStoreMetadata: sourceMetadata)!

        // Because iOS by default uses WAL to write new data to a SQLite database there's a chance not all data has been written to the
        // main SQLite file. The following will force iOS to write all lingering data to the main file before migrating.
        do {
            var persistentStoreCoordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: sourceModel)

            let options = [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
            let store = try persistentStoreCoordinator!.addPersistentStore(type: .sqlite, at: dataStoreUrl, options: options)
            try persistentStoreCoordinator!.remove(store)
            persistentStoreCoordinator = nil
        } catch let error {
            fatalError("\(error)")
        }

        // Search for a mapping model from the current store version to the target version
        // You could also attempt to infer a mapping model here
        guard let mappingModel = NSMappingModel(from: [Bundle.main], forSourceModel: sourceModel, destinationModel: finalManagedObjectModel) else {
            fatalError("Could not find mapping model")
        }

        // Fix the migration policies for the current target
        mappingModel.entityMappings.forEach {
            if let entityMigrationPolicyClassName = $0.entityMigrationPolicyClassName,
                let namespace = Bundle.main.infoDictionary?["CFBundleExecutable"] as? String {
                $0.entityMigrationPolicyClassName = "\(namespace).\(entityMigrationPolicyClassName)"
            }
        }

        // Set up the migration manager and temporary data store
        let migrationManager = NSMigrationManager(sourceModel: sourceModel, destinationModel: finalManagedObjectModel)
        let tempDataStoreUrl = documentsUrl.appendingPathComponent("TemporaryIncremental.sqlite")

        do {
            // Migrate the old data store into the temporary one
            try migrationManager.migrateStore(from: dataStoreUrl, type: .sqlite, options: nil, mapping: mappingModel, to: tempDataStoreUrl, type: .sqlite, options: nil)

            // Delete the old data store and move the temporary into the original spot
            try FileManager.default.removeItem(at: dataStoreUrl)
            try FileManager.default.moveItem(at: tempDataStoreUrl, to: dataStoreUrl)
        } catch let error {
            fatalError("\(error)")
        }
    }
}


Cannot install Git on Ubuntu 16.04 LTS

Question: When I was trying to install Git on Ubuntu 16.04, I get an error. The command I used to install git is:
sudo apt-get install git

The error I encountered was:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
  git : Depends: liberror-perl but it is not going to be installed
        Depends: git-man (> 1:2.7.4) but it is not going to be installed
        Depends: git-man (< 1:2.7.4-.) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or
specify a solution).

Even though I used the suggested command (apt-get -f install) to install git the error still persists. Anyone who has the idea to fix this problem?
Comment: yes, I ran it but the problem still persists
Comment: Please try `sudo apt-get update && sudo apt-get dist-upgrade && apt-get -f install`
Comment: Already tried, same error encountered
Comment: Lets see if `gdebi` will help: `sudo apt-get install gdebi && sudo gdebi git`
Comment: The previous solution (sudo apt-get update && sudo apt-get dist-upgrade && apt-get -f install) worked, I just had the 3 commands ran one by one. Thanks for the help
Comment: One down one more to go, glad it worked! Will be including answer for you to accept...
Answer: Some times our systems may not be up-to-date to receive an install so we can update with:

update package information:
sudo apt-get update

upgrade packages on system and fix broken packages in the process:
sudo apt-get -f dist-upgrade

only fix broken packages:
sudo apt-get -f install

Answer: I had the same problem with liberror-perl when trying to install git. The other answers (sudo apt-get update && sudo apt-get dist-upgrade && apt-get -f install) didn't work for me.
From manually following the chain of dependency problems by trying to install each package directly, it looks like the problem is with perl-base:
$ sudo apt install liberror-perl
  liberror-perl : Depends: perl but it is not going to be installed

$ sudo apt install perl
  perl : Depends: perl-base (= 5.22.1-9) but 5.22.1-9ubuntu0.5 is to be installed

$ sudo apt install perl-base
  perl-base is already the newest version (5.22.1-9ubuntu0.5).

So the perl package depends on an outdated version of perl-base. I'm not sure how that was caused, but I suspect at one point a newer version was available, perhaps from a temporary apt source that was later removed on my system. I fixed the problem by downgrading perl-base to the version perl wants:
$ sudo apt install -f perl-base=5.22.1-9

After that, git installs properly. Just in case there was a newer perl-base version available, I tried upgrading it, but the above version was also the latest version:
$ sudo apt install perl-base=\*
perl-base is already the newest version (5.22.1-9).
Selected version '5.22.1-9' (Ubuntu:16.04/xenial [amd64]) for 'perl-base'

As far as I know this should not cause any problems, but YMMV.

Cannot install Git on Ubuntu 16.04 LTS


DateFormat is printing new Date(0) as epoch + 1 hour

Question: The following test fails:
<code>DateFormat df = new SimpleDateFormat("HH:mm:ss z");
assertEquals("00:00:00 GMT", df.format(new Date(0)));
</code>
expected "00:00:00 GMT" but was "01:00:00 GMT"
Could someone point out where I'm being stupid please?
I've spent longer looking at this than is would have taken me to just replace everything with Joda-Time. There's a lesson there somewhere.
Answer: The problem is that Java has a bug around the name of the Europe/London time zone abbreviation in 1970.
In the winter of 1970, the UK was still on UTC+1 - but Java believes it's still called "GMT". So what you're seeing is the local time at midnight UTC on January 1st 1970... it's just that we're used to GMT=UTC, which is why it's confusing.
(As a side note, it would still be worth converting to Joda Time even now. Avoid the built-in libraries like the plague :)
Joda Time prints the time zone abbreviation as "BST". This seems equally bizarre given that it clearly wasn't summer time... but it's possible that the "S" here standards for Standard, as that was during the period of the "British Standard Time experiment". See Wikipedia for details.
(Note that UTC itself didn't even exist at the Unix epoch - it was introduced in 1972. I'm assuming a proleptic UTC for the sake of this answer :)
Comment: Ah. I just read http://en.wikipedia.org/wiki/British_Summer_Time#Periods_of_deviation and it mentions that Britain was experimenting with a temporary time-zone change. Thanks Jon.
Comment: There are quite a few years during the wars and 1970-1985 where the daylight saving times were introduced or changed through out Europe. (during WW2, the offset were 2 hours in UK. I suppose it was still called GMT )  I don't thin it's an error in the tables in Java, but rather a problematic corner case - the model isn't complex enough. "CET" for instance,  was introduce gradually in central Europe, so for a specific country, it's incorrect for at least a few years in seventies. Calendars (the concept, not the class) and time is annoyingly complicated, and it easy to get confused.
Comment: BTW, You would think UTC is initials for something when its a compromise of the English and French initial-isms. i.e. its not quite either of them.
Comment: Before the Gregorian calendar the year changed on March the 25th (nine months before Dec 25th ;) When the USA gained independence it adopted the calendar retrospectively. George Washington's birthday was February 11, 1731 when he was born but it changed to February 22, 1732 during his lifetime. Greece adopted the Gregorian calendar in 1924, making the time difference between Italy and Greece 13 days in 1923.
Answer: new Date(0) returns Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
So the value will be Thu Jan 01 05:30:00 IST 1970
"05:30:00" Depens on your location
Comment: The OP is confused because of the GMT being output along with 01:00:00. Most Britons don't realise that on the date of the Unix epoch, Britain was on UTC+1. Not that UTC existed at the time...
Comment: The Epoch is stated in GMT, and I specifically formatted the output to include the timezone, which is GMT.
Comment: Yes, but in 1969-1971 the timezone in UK wasn't GMT but rather British Standard Time (UTC+1) all year around. This is reflected in the offsets for the timezone called "GMT" but it's name is not changed in java. I think it is actually handled as if wintertime never happes those years. Anyway,  The encouraged timezone identifier is "Europe/London" - representing the whole administrative region, rather than a specific timezone, as a specific place may have (had) several timezones.


TypeError: Cannot read properties of undefined (reading 'status') in axios

Question: This is the code from the freecodecamp tutorial (https://www.freecodecamp.org/news/how-to-build-react-based-code-editor/), the code is meant for react but my project is for next js and when I run it in the react project I don't get this error but when I run it in the next js project I get the error:
 TypeError: Cannot read properties of undefined (reading 'status')

The code where the error is occurring according to the error message.
axios
        .request(options)
        .then(function (response) {
            console.log("res.data", response.data);
            const token = response.data.token;
            checkStatus(token);
        })
        .catch((err) => {
            let error = err.response ? err.response.data : err;
            // get error status
            let status = err.response.status;
            console.log("status", status);
            if (status === 429) {
                console.log("too many requests", status);

                showErrorToast(
                    `Quota of 100 requests exceeded for the Day! Please read the blog on freeCodeCamp to learn how to setup your own RAPID API Judge0!`,
                    10000
                );
            }
            setProcessing(false);
            console.log("catch block...", error);
        });
};

Comment: Is it the typo, you have `let error...` then `err.response.status`. Should it be `error.response.status`?
Comment: Just in general though, it is saying it cannot read `status` of an undefined variable. That means in your code, `err.response` is undefined. Try console logging `err` right at the top of the `catch((err)) => { console.log(err)` and see if you can find a `status` property
Comment: if you remove everything in that catch block except `console.log(err)` you get undefined? I don't think you do, otherwise I'm pretty sure the error would say `Cannot read properties of undefined (reading 'response')`
Comment: I think I figured out the problem, I think that the problem is that before this code I tried to pull some api keys from .env file which aren't getting pulled from there. However I am not sure about how to get a variable from the .env file.
Comment: Thats good, maybe best to start a new question. Good luck!
Answer: Take a look at Axious documentation. Looks like you are not even receiving a response, meaning error.response is left undefined. Maybe something wrong with the request options?
Comment: I think I figured out the problem, I think that the problem is that before this code I tried to pull some api keys from .env file which aren't getting pulled from there. However I am not sure about how to get a variable from the .env file.


WordPress fetch_feed()->get_items()->get_another()

Question: I want to import news to my WordPress site from an RSS structure like this:
<item>
    <title>...title...</title>
    <link>..link...</link>
    <description>...short description...</description>
    <full-text>...full-text...</full-text>
    <enclosure url="http://.../post_image123.jpg" type="image/jpeg"/>
    <category>...category...</category>
    <pubDate>Wed, 20 Nov 2013 17:32:41 +0400</pubDate>
</item>

I know how to get all of the tags except full-text, and I've not found any documentation about this. How do I get full-text?
Code:
<?php
$rsslist = array(
    'http://kavkazinfo.net/backend.php?region=%C4%E0%E3%E5%F1%F2%E0%ED',
    'http://kavkazinfo.net/backend.php?region=%C8%E7%F0%E0%E8%EB%FC',
);

// Fetch all of the feeds into a simplePie mashup
$rss = fetch_feed($rsslist);
// Set the max items to either 5 or all items if there are less than 10
$maxitems = $rss->get_item_quantity(5);

// Get the items (0-5)
$rss_items = $rss->get_items(0, $maxitems);

// If there are no items, output that
if ($maxitems == 0) {
    echo '
No items.
';
// Otherwise loop over the items
} else {
    foreach ($rss_items as $item) { ?>

        <?php echo $item->get_fulltext(); ?> // Of course, get_fulltext() doesn't exist as a function, so how do I get it?

    <?php
    }
}
?>

Comment: Have you tried `$item['full-text']`?
Comment: Tried now, Fatal error: Cannot use object of type SimplePie_Item as array
Comment: The feed element is actually called `full-text`?
Comment: Please http://kavkazinfo.net/backend.php
Answer: Try get_item_tags():
get_item_tags( '', 'full-text' )

AFAIK full-text is a nonstandard feed element so SimplePie's methods don't handle it.
Comment: I's works, thanks.
**$item->get_item_tags('', 'full-text')[0]['data']**
Answer: Some simple searching lead me to this:
http://simplepie.org/wiki/reference/start#simplepie_item
You might try get_Content();
Comment: I saw this documentation, the get_Content() function return only description element.


LINQ query issue regarding Date

Question: I want to list out all records where CloseDate is greater than DateTime.Now.
I have write a query for that but it doesn't fetch records where CloseDate is greater than DateTime.Now.
See my query below
 var query = (from x in objEntity.VacancyMsts
                     join o in objEntity.OrganizationMst on
                     x.OrganizationID equals o.OrganizationId into vacorg
                     from o in vacorg.DefaultIfEmpty()
                     where x.Status == true && x.CloseDate >= DateTime.Now
                     select new VacancyMstDTO
                     {});

Is there any problem in my query?
Comment: What SQL is executed against the database?
Comment: it returns recots .. my sql query is SELECT     dbo.VacancyMst.PositionTitle, dbo.VacancyMst.Description, dbo.VacancyMst.PositionLocation, dbo.OrganizationMst.OrganizationName,
                      dbo.VacancyMst.CloseDate
FROM         dbo.VacancyMst LEFT OUTER JOIN
                      dbo.OrganizationMst ON dbo.VacancyMst.OrganizationID = dbo.OrganizationMst.OrganizationId
WHERE     (dbo.VacancyMst.Status = 1) AND (dbo.VacancyMst.CloseDate >= GETDATE())
Comment: @Manatherin yes two records are there
Comment: in the `select new VacancyMstDTO {}` do you put something inside the braces?
Comment: yes of course.. put some feilds :)
Comment: @habibzare I had put some fields in select too,,
Answer: you dont need to join here if you have a FK relationship
var query = from x in objEntity.VacancyMsts
            where x.Status && x.CloseDate >= DateTime.Now
            select new VacancyMstDTO
            {
                OrganizationName = x.OrganizationMst.Name,
                ...
            };

But I wonder if you really want the CloseDate to be ahead of today, normally a close date happens in the past, no?
And, careful with timezones as well. I tend to always insert/update the database with DateTime.UtcNow and when reading, apply the user timezone...

LINQ query issue regarding Date


Vlans in Ubuntu 12.04.3 bonding are down after boot

Question: My issue is the following:
I've got two 10 GIG interfaces that i need to use in bonding - LACP - mode 4.
Here is my config:
mypc# cat /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet manual
bond-master bond0

auto eth5
iface eth5 inet manual
bond-master bond0

auto bond0
iface bond0 inet manual
    bond-mode 4
    bond-miimon 100
    bond-lacp-rate fast
    mtu 11000
    bond-slaves none

auto bond0.10
    iface bond0.10 inet static
    address 10.0.0.30
    netmask 255.255.255.0
    gateway 10.0.0.1
    mtu 11000
vlan-raw-device bond0

auto bond0.20
    iface bond0.20 inet static
    address 10.0.1.31
    netmask 255.255.255.0
    gateway 10.0.1.1
    mtu 11000
vlan-raw-device bond0

dns-nameservers 22.214.171.124

mypc# cat /etc/modprobe.d/bonding.conf

alias bond0 bonding

bonding mode=4 lacp_rate=1 miimon=100 max_bonds=1

probe bonding

mypc# cat /etc/modules

bonding
8021q

As you can see from the subject the interfaces bond0.10 and bond0.20 remain DOWN after boot.
Answer: I had the same problems with roughly the same configuration.  At first, I had some problems with the interface configs- inet static instead of inet manual on the bond0 interface and inet manual instead of inet static on the bond0.x interface.
Not sure if sorting that out was the only thing to resolve the issue.  While troubleshooting, I had several instances where the bond0.x interfaces would not come up.  Adding up statements at the end of each interface config section as shown below seemed to help bring the interfaces up, when they did not appear to come up in previous tries.
up ifconfig bond0 up ## or bondo.x for each vlan interface


How I can create a responsive image carousel and slides custom post type content in WordPress

Question: I want to create a responsive image carousel and slides custom post type content like featured image, title, etc.
I had created custom post type  as banner in the following way:
function create_banners_post_type() {
    $labels = array(
        'name' => __( 'Banners' ),
        'singular_name' => __( 'banner' ),
        'add_new' => __( 'New banner' ),
        'add_new_item' => __( 'Add New banner' ),
        'edit_item' => __( 'Edit banner' ),
        'new_item' => __( 'New banner' ),
        'view_item' => __( 'View banner' ),
        'search_items' => __( 'Search banners' ),
        'not_found' =>  __( 'No banners Found' ),
        'not_found_in_trash' => __( 'No banners found in Trash' ),
    );
    $args = array(
        'labels' => $labels,
        'has_archive' => true,
        'public' => true,
        'hierarchical' => false,
        'supports' => array(
            'title',
            'editor',
            'excerpt',
            'custom-fields',
            'thumbnail',
            'page-attributes'
        ),
        'taxonomies' => array( 'post_tag', 'category'),
    );

    register_post_type( 'banner', $args );

 }
add_action( 'init', 'create_banners_post_type' );

and to display the output on the front page:
// function to show home page banner using a query of banner post type

    function home_page_banner() {?>

    <?php
$query = new WP_Query( array(
            'post_type' => 'banner',
        ));

        if ( $query->have_posts() ) { ?>

            <?php while ( $query->have_posts() ) : $query->the_post(); ?>

                    <div id="post-<?php the_ID(); ?>" <?php post_class( 'bg-image' ); ?>><?php the_post_thumbnail(); ?>

<?php the_title(); ?>

                    <?php the_content(); ?>
                    Read More

            <?php
            endwhile;?>

            <?php

       }
        wp_reset_postdata();

    }

in front page I had inserted this code:

<?php
if ( is_front_page() ) {
    home_page_banner();
}
?>

which is creating a ul list and in ul list, each post is coming in li, following is inspect element screenshot:
Comment: which slider js your are using?
Comment: I had tried using owl carousel but cud not understand how to use WordPress
Comment: Can you show me the  owl carousel html code?
Comment:
Comment: or any other way u can suggest me ...?
Answer: Try this code
// function to show home page banner using a query of banner post type

function home_page_banner() {?>

<?php
    $query = new WP_Query( array(
        'post_type' => 'banner',
    ));

    if ( $query->have_posts() ) { ?>

        <?php while ( $query->have_posts() ) : $query->the_post(); ?>

                <div id="post-<?php the_ID(); ?>" <?php post_class( 'bg-image' ); ?>><?php the_post_thumbnail(); ?>

<?php the_title(); ?>

                <?php the_content(); ?>
                Read More

        <?php
        endwhile;?>

        <?php

   }
    wp_reset_postdata();
}

Answer: I've never used Owl Carousel before, but any time I have to do a carousel I go to either Slick or Flickity  - has basically everything you could ever need.
Flickity JS Carousel

The below is an example of how to include your post content inside of a carousel.
Create the initial query:
<?php
  // the query
  $recent_posts = new WP_Query( array(
    'category_name' => 'posts',
    'posts_per_page' => 3,
  ));
?>

Create your slider

 <? // this is your wrapper div ?>
  <?php if ( $recent_posts->have_posts() ) : ?>
    <?php while ( $recent_posts->have_posts() ) : $recent_posts->the_post(); ?>

                <div id="post-<?php the_ID(); ?>" <?php post_class( 'bg-image' ); ?>><?php the_post_thumbnail(); ?>

<?php the_title(); ?>

                  <?php the_content(); ?>
                  Read More

    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
  <?php endif; ?>

Add some jQuery to make Flickity work:


How to construct an example where $\sum_{n=1}^{+\infty} a_n$ diverges and $\prod_{n=1}^{+\infty} (1+a_n)$ converges?

Question:
My Problem: Construct an example where
$$ \sum_{n=1}^{+\infty} a_n \quad \text{diverges}, \qquad \text{and}\qquad \prod_{n=1}^{+\infty} (1 + a_n) \quad \text{converges}$$

My thoughts:
By '$\prod _{n=1}^{+\infty} (1 + a_n)$ converges', we have $a_n \to 0$, and by '$\sum_{n=1}^{+\infty} a_n$ diverges', we know that the sign of $\{a_n\}$ is not fixed. But I have no idea how to construct the $a_n$.
Please give me some hints to do it. Thanks a lot!
And how can I construct the ${a_n}$ when it is not constant?
Comment: Simple example : $a_n = -\frac{1}{2}$ $\forall n\ge1$ leads to $\sum_{n\ge1}a_n = -\infty$ but $\prod_{n\ge1}a_n = 0$.
Comment: But $\prod_{n=1}^{+\infty}(1-\frac{1}{2})=0$(In fact it's 1!),by  definition of the convergence of infinite product, it should converge to a nonzero real number. @Abezhiko
Comment: @Rogan what makes you think that an infinie product should converge to a nonzero real?
Comment: oh! It's my fault! @freakish
Comment: Thanks a lot. Maybe I need to check some easy examples.@freakin@Abezhiko
Comment: @freakin@Abezhiko And I want to know how can I construct the ${a_n}$ when it is not constant? Is there any common thought?Thanks a lot!
Answer: Some author says that $\prod_{n=1}^{\infty}(1 + a_n)$ is convergent only if
$$ \lim_{N\to\infty} \prod_{n=1}^{N} (1+a_n) \in \mathbb{C}\setminus\{0\}. $$
This definition has some advantages over the more lenient version that allows $0$ as a possible value of infinite product, see the related Wikipedia article for instance.
Even with this definition, we are still able to construct an example.

Construction. Define $(a_n)_{n\geq 1}$ so as to satisfy
$$ (1+a_n)_{n\geq 1} = \left( 1, \quad \frac{2}{1}, \frac{1}{2}, \quad \frac{3}{2}, \frac{2}{3}, \frac{3}{2}, \frac{2}{3}, \quad \frac{4}{3}, \frac{3}{4}, \frac{4}{3}, \frac{3}{4}, \frac{4}{3}, \frac{3}{4}, \frac{4}{3}, \frac{3}{4}, \quad \ldots \right) $$
By the construction, it is clear that $\prod_{n=1}^{\infty} (1 + a_n) = 1$. On the other hand,
$$ (a_n)_{n\geq 1} = \left( 0, \quad \frac{1}{1}, -\frac{1}{2}, \quad \frac{1}{2}, -\frac{1}{3}, \frac{1}{2}, -\frac{1}{3}, \quad \frac{1}{3}, -\frac{1}{4}, \frac{1}{3}, -\frac{1}{4}, \frac{1}{3}, -\frac{1}{4}, \frac{1}{3}, -\frac{1}{4}, \quad \ldots \right), $$
and so,
$$ \sum_{n-1}^{2^N - 1} a_n
= \sum_{k=2}^{N} \sum_{n=2^{k-1}}^{2^k - 1} a_n
= \sum_{k=2}^{N} 2^{k-2} \left( \frac{1}{k-1} - \frac{1}{k} \right)
= \sum_{k=2}^{N} \frac{2^{k-2}}{k(k-1)} $$
and this diverges as $N \to \infty$. Using this, it is then not hard to check that $\sum_{n=1}^{\infty} a_n = \infty$.
Comment: @Rogan, I am not sure if it is linked to the Riemann rearrangement theorem (if this is what you meant). My idea is to exaggerate the difference $\log(1+x)-x$ by repeating a pair of values as many times as wish. **GEdgar**'s construction is more natural than mine. In GEdgar's answer, $(a_n)$ is designed so that, if we write $b_n=\log(1+a_n)$, then $\sum b_n$ is convergent but $\sum b_n^2$ is divergent.
Comment: I think the common thought is that we can firstly construct $a_n$ to make sure that $\prod _{n=1}^{+\infty} (1 + a_n)$ converges, then we can use Riemann series theorem to make $\sum_{n=1}^{+\infty} a_n$ diverges. Am I right? @Sangchul Lee
Comment: Thanks a lot! I got your idea of "exaggerate the difference of $a_n-log(1+a_n)$". We can use the Leibniz Test ( Alternating series test) to make sure that $\sum log(1+a_n)$ is convergent(@GEdgar's construction), and we have $\sum a_n$ is divergent.
Answer: We have to do it so that convergence is conditional, not absolute.
Example:
$$
a_n = -1+\exp\left(\frac{(-1)^n}{\sqrt{n}}\right) .
$$
Then, as $n \to \infty$, Taylor's theorem yields
$$
a_n = -1+1+\frac{(-1)^n}{\sqrt{n}}+\frac{1}{2n}+O\left(\frac{1}{n^{3/2}}\right) .
$$
Write
$$
a_n = \frac{(-1)^n}{\sqrt{n}}+\frac{1}{2n}+b_n
$$
Now the partial sum is
$$
\sum_{n=1}^N a_n = \sum_{n=1}^N \frac{(-1)^n}{\sqrt{n}}
+\sum_{n=1}^N \frac{1}{2n}+\sum_{n=1}^N b_n
$$
where, as $N \to \infty$, we have
\begin{align}
\sum_{n=1}^N \frac{(-1)^n}{\sqrt{n}}\quad &\text{converges,}
\\ \sum_{n=1}^N \frac{1}{2n}\quad&\text{diverges to} +\infty,
\\ \sum_{n=1}^N b_n\quad &\text{converges.}
\end{align}
So the series $\sum a_n$ diverges to $+\infty$.
On the other hand,
$$
\log(1+a_n) = \frac{(-1)^n}{\sqrt{n}}
$$
and
$\sum \log(1+a_n)$
converges (alternating series) so $\prod(1+a_n)$ converges.


How to create this masonry layout

Question: Can anyone please guide me how to created this type of masonry layout? Is it possible to create this type masonry gallery using display: grid and how to overlap the layers? Is there any other way to create this?
I've tried using the below code but that does not seem good. I also want to make it responsive.
masonry gallery image

.masonry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-column-gap: 0px;
  grid-row-gap: 0px;
}

.masonry-grid .grid-item {
  position: relative;
}

.masonry-grid .grid-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-1 {
  grid-area: 1 / 1 / 2 / 2;
  height: 230px;
  margin: 20px -140px 0 0;
  z-index: 2;
}

.item-2 {
  grid-area: 1 / 2 / 3 / 3;
  height: 465px;
  z-index: 1;
}

.item-3 {
  grid-area: 1 / 3 / 4 / 4;
  max-height: 765px;
  margin-top: 20px;
  margin-right: -40px;
  z-index: 1;
}

.item-4 {
  grid-area: 1 / 4 / 2 / 5;
  /*margin-left: -40px;*/
  margin-right: 20px;
}

.item-5 {
  grid-area: 2 / 1 / 4 / 2;
  max-height: 585px;
  margin: -40px -10px 0 0;
}

.item-6 {
  grid-area: 3 / 2 / 4 / 3;
  max-height: 350px;
  margin: -160px -90px 0 0;
}

.item-7 {
  grid-area: 2 / 4 / 3 / 5;
  margin: 20px 0 0 -40px;
  z-index: 1;
}

.item-8 {
  grid-area: 4 / 1 / 5 / 2;
  max-height: 540px;
  margin: -300px 0 0;
}

.item-9 {
  grid-area: 4 / 2 / 6 / 3;
  max-height: 650px;
  width: 650px;
  margin: -310px 0 0 -50px;
}

.item-10 {
  grid-area: 4 / 3 / 5 / 4;
  margin: -491px 0 0;
}

.item-11 {
  grid-area: 3 / 4 / 4 / 5;
  margin: -50px 0 0 40px;
}

.item-12 {
  grid-area: 5 / 3 / 6 / 4;
  margin: -186px 0 0 -40px;
  z-index: 1;
}

.item-13 {
  grid-area: 4 / 4 / 5 / 5;
  margin: 50px 0 0 -50px;
  max-width: 480px;
}

Comment: There is this JS library that supposedly is the most used over internet for that purpose https://masonry.desandro.com/
Comment: This is fundamentally a 4x4 grid with items expanded/shrunk/translated. It looks as though it is emulating a notice board of postit notes placed at 4 different times. Is that the sort of thing it is to look like?
Answer: What you are doing looks okay, given the design.
However, I think this is the kind of design you want to push back against since it has several flaws:

arbitrary gaps
arbitrary overlaps
you need 4 different z-indexes and it's hard to see "a rule"
hard to scale (what if there twice as much images, I don't really see the logic of the design)

So, I would start with making an interpretation of the design that is more clear/logical.
EG:

I would start with an unsplash kindof layout, but 4 instead of 3 columns. (its also grid-based)
you probably need to alter the html a bit: lets wrap your grid-items in col-wrappers: .masonry-grid > .col-wrapper
I would not explicitly set the height or the width of any grid item, but keep the same width everywhere, and let the image decide the height to keep the original dimensions.
I would try to alternate the z-index & overlap behavior with a smart css rule based on the nth-child(odd) and nth-child(even) pseudo-selectors. (The negative margin might seem like a crazy hack, but if it works, why not. You can also try to get there using translate: scale(1.05) and transform: scale(0.95) or using the translate property.

eg:

.masonry-grid .col-wrapper:nth-child(odd) .grid-item:nth-child(odd) {
  [...]
}
.masonry-grid .col-wrapper:nth-child(even) .grid-item:nth-child(odd) {
  [...]
}

Responsiveness:
you can use the media query, eg: @media only screen and (max-width: 600px) and (min-width: 400px)  {...} to have different rules on different breakpoints.
The above mentioned, would only work on big sizes.
If you go a bit smaller, 3 columns would be enough.
If you go to smartphone size, you should just display the images above and below each other.
Note: your HTML would look different depending on the amount of columns (or the breakpoints). This adds a difficulty level, but I don't think you can have it without the using .col-wrapper.
Hope that helps
Answer: To get some order out of the seeming chaos, as you have spotted, the layout looks roughly like a grid with 4 columns.
If we also have four rows, the whole based on a square, we could start with a 4x4 grid with images (in this case a background color as in your picture just for demo) each roughly in the grid item space they seem associated with.
This gives you:

The point of this being that we can then size and position each image relative to its grid square. This can be done easily, if tediously, by measuring the width/height/left/top of each item in the original design picture and using them as
percentages of the grid item each is in.
That way we get responsiveness.
I do not claim to have done any accurate measuring, and I got a bit bored part way through, so here is a snippet with the first half of the imgs sort of positioned and sized as a demo. You will of course want to get out the ruler and be more accurate.
Note the z-indexes. Just for simplicity, 0 is given to an img which doesn't overlap any other item and 3 is given to an img which isn't overlapped by any other item. Then 1 and 2 are allocated to those in between that do some overlapping and are themselves partly overlapped.

How to create this masonry layout


ReactJS Uncaught TypeError: this.refs issue

Question: I am trying to use refs to access a DOM node in React, however, I am getting the following error.

Uncaught TypeError: this.refs.card.getDomNode is not a function(…)

I am following this tutorial, and as far as I can tell this should work.
Here is the code I have written. Can anyone spot anything obvious i am doing wrong.
var App = React.createClass({

    componentDidMount: function() {
        var card = this.refs.card.getDomNode();
    },

    render: function() {
        return(

                <Card ref="card"/>

        )
    }
});

Comment: `.getDomNode();` depricated
Answer: From 0.15 onwards React depricated .getDOMNode()

this.getDOMNode() is now deprecated and ReactDOM.findDOMNode(this) can
  be used instead.

Use like this
componentDidMount: function() {
   var card = ReactDOM.findDOMNode(this.refs.card);
},

For more details see here
Answer: According to the following link
You need to change the following
function() {
        var card = this.refs.card.getDomNode();
    },

TO THIS
function() {
              var card = this.refs.card;
    },

If it points to the input,select,div DOM node
and
function() {
                var mmo =  ReactDOM.findDOMNode(this.refs.card);
        },

for the custom component you have created yourself


How to remove the handles from this faucet

Question:
My bathroom faucet is leaking around the base of my right handle.  With previous faucets I've been able to use a set screw to loosen the handle and replace the washer.  With these, though, I can't seem to pop off the faucet handle.  Does anyone know how to remove this handle?  Does anyone know the brand of this faucet?
Update -- Nov 29th
I've already tried to get those cap ends off.  I tried to use some pliers and unscrew them, but couldn't remove it.  I tried taking a small flat head and popping off the ends.  Still nothing.  It doesn't seem like the come off.
I also tried unscrewing the handles, but they just don't see to turn for me.
Also there is definitely no set screw on the handles.  I've searched all around the faucet and found nothing indicating a set screw.
Comment: Should be a set screw at or near the base of the lever....
Comment: Can't tell what brand it is (there are hundreds, both foreign and domestic) but in the absence of a set screw it will very likely screw apart, starting at the top. Shut off the water prior to trying.
Comment: Doesn't seem to screw apart and there is definitely no set screw.
Answer: I have THE EXACT faucet. There is NO screw. JUST PULL UP!  May have to do a slight pry on the base but that is what it is, no screws.
Comment: It's hard to argue with "exact!"
Comment: You simply pull it up by the handles?
Answer: If the end caps don't come off, and there isn't a set screw, try simply pulling up (or taking a flat head screw driver with a towel so you don't scratch the faucet, and prying up). I'd recommend shutting off the water underneath the sink first (just in case).
If that doesn't work look underneath for some type of odd contraption to hold them on, but that would be a terrible design.
Answer: I know this is a bit old but if anyone else needs this information, the handles do pry off. I have this exact same faucet and I could not figure it out. I tried to pry them off but I did not want to use too much force without being sure. I removed the entire faucet from the sink and brought it into Home Depot. An employee was able to pry it off with a screw driver. In the end he offered me a new faucet at a discount. Since I already had it off, I jumped at the chance and just got a new one instead of repairing the old one.
Answer: This is what worked for me.  I used a 3 inch scraper blade and a hammer.  I very gently tapped that thin, tapered scraper blade between the bottom of the escutcheon (the bell-like part between the handle and the sink) just enough to loosen it a bit.  I then was able to unscrew (counter-clockwise) the escutcheon with the handle attached.
Note that the escutcheon is made of plastic, so be gentle.  Also, the handle is screwed to the escutcheon by a screw that is located at the inside top of the escutcheon.  So, pulling on the handle will not work.
Answer: I have one similar however there are 2 little caps above the stem.  I removed them thinking I'd see an allen screw, but there was none so I forced it off with a nail puller and discovered there was a phillips screw that held it on (really hard to see down  that hole).  So if there are caps on top, try a small phillips head first!  Hope this helps someone.
Answer: I have THE EXACT faucet also. There is NO screw. JUST PULL UP! May have to do a slight pry on the base but that is what it is, no screws. Try pulling up and pry at last resort. If you do pry be sure and pad so you don't scratch or damage the surface of the faucet. (Turn off the inlet lines in case something goes terribly  wrong!)
Answer: sometimes, you take the end cap off of the handle, remove the screw.  remove the handle (threaded or slide-on fit).  then there is a little port for a set screw or just a metal pin that secures it to the top of the valve core upper spline.
Answer: It looks as if the end caps are removable, the buttons on the very end of each handle. They may either pry off or unscrew. Then the handles themselves appear to be screwed on. I'm not positive this will allow you access to the washers, but from the photo those parts can be removed.
Comment: The handle part of the handles are often removable, allowing you to swap out handles (between wood and chrome). However, this is usually simply to change the look of the handle, and has nothing to do with removing the handles.
Answer: I had one fairly similar that came off by grabbing the widest part of the "bell" with padded channellock pliers, and turning counter clockwise. Unscrewing that part subtly lifts up on the upper part of the handle, and pops it off. Brute force did not actually work, so if you've tried brute force and are stymied, try unscrewing the wide part.


Why can't SABnzbd assign a port

Question: I'm attempting to run SAB on a new Ubuntu 14.04 box. But it won't start, always failing with 'error: [Errno 99] Cannot assign requested address' no matter the user or port I start with. Even root gets denied. I know that the typical answer is that the port is taken but it doesn't appear to be so:
    hofo@pellmell:~$ sudo netstat -anltp | grep "LISTEN"
    tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      6947/smbd
    tcp        0      0 0.0.0.0:34446           0.0.0.0:*               LISTEN      1942/Plex Plug-in [
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      31419/apache2
    tcp        0      0 0.0.0.0:32400           0.0.0.0:*               LISTEN      1652/Plex Media Ser
    tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      10246/Xvnc4
    tcp        0      0 0.0.0.0:32469           0.0.0.0:*               LISTEN      2449/Plex DLNA Serv
    tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2100/dnsmasq
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1631/sshd
    tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      27115/cupsd
    tcp        0      0 0.0.0.0:62202           0.0.0.0:*               LISTEN      2449/Plex DLNA Serv
    tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      6947/smbd
    tcp        0      0 0.0.0.0:50176           0.0.0.0:*               LISTEN      2828/Plex Plug-in [
    tcp6       0      0 :::139                  :::*                    LISTEN      6947/smbd
    tcp6       0      0 :::5901                 :::*                    LISTEN      10246/Xvnc4
    tcp6       0      0 :::22                   :::*                    LISTEN      1631/sshd
    tcp6       0      0 :::445                  :::*                    LISTEN      6947/smbd

Any ideas what I should look at next?
Answer: For me it worked with IP 127.0.0.1 instead of 0.0.0.0 or localhost. (Same same but different...)
sudo sabnzbdplus --server 127.0.0.1:8745

Why can't SABnzbd assign a port


In Kingdom Hearts, what counts as "Items Used"?

Question: When I finish Kingdom Hearts (PS2 Greatest Hits release) on Expert mode, after the credits and epilogue cutscenes, there's a screen that shows various statistics, such as Heartless Defeated, number of times Sora took damage, etc.  One of these is "Items Used".
But what exactly counts toward this "Items Used" statistic?  Does it include:

Sora uses a consumable (Potion, Ether, up to Megalixir) from inventory, in or out of combat?
An ally uses a consumable in combat?
A consumable (which could be in inventory) is used directly from stock out of combat?
The party uses a stock-only HP/MP restoration object (Tent, Cottage, etc.)?
Sora uses a stat booster (Power Up, Defense Up, AP Up)?
An ally uses a stat booster?
Sora gives an item to a flower in Wonderland's forest?
An item is consumed by the "recipe" or "experiment" in Deep Jungle's Camp area?
Anything involving unique plot-related or puzzle-related items?
Comment: After my 10+ years playing Kingdom Hearts, not once have I thought about this...
Comment: Never even noticed that in the credits, but I wonder this too, now.
Answer: TLDR: Anything in Active Inventory or originating from your stock is considered an item. Gifting/transferring an item doesn't count unless that item's specific effect was proc'd.
Long Version:
This question is very tough- the only two ways to 100% be certain is to play through multiple times keeping track of what you use, or two use a mod tool to view where the game stores 'items used.'
I looked at several sources for what Kingdom Hearts defines as an 'item,' and I found several references that corroborate what I had suspected- Items are defined as anything that can be stored in stock or active inventory, and item use is only proc'd if that item's effect is initialized (not necessarily triggered).
First, I found an old IGN guide (here) that items must be used from "the sub-menu" and are stored in the main stock, and must then be shifted to the active inventory.
Next, I found a wonderful guide put together by /hardcore rpg gamer/ (here) that itemized the types of items you may encounter in the game:

AP Boost
Defense Boost
Drive Recovery
Elixir
Ether
Hi-Potion
High Drive Recovery
Potion
Magic Boost
Mega-Ether
Mega-Potion
Megalixir
Power Boost
Tent
Torn Page

Lastly, I looked up the definition in the Item Page of the original Strategy Guide for Kingdom Hearts (found the PDF on a old site that I will not post due to copyright issues). It defined items somewhat nebulously, referring to weapons occasionally as items, yet having separate pages for both items and weapons. However, on the main item page it says: "Items may be stored in your main stock, your active inventory, or the inventory of a party member." I believe this fits my definition.
CONCLUSION:
Anything in Active Inventory or originating from your stock is considered an item. Gifting/transferring an item doesn't count unless that item's specific effect was proc'd. In addition, keyblades, synthesis items, and accessories do NOT count as items used, but summon charms do.
Comment: Your second link is about Kingdom Hearts II, not Kingdom Hearts. KH has no "Drive Recovery", and has a number of common and unique items not on that list. I'm asking more about what "used" means, not what "item" means. So do you know what "item use is only proc'd if that item's effect is initialized (not necessarily triggered)" means in terms of actual game actions?
Comment: The type of item doesn't matter- it matters where that 'item' is stored: if the item is stored in your main stock or active inventory, then it will count as used once you activate it from your battle menu. I believe I answered most cases of 'use,' but it really does matter more what the item is than when it is used. As I said in my response, activating an item from the battle menu is the only way to count it as a use. In response to each of your specific cases in your question: yes, yes, yes, yes, yes, yes, no, no, no/it depends (respectively).


MD5 hash in Rust

Question: I'm trying to create an md5-hash from a string in Rust.
This is what I have been able to find in the documentation:
let digest = md5::compute(b"abcdefghijklmnopqrstuvwxyz");

assert_eq!(format!("{:x}", digest), "c3fcd3d76192e4007dfb496cca67e13b");

So now my code is:
fn main(){
    let digest = md5::compute(b"abcdefghijklmnopqrstuvwxyz");
    assert_eq!(format!("{:x}", digest), "c3fcd3d76192e4007dfb496cca67e13b");
}

I can't figure out how to import the md5 lib, so I am getting this error message:
use of undeclared type or module `md5`

Comment: Please consider revisiting The Rust Programming Language book, especially [Chapter 7, section 4, on Using external packages](https://doc.rust-lang.org/beta/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#using-external-packages).
Answer: You should add use md5 import at the top of your file:
use md5;

fn main(){
    let digest = md5::compute(b"abcdefghijklmnopqrstuvwxyz");
    assert_eq!(format!("{:x}", digest), "c3fcd3d76192e4007dfb496cca67e13b");
}

playground
Comment: That only works in the playground, on an actual project using cargo, you'd add a md5 = "..." to the dependencies in your Cargo.toml
Comment: View the repo for md5 (i like [crates.io](https://crates.io/crates/md5)), use the copy button to grab the lib and version and add this to the `[dependencies]` section of your `Cargo.toml` file like the previous poster mentioned

MD5 hash in Rust


A limit with infinite product $\lim\limits_{n\to\infty}\frac1{n^4}\prod_{i=1}^{2n}\left(n^2+i^2\right)^{\frac1n}$

Question: How to calculate :
$$\lim_{n\to\infty}\frac{1}{n^4}\prod_{i=1}^{2n}\left(n^2+i^2\right)^{\frac{1}{n}}$$
Comment: Hint: Rewrite the logarithm of this as a Riemann sum...
Comment: Take logarithm of both sides maybe. This transforms product into sum and powers into products.
Answer: Pull the $n$ out of the product to get
$$L = \lim_{n \rightarrow \infty} \prod_{i=1}^{2 n} \left ( 1+\frac{i^2}{n^2} \right )^\frac{1}{n} $$
Rewrite as (corrected!)
$$\log{L} =  \lim_{n \rightarrow \infty} \frac{1}{n} \sum_{i=1}^{2 n}
 \log \left ( 1+\frac{i^2}{n^2} \right )$$
This is a Riemann sum whose limit is
$$\begin{align}\log{L} &= \int_0^2 dx \: \log{(1+x^2)}\\ &= [x \log{(1+x^2)}]_0^2 - 2 \int_0^2 dx \: \frac{x^2}{1+x^2} \\ &= 2 \log{5} + 2 \arctan{2} - 4 \end{align}$$
Then the limit $L$ is
$$L = 25 e^{-2 (2-\arctan{2})} $$


Mix between Gnome 2 menu an Unity possible?

Question: I very much like the old Gnome 2 menu style Ubuntu used to have before switching to Unity. Still, I like many of the new Unity features, too! Meanwhile though I've been using Ubuntu in many different ways with many different programs installed. If you have only a few programs in use, you can easily keep them in an orderly way within the launcher on the left side, but if you have many programs (i.e. +20) installed, this one bar just won't do a good job, because it tries to squeeze all them to this left bar area. The Ubuntu opened with the super-key is an alternative way, where you can find all your programs by typing the application name, but when you have many programs installed it can happen that you know what program you wanted to use, but you just cannot remember the name. Searching for it in this Ubuntu menu can be quite cumbersome. The old style menu was fantastic for this. Every program was categorised in Graphics, Office, Programming, etc. I found it always very easy to use.
Is there any addon or plugin for Unity to get back this old style categorised menu? It'd be nice to have that without having to change to another desktop environment.
Comment: Why don't you use [Ubuntu Mate](https://ubuntu-mate.org/)?
Comment: @mikewhatever I like Unity and the way you search for programs and set the settings of multiple screens. Mate is very reduced in that manner. I'm really just looking for a way to customize the regular Unity and add this category style menu we were all used to back in the day.
Answer: There is no way to get Unity to show programs in categories. If you have only problems putting many programs into the left bar, you can shrink the buttons there (using Unity Tweak Tool).
Otherwise, you can use Cinnamon instead of Unity to have most of the applets and searches and still retain the menu with programs ordered in categories.
Another possibility is using Cairo Dock. It adds a bottom bar that has programs listed in categories, in other features it's mostly similar to Mac.
Comment: Sad to hear, but regettably seems correct. Thx


Create a field with an default value toggle

Question: I've got an input field with a default value but I currently have the feeling no-one understands how it should be used.
The idea is if you toggle the switch on you use the default value and if you turn it off you can override this value.
Any suggestions how you could improve this? (I'm aware of the miss alignment)
Current implementation on android:
Comment: I don't think I've ever seen a default value used in this way, and I certainly wouldn't consider it usable. Usually you would just place the default value in the text field, and then let the user change that value. If you're worried that the user might want to return to the default value, you could simply put a label *default: 17* next to the field.
Answer: I'd remove the toggle as it is unnecessary and put the VAT in as it is, change the prompt underneath to something like "Type over the default rate to change it."
Answer: To make it simpler, I would recommend:

Having as default value 17%.
In the case that the user changes, they can see the information message which states that the default value is 17%
The label can be placed in different places, depending on your overall design.


Problems with Audio Playback

Question: I was previously using a VPN connection and realized I could watch localized video from the VPN Servers in different countries.
When I tried to watch Comedy Central using a VPN connection, the audio was slowed. It was clear that the website realized I was connecting from outside of the US.
Deterred, I stopped my VPN subscription and uninstalled the OpenVPN on my machine.
However, when going to a website called "mixer.com" that displays live feed videos of gaming websites, the audio distortion persisted.
Have my audio codex become corrupted? Has anyone else experienced this before?
Any help appreciated!
EDIT: I recorded some audio from Mixer.com so you can better understand what is happening: https://www.youtube.com/watch?v=YTeF8JHf6Fc
Answer: I was using "general.useragent.override" in Firefox to spoof a Microsoft Edge web browser. For some reason, when I removed the spoof and deleted my cookies the audio corrected itself.
Not sure if this is an Edge specific block or if it was a browser spoof problem.
Very strange to say the least.

Problems with Audio Playback


Change Color of counter while typing in

Question: I am trying to do a Character Count while typing in, in a text area. i have got a working code to get the count.
the code is as follows

and it is called from a div where the count to be shown.

Now it works perfectly. I want this to change color when it exceeds the count so the user can see that he / she has typed in too many characters.
if anyone can help it would be great
Comment: why not just use `maxlength="250"` ?
Comment: Sounds like you are trying to do data validation of inputs, is there a reason you chose not to use a pre-built validation tool?
Answer: Set a css class for #Char_Count1 if the length exceeds the limit:

then use css to give the element with the class the desired color
.limit { color: red; }

Like Paolo said, it would be possible to use a style directly, but it is good practice to use style only in style sheet files (css) instead of inline.
Don't create additional markup (html tags), this reduces readability and performance.
Comment: ...and use `$('#Char_Count1').removeClass("limit");` as the count goes below the limit
Comment: or even `$('#Char_Count1').toggleClass("limit", text_leftDes < 5)`
Comment: forgot about `toggleClass`. I think this would be the most elegant solution. +1
Comment: Edited my answer to contain a complete example.
Comment: It's no longer considered *bad practice* to combine HTML, Javascript and CSS together. If you don't believe me, take a gander at websites like Facebook or even Stackoverflow :) Since your javascript has intimate knowledge of how your application should look and act, it only makes sense that these would couple together. React and angular do a great job of this as well.
Answer: Simply done:

Comment: I am getting an error in this line
var dHtml = (text_leftDes<0) ? '' . text_leftDes . ' Characters left' : text_leftDes . ' Characters left';
it does not show the error but just shows as the code wont work
Comment: @Ruchith - did it still contain the words and number?
Comment: @Ruchith I edited my answer...got my PHP and Javascript concatenation chars mixed up. Now give it a try :)
Comment: No problem! Glad I could help :D
Answer: Just apply a style that makes the text colored (ex. red):
$('#Description').css( { "color", "#f00" } );

To let the color be toggled red/black appropriately depending on text length:
$('#Description').css( { "color", ( text_leftDes < 0 ? "#f00" : "000" ) } );

Side note:
As you're setting the text content of #Char_Count1 it's better to use jQuery's text() so you don't have to worry about escaping html:
$('#Char_Count1').text(text_leftDes + ' Characters Left');

Change Color of counter while typing in