How can I display a search form with a different style from search bock, inside a node?

Question: I have a search block enabled at top side of my site. But I also need to display the same search form, but with different css class applied inside a node. How this can be done?
Answer: Since blocks can only go in a single region (without some messing about), I think you'll have to use code for this. You could add the form in a preprocess function in your theme's template.php file:
function MYTHEME_preprocess_node(&$vars) {
  if ($vars['node']->type == 'my_node_type') {
    $form = drupal_get_form('search_form');

    $vars['search_form'] = render($form);
  }
}

Now in your node.tpl.php file, or node--content_type.tpl.php file, you'll be able to output the search form like this:
<?php if ($search_form): echo $search_form; endif; ?>

The default classes and ID added to the
 surrounding the node will be be perfect for targeting that particular instance of the form with CSS. You can easily use developer tools/firebug to determine what selector to use.
Comment: But I have already changed display of search block using function MYTHEME_form_alter(&$form, &$form_state, $form_id)  . So now i want another set of parameters for search form only for  particular node


How to remove inflate exceptions ocurring due to out of memory error

Question: I am facing too many crashes in Kids ABCD application and that too because of Inflate Exceptions which was arising due to OUT OF MEMORY ERROR.
Application is taking so much space, when it is running in foreground, causing it to crash.
This problem arises only when we are switching between different activities so rapidly that the heap area gets filled so fast and application begins to give inflate exception and crash eventually before the space freed on activity destroy.
(Rapid switching between activities is done to check the app performance).
The main cause could be large images or application taking more space in cache background storage.
Large size images could not be the problem as we already verified that all images should be of moderate size. Another thing that we had done with the code is that we have finished each activity on each intent by calling finish()method. Here finish() method is used so that the activity could release all the bitmaps from current space (on closing the activity).
super.onCreate(savedInstanceState);
    setContentView(R.layout.ringa_ringa);

    pause = (ImageView) findViewById(R.id.pause);
    txt = (TextView) findViewById(R.id.txt);
    pause.setVisibility(View.VISIBLE);
    txt.setTextColor(Color.parseColor("#ffffff"));
    list = new ArrayList<>();
    mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "Kids_Rhymes");

    ringa_thread_running = false;

    pause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (counter == 0) {
                mediaPlayer.stop();
                ringa_thread_running = false;
                position = 0;
                if (lyrics_ring.isAlive()) {
                    lyrics_ring.interrupt();
                }
                pause.setImageResource(R.drawable.play);
                counter = 1;
            } else if (counter == 1) {
                pause.setImageResource(R.drawable.pause);
                counter = 0;
                onResume();
            }
        }
    });

    String[] words = getResources().getString(R.string.ringa).split("\\$");
    for (String w : words) {
        System.out.println("=======String====" + w);
        list.add(w);

    }

Tried to find out the accurate solution for this but didn't get the suitable one.
Comment: refer https://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object
Comment: post your code here
Comment: Hi Anil, I have put code now, please check.
Answer: put below code in your manifest
 android:largeHeap="true"

like
 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

Answer:
How to remove inflate exceptions ocurring due to out of memory error

Use less memory overall, an in particular avoid repeated large allocations. You can use Android Studio to help with this, such as by generating a heap dump to see what objects you have in memory at various points.

Large size images could not be the problem as we already verified that all images should be of moderate size

Bear in mind that "moderate size" needs to be measured in terms of heap space used, which is much greater than disk space used, as most images are stored in a compressed form. Also, bear in mind that drawable resources get scaled based upon the screen density of the device and the screen density that you declared for the resource in the resource directory.

Here finish() method is used so that the activity could release all the bitmaps from current space (on closing the activity).

First, the timing of your activity being destroyed is not perfectly synchronous with the timing of the next activity being started. The interactions here are more complex than that.
Second, for bitmaps that you are likely to use again, releasing them and trying to re-allocate them later are one good way to get OutOfMemoryErrors.
Overall, there are books and courses that cover Android memory management. You might consider learning from such resources.


Aren't vacuous statements True and False simultaneously?

Question: Wikipedia states "a vacuous truth is a statement that asserts that all members of the empty set have a certain property". Clearly the statement: 'all elements of said (empty) set possess said property' is vacuously true. However, one could argue that the negation of the statement: 'no elements in said set posses said property' is also true. Shouldn't that mean that the statement is both true and false. I understand there may be slightly different definitions of what constitutes a vacuous statement, but I suppose this particular issue will show up nevertheless.
Comment: "Vacuous truth" means a statement that is true but mathematically inconsequential.  It comes up with more than empty sets.  "If 9 is even, then it is prime".  That's true, but (arguably) never useful.  That's why it is called vacuous.
Answer: You did not negate the statement "all elements of a set S have property X" correctly.  The opposite of "all elements of a set S have property X" is not "no elements of set S have property X".
The opposite of "all elements of a set S have property X" is "some element of S does not have property X".  If S is empty, "some element of S does not have property X" is definitely not true.
Comment: Your negation is also missing a "not" as it should be the existence of an element *without* the property.
Comment: Yes, of course.
Comment: @TobiasKildetoft Corrected.


Textmate OSX Yosemite ruby 1.8

Question: After upgrading to the OSX Yosemite, Textmate's duplicate line command
ctrl+shift D produces an error warning: -K is specified; it is for 1.8 compatibility and may cause odd behavior.

Previously, this was fixed by changing the PATH to /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

But now this does not work.

How can I fix this issue?
Answer: You can install Ruby 1.8.7 via rbenv and add it to Textmate paths:

PATH:
  /Users/YOUR_NAME/.rbenv/versions/1.8.7-p249/bin:/usr/bin:/bin:/usr/sbin:/sbin
TM_RUBY: /Users/YOUR_NAME/.rbenv/versions/1.8.7-p249/bin/ruby

If you have problems with installing ruby 1.8.7 with errors such as:

openssl_missing.h:68: error: conflicting types for 'HMAC_CTX_copy'

you can try to do brew unlink openssl. After successfully installing ruby you can link it back with brew link openssl --force
Good Luck!

Textmate OSX Yosemite ruby 1.8


Role Of Emitter (By Pass) Capacitor

Question: What is the importance of Bypass capacitor of Common-emitter amplifier? Will the gain be reduced when it is removed?
Comment: You should be more clear what exactly you are asking.  "Bypass" capacitor is a rather vague term.  We can't know what you think it means and how exactly it relates to whatever common emitter amplifier you have in mind.  SHOW A SCHEMATIC.
Comment: How is it vague?  How can you interpret the question in more than one way?  Previous commenters thought that "bypass cap" was ambiguous, yet OP specifies _emitter_ bypass cap, right in the title. He uses standard terminology regarding a standard transistor configuration, which he specified by its standard name.
Comment: @gwideman There are an infinite number of permutations and combinations. If the OP cannot provide a specific example, a specific answer cannot be provided.
Comment: For others wondering about schematic: See google images for "Common-emitter amplifier".  Note many schematics with emitter cap, often labelled CE.
Comment: @ Madmanguruman The term ""Common emitter amplifier" is pretty unambiguous, as is the term "emitter bypass capacitor". Can you find any examples where Phil's answer would not be correct? Perhaps not everyone is familiar with common emitter amp, and could become familiar thanks to a schematic. But so far as being ambiguous per se, the question is pretty clear.
Comment: downvoted because it's vague and the poster seems unwilling or unlikely to fix it up.
Answer: Usually, this capacitor is in parallel with a resistor:

In a common-emitter amplifier, any impedance between the emitter and ground (\$R_e\$ and \$C_e\$) serves to reduce the gain of the amplifier: it is a form of negative feedback. By increasing the negative feedback and decreasing the gain, we can make variations in transistors less significant. Perhaps most relevant to this point, by adding \$R_e\$ we make the bias current more dependent on the resistors (which are easy to control) and less dependent on the gain of the transistor (which varies over a large range, even among transistors of the same model).
But what if we still want high gain? Because a capacitor presents an impedance that decreases with frequency, putting \$C_e\$ in parallel with \$R_e\$ serves to decrease the negative feedback, and thus increase the gain, at high frequencies. Effectively, high-frequency signals can bypass the emitter resistor, through the capacitor. Yet, to DC, the capacitor appears as an open circuit, so adding the capacitor does not affect the DC bias current. Thus, if we are interested in amplifying AC signals only, this capacitor allows us to have a stable DC bias current while maintaining high gain for our signals of interest.
Comment: +1 for a well written answer, but a schematic would be helpful.  Between you and the OP, there is way too much hand waving such that if you don't already know what is being talked about, you're unlikely to learn it.
Comment: @Phil Frost and gwideman, great explanation. Now I have started to understand behaviour of Amplifier circuits.
Comment: Thanks for it, will it effect on voltage gain or current gain? please clarify
Comment: @AliKhan It sounds like either you have a more fundamental question about common-emitter amplifiers which would merit another question, or you are looking for homework answers.
Comment: @Ali: The key is to separate your thinking about DC conditions of the circuit, (baseline V's and I's which put the transistor at a particular part of its operating range), versus the AC behavior of the circuit, where presumably the AC signal of some significant frequency above zero (such as audio, or RF signal) is the signal of interest to be amplified.  At DC, emitter cap is invisible, so DC conditions are set primarily by VB and RE, assuming the collector load R is suitable. At AC, em cap looks like a short circuit, so for AC gain, the transistor behaves as though E connected to ground.
Comment: @Ali cont'd. So removing the emitter cap will have no effect on DC behavior (basic operating conditions of transistor) but will increase the AC equivalent emitter R from zero to the value of the actual emitter R. As explained by Phil, that acts to reduce the gain of the overall amplifier circuit.
Answer:
What is the importance of Bypass capacitor of Common-emitter
  amplifier?

I would just like to add a bit to Phil's answer.
To be precise, for a common emitter amplifier, the emitter is tied to the signal common node thus the title "Common Emitter".
This means that, for the signals of interest, the emitter is effectively at zero volts.
If the emitter resistor is not bypassed at signal frequencies, one does not have a genuine common emitter amplifier since there are signal frequencies present at the emitter.
In this case, as Phil points out, there is emitter degeneration present which, essentially, reduces signal (AC) gain while increasing linearity.
Sometimes, you will see a hybrid emitter circuit with two resistors in series, one bypassed by a capacitor and one not.  This extra degree of freedom allows more flexibility in choosing the DC operating point and AC gain.
Comment: And I +1'ed this for noting the possible configuration with the two emitter resistors, allowing finer separate control of DC operating point and gain. Example: http://wps.prenhall.com/chet_paynter_introduct_7/30/7753/1985017.cw/-/1985020/index.html  See Figs 9.3 and 9.4.

Role Of Emitter (By Pass) Capacitor


Installing newer version of lsblk to RHEL

Question: I am trying to install newer version of lsblk to Red Hat Enterprise Linux Server 7.6. I have installed util-linux on my system in version util-linux.x86_64-2.23.2-59.el7_6.1 but due to a compatibility issue i need to have lsblk at teast on version 2.27.1
Unfortunatelly Red Hat does not privide newer package of util-linux. I have tried to search epel repository with no success. Is there any way to install newer version of lsblk ?
Answer: You can use the third-party package manager Nix to install a newer version of util-linux.
In fact, to avoid any potential compatibility issues with the rest of RHEL 7.6, I recommend running your application within a Nix environment which contains the newer util-linux. In other words, I recommend using nix-shell over nix-env. For example, after installing Nix you can run nix-shell -p utillinux to enter a shell which contains a newer version of util-linux. Outside of said shell the RHEL util-linux would be available.


Fluid Sim - Changing fluid velocity at certain location

Question: So I have a fluid simulation where I want the fluid to hit a specific object and then flow at a slower pace. I have an effector guide in the domain that has a velocity factor change but it doesn't seem to do anything. The domain has Guides checked on and the Velocity Source marked to Effector. Am I missing something here?
Comment: Can you add a picture of the setup?
Answer: If i understood you right you want a slow motion effect.
This can be done by giving keyframes to timescale in the domain:

In my example i change the timescale from 1 to 0.1:
Comment: This could almost work for me and might be a work around in the end if need be. My fluid sim currently has a constant flow coming out of a pipe and then hitting a separate block surface to show porous sediment, so I'm hoping to only have the fluid hitting that block slow down.
Comment: Ok, looks like I misunderstood you. Could you provide some sketch with annotations to your question to make it more clear?


Fair catch after football hits the ground

Question: A kicked ball hits the ground before a fair-catch signal is made. After the ball hits the ground the return man signals for teammates to stay away (hands waving below waist).
Is it legal for him to pick up and return the ball in collegiate rules?
Also, once the ball hits the ground are the fair-catch-related rules not applicable?
Comment: Please include context when this is coming from context (as I assume this comes from Northwestern-Wisconsin?)
Answer: This is not necessarily 100% clear in the rulebook, but it does seem that "in the know" folks think this is clear (albeit with the grain of salt that refs don't always enforce this consistently).
From the NCAA rulebook, Rule 6 (Kicks), Section 5 (Fair Catch):

No Advance

ARTICLE 2. No Team B player shall carry a caught or recovered ball more than
    two steps in any direction after any Team B player gives a valid or invalid fair
    catch signal (A.R. 6-5-2-I-III).

Invalid fair catch signal is clarified up in Rule 2 (Definitions), Section 8 (Fair Catch):

Invalid Signal

ARTICLE 3. An invalid signal is any waving signal by a player of Team B:

a. That does not meet the requirements of Article 2 (above); or
b. That is given after a scrimmage kick is caught beyond the neutral zone, strikes the ground or touches another player beyond the neutral zone (A.R. 6-5-3-III-V); or
c. That is given after a free kick is caught, strikes the ground or touches another player. [Exception: Rule 6-4-1-f]

So the primary question is, "Does waving the arms below the belt qualify as a "waving signal"?"  The timing is irrelevant (as b. clarifies, invalid signals can be made after the ball hits the ground or are caught, and are still considered invalid signals).
This detail isn't clarified in the rulebook, but it seems a reasonable interpretation that waving other players off is a "waving signal", and in fact may well have been specifically considered by the rules committee given that terminology.  As such, it is a reasonable interpretation that this would be considered an "invalid fair catch signal", which means the ball cannot be returned.

This question is likely referring to this game between Northwestern and Wisconsin on 11/21/2015.
Mike Pereira (a former NFL VP of officiating) notes on twitter, for example:

Those asking about the invalid fair catch signal Wisconsin, that is a correct call. The get-away signal is invalid by rule.

Absent a specific instruction in the referee's handbook, it's unlikely to be clarified further than that (unless the Big Ten chooses to clarify it further themselves, which they may or may not).


Identifying neutral and hot on wire connector

Question: On my ceiling there's this connector where you attach your lamp's wires but it has no indication which side is hot and which is neutral. Is there a simple way to figure it out or does it not really matter?
Comment: It's hard to tell what's going on with all that plaster coating everything.   That looks like a ground wire on the left, completely coated.  The terminal on the right .... does it have a cable attached at the back, buried in plaster?   Or is it just a terminal block where the supply and lamp wires can be attached?  If the former ... you need to dig it all out and clean it up.   Then hopefully it will be obvious which one's hot.  If the latter .. then it doesn't matter but then you have bigger problems. You might have a box with a cover that can be removed.  Scrape off the plaster.
Comment: This must be in the UK. Don't need to scrape off. You need to get a non-contact voltage tester. Some lights might be polarized so you should find out which is hot and which is neutral.
Comment: Yes indeed, that's the ground wire. Apparently when the house was painted they spray painted everything so now it's all coated. There is a cap, all the wires are underneath it and I assume there are 2 screws (also currently coated) to hold it in place. I believe my situation is the latter. Could you elaborate on the bigger problems?
Edit: This is in the Netherlands. Considering I am a complete noob, is there any danger while handling this voltage tester?
Answer: Looks like they just covered the connector and textured everything.
Using a volt meter put one side to the cover plate then one side of the receptacle should show line voltage the other much less or nothing,
there is a possibility of a voltage being measured on the neutral with no connection to a load (called phantom voltage) in that case the lower voltage is neutral.
It matters for safety if wired wrong a metallic fixture may be energized on conductive surfaces but since there is a ground this should trip the breaker.
Comment: With the an Edison socket the shell is required by code to be neutral if the shell is live it creates a greater hazard even if the housing is plastic. I have seen fixtures that both the neutral and ground were connected that would not be code or UL and would trip the circuit breaker. Note the code issue is nfpa or underwriters labs,
Comment: @john: almost nothing: the exception being while carelessly changing the bulb (touching the ring) without turning off the switch, and being referenced to ground somehow. It's happened to me a few times in the US, and would be worse in the UK.
Comment: Thank you for the answer. As for the safety part, if a light's wired wrong and its fixture is plastic nothing can happen?
Comment: I agree with Dan, 230/240 to ground bites hard compared to 120v.


What is to be understood by Mary being the "mother of the church"?

Question: Ever since St. Ambrose of Milan there has been a line of thinking that Mary is the "Mother of the Church" - what is to be understood by this title?
Comment: The Church is the Bride of Christ. Mary is the mother of Jesus. Isn't Mary the Church's mother-in-law?
Answer: Catechism of the Catholic Church 963 referencing Lumen Gentium 53 says, "She is 'clearly the mother of the members of Christ' . . . since she has by her charity joined in bringing about the birth of believers in the Church, who are members of its head."

Lumen Gentium 53 The Virgin Mary, who at the message of the
  angel received the Word of God in her heart and in her body and gave
  Life to the world, is acknowledged and honored as being truly the
  Mother of God and Mother of the Redeemer. Redeemed by reason of the
  merits of her Son and united to Him by a close and indissoluble tie,
  she is endowed with the high office and dignity of being the Mother of
  the Son of God, by which account she is also the beloved daughter of
  the Father and the temple of the Holy Spirit. Because of this gift of
  sublime grace she far surpasses all creatures, both in heaven and on
  earth. At the same time, however, because she belongs to the offspring
  of Adam she is one with all those who are to be saved. She is "the
  mother of the members of Christ . . . having cooperated by charity
  that faithful might be born in the Church, who are members of that
  Head."1 Wherefore she is hailed as a pre-eminent and
  singular member of the Church, and as its type and excellent exemplar
  in faith and charity. The Catholic Church, taught by the Holy Spirit,
  honors her with filial affection and piety as a most beloved mother.
1. cf. Rom 8:29.

cf. Catechism of the Catholic Church 963-970.
Comment: I support this answer, but would like to add:  she is also considered to be the first Christian, and preeminant church member, that was not also God.  (As noted above: "Because of this gift of sublime grace she far surpasses all creatures, both in heaven and on earth.")
Answer: She is Mother of the Church because without her consenting to conceive of Jesus by the Holy Ghost in her womb, Jesus would not have assumed flesh (become man) and founded His Church.


Does NY state hold that a ketuba is a marriage license?

Question: Does NY state hold that a ketuba is a marriage license?
Comment: Does NY state hold that a ketuba is a marriage license?
Comment: @sabbahillel I think this question is fine here. It's related to Judaism and not likely to require extensive law knowledge to answer.
Comment: @Daniel OK I answered it from the New York State web site stating what a marriage license is and how it is obtained.
Answer: No. The ketuvah is no more than any other private pre-nuptual agreement as far as its legal effect in New York State. The marriage license must be obtained from a person who is authorized to issue the license (a town or city clerk) between 1 and 60 days before the wedding ceremony. It must be obtained in person by both parties.
The document must be the official form issued by the state of New York and obtained from the appropriate office.
As far as the effect of the kesuvah @DoubleAA has pointed to Is the ketuba enforceable in American law? in which certain provisions of the kesuvah were upheld because they were purely secular (religiously neutral) parts of a pre-nuptual agreement.
Information on Getting Married in New York State

The Marriage License
Where do you get a marriage license?
A couple who intends to be married in New York State must apply in
  person for a marriage license to any town or city clerk in the state.
  The application for a license must be signed by both applicants in the
  presence of the town or city clerk. A representative cannot apply for
  the license on behalf of the applicants. This applies even if the
  representative has been given a Power of Attorney. Notarized marriage
  license affidavits signed by the applicants cannot be substituted for
  their personal appearance.
Is there a waiting period?
Yes. Although the marriage license is issued immediately, the marriage
  ceremony may not take place within 24 hours from the exact time that
  the license was issued. When both applicants are 16 years of age or
  older, the 24-hour waiting period may be waived by an order of a
  justice of the Supreme Court or a judge of the County Court of the
  county in which either of the applicants resides. If either person is
  under 16 years of age, the order must be from the Family Court judge
  of the county in which the person under 16 years of age resides.
How long is the license valid?
A marriage license is valid for 60 calendar days, beginning the day
  after it is issued.
Comment: this is not necessarily true http://judaism.stackexchange.com/a/27271/759
Comment: @DoubleAA the question was "*Does NY state hold that a ketuba is a marriage liscense?*". The question that you point to is if the secular aspects of a kesuvah can be enforced. That compares it to any other prenuptual agreement. A marriage license is a document issued by the state that causes the change of legal status. Only the state issued marriage license can do that (as I cite from the web site) If only the ketuva and chuppah are done (without a stqate license signed by the rabbi) , the state will not recognize the couple as married.
Comment: But "The ketuvah is strictly a religious document that has no legal effect in New York State." is not necessarily true.
Comment: @DoubleAA i will edit that sentence
Comment: I knew a group of people (I won't mention their "nationality") that were secularly divorced but never did Gittin. The secular divorce was their means of collecting Food stamps, welfare, health benefits, etc. Sounds immoral and anti-halachic, but, apparently, in NY State, it's legal. And, it shows, in a way, that the ketubah, in fact, is NOT a "marriage license" or proof of "legal" secular marriage.


How correctly traslate into English "тестовое задание"?

Question: For example when you go to get new job, you will be given a "тестовое задание". How to translate this combination of words into English?
Answer: This type of question is definitely off-topic on this site.  However to help you out, the right translation is test assignment or trial assignment. I work as a manager in the software development organisation in England.  When I look for new people, part of the selection process is technical test.
Once a candidate is hired, they will typically be given some test assignments (in my previous job we called them trial assignments) to confirm that they can really do the work expected of them.
Answer: I would translate "тестовое задание" as "an aptitude test (for job applicants)".
Answer: We call it just 'test task', esp for IT-related positions


Show full category tree for a year with all post titles?

Question: Is it possible to print all categories used for a specific year in a hierarchical tree with all the post titles underneath each category title?
How?
Comment: If a post has multiple categories, should its title be printed multiple times?
Comment: Is this different to your question yesterday? http://wordpress.stackexchange.com/q/237853/94267
Comment: @cjbj Yes it should. And no, I should delete the other one. I changed my mind how I want it.
Answer: The start is easy. Let's fetch all the posts from 2015:
$posts = new WP_Query( 'year=2015' );

Now, we have an array of post objects, which we must sort into categories, duplicating them if they have multipe categories. The result goes into a multidimensional array.
$categorized_posts = array ();
foreach ($posts as $post) {
  $post_cats = wp_get_post_categories ($post->ID, array('fields' => names));
  foreach ($post_cats as $post_cat) {
    $categorized_posts[$postcat][] = $post->ID;
    }
  }

So $categorized_posts is an array with category names and for every category name there is an array of ID's of the corresponding post. What's missing is a hierarchical tree. We're going to loop through all categories, printing them along the way with the corresponding post titles. To do this hierarchically we use the recursive function found here, which we modify to output post titles.
// this goes in the template where you want the tree to be printed
wpse237979_hierarchical_category_tree (0, $categorized_posts );

// this goes in functions.php
function wpse237979_hierarchical_category_tree ( $cat, $categorized_posts ) {
  $next = get_categories('hide_empty=false&orderby=name&order=ASC&parent=' . $cat);
  if ($next) {
    foreach ($next as $cat) {
      if (array_key_exists($cat,$categorized_posts)) {
        echo '

' . $cat->name . '';
        // now loop through the gathered ID's of posts belonging to this category
        $current_cat_posts = $categorized_posts[$cat];
        foreach ($current_cat_posts as $current_cat_post) {
          $this_post = get_post ($current_cat_post);
          echo '
' . $this_post->post_title . '
';
          }
        }
    wpse237979_hierarchical_category_tree( $cat->term_id, $categorized_posts );
    }
  }
  echo '

'; echo "\n";
}

Note: I didn't actually test this code, so some debugging may be necessary, but I trust you get the general idea.


Have you ever had to create a Finite-State machine?

Question: This does not include a finite-state machine you might have done for college.
I want to know who has had to create one and why?
What was the most difficult aspect of creating the machine?
Answer: Yes, lots of them. Basically, I had to implement lexical analyzers manually for performance reasons. Other personal uses have been in GUI designs where the FSA has controlled the flow of interaction with the user.
Creating such machines is not difficult at all. Changing them is because at least part of the structure of the FSA is embedded rigidly in the code. The state pattern helps to ease some of these transitions – but not all of them.
Answer: Many times!
Most protocol stacks used in communications systems are implemented as state machines. The CSTA call model being one good example.
Also most embedded systems are essentially state machines.
Basically any system that has to react to events in the real world is a good candidate for implementation as a state machine.
The most difficult thing about state machines is understanding what they do in the absence of up to date documentation. They have a tendency to get bug fixed beyond recognition.
Answer: Sure, I designed and created a turbine governor to control small turbines, pumps, and motors. It is an embedded device with a DSP chip. It has states such as stopped, startup, running, overspeed-test and then there are several states within the running state to cover other control possibilities.
In my case, the hardest part about the state machine management was designing a clean transition, especially when states can have sub-states. For the turbine governor, this meant that the speed output (actuator) had to be adjusted smoothly between transitions. Other challenges were related to the user interface (push buttons and 7-segment LED display) and how they interacted with the state machine. So there ended up being a master control state machine, a related user-interface state machine, and a related communications state machine (it was not permissible to write certain values while the turbine was running).
I have used state machines in a variety of other projects, some embedded and some standard software, as well from communications to user interface software.
Answer: As above, the purpose of an FSA is just that, going from step to step to step, all your processing (and state changes) are handled in one loop.  And, when something changes in the process, getting to the next logical step is easy.
And yes, they're easy to do, I have used them frequently over 25 years.
Answer: I have too. I usually create small FSMs (with few states) because bigger ones become maintenance nightmares, but sometimes an FSM is a very simple and elegant design for a given task.
As a real-world example, I created a little utility to repair a certain type of file once. There were only 3 or 4 possible interaction paths with the user:

show a little message, select file (maybe cancel and start over),
repair file (maybe cancel and exit with error message),
show a confirmation message.

Creating the state machine made those paths apparent and easy to implement.


When should we use Java's Thread over Executor?

Question: Executor seems like a clean abstraction. When would you want to use Thread directly rather than rely on the more robust executor?
Answer: To give some history, Executors were only added as part of the java standard in Java 1.5. So in some ways Executors can be seen as a new better abstraction for dealing with Runnable tasks.
A bit of an over-simplification coming... - Executors are threads done right so use them in preference.
Comment: Well, Erlang is threads done right, but Executors are about as good as it'll get in java...
Answer: I use Thread when I need some pull based message processing. E.g. a Queue is take()-en in a loop in a separate thread. For example, you wrap a queue in an expensive context - lets say a JDBC connection, JMS connection, files to process from single disk, etc.
Before I get cursed, do you have some scenario?
Edit:
As stated by others, the Executor (ExecutorService) interface has more potential, as you can use the Executors to select a behavior: scheduled, prioritized, cached etc. in Java 5+ or a  j.u.c backport for Java 1.4.
The executor framework has protection against crashed runnables and automatically re-create worker threads. One drawback in my opinion, that you have to explicitly shutdown() and awaitTermination() them before you exit your application - which is not so easy in GUI apps.
If you use bounded queues you need to specify a RejectedExecutionHandler or the new runnables get thrown away.
You might have a look at Brian Goetz et al: Java Concurrency in Practice (2006)
Comment: I was implementing a polling queue using a Thread, when I noticed I can get exactly the same functionality but easier with an Executor (easier to detect when it's done).
Answer: There is no advantage to using raw threads. You can always supply Executors with a Thread factory, so even the option of custom thread creation is covered.
Answer: You don't use Thread unless you need more specific behaviour that is not found in Thread itself. You then extend Thread and add your specifically wanted behaviour.
Else just use Runnable or Executor.
Comment: You can always return your custom Thread object from a ThreadFactory, and pass that to the Executor.
Answer: Well, I thought that a ThreadPoolExecutor provided better performance for it manages a pool of threads, minimizing the overhead of instantiating a new thread, allocating memory...
And if you are going to launch thousands of threads, it gives you some queuing functionality you would have to program by yourself...
Threads & Executors are different tools, used on different scenarios... As I see it, is like asking why should I use ArrayList when I can use HashMap? They are different...
Answer: java.util.concurrent package provides executor interface and can be used to created thread.
The Executor interface provides a single method, execute, designed to be a drop-in replacement for a common thread-creation idiom. If r is a Runnable object, and e is an Executor object you can replace
(new Thread(r)).start();
with
e.execute(r);
Refer here
Comment: the documentation do not specify if in case of " e.execute(r)" there is need to shutdown() . someone know?
Answer: It's always better to prefer Executor to Thread even for single thread as below
ExecutorService fixedThreadPool = Executors.newFixedThreadPool(1);

You can use Thread over Executor in below scenarios

Your application needs limited thread(s) and business logic is simple
If simple multi-threading model caters your requirement without Thread Pool
You are confident of managing thread(s) life cycle + exception handling scenarios with help of low level APIs in below areas : Inter thread communication, Exception handling, reincarnation of threads due to unexpected errors

and one last point

If your application does not need customization of various features of ThreadPoolExecutor
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory,
RejectedExecutionHandler handler)

In all other cases, you can go for ThreadPoolExecutor


Multi-channel CNN - ValueError: Output tensors of a Functional model must be the output of a TensorFlow `Layer`

Question: I am trying to construct a multi-channel convolutional neural network. I have two tensors (i.e., training_x1 and training_x2), each including float values with (476, 47, 3, 1) dimension. I build the multi-channel NN as follows (a minimal example):
import numpy as np
from tensorflow import keras
from keras.models import Model
from keras.layers import Dense, Conv2D, MaxPooling2D, Flatten, Dropout, concatenate, AveragePooling2D, Input

training_x1 = np.zeros((476, 47, 3, 1))  # just as an example
training_x2 = np.zeros((476, 47, 3, 1))  # just as an example

inputs1 = Input(shape=(training_x1.shape[0], ))
conv1 = Conv2D(filters=32, kernel_size=3, activation='relu')(training_x1)
drop1 = Dropout(0.5)(conv1)
pool1 = MaxPooling2D(pool_size=2)(drop1)
flat1 = Flatten()(pool1)

# channel 2
inputs2 = Input(shape=(training_x2.shape[0], ))
conv2 = Conv2D(filters=32, kernel_size=3, activation='relu')(training_x2)
drop2 = Dropout(0.5)(conv2)
pool2 = MaxPooling2D(pool_size=2)(drop2)
flat2 = Flatten()(pool2)

# merge
merged = concatenate([flat1, flat2])

# interpretation
dense1 = Dense(10, activation='relu')(merged)
outputs = Dense(1, activation='linear')(dense1)
model = Model(inputs=[inputs1, inputs2], outputs=outputs)

However, my model fails with error ValueError: Output tensors of a Functional model must be the output of a TensorFlow Layer (thus holding past layer metadata). What mistake am I making?
Answer: There are few corrections that need to be done in your code as below:

Provide the correct input_shape of dataset in the input layer
Add this input layer to the next layer of the model(Conv2d layer) instead of attaching the dataset
Mention the padding='same' in Maxpooling2D layer

Something like this:
inputs1 = Input(shape=(47, 3, 1)  )
conv1 = Conv2D(filters=32, kernel_size=3, activation='relu')(inputs1) #provide the input1
drop1 = Dropout(0.5)(conv1)
pool1 = MaxPooling2D(2, padding= 'same')(drop1) #add padding='same'
flat1 = Flatten()(pool1)

Please find the replicated code gist here for your reference.


How can power drawn from one outlet cause another outlet to burn up?

Question: I had accidentally overloaded a circuit when I plugged something into an outlet but it caused another outlet in the same circuit (which had some, but not much power being drawn through it) to burn up. Fortunately, the circuit breaker tripped and nothing bad happened, but I'm wondering why this could have happened so I can prevent it form happening again.
Answer: Note: I'm assuming you are in North America.
Most likely, the power passed through the "bad" outlet on its way to the outlet you overloaded. A standard US outlet (pair) has two screws each for the hot and neutral, as well as two "back-stab" holes for each. It is not uncommon to connect the wires coming from the breaker box to one pair and the wires going to the next outlet to another, rather than joining the wires and running "pigtails" (short wires) to the intermediate outlet.
If  one of the connections is not making good contact, the resistance will generate heat under the heavy load and this can damage the outlet. Most likely, the back-stabs were used, which are known to come loose.
(Side note: the reason there are two sets of connections is to allow isolating each of the two outlets, for example, if you wanted only one outlet switched. There are metal tabs on both sides of the assembly connecting the top to the bottom. These can be broken off. If you are examining an outlet and either or both tabs has been removed, then something else may be happening with that outlet.)
[Excuse the poor drawing]
Using back-stabs with power passing through the outlet. This is to be avoided.

Using side screws with power passing through the outlet. This is better.

You can also avoid running the power through the outlets by using wirenuts and pigtails to the screws on the outlet. This avoids running the power through the outlet to the next and is marginally better than the previous.

If I were you, I'd check (or hire someone to check) each outlet in your home. Look for signs of damage from heat and replace any such outlets. Also, if the back-stabs were used, change to use the side screws instead or use wirenuts with pigtails to the side screws.
If you do replace any outlets, check if either of the metal tabs has been removed. If so, make sure to break off the same tabs on the new outlet and don't change the wiring unless you understand how it works.
Also check the tightness of any screws already in use.
Answer: Outlets are often connected in a series, with current for all loads passing through the contacts on each side of each outlet. If a connection is going to fail, it's usually the one with the poorest contact, which generates the most heat.
Some electricians pigtail the wiring in each box to avoid this problem. An outlet only carries the current to loads connected directly to it.
Comment: I would like to suggest you change the words used here describing "series". This could be confusing to many.
Comment: It crossed my mind when I wrote it, but I did say *a* series. I guess I don't feel too responsible for people who can't read carefully.


What, fundamentally, is the reason for the shape of a sin curve?

Question: Say we have a metal bar in space aligned horizontally and we start rotating it counter-clockwise about its left end. Then, the sin of the angle from between the horizontal and the bar is the y coordinate of the far end divided by the length of the bar. So, I understand that sin/cos are related to projections of things when you rotate them. Is this the fundamental idea? Why do sin curves look the way they do? Why is the slope most negative when sin(x) = 0? I'm looking for an intuitive answer, not just that the derivative of sin is cos.
Comment: @Jared: ... or their definitions in terms of circles.
Comment: The $y$-coordinate is changing most rapidly when the moving end of the bar is on the $x$-axis, when the bar is horizontal. This is reasonably clear from visualization, and does not require taking the derivative. Similarly, it is visually clear that the rate of change is $0$ when the bar is vertical.
Comment: Now one caveat to what I said is that it's hard to make sense of trigonometric functions _at all_ when we start talking about complex values.  At that point we sort of have to trust the algebra.  I don't think there's anyway to argue, fundamentally (from right triangles), that $\sin(x) = \frac{e^{ix} - e^{-ix}}{2i}$...for that we have to trust the algebra of Euler's equations.
Comment: When dealing with the trigonometric functions you must _always_ go back to their definitions in terms of right triangles.  The shape of the sinusoid is determined by that definition and I don't think you can really make sense of the shape other than that they are equivalent.
Comment: @Hurkyl The unit circle is helpful when thinking of trigonometric _functions_ but we make sense of the unit circle through the elementary definitions from right triangles.
Comment: Answer: because that is how the sin curve was defined. It's a function from real numbers to the subset of real numbers between -1 and 1. Right there that constrains a lot of the properties of the function and it's graph.
Answer: Yes, that's the idea.  The end of the bar is moving at a constant speed, so the $y$ component of its velocity (which is the rate of change of $\sin(\theta)$) is greatest in magnitude when all of that velocity is in the $y$ direction, and that happens when $\sin(\theta) = 0$.
Comment: I made it with Maple.
Comment: Is there some place that you use to generate the gifs or are you creating these from scratch (or did you just find this gif)?
Answer: Graphically you can see that at $\theta = 0$ the derivative of the $\sin$ (the $y$-value) is changing the most as opposed to anywhere else (other than the other side of the circle at $\theta = \pi$):

Here's another picture which shows that the shape of the sinusoid is due to the definition of sine in the first quadrant (forgive the approximate nature of this sketch--but it is basically correct):
Answer: I think the other answers fully answer the question, but this might be helpful.  My favorite real-life visualization of a sin curve comes from a telephone handset cable:

When stretched out on a flat surface, and viewed from above, the shape of the cable approximates a sin curve.  The equations for the center of the cable will be something like:
$$y=R\sin(Ax)$$
$$z=R\cos(Ax)$$
where R is the radius of the cable spiral, and A depends on how much the cable is stretched.
Comment: Soon enough you'll need to explain what a telephone handset cable is...
Comment: @Joe I can see it now. I can't wait to say to my kids: "Phones weren't always wireless y'know! Back in my day phone service came directly to the house through physical cables! And you could only walk a few feet from the phone, because it was connected to the wall!"
Comment: @Joe it's the waves representing modulated signal transmitted from my smartphone, right?
Comment: @Joe perhaps I should add an image like this to clarify http://upload.wikimedia.org/wikipedia/commons/8/8a/1979_TMA7214_706_Style_Two_Tone_Grey_Rotary_Dial_Telephone.JPG ;-)
Comment: Fun Fact: Contemplating a telephone handset cable —specifically, the idea that rotating the helix along its axis induces a phase shift in the projected curve— is what initially inspired [this visualization](https://math.stackexchange.com/a/1093/409) of the derivatives of sine and cosine.


What should we do if we realise the Queen should have been on the board?

Question: We forgot to return the Queen to the board after my opponent failed to cover it, and continued to play. What's the correct way to rectify this?
Answer: Treat it as covered.
According to these rules:

96) If the Queen is pocketed by a stroke and is not covered, the Queen shall be taken out for placing. If not noticed by the Umpire or by the opponent, before the next stroke is made, the Queen shall be recorded as properly covered.

In a casual setting, however, I'd take it out and place it before your next turn (so you get the next shot on it).
Comment: What is the source of these rules? Are they from a Carrom publisher or just something that some guy made up? The bright green website doesn't inspire a lot of confidence. He mentions some books, but I don't know anything about them.
Comment: They line up with these http://www.carrom.org/icf/?page=3&subcat=20 but that site seems to be broken on additional pages. I've seen the same rules in a few places previously, but it's been a while since I looked.around.


End sox recording once silence is detected

Question: I'm writing a script that uses sox to record me talking.
Now I need sox to wait until it detects sound before it begins recording, and I do have that figured out. But I also need sox to exit once there has been silence for at least 3 seconds.
As it is now, I have to manually kill sox once I finish talking, otherwise sox just waits again until I talk some more, appending to the output file (That's not what I want).
Here is the command for recording I am using now:
rec /tmp/recording.flac rate 32k silence 1 0.1 3% -1 3.0 3%

Again, just to be clear, Sox should wait until I start talking, and then record until I stop talking, then the sox program should quit.
Answer: Remove the negative sign from your original command:
rec /tmp/recording.flac rate 32k silence 1 0.1 3% 1 3.0 3%

When the "below count" is negative, the silence command will trim all silences from the middle of the file. When it's positive, it trims silence from the end of the file.
Comment: That is a much simpler solution than the one I came up with, LOL!
Answer: I tweaked the above ideas some more. It records forever, records all noise until (roughly) a second of silence is encountered. Then:

Ensures two subdirectories are created
Calculates two spectrographs of the recording - one before normalisation, and one after, and writes to datestamped folders.
Writes the normalised one to a file to a datestamped folder.
Plays the normalised file back, with two chirp .ogg files (back through voice operated CB Radio)

(Makes for a very handly little UHF / 2 metre echo repeater)

#!/bin/bash
while true; do
  rec buffer.ogg silence 1 0.1 5% 1 1.0 5%
  DATE=`date +%Y%m%d%H%M%S`
  DPATH=`date +%Y/%m/%d/`
  mkdir -p ./spectro/$DPATH
  mkdir -p ./voice/$DPATH
  echo Renaming buffer file to $DATE
  sox buffer.ogg -n spectrogram -x 300 -y 200 -z 100 -t $DATE.ogg -o ./spectro/$DPATH/$DATE.png
  sox buffer.ogg normbuffer.ogg gain -n -2
  sox normbuffer.ogg -n spectrogram -x 300 -y 200 -z 100 -t $DATE.norm.ogg -o ./spectro/$DPATH/$DATE.norm.png
  mv normbuffer.ogg ./voice/$DPATH/$DATE.ogg
  play pre.ogg ./voice/$DPATH/$DATE.ogg post.ogg
done
Answer: I found a kind of shaky way that sort of solves this problem.
I noticed that when silence is detected, sox naturally won't append anything more to the file until it hears more sound. So I decided I could try and take advantage of this fact.
First of all, I start up sox's sound recorder in the background:
rec /tmp/recording.flac rate 32k silence 1 0.1 3% -1 3.0 3% &

Next I get the PID of the recording process with: p=$!
Then I give the recording process a second to finish starting up, and then wait until the file starts to grow.

sleep 1
until [ "$var1" != "$var2" ]; do
    var1=`du "/tmp/recording.flac"`
    sleep 1
    var2=`du "/tmp/recording.flac"`
done

After this loop breaks, that means that sound has been detected. So now I create another loop to wait until data stops being appended to the file (This will happen once sox detects silence again).

echo "Sound Detected"
until [ "$var1" == "$var2" ]; do
    var1=`du "/tmp/recording.flac"`
    sleep 0.5
    var2=`du "/tmp/recording.flac"`
done

Now I just need to quit rec:

echo "Silence Detected"
kill $p

And that's it.
Here is the completed script:

rec /tmp/recording.flac rate 32k silence 1 0.1 3% -1 3.0 3% &
p=$!
sleep 1
until [ "$var1" != "$var2" ]; do
    var1=`du "/tmp/recording.flac"`
    sleep 1
    var2=`du "/tmp/recording.flac"`
done
echo "Sound Detected"
until [ "$var1" == "$var2" ]; do
    var1=`du "/tmp/recording.flac"`
    sleep 0.5
    var2=`du "/tmp/recording.flac"`
done
echo "Silence Detected"
kill $p

Now I would prefer a better, more stable way to do this, but this will have to work for now.
Answer: This listens forever, records only the last sounds until it hears one second of silence, then writes the file, timestamps it, and restarts:
#!/bin/bash
/usr/bin/sox -t alsa default /home/default/working/recording.wav silence 1 0.1 5% 1 1.0 5%
DATE=$(date +%Y%m%d%H%M%S)
mv /home/default/working/recording.wav /home/default/waiting/$DATE.recording.wav
/home/default/startrecord.sh

Comment: Bash has [`while true`](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html) loops
Comment: This works great for me except I want to wait for at least 3 seconds of silence before killing the recording. How would I do that?


pax jdbc datasource configuration variable

Question: I'm using a connected Docker mysql instance with my docker container which contains a Karaf 4 instance configured with a Pax JDBC datasource.
My problem is that my jdbc url depends on some environement variables setup by docker (as the mysql container IP is not always the same). The IP address variable is MYSQL_PORT_3306_TCP_ADDR.
I tried to start karaf with -DMYSQL_PORT_3306_TCP_ADDR=XXX.XXX.XXX.XXX and to setup my datasource with a config file (etc/org.ops4j.datasource.mydb.cfg) which would contains:
url=jdbc:mysql://${mysql.port.3306.tcp.addr}:3306/mydb

but looking at the service:list in karaf I see:
url = jdbc:mysql://:3306/pandoradb

so the variable is clearly not used.
Is there an way to do what I want ?
Best.
Answer: I finally found the solution!
I don't know why I tried to use the ${mysql.port.3306.tcp.addr} variable in my conf.... using the correct variable is properly interpreted:
url=jdbc:mysql://${MYSQL_PORT_3306_TCP_ADDR}:3306/mydb

Best.


Inventory management in Rails

Question: I'm creating a inventory management app in rails. I have an User Table and a Recipe table, there is also some tables with types of material (pens, sharpies, paper, and so on). Because there is a lot of types of paper, pens and other things, and every user may want a diferent pen, but a pen I think that it will be better to have a type of article and have in the Recipe table the Quantity of articles needed. So when an user checks his list of articles there will be Pens: 2  and maybe some options and a search for more info of an specific pen. Like a ToDo list. But I having trouble to figure out the relationships of the tables for this purpose. Right now im designing the database. I was thinking in use MySQL in Rails.
Answer: Try to put 'on paper' what you 'fields' that you need. Once you have that then you must group them based on what fields have a same identifier. In you case you might have 3 entities:

User with an ID and a name
Group with an ID and a name (with values like like pen and paper)
Material with an ID, the GroupID and a name

For the ToDo you can try yourself to figure it out.
Google on database normalisation to find some more information. You do not need to go down all the way but try to figure out the first 3 forms.

Inventory management in Rails


How do fact and belief relate to each other?

Question: So I understand the main differences between facts and beliefs, but is there a part where they overlap? Is it possible that there is a point where one can find similarities between both concepts?
How exactly do fact and belief relate to each other?
Comment: A [Fact](https://plato.stanford.edu/entries/facts/) is a "piece" of reality. A [Belief](https://plato.stanford.edu/entries/belief/) involves a human believing.
Comment: They are not different, they refer to unrelated objects. A fact is an instance, an existence. A belief is some knowledge. The opposite of fact would be a lack, a void. The opposite of a belief would be an uncertainty, an skeptic attitude, ignorance. You might experience a fact of belief (I have felt faith) , a fact of disbelief (I have felt a lack of faith), a lack of belief (I haven't felt faith) or a lack of disbelief (I haven't felt skeptical). Or an unreal fact (a fact is not "a piece of reality": I've felt my missing arm; in this case, the belief is the same as the fact).
Comment: Added 'epistemology', 'subjectivity', 'objectivity', and 'social-epistemology'.
Answer: Due to the spinning of the earth we experience sunrise and sunset.  This is a fact. Standing on one side of the earth we believe the sun is on the other side after sunset and before sunrise. You can find so many instances like this where fact and belief overlaps.
You believe your internal organs like stomach, liver, kidneys etc are functioning. (If you have no equipment) In your case that also is a fact as well as a belief.
A thing that is not perceivable while believing (as mentioned above) are often like this.  While one may believe, another may experience the fact.  So it may not be the same from someone else's point of view. (I mean this is not universal.)
How exactly do fact and belief relate to each other?
All beliefs are not facts. One can believe something even if there is no evidence of facts. One's character, likes, dislikes, and feelings only affect beliefs, never facts. Subjectivity has a role on beliefs; but not on facts. So they are related to each other only when there is a possibility of objectivity.
Answer: A belief is an view held by an individual in the absence of overwhelming evidence to support it.  Where overwhelming evidence does exist we would say that we 'know' something rather than believe it, although the threshold for this is a worthy subject for philosophical debate.  A belief may correlate with facts although it doesn't have to.
Answer: Adding on to what @MauroALLEGRANZA said in the comments, there is reality as it is, then there is our mental model of said reality based on experience and inference. If fact is a piece of reality, then belief is a piece of our mental model.

[...] but is there a part where they overlap?

Imagine a computer with a wired webcam. When the camera is running, a piece of the world -- a fact -- is translated into a piece of data in the computer's memory -- a belief.
Now imagine the camera is pointed back at the screen while the screen is showing the image in real-time, giving a video feedback loop. In this scenario, the computer holds a belief about what is out there in the real world, yet this belief contains translated copies of its own prior beliefs, in continuous recursion. In a way, the computer becomes aware of its own vision through time. Moreover, the computer now holds belief of its own prior belief.
As the rate and accuracy of video feedback increase, the closer becomes belief to its corresponding fact. That is, the computer's belief about its own belief approaches current and true. Belief approaches fact.
If awareness is belief on the current state of reality, and if consciousness is real-time awareness of one's awareness, then perhaps consciousness is an approximation of convergence between fact and belief.
In conclusion, consciousness is an overlap between fact and belief, and higher consciousness is greater overlap.
Answer: A fact is a solidified belief: a belief that we have (for one reason or another) become convinced is true and inviolate, and projected onto the world. Sometimes we solidify that belief for good reasons, sometimes for bad reasons, sometimes out of mere custom and habit (which don't really count as 'reasons' in the proper sense).
It makes some sense to talk about 'sensory' facts: observations and perceptions that we can collectively experience. This is the lynchpin that holds scientific investigation together. But even this is better conceived of as intersubjective belief, where we have convinced ourselves of the belief that others actually experience the world exactly as we do.
Answer: Short Answer

How do fact and belief relate to each other?

A belief is one type of mental state that collectively is recognized by philosophers as a type of intentionality, and is expressed as a proposition. In contrast, a fact is a specific type of belief. A fact is a specific type of proposition that is generally understood as a collective, reasonable, and empirical belief, a type of objective knowledge. Both are studied by epistemologists, and the question of objectivity, subjectivity, and intersubjectivity as well as belief, justification, truth, and knowledge are central to metaphysics.
Long Answer
Intentionality, Belief, and Language
Human agents are posited to have a property called intentionality. Intentionality is often characterized as "aboutness", as in people can have thoughts, feelings, and so on about objects such as trees, ideas, or other people. From WP:

Intentionality is the power of minds to be about something: to represent or to stand for things, properties and states of affairs.1 Intentionality is primarily ascribed to mental states, like perceptions, beliefs or desires, which is why it has been regarded as the characteristic mark of the mental by many philosophers. A central issue for theories of intentionality has been the problem of intentional inexistence: to determine the ontological status of the entities which are the objects of intentional states.

Beliefs are perhaps the most important example of mental states because they are an intersection between experience and language. Robert Audi in his Epistemology: A Contemporary Introduction to the Theory of Knowledge offers a number of sources for belief: perception, memory, consciousness, reason, and testimony. For instance, you may believe that you are hungry because your stomach growls. You may believe that a car is moving down the street because you are aware of the change of position. You may believe your wife when she says she's angry you didn't buy a gallon of milk at the store. When your beliefs conflict, you may experience cognitive dissonance. What is belief more specifically? Here philosophers split hairs. From WP:

There are various different ways that contemporary philosophers have tried to describe beliefs, including as representations of ways that the world could be (Jerry Fodor), as dispositions to act as if certain things are true (Roderick Chisholm), as interpretive schemes for making sense of someone's actions (Daniel Dennett and Donald Davidson), or as mental states that fill a particular function (Hilary Putnam).2 Some have also attempted to offer significant revisions to our notion of belief, including eliminativists about belief who argue that there is no phenomenon in the natural world which corresponds to our folk psychological concept of belief (Paul Churchland) and formal epistemologists who aim to replace our bivalent notion of belief ("either we have a belief or we don't have a belief") with the more permissive, probabilistic notion of credence ("there is an entire spectrum of degrees of belief, not a simple dichotomy between belief and non-belief").2

Beliefs are generally expressed as propositions, and our attitudes towards propositions are called propositional attitudes. A proposition can be thought of as a complete sentence or a statement. The fancy philosophical terminology to describe the act of conveying knowledge with a statement is called predication. A simple prediction follows:

The Willis Tower (formerly the Sears Tower) is a tall building.

When an honest person utters this, at a minimum they are expressing a belief and  demonstrating intentionality. That is to say, they are thinking about the Willis Tower as they experience them. Now, is it a fact that Willis Tower is tall? Things become a little more complicated.
Facts and Opinions; Objectivity and Subjectivity
As most school children are told (and some struggle to retain), generally, propositions can be divided into subjective statements, called opinions, and objective statements, called facts. Opinions are difficult to "prove" because they often reflect internal, mental states of agents. 'The Mona Lisa is creepy' is subjective or opinionated because an agency's intentionality, their feelings are not shared experience. Opinions can be popular ('Ice cream is delicious'), and they can be unpopular ('Goat poop is delicious'). But they are not public, and therefore, it's hard to justify. Remember, knowledge is justified, true belief (at least on a simple reading). Facts are different. They are easy to justify and show are true. 'Snow is white' is easy to show because if you have a group of people, few people will dispute the proposition, explanations can usually accommodate dissenters, and modern scientific theory and equipment can measure wavelengths of light. Hence, 'pure snow is white' is generally recognized as a fact. So far, it seems simple.
But take our example about the Willis Tower. Is it true that the Willis Tower is tall? This gets difficult, because it's not clear what 'tall' means. I may think it is tall, but a geologist who studies the Alps may disagree and claim the opposite. How is this dispute settled, and why does it happen in the first place? Well, philosophers have distinguished that there are some fundamental divisions among propositions, a fact-value distinction and an is-ought distinction reflect the dichotomy between the objective and subjective. The former:

The fact–value distinction is a fundamental epistemological distinction described between:1
'Statements of fact' ('positive' or 'descriptive statements'), based upon reason and physical observation, and which are examined via the empirical method.
'Statements of value' ('normative' or 'prescriptive statements'), which encompass ethics and aesthetics, and are studied via axiology.
This barrier between 'fact' and 'value' implies it is impossible to derive ethical claims from factual arguments, or to defend the former using the latter.2

and the latter:

The is–ought problem, as articulated by the Scottish philosopher and historian David Hume, arises when one makes claims about what ought to be that are based solely on statements about what is. Hume found that there seems to be a significant difference between positive statements (about what is) and prescriptive or normative statements (about what ought to be), and that it is not obvious how one can coherently move from descriptive statements to prescriptive ones. Hume's law or Hume's guillotine1 is the thesis that, if a reasoner only has access to non-moral and non-evaluative factual premises, the reasoner cannot logically infer the truth of moral statements.2

So, if an English teacher assigns an essay with the prompt "Is the Willis Tower tall, and should it be predicated as tall?" you are firmly in philosophical territory.
Intersubjectivity, Convention, and Dispute
How do philosphers and practical people of all stripes resolves these sorts of dilemma and dichotomies? Well, sophisticated thinkers invoke the explanations of intersubjectivity and convention. Simply put, intersubjectivity is a the idea that what constitutes 'objectivity' is actually just (near-)universal consent. Is this Willis Tower tall? Yes. Why? Because most people judge size relative to their own height. In linguistics, certain expressions are understood in terms of an implicit context, and this is known as deixis. Elephants are big, and mice are small because of their size relative to average people. In fact, NBA players are tall, and leprechauns are small because of their (purported) size relative to average people. Thus, it becomes a convention in language to use tall in a certain way. You shouldn't use 'short' to describe the Willis Tower because it violates convention, and in doing so violates one of Grice's maxims, probably the Maxim of Clarity. When a person uses idiosyncratic meanings instead of conventional one's, it leads to confusion.
So, is the Willis Tower tall? Yes, and it is a fact. But, anyone can challenge the facticity of the statment. Just like the claim 'The Willis Tower is 10 meters tall' is a demonstrably false fact, so too can someone claim that 'The Willis Tower is tall' is a false fact, or even an opinion. In fact, a clever person can use philosophy and language to assert something like 'There is no Willis Tower at all, so it can't be tall'! Once the conversation is in that territory, you're clearly in what philosophy calls metaphysical speculation. Deeper discussions, of course, can be had about subjectivity, beliefs, facts, and truth such as in this post on post-modernism (PhilSE).


Is there a way to array an object along a few faces?

Question: Of course, objects can be arrayed along a curve, but I was wondering if there was a way to array them along a series of faces. I'm gonna be adding details to my Titanic model, and I'm wanting to array objects along the hull and walls, but most of them are curved (at least slightly) so a straight array just won't do.
Answer: You can use the Shrinkwrap Modifier to the curve, but if you are planing to add details to a mesh you already have, I'll recommend to:

Tab enter edit mode, chose edge select, select the edges
shift+D duplicate it, then press P separate selected.
With this you'll have made a new object copy of the selected edges.
tab to go back object mode, select the new object, and convert it
to a curve
AltC curve from mesh.
You can also use parent object, on the property panel select
verts on the parent object ,"the curve or the line you chose".
Comment: That's the way I have been doing it, and I suppose I can continue using this method for the rivets. I'm also trying to figure out the joggling effect of the hull's plates (the seams along the horizontal parts of the plating).
Photo reference:
http://www.travellinghistorian.com/vicp45gig.jpg

Diagram reference (top diagram is what I'm referring to):
https://www.encyclopedia-titanica.org/community/attachments/demonstration-jpg.40384/
Comment: i dont understand whats your goal, but if you need it to be parented to a face,  select [face] instead of [verts] in the property panel at right side.
see: https://www.youtube.com/watch?v=yNjk83mCVu8


How to mix large amounts of sponge for bread?

Question: I am making large batches of bread with 100% hydration poolish. In the current situation, using a large mixer and then having to clean the bowl after is not an option because of time. Mixing by hand does not effectively eliminate all lumps of flour. A dough whisk is not large enough for the task (think 10 pounds flour and 10 pounds water at a minimum). How do bakeries mix their pre-ferments when they can't use a machine?
Answer: Our local large bakery has mixers that have a tiltable bowl: mix, lift the bowl (with a kind of crane), dump the content out - wherever it's supposed to go. But we are talking about five to ten times the amount you asked about.
For 10kg in total, you don't need a mixer. Roll up your sleeves, wash your hand and give the poolish a good mix with your hands in a large tub. I have kneaded similar amounts of bread dough (60-70% hydration) by hand and know others who have done the same. Your 100% hydration poolish will be even easier to handle. Then scrape off what sticks to your hands and let rest as usual.
Note that a poolish doesn't need dilligent kneading, gluten development happens during the long fermenting phase, not during kneading. So if the poolish is somewhat "shaggy", it's ok.
Answer: I don't get your comment - Stephie describes doing it by hand.
At 100% hydration, a large, sturdy spoon should also work.
A large immersion blender might also do (no personal experience, I consider them more of a fad than a tool I need.)
Or if you have trouble dealing with effectively mixing 20 pounds of glop at once by hand or spoon, mix 5 4 pound batches and dump them into a bucket after they are mixed (or whatever size batch you find comfortable.) Or do those in quick succession in a small mixer and only clean it at the end.
On the further-out end of specialized tooling and timesaving that's not a mixer, something like a mortar box and hoe (the hoe has large holes in it), made of wood or stainless steel (wood seems more likely - I doubt you'd find one made for mortar that you'd want to use in food, so it would be a custom-job) - or a plastic tub and the "hoe." Of course that actually is a mixer, just one that's hand-powered.
Comment: Not a suggestion but I've heard of people using a drill-mounted paint/plaster stirrer successfully
Comment: And I've certainly seen those in stainless steel...
Comment: An immersion blender would be way out of its range of uses for that task.


Gibbs Sampling Detecting Change point in time series

Question: I was reading through this one page paper on using Gibbs sampling for detecting a change point in a time series like data. While I understand the part where the $\lambda$ and $\phi$ are chosen from a gamma distribution I do not understand how the author generated the posterior distribution for $k$.
My thinking is, if the first $k$ points came from a Poisson distribution then the probability of $P(k|\lambda,\phi,Y_i)$
$$
P(k|\lambda,\phi,Y_i) = \Pi_{i=1}^{k}\frac{e^{-\lambda}\lambda^{Y_i}}{Y_i!} \times \Pi_{i=k+1}^{N}\frac{e^{-\phi}\phi^{Y_i}}{Y_i!}
$$
The author shows an expression of the form $\frac{A}{B}$ where $B$ is the normalizing term. This part I understand. However it is unclear to me how he found the numerator term which appears to be a log of
$$
P(k|\lambda,\phi,Y_i) = \frac{\Pi_{i=1}^{k}\frac{e^{-\lambda}\lambda^{Y_i}}{Y_i!}}{\Pi_{i=k+1}^{N}\frac{e^{-\phi}\phi^{Y_i}}{Y_i!}}
$$
How does he arrive at that? Any help appreciated. Thanks in advance
Comment: Nope. A good lesson in why you should give full references for anything. From my initial comment it looks like I may have briefly glanced at the paper (the general issue of normalizing such terms is quite familiar though) but I have no recollection of any of the specifics of this instance. Does the wayback machine archive github?
Comment: It doesn't look to me like the author is saying what you say he seems to show.
Comment: He has the term $\frac{A}{B}$ where $ A = e^{k(\phi - \lambda) + \ldots} $. This appears to imply he is taking the ratio
Comment: He has *a* ratio of two terms (and he should, since the denominator normalizes the numerator so that it sums to one). He doesn't have the ratio you state.
Comment: But the normalizer is $B$ , which is already in the form of $\sum A$, which I understand. How did he get the term in the numerator, i.e. $A$? That is the part that is confusing me
Comment: That's a better question. The stuff you have about the denominator is a distraction from answering that.
Comment: Does anyone know what this paper was? the link doesn't seem to work (it looks like the repository was removed). Maybe @Glen_b remembers?
Answer: I believe the glitch is in your second equation, as the author's formula for $p(k|\textbf{y}, \lambda, \phi)$ doesn't depend on $N$. Manipulating his formula gives a quotient of products, but indexed slightly differently:
$$
e^{k(\phi - \lambda) + log(\frac{\lambda}{\phi})\sum_{i=1}^ky_i} = e^{k(\phi - \lambda)}e ^{ log(\frac{\lambda}{\phi})\sum_{i=1}^ky_i}
$$
$$
= \frac{e^{-\lambda k}}{e^{-\phi k}}\left(\frac{\lambda}{\phi}\right)^{\sum_{i=1}^ky_i}
$$
$$
= \frac{e^{-\lambda k}}{e^{-\phi k}}\left(\frac{\lambda^{\sum_{i=1}^ky_i}}{\phi^{\sum_{i=1}^ky_i}}\right)
$$
$$
= \frac{\Pi_{i=1}^{k}\frac{e^{-\lambda}\lambda^{y_i}}{y_i!}}{\Pi_{i=1}^{k}\frac{e^{-\phi}\phi^{y_i}}{y_i!}}
$$
To find our way to this equation, first factor the joint probability $p(\lambda, \phi, k, \textbf{y})$ two ways:
$$
p(\lambda, \phi, k, \textbf{y}) = p(\textbf{y}|\lambda, \phi, k)p(\lambda, \phi, k) = p(k|\lambda, \phi, \textbf{y})p(\lambda, \phi, \textbf{y})
$$
To solve for $p(k|\lambda, \phi, \textbf{y})$, divide both factored probabilities by $p(\lambda, \phi, \textbf{y})$:
$$
p(k|\lambda, \phi, \textbf{y}) = \frac{p(\textbf{y}|\lambda, \phi, k)p(\lambda, \phi, k)}{p(\lambda, \phi, \textbf{y})}
$$
As succinctly put on p. 4 of this similar treatment of the same data and approach, "Trick: in conditional posterior distribution, the parameters that are conditioned on are treated as constants." Using this and the fact that $\lambda, \phi$, and $k$ have independent priors, and the prior for $k$ is a uniform constant, we now have a slight variation on your first equation:
$$
p(k|\lambda, \phi, \textbf{y}) \propto p(\textbf{y}|\lambda, \phi, k)
$$
$$
p(k|\lambda, \phi, \textbf{y}) \propto \Pi_{i=1}^{k}\frac{e^{-\lambda}\lambda^{y_i}}{y_i!} \times \Pi_{i=k+1}^{N}\frac{e^{-\phi}\phi^{y_i}}{y_i!}
$$
Because $\phi$ and $\textbf{y}$ are known, we can divide both sides by $\prod_{i=1}^{N}\frac{e^{-\phi}\phi^{y_i}}{y_i!}$ and maintain proportionality.
$$
p(k|\lambda, \phi, \textbf{y}) \propto \frac{\prod_{i=1}^{k}\frac{e^{-\lambda}\lambda^{y_i}}{y_i!} \times \prod_{i=k+1}^{N}\frac{e^{-\phi}\phi^{y_i}}{y_i!}}{\prod_{i=1}^{N}\frac{e^{-\phi}\phi^{y_i}}{y_i!}} = \frac{\prod_{i=1}^{k}\frac{e^{-\lambda}\lambda^{y_i}}{y_i!} \times \prod_{i=k+1}^{N}\frac{e^{-\phi}\phi^{y_i}}{y_i!}}{\prod_{i=1}^{k}\frac{e^{-\phi}\phi^{y_i}}{y_i!} \times \prod_{i=k+1}^{N}\frac{e^{-\phi}\phi^{y_i}}{y_i!}}
$$
The rightmost products in the numerator and the denominator cancel, and we've solved for for $p(k|\lambda,\phi, \textbf{y})$ up to a proportionality constant:
$$
p(k|\lambda, \phi, \textbf{y}) \propto \frac{\Pi_{i=1}^{k}\frac{e^{-\lambda}\lambda^{y_i}}{y_i!}}{\Pi_{i=1}^{k}\frac{e^{-\phi}\phi^{y_i}}{y_i!}} = e^{k(\phi - \lambda) + log(\frac{\lambda}{\phi})\sum_{i=1}^ky_i}
$$
To yield a proper conditional posterior, we normalize over $k$, giving the author's formula.
Comment: Thanks, this is very useful. Could another way of looking at this be the following (?)... Engineer a likelihood function $p(k|\lambda,\phi,y)$ such that it is maximum just when $i = k$, the point where the change point happens?
Comment: Quite welcome! I'm not quite sure I follow your alternate view. The actual change point is never observed, so we can't really compare the posterior for $k$ to an actual value. We *can* view the posterior marginal for $k$ as the best compromise between the prior and the data, and in some cases a maximum likelihood estimate will be equivalent to the mode of the posterior using an uninformative prior. Is that helpful, or is your question something different?


Gnome-shell and compiz

Question: I was using ubuntu 2d till now along with compiz. now i installed gnome-shell and after that compiz effects are not working. Is there any way to get compiz effects to work,else is there any other similar packages?
Comment: im using gnome shell
Comment: have you tried Gnome Shell?
Answer: Compiz and gnome-shell do not go hand-in-hands together... Third heading in the link provides more insight about it: https://live.gnome.org/GNOME3Myths
Also the mailing list post about compiz and gnome-shell might be of interest for you:
http://firstname.lastname@example.com/msg15602.html
So as far as I know, you can't get effects equivalent to those provided by compiz in gnome-shell... You might try to look for the gnome-shell extensions with similar functionality.
Comment: Thanks. I saw that. was just looking fr someone with links to gnome-shell extentions that provide similar customizions of wobbly window.
Answer: In terminal: sudo apt-get install compizconfig-settings-manager and then run the program (ccsm) to edit compiz settings.
Comment: i did.. but compiz settings wont work in gnome-shell.
any alternatives for compiz with features like wobbly windows?
Comment: OK, you could also consider using gnome classic, same look and feel as in Lucid and with all the features of compiz (even the wobbly windows ;-))
Answer: Have you attempted to type in compiz --replace within the terminal? I had to do that for the Cinnamon shell, but I am not certain whether gnome uses metacity or compiz by default.
[edit]:
Or press ALT F2 to open up a command field and then type in compiz --replace

Gnome-shell and compiz