What is the origin of "weighing the pig doesn't make it fatter"

Question: What is the origin of "weighing the pig doesn't make it fatter"
Comment: Seems like a phrase similar to *"A watched pot never boils"*
Comment: Never heard it before.
Comment: @Oldcat: I would assume the pig quote says that it doesn't get better by observing it, whereas the pot comment would mean observing it has a negative impact on your intended goal (a "watched pot" meaning you often pull the lid off to inspect it, therefore letting the heat out. Also, that watching the pot makes the time needed to boil seem longer, subjectively speaking)
Answer: There are multiple versions of this saying:

Weighing the pig doesn't make it [any] fatter.
Weighing the pig doesn't make it grow [any faster].
Weighing the pig doesn't make it gain weight.
Weighing the pig doesn't fatten it.
Weighing a pig doesn't make it heavier.

But I noticed a couple of odd things about this bit of down-home wisdom. First, a Google Books search reveals that the oldest match for either "Weighing the pig doesn't" or "Weighing a pig doesn't" is from the year 2000. From British Records Association, Archives, volume 25 (2000):

Most of the information contained in these pages suggests that the PRO is doing pretty well in setting and meeting targets. But the farming analogy that 'weighing the pig doesn't make it any fatter' is one that springs to mind.

The second odd thing is that most of the 30 or so Google Books matches for "weighing the pig doesn't" and "weighing a pig doesn't" come from books and articles on on education. It seems fairly clear that the controversy over focusing on standardized testing as a means of gauging the quality of education that a school offers has caused this small geyser of pig-weighing analogies.
Even so, a Google Books search does turn up one significantly older instance of the expression "Weighing a pig doesn't fatten it"—from Housecraft, volume 51 (1978) [combined snippets]:

The reader may appreciate one or two cautionary notes here. First, the only reason for carrying out evaluation activities as outlined is to become a most efficient professional. If the evaluation activities of the teacher do not make her effective as a teacher, then they are a waste of time. Secondly, and just as important, it is timely to remember that 'weighing a pig doesn't fatten it'. The evaluation role is a weighing role. Essentially, teaching is a fattening activity on terms of the analogy.

And it finds one truly old instance of the expression "Weighing a pig doesn't make it grow any faster"—from The Swine World (July 5, 1919), involving a story about a child in Iowa who told his father that he wanted to weigh his pig every day:

"Why," the father replied, "you can't do that for we haven't any scale. Anyway, weighing a pig doesn't make it grow any faster." But the boy insisted he was going to find a way to weigh that pig and do it right there at home. Finally his father said, "Well, I've got no objections to your weighing the pig, but there's no way to do it but to take the pig to town, and you can't do that. But go ahead, and if you can weigh your pig I'll furnish all the feed it eats this summer and not charge you a cent for it."
He had made a safe offer, for the only scale on the farm was a small kitchen balance that might weigh as much as fifteen pounds. But the boy didn't quit and the next day he weighed his pig. This is how he did it: First, he selected a strong piece of 2x4 and balanced it over a 2-inch plank in the barn-lot fence. Then he hung a box on each end of the 2x4 and balanced it carefully. Then he put the pig in one box and into the other box piled stones until it just lifted the pig's box on the other end. Then he took the old kitchen balance and, a few at a time, weighed out the stones, added up their total weight and he had the weight of his pig.
That perseverance won the summer's feed for his pig, but best of all he had done something worth while and done it by himself.

Somehow I doubt that the lesson that the education commentators want to draw from their invocation of the pig-weighing proverb has much to do with the moral of the 1919 story in The Swine World, which might be summarized as

"Weighing a pig doesn't make it grow any faster, but figuring out how to weigh it could win you free pig feed for the whole summer."
Comment: As Benjamin Franklin once said, "A wise saying gets 10 years older every time someone repeats it." Or was it Confucius?
Comment: That's a fine story, though, and a great example of scientific curiosity and reasoning. As another adage says: "Necessity is the mother of invention."
Comment: So is there an adage for "A clever adage is not always true"?
Answer: John Dewey told the story that New England farmers used a unique method of weighing the pig. They first tied the pig to a beam resting on a fulcrum and then piled rocks on the other end of the beam. When the beam was balanced they then tried to guess the weight of the rocks.
This story seems to have been corrupted, that weighing the pig does not make it any heavier.


How to comment previous answers in SO

Question: I have comments on answers to some questions but I see no GUI affordance to make my own comments. However, I can reply to comments in my own answers. Any level required to comment?
Comment: https://meta.stackexchange.com/questions/19756/how-do-comments-work?noredirect=1&lq=1 > "All users may comment on their own posts and any answers to their own questions.".
Answer: 50 reputation is required for adding comments (apart from comments to your own answers), see the FAQ.
PS: Such questions should be on meta.stackoverflow.com.

How to comment previous answers in SO


Is it better to use char or unsigned char array for storing raw data?

Question: When need to buffer in memory some raw data, for example from a stream, is it better to use an array of char or of unsigned char? I always used char but at work are saying it is better unsigned char and I don't know why.
Comment: if it's a string stream then it'd be OK to use `char` array. for other numerical (for example, hexadecimal, bits) raw data, it's best to use `unsigned` variables so that you don't have to deal with the sign bit
Answer: UPDATE: C++17 introduced std::byte, which is more suited to "raw" data buffers than using any manner of char.
For earlier C++ versions:

unsigned char emphasises that the data is not "just" text
if you've got what's effectively "byte" data from e.g. a compressed stream, a database table backup file, an executable image, a jpeg... then unsigned is appropriate for the binary-data connotation mentioned above

unsigned works better for some of the operations you might want to do on binary data, e.g. there are undefined and implementation defined behaviours for some bit operations on signed types, and unsigned values can be used directly as indices in arrays
you can't accidentally pass an unsigned char* to a function expecting char* and have it operated on as presumed text
in these situations it's usually more natural to think of the values as being in the range 0..255, after all - why should the "sign" bit have a different kind of significance to the other bits in the data?

if you're storing "raw data" that - at an application logic/design level happens to be 8-bit numeric data, then by all means choose either unsigned or explicitly signed char as appropriate to your needs
Answer: Internally, it is exactly the same: Each element is a byte. The difference is given when you operate with those values.
If your values range is [0,255] you should use unsigned char but if it is [-128,127] then you should use signed char.
Suppose you are use the first range (signed char), then you can perform the operation 100+100. Otherwise that operation will overflow and give you an unexpected value.
Depending on your compiler or machine type, char may be unsigned or signed by default:
Is char signed or unsigned by default?
Thus having char the ranges described for the cases above.
If you are using this buffer just to store binary data without operating with it, there is no difference between using char or unsigned char.
EDIT
Note that you can even change the default char for the same machine and compiler using compiler's flags:

-funsigned-char
  Let the type char be unsigned, like unsigned char.
Each kind of machine has a default for what char should be. It is either likeunsigned char by default or like signed char by default.
  Ideally, a portable program should always use signed char or unsigned char when it depends on the signedness of an object. But many
  programs have been written to use plain char and expect it to be
  signed, or expect it to be unsigned, depending on the machines they
  were written for. This option, and its inverse, let you make such a
  program work with the opposite default.
The type char is always a distinct type from each of signed char or unsigned char, even though its behavior is always just like one of
  those two.
Comment: "if it is [-127,127] use `char`." `char` might be unsigned too, if you need signedness, use `signed char`. "... give you a negative number." Maybe, maybe not, signed overflow is UB.
Comment: You assume `char` is signed. So the "range" and "overflow" parts are not necessarily true.
Comment: @BaummitAugen It is true but in that case OP should not expect to get the desired value.
Answer: As far as the structure of the buffer is concerned, there is no difference: in both cases you get an element size of one byte, mandated by the standard.
Perhaps the most important difference that you get is the behavior that you see when accessing the individual elements of the buffer, for example, for printing. With char you get implementation-defined signed or unsigned behavior; with unsigned char you always see unsigned behavior. This becomes important if you want to print the individual bytes of your "raw data" buffer.
Another good alternative for use for buffers is the exact-width integer uint8_t. It is guaranteed to have the same width as unsigned char, its name requires less typing, and it tells the reader that you are not intended to use the individual elements of the buffer as character-based information.
Answer: As @Pablo said in his answer, the key reason is that if you're doing arithmetic on the bytes, you'll get the 'right' answers if you declare the bytes as unsigned char: you want (in Pablo's example) 100 + 100 to add to 200; if you do that sum with signed char (which you might do by accident if char on your compiler is signed) there's no guarantee of that – you're asking for trouble.
Another important reason is that it can help document your code, if you're explicit about what datatypes are what.  It's useful to declare
typedef unsigned char byte

or even better
#include <stdint.h>
typedef uint8_t byte

Using byte thereafter makes it that little bit clearer what your program's intent is.  Depending on how paranoid your compiler is (-Wall is your friend), this might even cause a type warning if you give a byte* argument to a char* function argument, thus prompting you to think slightly more carefully about whether you're doing the right thing.
A 'character' is fundamentally a pretty different thing from a 'byte'.  C happens to blur the distinction (because at C's level, in a mostly ASCII world, the distinction doesn't matter in many cases).  This blurring isn't always helpful, but it's at least good intellectual hygiene to keep the difference clear in your head.
Answer: It is usually better to use char but it makes so little difference it does not matter. It's raw data so you should be simply passing it around as such rather than trying to work with it via char pointers of one type or another. Since char is the native data type it makes most sense to use this rather than imagining you are forcing your data into one type or another.
Answer: If you use unsigned char then it will take only valid ASCII characters as its range will become -127 to +127.
and you can find complete difference between char and unsigned char details in this question.
diff bet char and unsigned char
and you can see the table here.
ASCII table
complete tables of raw characters
Answer: If you are able to work with C++17 there is a std::byte type that is more appropriate for working with raw data. It only has bitwise logic operators defined for it.


Embbed an image in xml file

Question: I am exporting some data from my database in xml format.
The file exported has an extension as .xml and it is viewed as Excel file.
I want to insert an image in this xml file so that when we view it as Excel we will be able to see the image along with the data.
Whatever I have found from the internet is that there is no straight forward way to insert an image in xml file as xml file were designed for handling the data.
Can any one tell me what is the approach I will have to follow in order to obtain the desired functionality.
Comment: Related: how do you insert an XML file within an XML file?  Answer: not without grinding your teeth. (Probably involving base 64.)
Answer: xml files are text files, and you can embedd binary data if you encode it with Base64 algorithm.
But to view the image you will need to decode the Base64-string and pass the result binary data to an image viewer implementation.
It cannot be done in MS Excel. You will need to implement your own viewer.
Answer: You won't be able to view an image inside of an XML file unless you write a dedicated application for it that knows about your particular requirement.
The reason is that XML is character-based, but images are not - they are binary data. A way to embed your image nevertheless is to transform it to something character-based first. For example, you could Base64-encode your image first and embed the resulting string in your XML. But I suppose there is no way to tell Excel to interpret this data as an image right away.
Because embedding binary files into XML using Base64 is such a common idiom, XML Schema even has its own data type for this: base64Binary.

Embbed an image in xml file


Can anyone please recommend any good Load Testing software?

Question: Can anyone please recommend any good Load Testing software?
I have a website which updates scores every minute via ajax calls and need a load testing software which supports ajax calls (javascript) too!
Comment: Possible duplicate of http://stackoverflow.com/questions/530891/tools-for-ajax-load-testing
Answer: This is a pretty broad question that depends greatly on exactly what you want to test and how you define "good" software. Many people will say you can't load test AJAX based sites using HTTP-simulation tools. We do it every day, so I can tell you that isn't true. However, the difficulty of the task varies greatly depending on the testing software you choose and the complexity of the site and scenarios you are testing.
My recommendation is to pick a few tools within your price range and evaluate how well they work for your particular scenario. If they have good support, you should contact them with any difficulties. If they can't get you going in short order, move on to the next product.
(Disclaimer: I work for Web Performance - our Load Tester product handles most AJAX scenarios just fine - which may be why we're on the first google page for "ajax load testing").
Answer: Ajax is just an HTTP call, so you have many options.
I can recommend WebLOAD.
Works well with Ajax. The script is written in JavaScript, which is a plus.
Answer: Although I cant recommend an AJAX load testing utility I can however recommend an alternative to normal AJAX calls to me it sounds like what you need is APE (Ajax Push Engine).
So instead if your application spawn repeatedly contacting the server

Your App -> Do you have a message for me server?..
Server -> No..
repeat X 10 Ajax Calls until Server -> Yes!

What APE does it pushes the data/information directly to your users browser without
the application contacting the server. Think of it this way, the server "shouts" a message and your web apps then receive this message and interprets it. This concepts is known as long polling.
APE is pretty darn fast and not that difficult to implement.
Heres a link to the APE project - http://ape-project.org
Theres a few guys that have some excellent examples available on the Internet,
heres a link to an interesting one which uses APE to create an SMS gateway.
http://www.ifc0nfig.com/esenape-send-and-receive-sms-in-real-time-using-ape-jquery-php-and-libape_controller/
I hope this interests you.
Regards


HeapCreate vs GetProcessHeap

Question: I'm new to using Heap Allocation in C++.
I'm tryin to understand the scenario that will force someone to create a private heap instead of using the Process Heap. Isn't Process Heap generally enough for most of the cases?
Thanks
--Ashish
Answer: If you have a flurry of transient heap activity, using a private heap for that can be faster than churning on the process heap.  If you start a thread and give it a private heap, it can be thread-safe in those heap operation without needing to deal with locking for them. There are other reasons, but these two are relatively common ones.
Answer: It is an easy way of using a memory pool, which is useful especially on deallocation: Instead of tracking the lifetime of many small objects and deleting them one after another, create a seperate heap for them and destroy the entire heap when you're done.

HeapCreate vs GetProcessHeap


Distributed Transcations, DTCPING, How to set NetBIOS

Question: I'm the Microsoft Distributed Transaction Coordinator to write to two different databases on separate servers that are not on the same network. When I attempt to execute the code inside a C# TransactionScope, I get the following error:
"Communication with the underlying transaction manager has failed."
I'm using the DTCPing.exe tool to attempt to ping the remove server to see why I get this error.
However, I'm being told I need to only using the NetBIOS name of the remote computer instead of its IP address.  However, I'm not sure how to accomplish this, given that my two machines are on separate networks.
NOTE - I've also temporarily disabled the windows firewall on both machines.
Answer: I might be wrong, but I believe you just add an entry to your hosts file.
http://technet.microsoft.com/en-us/library/cc751132.aspx


Event Listeners in Chrome with Jquery

Question: I am using "Event Listeners" to check the event attached to my DOM object. However, when the event is attached using jQuery, all I see is jquery-1.8.3.min.js, is there any ways to work this around?
Answer: Add jQuery and Chrome extensions to the framework blackbox in developer tools settings.
Chrome Developer Tools > Settings (F1) > General > Manage framework blackboxing...
Check the Blackbox content scripts to disable breaking points on Chrome extensions, and add /.*jquery.*\.js$ to the URI patterns that should be blackboxed.
Now in the Sources tab in the developer tools open Event Listener Breakpoints list on the right, and check the event you want to break the script at, this will stop the script execution on the script you've written to attach the event using jQuery.
Another quick way to blackbox a library is by right clicking its name in the Call Stack in the Sources tab.  It will show up when you add an event listener break point.
Answer: When you use jQuery to attach event handlers, then a jQuery function is the one that is actually attached as the event handler (it then calls your event handler function when the event occurs).  So, if you look in a generic debugger, that's what it is going to tell you and that's what you see.
To the debugger, jQuery is just javascript and it's showing you what javascript has attached the event handler.  There is no way to make the debugger show you something different for jQuery event handlers.
The jQuery library itself has ways to programmatically query what jQuery event handlers are attached to a given object.  How to do this varies by jQuery version, but you see generally how it works here: Can I find events bound on an element with jQuery?

Event Listeners in Chrome with Jquery


Usb Speaker with External Power supply? S ll

Question: I'm using a 2x3W yenkee usb speaker with my phone through an usb otg cable and it's working fine, but when I turn the volume up the speaker turns off.I assume it's because of the high power consumption, because if I plug it into my pc it works even when i turn it all the way up. I was wondering whether an external charger would solve the problem, that way I could plug the usb into the charger and the jack into my phone.I'm not sure though if it works. Do you think it's a viable solution?
Comment: Does the speaker have it's own battery?
Comment: Yes, please try to charge the speaker while you turn the volume up and see if it still plays music. Then it means the speakers require more power which the mobile couldn't provide. And this may affect your battery in the long run.
Answer: Okay, so I tried to power it with pluging it into a common charger and I'm happy to say it worked and didn't cut out .Considering the external charger use the same method to give power it really should work. Although I haven't had the chance to try it yet but I'll definitely grab one so i could max out my speakers volume anywhere I am.
Adam


Is there a website for academic physics jobs in the US like mathjobs.org?

Question: I am in math, and we usually apply to most academic jobs (in the US) through a generic application at mathjobs.org. Is there an equivalent in physics?
Answer: In particle/nuclear physics there is http://inspirehep.net/collection/Jobs
More generally, many (but definitely not all) physics jobs are announced on http://academicjobsonline.org.
Answer: I am not aware of any physics-wide collection of jobs. The closest thing I know of is the HEP (particle physics) rumor mills, where jobs are linked and results are posted.
Theory:
http://particle.physics.ucdavis.edu/rumor/doku.php?id=current
Experiment:
https://sites.google.com/site/hepexrumor/


How would Gauss' Law hold in non-uniform electric fields?

Question: Let's say we consider an electric field in a vacuum where the fields lines are parallel but the fields strength varies with distance, and then consider a cube in this space as our Gaussian surface. Since the field strength varies at the 2 opposing faces of the cube where the field lines can contribute to the flux, the flux through the cube must be non-zero. But Gauss's dictates that for non-zero flux, the surface must contain charges within it. How is this possible in this case?
Answer: The electric field configuration you describe is not possible.
For a loose explanation, try to visualize the field lines you're describing.  The strength of the electric field is related to the density of the field lines, so in your picture, the field lines must get closer together or further apart - but how could they do this if they are parallel?
If you understand and accept that positive/negative charges are the only local sources/sinks of the electric field (i.e. field lines can only "start" on positive charges and "terminate" on negative charges), then Gauss' law follows as a mathematical theorem.
If you don't accept that as a premise, then all I can tell you is that it is supported by a mindblowingly vast mountain of evidence, and that it is on as solid a scientific footing as it's possible to have.
Answer:
Consider an electric field in a vacuum where the fields lines are parallel but the fields strength varies with distance.

No such field exists.
You're talking about $\vec E=E_z(z)\hat z$. Its divergence is nonzero, unless $E_z(z)$ is a constant, and you said it isn't. But a nonzero divergence implies that there is a nonzero charge density in that "vacuum", which is a contradiction.
Answer: I support @J Murray answer. The strength of an electric field in a region of space is associated with the density of the field lines in the region. The lines themselves with arrows indicate the direction of the field in the region. It is impossible to have lines that are both parallel and of varying density. A field represented by parallel lines has to be uniform.
Hope this helps


Need help with manipulating center points!

Question: I have an object which is formed of different layers of mesh. I want to show it open up , with smooth animation, and then close again. I have tried what some people suggested on here before, which was to use manipulate center points and scale. However i get a little problem with this, which you can see in the image. If anyone knows how to fix this, i'd be really happy :)
Comment: As @R00t suggested, it's hard to help without the .blend. If you can, can you upload it using blend-exchange.giantcowfilms.com and edit your question with the link? Thanks!
Comment: hard to know without a `.blend` file , try apply the scale and location (in object mode , select an object and `ctrl`+`A`), also see if the origin is in the right place (with an object selected , object->transform->origin to geometry). if you want planes with the same offset , add one plane and apply an array modifier and separate them by loose parts.
Answer: Driver controls Delta Transformation Location X value

The red object location relative the to yellow object location controls the final locations of the blue planes via a driver.  The red object is useful for the Blender python script driver described below.
A red delta mesh object controls the Blender Object [Delta Transformation] Location X value of the two flanking light and dark blue planes relative to the yellow middle plane.  A Delta Transformation Location value is added to the regular Location value to see a final location on the screen.  Simple Addition.  A python script driver allows us to use the distance between the red cube and yellow plane to offset the blue flanking planes.  The red cube can be animated. Multiple locations for the the red cube and controlled movements of flanking planes are shown in the animated .gif file above.

Many of the images below are composed from multiple Blender screen captures to reduce time, produce single size images.  Keep that in mind when inspecting the images.  Click on images below for larger version and to read the text.
Flanking planes final placement is controlled by red object. Outliner windows shows objects involved. Composed image above emphasized by black divider.

Flanking Planes left and right.  The tool tip on the Delta Transform X Location show a simple python formula.  The purple coloring of the value and the tool tip indicate a python script driver is used.  Add Single Driver was selected  from value pop-up menu.

The driver windows show the driver values for the moving planes.  The arrows indicate the Graph Window and the Editing context. A Composed image to compare formulas .... emphasized with black areas.  Click image to see larger view.
You must select one plane and add a driver.  Then you must select the second place and add a driver.
The two simple names and text formulas you must type into the respective windows below and are visible in the screen capture as well.
(delta - middle) ... and ... -(delta-middle)
All other values come from the menus.
Simplified sequence of steps.  Inspect and Improve.
This proposed answer is not a tutorial for beginners.
Please search [Blender Driver Tutorials] and you will find many matches for free on the famous video website.  If you need a tutorial see a video tutorial, this is an efficient use of time.  Many videos will show you how to create a driver in general.
A recent video on Blender Driver Tutorials on a video website will provide a better visual tutorial.  The video will not have the simple formulas stated below. Video tutorials often work better than text tutorials for Blender.  Recommended for people who state they are beginners.   You can even search here at BSE with the keywords provided.  I am sure I and many others here at BSE learned about drivers by searching on the very famous video website. This is not intended as a tutorial on drivers in general.  This site has claimed not to be about tutorials.
The 4 objects placement is indicated above. Red cube is controller. 3 planes have initial separation.  Select a flanking blue plane.  Locate and Know the Delta Transformation values are listed below the regular Transformation values.  I am using the X location for this example.  Mouse over Delta Transformation X value, alternative mouse click brings up the menu indicated above.
Add Single Driver.  Purple indicator appears.
Create a new window or reuse window. Change to Graph Window.  Select [Drivers] editing context.  Make driver info appear by click the + sign faintly visible on the right side of window if necessary.  Add variables and create your variables to match the values in the screen captures above.  Note the object names I use may not be the same as your object names.  Thus use the object names in this proposed answer or translate with awareness.
The red cube need not be rendered.
Make sure  User Preferences allows scripts to be executed  ... if a related error message appears.
Comment: hmm this is a bit confusing, the interface looks different to me. Can you explain it in step by step, a more noob friendly example please :)
Comment: Now you must take time to understand the above. Its not trivial but it is worthwhile. Take a few minutes to reflect.  Be adventurous.  Once you have practiced ... all the driver window activity will be 20 minutes or less.  Eventually 8 minutes with practice. Every Blender use can change the colors and and window layouts.
Comment: sorry but this didn't help me. thanks for your time. im sure it will help someone else who wants to read it
Answer: Copy Location Constraint

For certain cases a
[Copy Location] constraint
may work.  In the settings above note that the X axis is used, offset used, and one object has invert specified since the objects move in opposite directions.  For the current settings we rely on the red DeltaObject being a Location X = 0 for rest position.
Note the image above contains two screen captures.  You can read which object is selected on the left and differently on the right sides.  The highlight is often difficult to see.

Click to see larger image.


Examples of firms using attachment bias

Question: Are there any nice examples of firms using attachment bias to increase profits? Examples from the academic literature or well-motivated anecdotes are both acceptable. For instance, pet stores seem to let you play with the animals and GM used to have 24 hour test drives for some of their cars. However, both of these examples are also consistent with a match quality that takes some time to learn, rather than mere attachment bias.
Answer: The field of performance marketing makes ample use of attachment bias.
For example, skiers often purchase race-level ski boots and skis which are too stiff relative to their ability, so the product is actually detrimental to performance.
In this case, self-attachment bias causes buyers to overestimate their own ability.
The ski manufacturers know this and market and price the stiffness of this equipment at a premium even though it is not objectively helpful for the vast majority of consumers.
In pharmaceuticals, attachment bias to familiar medications like Tylenol cause consumers to pay premiums for this medicine even while knowing that the generics next to it on the shelves contain exactly the same active ingredients and are often made by the same manufacturers.  Here, attachment bias to a familiar product causes allows manufacturers to pay a premium, and the manufacturers tune marketing messages to amplify the attachment bias ("Tylenol, what matters most", "Advil, the original round tablet).

Examples of firms using attachment bias


What rules are tested during the Wisconsin Card Sorting Task?

Question: I was reading about the Wisconsin Card Sorting Test and although I understand the concept, I'm not clear on what rules are usually tested. Does it always vary between associations between shape, colour and number? For example, let's say I have a card with two red circles. Are the only possible matches to this card something with two shapes on it, red shapes on it or circles on it? Are more complex rules, such as the number of shapes + 1 or circles associate to green also tested?
Answer: If you read between the lines of Evaluation of a Short-Form of the Berg Card Sorting Test, you can find that indeed the only rules tested are the simple colour, number and shape matching. This can be identified by either looking at the source code attached to the paper or looking at the sample result table.
Update:
See also this paper.
Answer: There is a good explanation here.
This is not a test of IQ or something similar. It is more complex test of ability to find rules and follow from very limited feedback, rules that are changing in time and might be counter-intuitive.
WCST is about sequential learning, adaptivity, and memory. Rules usually are as simple as "same color" or "same shapes".
Comment: This is what I've concluded as well after going through a few papers, however I can't find a canonical definition. Even the one you linked to (which I've read before, but is still helpful to link to here) seems a little vague for my taste.
Comment: finding original paper should help. It seems that since PC era started, researchers use standard software and never disclose (or even make a reference) exact protocol.


Import RSS into iCal

Question: I have an online calendar in an RSS-format. Is is possible to import it into iCal and will it be kept synced automatically?
An example of such a calendar is: RSS-Calendar
Answer: Generally speaking Calendar supports CalDAV and Exchange calendars. I am not certain what an "rss-calendar" is but if it can be converted to or supports CalDAV or Exchange calendar formats you are golden.
I have not had to import a or subscribe to a calendar in quite a while so Calendar in the last couple of versions of Mac O/S may have some new supported formats. You may want to try just pointing Calendar to the URL of your "rss-calendar" and see what happens.
The other possibility is if you can export an ICAL compatible file that can then be imported into Calendar. It's not automatic syncing but it may be better than nothing.
Comment: Please see my updated question for an exampe.
Comment: Calendar in Yosemite does not support that format
Answer: As you can see from the example you provided, RSS feeds are not meant for calendars. Instead, they are meant for use with an RSS reader (like Safari) that will display, in your example, dates in text format and provide a "Read more..." link that will direct you to the website.
Unfortunately, there's not much you can do, because even converting the RSS feed for use with a calendar would mean you need to convert it every time the feed updates.

Import RSS into iCal


Bypass SuperSpeed USB3.1 lines around USB2.0 Hub

Question: I found this document online, which shows an interesting USB routing topology that I have not seen before.  The 4x superspeed lines go straight from the USB3 connector to the SuperSpeed IC, but the USB2.0 lines go off to a USB2.0 hub, where one of the down stream ports connects back up to the SuperSpeed IC.  I can't find any other examples of this online... is this allowed?  I would have probably just designed in a USB3.1 SuperSpeed hub, and not split the signal lines off.
Comment: Clearly it works. Seems quite useful.
Answer: This design uses one USB 2.0 channel for the high-speed data channel of USB 3.0 and another for FT2232 for jtag/uart/spi for programming and debugging.
Traditionally FT2232 is usually connected a independent USB 2.0 port, but this design multiplexes it into the main USB port using a USB 2.0 Hub IC.
Super-speed channel is not split because FT2232 is a full-speed chip and can not make use of the super speed channel.

But in the proposed FPGA host interface scheme,
  instead of connecting the USB 2.0 signals (D+/D-) directly to the
  upstream connector, a USB hub (USB2422 – A 2-  Port USB 2.0 Hi-Speed
  Hub Controller from Microchip Technologies) is inserted in between.
  This allows the USB2.0 bus available on USB C connector to be shared
  between FT601 and the FT2232H USB 2.0 FIFO bridge acting as the
  sideband processor (See figure 3   below).    In this scheme, the SPI
  signals available on FT2232H Bus A are connected to the SPI bus used
  for FPGA configuration. A General Purpose IO on this bus is also
  connected to PROG_B of the FPGA to allow the host to reset the FPGA.
  Optionally,  additionally available General Purpose IOs on FT2232H can
  be used to monitor the FPGA configuration progress by observing the
  DONE signal.

This solution works because the high/full/low-speed channel and super-speed channel work independently and not simultaneously on one endpoint, so the FT601 chip either sees itself directly connected to the super-speed channel, or to the high/full/low-speed channel via a hub. One more hoop in the high/full/low-speed channel than the super-speed channel is not an issue.
Answer: USB3 endpoints (upstream-facing ports) are allowed to have only standard (LS/FS/HS), only SuperSpeed, and of course, both.
USB3 downstream-facing ports must support standard and SuperSpeed, or standard only, but not SuperSpeed only. This is to allow backwards compatibility with legacy LS/FS/HS devices.
Further, you can't 'split' a USB3 downstream facing port into two endpoints, one SuperSpeed and one standard. It is only allowed to negotiate a connection to one device. To split it, a hub is required.
Comment: Can you clarify your last point?  It sounds like you are saying this shouldn't work.
Comment: It's not an allowed topology under USB3 rules. It will not do the negotiating with USB3 correctly. It would work only with USB2.


Thermal Pad Size CPU/Heatsink

Question: If using a 2mm thick thermal pad to connect the CPU to the heatsink, does the size of the pad matter? Should it be cut to the size of just the metal piece in the middle of the CPU (10mm x 10mm) or does it need to be sized for the entire CPU (25mm x 25mm) (i.e. including the green bit).
Answer: It would just be for the metal areas.

Follow these guidelines to install a heatsink on a processor, using a thermal pad as the thermal
interface material. Thermal pads should be used with AMD Athlon MP, AMD Athlon XP and
AMD Duron processors only. These processors are lidless, that is, the processor die comes into
direct contact with the heatsink.

Verify that the heatsink has a thermal pad attached. If the heatsink does not have a thermal pad attached, locate the area of the heatsink that will directly contact the processor, and apply the thermal pad to this area only.
2. Remove the protective film(s) from the thermal pad.
3. Mount the heatsink onto the processor.

Always follow the AMD-recommended procedures to install a heatsink onto a processor to
avoid damaging the processor or motherboard. See the Socket A AMD Processor and Heatsink
Installation Guide, order# 23986
Do not re-use thermal pads. Before re-using the heatsink remove the thermal interface material
and reapply a new thermal pad.

I highly suggest using thermal paste for capped processors though, it provides better conduction and paste life. This research paper from AMD has good instructions for both methods, as well as advantages and disadvantages.
Comment: Given that thermal pads don't technically 'stick' to a component like thermal paste does, that would imply that the CPU can be changed without changing the thermal pad yes? Assuming stick side of the pad is stuck to the heatsink.
Comment: You need to put down a new pad with each CPU change.  Phase-change thermal pads melt when the CPU is in use.  Over time, it tends to stick to the CPU and the heatsink.  I did a research project with thermal interface material, and I could never get a CPU off without breaking the phase-change pad.
Answer: I would personally recommend using thermal paste, two of my favourites are:

Arctic Cooling MX-2
Arctic Silver 5

Using a small blob smoothen it out with a cut piece of card and make the application a thin layer over the processer lid, there should be just enough that it covers an even film across.
Thermal Pads provide a thick layer increasing heat and are only recommended for components like Memory
Comment: This application is for an embedded PC where the processor's heatsink is a solid internal extrusion of the outer casing (alluminium). We are using a think thermal pad to absorb any minor pressure or vibration that might be exhibited from the casing.
Comment: @ Nicholas, Thermal pads are used by the PC industry for ease of assembly, low risk of an improper assembly, that being said "thermal paste" is the way to go when doing your own work on the heatsink.
Answer: Most of the heat will be coming from the metal section, but I'd cut the pad for the full size of the CPU package.  The larger the heat transfer area the more heat you'll get out.
Comment: My concern is that if the pad conducts heat, it will do so evenly over the entire pad area. Meaning that a larger pad would spread the heat evenly across the whole chip. Whereas a smaller pad would only duct the heat from the metal section and not spread the heat to the green section.

Thermal Pad Size CPU/Heatsink


Is it possible to use Raspberry PI for contactless payments?

Question: It's very easy to read some data from contactless credit cards (PayPass/VisaWave-enabled) like card number with NFC/RFID Shiled for Raspberry PI and i'm just wondering, if it's possible to use Raspberry PI as a EMV contactless payment terminal?
Answer: Even if it is technically possible to read info from the card and to start a transaction with the related back-end, I think it will be really hard for a solution to be EMV or PCI compliant (or more importantly legal).
In countries, there have to be a regulatory authority who gives permission or license to solutions which will be used in payment processes. Without the permission/license, a solution cannot be used in payment processes.
These authorities have strict specifications/conditions. EMV or PCI standards are included in their minimal set.
Answer: Assuming you can read/write from/to a contactless card using something like the PN532 NFC Breakout Board, then you could certify your EMV kernel with EMVco. To achieve this certification takes time and money.
Time: to build the EMV Kernel, which is basically a binary that talks to your hardware from one side, and talks to the card issuer on the other side (sort of a bridge with a bit of logic in it).
Money: Certifying your EMV kernel means a bunch of people are going to have to test it and inspect it, and once they approve your binary it is done for a specific hash which means if you changed your code and recompiled your binary, it will have to be re-certified which will again cost you dearly (it's not cheap!).
However once you have your EMV kernel certified you should be good to go!
My personal opinion is that EMV is a failure because of how overly complex it is (and how costly it is to implement as a result), and that before it gains industry wide penetration it will be superseded by a better framework/standard that are easier to understand and implement, come with plenty of reference implementations to copy from, and are easier to certify (freely accessible automated test tools).


Best protection against a "chosen-ciphertext" attack?

Question: What is the best protection against a "chosen-ciphertext" attack when transmitting (=streaming) secured (=crypted) data via networks using the TCP protocol?
Answer: Firstly, a little crypto background. I'll provide you with links and you can decide how far you read.
The key to avoiding CCA/CCA2 (Chosen ciphertext attacks) is to not provide an "oracle" (something the attacker can query either in a limited fashion or at will). In terms of practical implementations of such oracles, replying to encrypted email messages with the stuff you previously decrypted is an example of providing an oracle - whatever ciphertext went in has been decrypted and provided to the attacker. , a m
The key is to not provide that oracle, to which there are two solutions. One is to encrypt-then-mac - i.e. use a pre-shared secret to produce a message authentication code which the recipient can check before decrypting. That way, if the ciphertext is not from the sender, you reject it. An alternative to this is to use an authenticated encryption mode, a complete, integrated approach (it combines your block cipher with a MAC).
So the approach to solve the CCA/CCA-2 problem is to use some kind of authentication of your messages.
What can you do now? Read about the protocols your ciphers use and ensure they use something like EAX, or a MAC.
Answer: First off, don't design your own cryptographic protocol!  Please don't be offended, but: if you have to ask this kind of question, you are not qualified to design cryptography.  (Frankly, even I would try to avoid designing a cryptographic protocol, even though I am qualified.)
I know some other answers have suggested you go learn about IND-CCA2 and authenticated encryption and encrypt-then-mac and digital signatures and checksums and stuff like that, and then (presumably) go implement your own crypto.  Personally, I think that's a bad idea.  There are many opportunities to screw something up, so I think that's a dangerous approach.  Fortunately, it is not necessary to design your own crypto -- there are good schemes out there that have been vetted carefully by many experts, over a period of years.  You can just re-use them.
Therefore, instead of trying to design your own crypto, I strongly recommend you try hard to reuse some existing, well-vetted scheme.  For communication security, I recommend TLS.  For protecting stored data, I recommend GPG with signed, encrypted messages (or other software that supports the OpenPGP format).  This way, you don't even need to know how to protect against chosen-ciphertext attacks; you just need to do know that TLS and GPG already protect against them for you.
Isn't it great?  You get both strong security, and you don't have to do any hard lifting yourself; someone else has already done all the hard work.  It's a win-win all around!
Comment: I never said I was going to write my own protocol. So, to keep is short: your answer does not fit my question... at all! Besides, asking a question does NOT indicate a person's knowledge level. I've given birth to a streaming crypto that's been implemented on military level and still is actively used. Yet, that doesn't mean that I am "up-to-date" on every kind of attack. FYI: That's where the question initially came from. So I'll have to give you a "no" on your answer. Isn't that a downer? Next time, try to read and understand the question before posting a useless Sunday-school answer. Thanks.
Comment: @e-sushi, it sounds like you were offended by my answer.  I'm sorry to hear that, and invite you to flag my answer for a moderator if you consider it inappropriate.  However, my technical advice stands: I continue to believe it is the best advice that provides the maximum likelihood of security (even if you have experience designing cryptosystems; like I said, I would follow the same advice myself).
Comment: I can only repeat: your answer does not fit my question. That's all. Remember: this is not a discussion forum!
Answer: First of all, it's worth to analyze whether this relatively difficult attack is indeed a risk or threat for your system and specific setup.  If you could provide a bit more details, it would be easier to give an advice in this respect.
In general, the best protection against the chosen-ciphertext attack is to make impossible for an attacker to both
1) insert encrypted pieces of data, especially large amounts of them and
2) review the decrypted versions of the data they inserted.
Transmission of the encrypted data over SSL could help to prevent insertion of the data in the stream since it would guard against man-in-the-middle attack.  Another defense is to detect invalidly encrypted message (for example, with checksums or digital signatures) and in case of checksum validation or decryption failure, avoid providing to the attacker the decrypted version of the data - this way even if the attacker manages to insert ciphertext, he would not be able to use your application as a "decrypting oracle".
Comment: Thanks for the reply. I know that from a risk-analysis point of view, it's probably never going to happen. But you know what they say: "never say never" when it comes to security. Again, thanks! ;)


Emit event in view function or

Question: Is it possible to emit event in view function (via event or logi)? Or is it possible to return value to javascript without(before) mining in a transaction function? My aim is to avoid wait due to mining with event logging.
Answer: Q1: An event is a state change. It's not possible to emit them from view or pure functions, or constant in the old syntax.
Q2: It is not possible to get response values from a signed transaction. You will always get a transaction receipt.
The patterns take some getting used to. I'm a big believer in emitting auditable event logs for every important state change. When transactions are mined, the pertinent information arrives with the confirmation as event log arguments. Those are for off-chain clients.
The return values or still important. They are the response values if the function is called from another function or contract.
For example:
bool result = myOtherContract.insertSomething(); // expecting "true"/success
If that's important to a client, something like:
emit LogResult(msg.sender, result);
Hope it helps.
Answer:
Is it possible to emit event in view function (via event or logi)?

Since event logs are stored in transaction receipts, I do not believe it is possible to emit an event within a view function since no transaction occurs.

Or is it possible to return value to javascript without(before) mining in a transaction function?

I don't think this is possible either.  The return value from a function which creates a transaction will be the transaction receipt. Within the receipt, you can find any events which were emitted within that function.
Comment: But receipt will require mining of the block and thus, we need to wait. I am writing a time critical function with logs.
Comment: You can execute the function locally using Call in web3. I think the second part of your answer is not correct. See my answer below.
Comment: From what I observed, transaction submission returns transaction hash and transaction confirmation returns transaction receipt with emitted event details.
Answer: The first question, It is not possible because the event modifies the state. In Remix you will see a warning for doing this.
The second question. You can execute the functions locally without sending a transaction to the network using Call, it will not consume gas and will be executed immediately.
However, if what you are aiming at is to get transaction made by users of your system before the transactions are mined, this is not possible.
Hope this helps

Emit event in view function or


Does Fermat's Principle of Least Time imply that he believed light moved at a finite speed?

Question: And if so, how did he imagine that light moved at different speeds in different media?
Comment: This might get "close" votes removed if you reworded as "Did Fermat believe lightspeed is finite as one of the axioms in developing his Principle..."
Answer: Yes, Fermat believed that the speed of light was finite, initially in reaction to the muddle created by Descartes, who wanted to have it both ways, the speed being infinite, yet different in different media, see Nahin, When Least Is Best, p. 107:

"When Fermat read La Dioptrique he was unimpressed and, as mentioned
earlier, was blunt in his criticism. He wrote, in part, "of all the
infinite ways [to analyze the motion of light] the author [Descartes]
has taken only that one which serves him for his conclusion; he has
thereby accommodated his means to his end, and we know as little
about the subject as we did before."... Further, Fermat rejected as
nonsense Descartes' assertion of the infinite speed of light and his
subsequent illogical argument that light travels faster (than infinity?)
in water than in air. Fermat's position was that light traveled at
a (very fast) finite speed in air, and that it was slowed when traveling
through a denser ("more resistive") medium such as water."

But the order of causation was reversed. Fermat first decided that light traveled at finite speed, and only later came to the least time principle, when he learned that the Snell's law was experimentally confirmed:

"Fermat initially believed that, since Descartes' derivation was
clearly (to Fermat) built on sand, then the "ratio of sines is a constant"
result must be incorrect. Eventually Fermat learned that the
formula was, in fact, generally accepted as true because it could be
verified by direct experiment! This greatly puzzled Fermat; how had
Descartes managed to derive the correct law of refraction from erroneous
arguments?... With Fermat's subsequent great discovery of
the "principle of least time" (discussed later in this chapter) his quest
ended in 1658 with success... Fermat's solution to finding a physically correct derivation of Snell's
law of refraction was the result of developing a generalization of
Heron's derivation of the reflection law."
Comment: @releseabe - at the time, most everyone was a bit of this, that, and the other.
Comment: i note that Fermat is called a mathematician and lawyer in his wikipedia bio. Surely he was also a physicist.
Comment: @JonCuster: Yes, if u look at the Math or Physics genealogy project, and you go back to the 18th century, some ancestors had unusual backgrounds -- one studied reptiles iirc. But I about Fermat, most people think of him only as  number theorist while he clearly was a physicist also.


Emulate hard disk in .NET

Question: Is there a way to emulate a disk drive in .NET, intercepting read/write/lock operations?
I would like to create something with a front-end similar to GMail Drive in C#.
Thanks,
Tom
Answer: On Linux you can use the Mono.Fuse API (http://www.jprl.com/Projects/mono-fuse.html) to implement .NET-based file systems with user-land code.
Answer: You could see how http://www.truecrypt.org/ is doing it. It's doing exactly that either by using files or by using a drive or a partition. And then it mounts the file as if it were a real drive. Now, probably that the source code is a bit complex ;)
Answer: I use the Eldos Callback File System myself for this purpose, but although it's good, it's not exactly cheap.
There are some free/cheap projects as well, and I'm sure one of them was mentioned in a similar question on SO recently -- can't find it anymore at the moment, though. Stability tends to be a major issue, though, as layered Windows file system drivers aren't trivial.
Answer: Not really, .Net sits on top of OS functionality like disk access to give you things like managed file accessors.You could write all of it in managed C#, but you'd need unmanaged calls to make the OS treat it like another drive.
All the shell extension stuff is COM: http://msdn.microsoft.com/en-us/library/cc147467(VS.85).aspx
You could, however, write a .Net desktop app that allowed drag-drop from explorer and that looked like a file system view.
Answer: You could also use EZNamespaceExtension for .NET. This gives you integration with Windows Explorer. Not too expensive given that the license is per developer and not distribution.
Update
Big problem with EZNamespaceExtension.NET. It hasn't been updated for a long time. LogicNP seems to have lost their interest in EZNamespaceExtension.NET because there hasn't been a release with new a handful of features since 2010. No .NET 4 support and no support for Windows 8 ribbon toolbar
Answer: I've just checkout EZNamespaceExtension for .NET with the above link. It seem that they keep up to date as release 2013 version. But not sure that can answer the question of Showing as a Drive in Explorer.exe (AFAIK. it can't show as drive letter)

Emulate hard disk in .NET


How to limit visible hours in new Google Calendar

Question: Until Google forced the new calendar on users, I was able to hide selected morning/night hours using a Labs feature. Is there any way to do the same in the new version, either through the calendar itself (preferable), a browser extension, CSS sheet, or another method?
Answer: With the new (ca. 2017) Google Calendar, there is not a way to limit the number of visible hours. If that's a feature you think is missing, use the "feedback" tool to let them know. Otherwise, you'll need to seek out some third-party tool to do it for you, if such a thing exists.
Answer: Since no one wanted to provide an actual solution, and somehow the standard Google response got accepted as the answer, this extension will allow you to change the working hours of Google Calendar, and more. This will work for the Material redesign of GCal.
https://chrome.google.com/webstore/detail/google-calendar-plus/mjelhipeelammmhpghkpigkdonihkakj
Comment: This needs access to read, and change data on accounts.google.com, and read browsing history. The other extension listed here doesn't, but it only works on weekly view.
Comment: So far as I can see, this extension can reduce the number of hours displayed, but it doesn't expand the calendar to fill the page.  :(  You just end up with more white space at the bottom.
Comment: both this extension and tone below Google Calendar Plus, work well
Answer: There is a browser extension, Google Calendar Plus, maintained for Chrome that does this well.
Opening the GCalPlus options via the puzzle icon you see, e.g.:

At the bottom you will see the X am to Y pm option which limits visibility on the hours.
Answer: Google allows G Suite users to set "Working Hours" From General settings. However, normal GMail users do not have this same functionality. I've tried the extensions above and they do not see to be effective - all they do is force the "Collapsable Day" function that hides the hours when your browser window size is reduced. It isn't worth the unnecessary extension that can hide malicious behavior.
The best answer is to adapt to the current software structure and provide feedback to Google via the feedback form. This is what leads to UI development and updates.
Comment: The "working hours" doesn't seem to have any relationship to the question asked.  It doesn't affect what hours are displayed.  :(
Comment: This no longer appears to have any effect on the hours displayed, if it once did.
Comment: In my experience with Google Workspace, adjusting the working hours changes what hours are displayed first which may be a solution to "hide selected morning/night hours" from the original question.
Answer: There is a Google Chrome extension which hides the morning section of the calendar, essentially doing what you ask.
https://chrome.google.com/webstore/detail/hide-morning-in-calendar/oaikandahkibeihnampagmegnpfefhca/related?hl=en


How to overcome Blind SQL Injection

Question: I know that SQL Injection can be sanitized by using
mysql_real_escape_string();

but how to Sanitize Blind SQL Injection and how is it different from normal sql injection.
Comment: Blind SQL injection is sanitized the exact same way as SQL injection... the only different thing about Blind SQL injection is that SQL syntax errors are not shown; a generic message is shown instead.
Answer: Blind SQL injection and "normal" SQL injection are both SQL injections, i.e. the attacker is able to modify the SQL statement sent to the database. The only difference is that with blind SQL injection the attacker does not see any obvious result (i.e. data returned by the database) but can only deduct from timing, error messages or similar what happened in the database. See OWASP for more information.
Because the cause of both blind SQL injection and "normal" SQL injection is the same the prevention is too, i.e. make sure that the attacker cannot modify the SQL in a malicious way. The preferred way to do this is parameter binding and not escaping (i.e. mysql_real_escape_string). For more information how to do it right see Bobby Tables: A guide to preventing SQL injection which both describes the problems and has also solutions in various languages like for PHP.
Answer: Using parametrized queries!
http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
http://php.net/manual/en/pdo.prepared-statements.php
That way you also don't - always - have to worry about escaping everything always each time, in each query.
Also I'd like to mention that mysql_real_escape_string(); is outdated.
mysqli_real_escape_string();

Is the current supported version.

How to overcome Blind SQL Injection


How to export sqlite into CSV using RSqlite?

Question: How to export sqlite into CSV using RSqlite?
I am asking because I am not familiar with database files, so I want to convert it using R.
It may be very simple, but I haven't figure out.
Answer: not quite sure if you have figured this out. I am not quite sure how to do it within R either but it seems pretty simple to export to csv using SQLite itself, or by writing out csv from the database you have loaded to R.
In SQLite, you can do something like this at your command prompt
<code>>.mode csv
>.export output.csv
>.header on
>select * from table_name;
>.exit
</code>
SQLite will automatically wrote out your table to a output.csv file
Answer: If the table is not too large, you can first export it into an data frame or matrix in R using the dbGetQuery or the dbSendQuery and fetch commands. Then, you can write that data frame as a .csv file.
<code>my.data.frame <- dbGetQuery(My_conn, "SELECT * FROM My_Table")
write.csv(my.data.frame, file = "MyFileName.csv", ...)
</code>


uniqueidentifier in Sql Server database - how to generate in Java environment?

Question: I have a database table that uses Sql Server 2005's uniqueidentifier column.
I know how to create GUIDs in C#...
<code>string newid = System.Guid.NewGuid().ToString();
</code>
However, the application that is inserting into this database is running Java.
Is there a way to generate Sql-Server-compatible GUIDs using Java code?
(NOTE: generating the GUIDs on the Sql Server side is not an option in this case)
Is this - http://johannburkard.de/software/uuid/ - equivalent to the C# version?
Answer: Why not simply use the built in class java.util.UUID, assuming you are using at least Java 1.5
Answer: The code you linked ought to work fine. For kicks, here's another implementation with some good documentation to boot. http://jug.safehaus.org/Home
GUID's are a pretty well defined phenomenon, typically involving a unique machine identifier and the current time and then a bunch of randomness. Anybody who has taken the time to write a GUID library ought to have spent enough time on it to be much better at it than you or I are, so using a library is the right choice. The code I linked has a bunch of links to the IETF specs etc, so I think that's a pretty good sign that they did their due diligence.
See http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt


What is critical section in threading?

Question: Please can some one briefly tell me with example what does the means of critical section? in simple language
Comment: Possible Dupe: http://stackoverflow.com/questions/419145/python-threads-critical-section
Comment: Please don't LMGTFY, it's rude.
Answer: A critical section is a section of code that needs to be executed without outside interference  - i.e. without another thread potentially affecting/being affected by "intermediate" states within the section.
For instance, a reservation system might have a critical section when reserving something in that it needs to both check to see if the item is available and then mark it as no longer available, without some other attempt at reserving the room changing that status in the middle.
Thus, the critical section of a piece of code is a place where only one thread of execution is allowed to be at a time, to prevent things like race conditions.
Answer: A critical section is a section of code where if more than one thread was to be doing it an the same time, they could interfere with each other is such a way as to cause an incorrect result or other malfunction.  Imagine a simple bank routine for processing a check:
doCheck (writer, recipient, amount) {
    if (amount < 0) return DIAF;
    balance = getBalance( writer );
    if (balance < amount) return NSF;
    setBalance( recipient, getBalance(recipient) + amount );
    setBalance( writer, balance - amount );
}

Now imagine my balance is $11,000 and I wrote two checks:
John, ColumbiaHouse, $0.01
John, MrsJohn, $10,000

Now our bank processes so many checks that "ace" programmer DonaldJavaSlump adds threading, because performance -- but he doesn't know about critical sections, so thread 1 starts processing the first check:
if (amount < 0) return DIAF;             // (0.01 < 0)?  OK
balance = getBalance(John)               // $11,000
if (balance < amount) return NSF;        // (11,000 < 0.01?)  OK
setBalance( ColumbiaHouse, ...           // KaChing! ColumbiaHouse gets paid

and now thread 2 starts through the same section of code processing the second check:
if (amount < 0) return DIAF;             // (10,000 < 0)?  OK
balance = getBalance( John );            // $11,000 (still!)
if (balance < amount) return NSF;        // (11,000 < 10,000?)  OK
setBalance( MrsJohn, ...                 // KaChing! MrsJohn gets paid
setBalance( John, balance - amount );    // my balance is now $1,000 :(

and then thread 1 gets around to finishing its job:
setBalance( John, balance - amount );    // now balance is $10,999.99!!! :)

Now John and MrsJohn are extra happy and go on a cruise with free money!!
Answer: A critical section wraps that portion of your code where shared data is being modified.  The monitor ensures that only one thread at a time enters.
Answer: a critical section routine is an approach to the problem of two or more programs competing for the same resource at the same time. Imagine that two programs want to increment a counter. If both do it at the same time: fetch the operand , increment it, and store back the incremented value, then one of the increments will be lost. On today's processors, the programs can use an atomic read-modify-write instruction, such as fetch-and-op, compare-and-swap, or exchange. On early processors, these instructions did not exist; the problem was to accomplish the incrementing atomically, using only ordinary assembler instructions. The problem was defined and first solved by Edsgar Dijkstra. "Critical section routine" was his name for the code that solved the problem.

What is critical section in threading?


Squid as cache proxy

Question: The only internet connection I have is through mobile data, although I have an unlimited use in the browsers for the cache, to optimize the bandwidth and not have to be downloading the css and js files again maybe because of the time of expiration that the sites have defined. I would like to install a squid to navigate through the squid and maybe so I can increase the cache and optimize my data connection. I have searched the net and I have seen very good reviews about this, but I am not sure that it is a good idea and that it is really worth it, please, I need an opinion, if someone has already done something similar.
Answer: This is not a real answer, it's a frame challenge.
If you don't have multiple clients, squid will offer few, if any, benefits over browser caching.
Browsers cache content, but the cache is local to the browser. Squid shares it cache among clients. As long as you have few clients, this doesn't really make sense.
In addition, most traffic those days are TLS. Caching this with squid requires configuring certificates to allow squid to read traffic. The browser, on the other hand, is able to cache TLS content without any configuration.
What you should do is use some kind of ad and script blocker in your browser. Those can reduce the amount to download significantly.
Comment: Hello @vidarlo, thank very much for your answer, I have to try it.

Squid as cache proxy


What is a Passion Project and Is It Considered a Bad Thing in the Minds of Agents and Publishers?

Question: I've heard from a literary agent that one of my books is a passion project. I told this agent that I normally write speculative/fantasy fiction, and for one book - an international thriller/suspense, was something I wanted to explore to broaden my portfolio. This thriller novel is based in Saudi Arabia and is about a persecuted Christian who overcomes his oppressive exile. What is a passion project and is this something negative? Because I wrote that thriller novel to appease mainstream publishers.
Comment: This question may be too subjective to answer, as opinions on this will vary wildly from publisher to publisher. That being said, when I have heard of my author friends receiving feedback to the effect of "this looks like a passion project," it was usually a gentle way of saying the book was not to that publisher's liking, despite obviously having a lot of love put into it. So you may want to take this as a very gentle rejection and seek out a second opinion.
Comment: @Sciborg Thank you.
Comment: While I agree with all the comments and answers (it isn't necessarily mean-spirited, or invalid regarding commercial appeal), I read the title and thought *"passion project" = "religious agenda"* before I read the rest of the question. My inference for 'passion' is [Passion of Jesus](https://en.wikipedia.org/wiki/Passion_of_Jesus) the dramatized suffering of a martyr. That might just be me, but it's the reference that immediately came to my mind.
Answer:
What is a passion project and is this something negative?

A "passion project" is normally one written primarily to serve the needs/wants of the person writing it. It's not as simple as being always negative - certainly there's many reasons to undertake them and they can also fulfill a successful secondary position of having wide appeal.
In this context however I think it's unavoidable to consider it a negative - I think you have to take that as a comment that they don't believe the book has the mainstream appeal you were aiming for. That doesn't mean they were right - and I don't think we're particularly in a place to determine whether they were or not.
Further complicating the picture is that it may not even be the real reason for the rejection - it could be, or it could be a generic platitude to cover up anything from as mundane as "I just didn't like it" to "I don't want to touch a book that covers religious persecution in a country with a reputation for taking extreme dislike to criticism".
Single data points don't generally tell you much and single rejections are no exception - remember Decca Records rejected the freaking Beatles. So if this is a book you remain interested in getting published then shop it around a bit more - see if anyone else is interested.
Comment: It was just from one person but the other agents liked the book and my writing, just they don't represent my genre so they declined me. I plan on registering for a Christian writer's conference to meet agents who represent my genre.


I have a smart home with a lot of wifi connected devices. Is there a limit to how many I can have?

Question: So I have approx 30 devices that can only connect to 2.4ghz bands and about 20 that can connect to either 2.4ghz or 5.2ghz.
Keeping in mind that most of the former (only 2.4) are light switches, outlets and light bulbs, they are dormant most times (I would assume).
However I am getting consistent connectivity issues from this router since I started setting up the smart devices.
I am working with a Nighthawk AC1900 Smart WiFi Router. Any suggestions?
Would a mesh network do better? (Such as Google WiFi) I am only asking because I am not sure if each devices increases the total "bands" I can work with.
Comment: This whole question basically revolves around the WiFi connection limits imposed by your AC1900 router. It would be interesting to know exactly how many of your dual-band devices are currently using (or *trying* to use) the 2.4 GHz network and how many are on the 5 GHz network.
Answer: All Netgear dual-band home routers, including the Nighthawk AC1900, can accommodate a maximum of 32 devices on each of their two bands, giving you a total of 64 wireless devices.

2.4 GHz = 32 wireless devices
5 GHz = 32 wireless devices

I wouldn't be concerned about running out of bandwidth or saturating your network in this case. You stated that most of your wireless devices are smart devices, such as light switches, which would require extremely small amounts of bandwidth. The challenge here is working around the hard 32-device limit imposed on each band by the router.
You already have around 50 wireless devices, so you are rapidly approaching the 64-maximum number of wireless devices this router could theoretically support. There isn't much room for expanding this network right now and, if you ever have a group of visitors who want to use your WiFi, they may have a poor experience as the router would probably struggle to provide additional connections (particularly on the 2.4 GHz band).
Your 30x 2.4 GHz devices already occupy almost all of the 32 connections the router can support on the 2.4 GHz band, so you definitely want to put the 20x dual-band devices only on the 5 GHz network, to alleviate congestion on the 2.4 GHz band as much as possible.
That would leave you with:

2x remaining 2.4 GHz connections
12x remaining 5 GHz connections

I think you should consider expanding your network. This could be done either by introducing an additional access point or by replacing your dual-band router with a tri-band model. For example, the NETGEAR Nighthawk X6 AC3200 Tri-Band WiFi Router would increase the total number of potential WiFi connections from 64 to 96 devices.
It does this by simply adding a second 5 GHz radio:

2.4 GHz = 32 wireless devices
5 GHz = 32 wireless devices
5 GHz = 32 wireless devices

Personally, I would consider adding another dual-band router, instead of replacing your existing one with a tri-band. The reason for this is that you have an extremely high demand for 2.4 GHz connections. This is the bottleneck! Your smart devices are single-band and can't use 5 GHz, so adding another 5 GHz radio wouldn't take any pressure off the congested 2.4 GHz band.
Adding another dual-band router would give you an additional 32x 2.4 GHz + 32x 5 GHz potential wireless connections, which should eliminate all of your current connectivity problems.
Nighthawk AC1900 #1:

2.4 GHz = 32 wireless devices
5 GHz = 32 wireless devices

Nighthawk AC1900 #2:

2.4 GHz = 32 wireless devices
5 GHz = 32 wireless devices

This would give you a total of:

2.4 GHz = 64 wireless devices
5 GHz = 64 wireless devices

Summary:

Short term: all of the 2.4 GHz devices have no option but to connect to the 2.4 GHz network but those that have the option of 5 GHz should all be on 5 GHz. This should resolve your immediate problems with what appears to be an excessive demand for 2.4 GHz connections
Long term: you should consider expanding your wireless network to allow for more devices to connect. I would do this by buying an additional AC1900 and configuring it as an additional AP, doubling the maximum number of potential connections on each band from 32 -> 64 devices.
Comment: So I would just chain the routers? I know double NAT is an issue with VOIP, but would it not be a problem aside from that?
Thank you for your quick response btw.
Comment: Also, I am assuming the second router does not have to be the same model. As far as you know, does that logic track?
Comment: So I added a Google Wifi point (in Bridge mode) in my place and it seems to be working perfect now.. I will update if this stops being the case.
Comment: @MattMoore, You can just connect your routers together by running an ethernet cable between LAN ports on each one.  One of your routers would need to be configured as a simple access point (AP Mode) and disable NAT, DHCP, etc.  For best results, place them on opposite ends of the house so you have better signal coverage.
Comment: @MattMoore the two wireless routers could certainly be different models but I always prefer to match AP models if possible. That way, you get all the benefits that come from standardization and a consistent experience across both APs. Having the same radio hardware in each AP means you get similar reliability, similar broadcast strength, identical web UIs and identical WiFi connection limits on each band. It's not the cheapest router though, so if you want to use something else, we could still make it work! I'll update my answer with configuration specifics.
Answer: The 802.11 protocol has a hard limit of 2007 clients per BSS (that's the same as saying "per AP", but be aware that a dual-band AP is really two APs in the same box, and a so-called "tri-band" AP is three APs in the same box). This limit of 2007 has to do with how the dual-use "Duration/ID" field is used, which only allows it to support 2007 separate client IDs.
However, many implementations have lower limits. It can vary from model to model within a single company's product line. Check your documentation or contact the manufacturer.
Also, even if you had an implementation that was only limited by the 2007 client hard limit, if you cut your airtime pie into 2007 slices, you might not like how small the slices turn out to be.
Comment: All NETGEAR home routers, irrespective of model, have a limit of 32 devices per band. https://kb.netgear.com/24043/How-many-clients-can-you-connect-wirelessly-to-a-NETGEAR-router


What is a good spot to farm souls before going against the Depth boss?

Question: I've beaten the Capra Demon and the Church Gargoyle and now intend to go down into the Depth. I'm wondering what a good place to level up is before going against the boss.
Answer: One of the best places in the game to farm for souls that you could have access to is in Darkroot Garden.
The blacksmith near the church sells a key for 20,000 souls (expensive yes, but easily worth it) that you can use with a door in the forest. To get to the door you'll need to either deal with or run past the Titanite Demon that resides down the stairs from the blacksmith and deal with 4 or so bush monsters. Then you'll be at the door. BTW, next to the door is an illusory wall hiding a bonfire that will be very useful.
Through the door and into the trees are 4 Human enemies that respawn. The closest is a Sorcererr, the next closest in the trees is a Cleric with a mace/shield. Around here is also an 'invisible' rogue. He's about as visible as the phantoms you see when looking at a bloodstain. You also can't lock on to him (unless the 1.04 patch has hit already). If I'm remembering correctly there's also a one-time Invisible Knight enemy as well. Finally, on the other side of the trees is a Bandit (Spider Shield + Battle Axe). The first three give 2000 souls apiece and the bandit gives 1000 souls. There's nothing in between the nearest bonfire and those enemies, so farming them is a straightforward process.
Also, depending on how you draw them out and if you're having trouble dealing with them, you can lure them up the stairs towards the bonfire, but drop off the side and land on a narrow ledge. When they follow you, they'll just drop into a pit. Plus I'm not aware of any drops you'd be missing out on.
Honestly though, it's not the Depths that you'll have to level for. I think the boss there is one of the easier ones in the game and I've played through as both melee and magic characters.
Comment: Thank you for the very detailed answer. I have not yet tried to face the boss of the Depth, but I am only doing a mere 12 hit point to the slime enemies, so I was thinking I needed to do some leveling up.
Comment: The slimes aren't a good indicator of strength really. They have a very high defenses. Even with a lightning spear +5 that does 200+ damage to bosses and enemies at the end of the game, the slimes only take 50 or so.
Comment: If he's having trouble in the Depths, then defeating the Stealthed Knight in the forest is going to be very difficult.  I'd suggest the OP just try the Depths boss; he's very easy to kill, all you need to do is keep you're distance and run in to attack when safe.
Comment: FYI, the slimes are weak to fire. I can one-hit them with my Fire +4 Claymore.


Why doesn't my mob grinder work?

Question:

This is my 10th failed mob grinder I haven't got one to work even though I've followed multiple tutorials all leading to nothing. Caves in the area have been lit up and this was built near land but above the ocean. The close land has also torches and mobs don't spawn there. My friend built one on land without lighting up caves or spawn-proofing undesignated areas. This was also built-in survival if that changes anything. The spawn platforms are 9x8x4. I read that I should build it higher up, my previous attempts were higher up, although they didn't work either
Comment: Please don't answer in comments.
Comment: Is this in singleplayer or multiplayer?
Answer: In Minecraft you have a safe zone, that means that mob will not spawn in them (avoid the mob pop in front of you)
You need to keep a distance for the mob spawn and wait for spawn
Here's an image from the wiki:

In your pictures we can see the at the top mob grinder Y : 91 , and inside the structure the platforme for mob spawn shoud be 88 ,
the spwan area is 24-32

afk platforme Y should be 112- 120 (88 +(24~32)) or 56-64 (88 -(32~24) )
Answer: The mob grinder doesn't work, because it is basically what the mobs want, i.e. It is totally up to the mobs whether they will walk ahead and fall into the water stream, which happens, but very slowly.
I want to say that I also encountered this problem, how I fixed it was, I used a soul sand elevator and trapped a villager in a glass chamber just above the hole such that zombies could fall in. This made it so that mobs could fall down. You can use this solution, but it is still not very efficient.(this makes most zombies fall down, but creeper and skeletons don't which ultimately makes the farm ineffective)
I would suggest you to build a spawner mob farm, it is very useful. If you want, you could build this farm, and instead of keeping campfire in the center, you could make a 23 block height pit where you could make a collection chamber to turn it into a xp farm. You could even try this if you are looking for trident drops as well as xp.
I hope this helped. :D
Answer: Firstly, make sure that your difficulty isn't peaceful.
And then try block out all of the light rays (placing blocks around the edges to not make light come in)
Answer: You've built your afk platform too low. You should use this tutorial
:

and follow the instructions to build your afk platform at least 100 blocks about the roof of the grinder. It's the height of the afk platform that's the problem, mobs won't spawn if you're too close to the spawning area.

Why doesn't my mob grinder work?


Are present state and next state equal between two clocks?

Question: I know things that happen every time clock ticks. Present state and inputs are delivered to the combinational circuits and it produces the outputs and the next state information and sends the next state to the memory elements. Then memory elements(e.g A SR flip flop) read the S and R signals and lock the Q on a new value based on them.

The thing that I don't understand is what happens until the next clock? It seems that there's no apparent obstacle/isolation between the next state and the current(present) state in this time interval... Are they equal until the next clock?
Of course still everything else make sense to me and this is not contradictory to anything I knew about memory elements and flip flops and etc... , because actually, at every clock-tick moment, information from memory elements are read from one epsilon moment before, and the combinational circuits have a delay too, so for a special moment the present state and the next state are different and are really what their names suggests, but in the middle of two clocks, my defective understanding says they should be equal... .
Answer: In a topology like this, the present state is read from memory and passed through combinational logic to compute a new state. Until the clock ticks, that new state is sitting at the write port of the memory waiting to be written. As soon as the clock ticks, the new state is written to the memory, and for a brief instant the present state and next state are equal. This brief instant is the propagation delay of the memory (time from clock edge to availability on read port) plus the propagation delay of the combinational logic. After this time, the NEW new state is sitting at the output waiting to be written, and the cycle continues.
Comment: Wow great answer thanks! Unfortunately nowhere in books such nuances are explained and once again stackexchange, to the rescue :)
Comment: your explanation got me thinking that this is a contrived topology and such a thing doesn't exist at all, because we have only one Q port and thus we also only have one state... right? This topology is only trying to make understanding easier, but in reality combinational circuits produce signals say for example S and R which is used at the next clock to write the next state into the memory, yep?! :)
Comment: Nope! Once you consider a flip-flop or latch that has set and reset signals, it isn't combinational logic anymore - it's *sequential* logic, since the outputs depend on past inputs. The output of combinational logic depends purely on the current inputs.
Comment: Yeah I don't have any problem with combinational logic, sorry if I wasn't clear, I didn't talk about inputs and outputs, I talked about states... I say if there is only one Q, there is also only one state in our whole sequential logic. new inputs are only new information for our memory and flip flops and etc..., to produce a next state. But two states never exist at the same time. That's what I meant to say.
Comment: They sure do - the "current" state, the one stored in Q and passed to the input of the combinational logic, and the "next state" at the output of the logic waiting at the Q write port.


2-to-1 Multiplexer logic equation: is order of inputs important?

Question: The boolean logic equation for a 2-to-1 multiplexer is \$(A.\bar{S})+(B.S)\$, where \$A\$ is the first input and \$B\$ is the second input. Is this logic equation equivalent to \$(A.S)+(B.\bar{S})\$, given that the inputs \$A\$ and \$B\$ have the same order? Thanks in advance!
Answer: If you set A to 0 and B to 1 and S to 0 you get a value of 0 for the output. If you invert S you effectively swap A and B and get 1 at the output. So this is not equivalent.
Answer: The logic is the same, in that both formulae describe a 2-to-1 multiplexer that will select either \$A\$ or \$B\$ depending on the state of \$S\$.  However, the two forms are different in that \$(A\cdot\bar{S})+(B\cdot S)\$ will select \$B\$ when \$S\$ is true, but  \$(A\cdot S)+(B\cdot \bar{S})\$ will select \$A\$ when \$S\$ is true.


Downsides to using test strips from different packages of photo paper?

Question: Sometimes, after using the last full sheet of photo paper in a package, I'm left with a number of extra test strips. Is there any problem with gauging exposure with paper from a different package of photo paper, while using these leftovers?
Answer: Leftover test strips imply that you have more test strips than you need. Implies that a pack of paper includes enough test strips (or more than enough depending on how you look at it).
This suggests that keeping them is just cluttering the darkroom.
Worse, it is clutter that is possibly out of date or a different emulsion…which would make mistakes more likely even if you were not going to be working in the dark with dim light.
Darkroom processes are better when consistent and simple. Saving old test strips is neither.
Answer: As long as both are the same paper emulsion (i.e. both Ilford MGRC IV) and from the same batch number this is likely to work well.
If they're the same emulsion, but different batches, there may be a significant difference in speed -- enough to make a "good" exposure a second or two too long or too short, which will cost you at least one full sheet to correct.
If they're different emulsions (for instance, MGRC III vs. MGRC IV) or different surface finish, I wouldn't even try it.  Test strips are supposed to save you from wasting whole sheets printing with wrong contrast or exposure -- not trick you into wasting more.
Comment: I guarantee they aren't the same batch (purchases many years apart), but where is the batch number on Ilford paper packages?
Comment: Honestly, I've never used Ilford paper, but I'm used to seeing it on Kodak and, many years later, Arista papers on the box label near the expiration date.
Comment: Even if the packages are from the same batch, storage conditions will also after some time play a significant role. If you (or the dealer if you buy it later) has kept the new package stored coolly and the old almost empty package has been in and out of the dark room and often kept in warmer surroundings, it is quite likely that the paper in the old pack has lost sensitivity compared to the new package. In that case, a print on the new paper will be overexposed (too dark and/or too contrasty) even if the test strip is good.
Comment: @jarnbjo Notice I said "likely" to work well, not "guaranteed" to work well.
Answer: I've done this in the past with Ilford papers and had no issues. I would recommend trying one old and one new test strip together, to make sure they produce the same result. A similar issue is making a final print from the last sheet in a box, and then wanting a second print, which needs to be taken from the next box. Again, this has worked for me when I had to do it.
On a related note: I also tried using Ilford MGRC Deluxe Glossy (RC paper) test strips for final printing on Ilford MGFB Classic Glossy (Fiber paper), and it's amazing how similar those two papers are. Starting out on RC paper saves a lot of time. I got the idea from watching people on YouTube testing this 5th generation Ilford RC paper. Note that you can't do this with the previous generation MGIV (4th generation) RC paper.


Switch to admin theme based on path using hook_init() or template.php in Drupal 7

Question: I'm running a site that uses a separate admin theme. I'd like to include a couple additional pages that use the admin stylesheets. How can I apply the theme selectively to these pages. I'd rather do this in hook_init() or template.php. I don't want to add any more contrib modules to the site at this point. Thanks for any illumination.
Answer: The Administration theme module will do it, but given you'd like to do it yourself, it does cast some light on that path by suggesting the hook_admin_theme_check() and hook_admin_theme_info() hooks.
Comment: I did enable the Administration theme module which worked nicely - thanks.
Answer: You can use the module Administration theme for that but if you just want to use the admin theme for a single path you can define it in hook_init
/*
 * Implements hook_init().
 * Use the admin theme on path 'batch'
 */
function MODULENAME_init() {
  if (arg(0) == 'batch') {
    global $custom_theme;
    $admin_theme = variable_get('admin_theme', 'garland');
    init_theme();
  }
}

Answer: If you don't want to enable more modules (like the admin_theme module), and prefer to write a few lines of code to achive the same thing, you can use hook_custom_theme().
e.g. This snippet switches the user to the admin theme when they're viewing the revision comparison report from the diff module.
function MODULENAME_custom_theme() {
  global $conf;
  $args = arg();

  // Set the admin theme when viewing a diff comparison with the diff module.
  if (isset($args[3]) && $args[3] == "diff") {
    return array($conf['admin_theme']);
  }
}


Can i show imageurl that exist in a library as a column?

Question: I got a picture library.I store the images. There are image urls. I want to reach these urls as a column. Is there a way to show them as a column?
Answer: none out of the box but you could do this by creating a hyperlink column and pasting the link from the image into it.
Upload the image and save it, then open the image properties and right click > copy shortcut to capture the direct link to the image. then paste the link into the hyperlink field you added to the library.


What are some middle game chess books that are good for beginners?

Question: What are some great middlegame chess books that are for beginners that will help me to improve my middle game in chess? There aren't a lot of books on the middle game.
Comment: By the way, there's hardly any middle-game books targeted at beginners since if youre studying the middle-game you probably arent a beginner by definition.
Answer: As alluded to in this answer, Seirawan has two useful books that are wonderful for beginners.

Play Winning Chess covers the fundamentals very well, focusing on concepts such as Force (material), Time (tempo), Space, and Pawn Structure. Targeted at the beginner level.

Winning Chess Strategies is the perfect introduction to positional ideas for beginners. Very useful for beginners struggling to find ideas to generate candidate moves. Includes positional puzzles.
Answer: Beginners don't really need to understand the middle game. You mostly just need an understanding of basics and tactics to move beyond the beginner stage. Seirawan had a series  with a couple of books on the middle game. That's probably plenty for beginners.
Once you start pushing for 2000, Nimzo's My System and Silman's HTRYC are good.
If I were teaching middle-game planning to a beginner, I would just say, pick a target and point all of your pieces at it. The target can be the king or a weak pawn or a hanging piece or whatever. If you don't know what to do, just improve the mobility of your pieces. Most middle-game planning comes down to increasing mobility anyway.


How to know difference between 2 devices connected to the same Wi-Fi hotspot in IPV4?

Question: I am working on a small project to make a client server program to make a connectionless implementation & I want to transmit Information between 2 devices which is connected to the same Wi-Fi hotspot & so they are showing same IPV4 address . How can I differentiate between the 2 devices or could I possibly use IPV6 address to make client server program?
Answer:
connected to the same Wi-Fi hotspot & so they are showing same IPV4 address .

Apparently, they are NATed towards your server. If this is on the same enterprise network you should remove NAT.

How can I differentiate between the 2 devices

On the network level, you can't. On the application level, you might use some kind of fingerprinting or authentication, but that is off-topic here. Possibly Stack Overflow is the right place to ask.

or could I possibly use IPV6 address to make client server program?

Possibly. The clients might be using various v6 IPs, so you can't be 100% sure.
Answer:
... between 2 devices which is connected to the same Wi-Fi hotspot & so they are showing same IPV4 address.

This is not really the way NAT is working:
The Wi-Fi network (the same is true for a home network) forms a local network. All devices in the network have their own IP addresses. However, these IP addresses are not valid in the internet.
To establish a connection (for example a TCP connection) to a computer in the internet, a device actually establishes a connection to a NAT router or proxy server, which then establishes a connection to the computer in the internet.
So actually the global IP address is not shared between the devices, but the only devices really using the global IP address is the NAT router or proxy server. And actually none of the devices inside the network is really connected to the internet, but only the NAT router or proxy server is.

How can I differentiate between the 2 devices ...

If both devices are in the same Wi-Fi network, you don't have any problem:
Both devices have an own IP address.
However there are Wi-Fi networks with a firewall that does only allow devices to communicate to the NAT router but not with each other. In this case you have no chance.
If only one device is in the Wi-Fi network (and the other one is in another Wi-Fi network), you will also have no chance:
As I already wrote, the only device which is really connected to the internet is the NAT router. And by default this router won't forward UDP packets to the device.

... IPV6 ...

In most cases all devices will have an IPv6 address which is valid in the entire internet. So devices inside the Wi-Fi network can communicate directly to computers in the internet.
However:

Most Wi-Fi routers for IPv6 have a "stateful firewall" which will block packets which would be blocked in an IPv4 Wi-Fi network by default.
There surely are networks that work using proxy servers or NATs ("NAT66") together with IPv6.


Splitting a double into an array in C

Question: I'd like the following code to work:
double num = 31415; /* num will never have a decimal part */
/* ... code here so that we can now say */
printf("%d", num_array[0] == 3 && num_array[1] == 1 && num_array[4] == 5); //1

I realize it's trivial to do this with ints (just int i=0; while(num>0) numarr[size-++i] = num%10, num/=10; where size is predetermined to be the number of digits in the number), but that obviously won't work for floats/doubles because you can't mod one floats.
And yes, I need to use floats/doubles, despite not using the floating point section (it's an exercise).
And I have figured out how to determine the number of digits in a double, using floor().
/* n > 0, n=floor(n) */
int numdigits(double n){
    int i = 0;
    while (n >0)
        n = floor(n/10), i++;
    return i;
}

Answer: Look up fmod. The number of digits will probably be easier to compute using log10.
Comment: +1 for the log10() suggestion.  `int digits = (int)log10(n) + 1;`
Answer: It's probably easiest to just convert it to a string:
char* str = malloc(num_digits+1);
snprintf(str, num_digits+1, "%f", num);

Indexing into str will give you each digit as an ASCII value, so you'll need to subtract '0' to get the actual numeric value:
str[0] - '0' == 3;
str[1] - '0' == 1;
str[2] - '0' == 4;
...

Comment: I wanted to see if I could do it without strings :), but thanks anyway :)
Answer: Apart from fmod(), you could also cast to a int64_t or long long int, and use % as before.  If the range is less than 10 digits, you could use a int32_t.

Splitting a double into an array in C