Go, MahJong, and Chess. Together?

Question: Do you think these games have enough in common to start a serious, competitive club focusing around them? There's definitely enough between Go and Chess, but what about MahJong? I know there is plenty of strategy behind MahJong, having played it, but is it too far removed from the other two?
Answer: I feel there are two major differences:

Go and chess are strictly strategic, whereas mahjong involves chance,
In go and chess, everyone has complete knowledge of the game at all times; in mahjong you don't know what your opponents have.

Mahjong is kinda of like poker or gin rummy in these ways; they more strongly depend on reading your opponent. So, in terms of core properties, I think mahjong is a different category of game to go and chess. Additionally, mahjong is more rules-heavy compared to the rules-light, strategy-rich go and chess.
That said, there's no reason not to play it in a club, as long as there are people who want to play it. Probably the best way to find out if it's suitable for your club is to try making the club, and offering mahjong as an option. If people don't want to play it or don't take it as seriously, then you can move your focus to the other games.
Answer: Shogi is an excellent suggestion, being similar to Chess yet having the Asian origins that Go has. If you want to go for the more western games, Draughts or Checkers are closer to Chess than Mah Jong.
The 5 in a row "Go moku" is also a fun, if simple game. It can be played with a standard Go set.
Comment: I've actually played quite a bit of gomoku, and it is far from simple. I also play many forms of Chess, including Shogi and Xiangqi. Also, Chess technically has "asian" origins, as it is believed that all variants of chess stem from the Indian game Chataranga. Thanks for the help and suggestions, though!
Comment: You are of course, correct on all counts. I should probably be more accurate in my thoughts. I meant Gomaku has incredibly simple rules, that lead to interesting emergent strategies. Both great features. I knew that Chess originated in India, and when I wrote 'origins' I was thinking more of the last few hundred years when both games were developing into their modern forms.
Answer: I don't see these as a natural blend with one another, but whether they fit may not really matter.  As noted earlier, Mahjong (or dominoes for that matter) is much more luck oriented as opposed to the strategy involved in Chess or Go.
If you're considering starting a club, as with any other group or ahem forum, you need a critical mass of interested participants.
If you're thinking of a club for serious play then your club's focus can be about tournament level play first and the specific game second, in which case you can fit in any game you feel will help you attract participants.
Answer: Go and Mahjong can "go" together insofar as they might both attract Asian players. The best place to start such a club is in a physical "Asiatown" in a place like New York City, or perhaps one on line. If you wanted to add "chess" to the mix, I would suggest Chinese chess and/or Japanese shogi in this context.
Otherwise, go and chess are strategic games that both attract "geeks," who probably aren't turned on by the "chanciness" of Mah Jong.
In either case, starting a club is about knowing your audience.
Answer: Go and Chess is more of objective count in brain as broad and deep as possible. When playing Go and Chess, players brain works like a search engine.
Mahjong is more of subjective judgment about your components mind. Hard to deploy a search strategy because opponents hands are concealed.
But I wonder they all can be played with a probability strategy, though the computing of probability may be quite different.
Answer: MahJong is played with different rule sets. I have heard (from a Go club member who played MahJong regularly) that there is are Japanese rules for MahJong making that game very strategic.
I also know some Go and Chess players that are very good at Poker–another strategic game with an element of chance in it.

Go, MahJong, and Chess. Together?


Receiver Automatic Gain Control purpose

Question: Receiver AGC objective is to have a constant amplitude signal in order to optimize the receiver performance, so it should respond according  to the amplitude of the signal of interest and not to the amplitude of another signal (interferer) next to the signal of interest ( next in frequency domain), or RSSI (in the presence of a strong interferer for example).
Is there any application or any case where the AGC operates according to RSSI in the presence of a strong interferer, i.e. it responds practically to the power of the interferer and not to the power of the signal of interest? Would that make any sense at all?
Comment: Sounds to me that if a receiver with an AGC responds to an interfere, then it's a poorly designed system. For instance, an AM Radio Receiver for cars needs hum filtering. The AGC loop will react on this, but there must be another loop with a hum sensing mechanism that makes the amplifier suppress that signal even further,ñ. After this happens, the AGC loop should behave normally.
Comment: Depending on what kind of radio design it is, the AGC can be placed at different locations, as I found out [here](https://electrical.codidact.com/posts/285543). Either on the LNA or on the IF amp. I guess that the difference could be what kind of signal you are expecting, analog or digital.
Answer: The function of the AGC in a radio receiver is to keep the audio output fairly constant even as the incoming RF signal varies. This avoids annoying changes in the audio level as you change stations or, especially in the case of mobile radios, go in and out of good and bad reception areas. A good AGC can keep the audio level constant within 1 dB as the RF level varies as much as 100 dB. This is especially useful in shortwave receivers where the input RF level is subject to large variations due to changes in station distance, direction, and transmitting power. However AGC is not really intended to handle interference problems. These are better done by filtering, passband tuning, noise limiters, and other techniques.
Answer:
it [AGC] responds practically to the power of the interferer and not
to the power of the signal of interest? Would that make any sense at
all?

It makes no sense for the purpose of controlling amplitude of sound for your ears, so that strong signals and weak signals are similarly loud. AGC circuits most commonly have fast attack time constant, and slow decay time constant.
There is a case where interfering signals are used to control amplitude: to reduce impulse noise. Rather than calling it AGC, this function might be called noise blanking.
Unlike AGC, time constants for noise blankers are very fast attack, and fast decay too. Noise blanking bandwidth must be necessarily wide, often much wider than the audio communication channel (and its AGC control).
Noise blankers use a fast-acting gating circuit whose purpose is to completely attenuate for a very short interval, timed so that a short noise spike is killed...so short that a listener's ears don't notice. Also, the attenuated noise spike will now not activate AGC.
Answer: Expecting one single purpose for AGC is unrealistic. Glen_geek's answer illustrates one purpose for allowing interfering signals to control gain automatically - noise blanking.
But there are others. If you allow a mixer to be overloaded you can at the very least expect distortion, or worse, intermodulation between multiple interfering signals to drown out the wanted signal.
In this case you must control the gain of an RF stage according to ALL the signals it processes, to stay below the point where a following mixer stage overloads (usually related to its 3rd order intercept point or IP3), so that you can separate wanted from interfering signals in an IF filter following the mixer.
(For SDR, the ADC replaces the mixer; you cannot allow the total output from any front end to exceed the ADC input range, however weak the wanted signal. If the interfering signals clip the ADC, say goodbye to the wanted signal)
So multiple AGC loops are common : one to protect linearity at each mixer or ADC; and one before the final demodulator to maintain a constant audio level.
Comment: Most wireless receivers today are direct down conversion receivers. Standards (WiFi or LTE) specify the nature of the interference ( frequency offset, power level, modulation) , the challenge is to be able  receive  the signal of interest at sensitivity level in the presence of an interferer ( with a 3 dB hit) . ( LNA +mixer)  need to take the hit in terms of linearity while providing maximum gain . After down downconversion  the interferer gets knocked down by low pass filter(s). AGC is about the signal of interest, the goal is a constant optimal power level at the ADC input

Receiver Automatic Gain Control purpose


ctrl+backspace overwrites copy buffer

Question: When I copy something first and then want to paste after I delete something, if I delete with CTRL+Backspace it pastes what I deleted when I CTRL+V (I can copy with CTRL+C and paste with CTRL+V in emacs). How can I configure emacs to paste what I copied before?
Answer: As you can paste using C-v, I guess you are using cua-mode. In cua-mode yanking earlier kills using a numeric prefix does not work. However, cycling over earlier kills by pressing M-y (after first pasting using C-v) still works fine.
Answer: When you delete text with C-<backspace> it is added to the kill-ring in front of the text you copied previously using C-c. You could of course change this behavior by binding something like (delete-region (point) (progn (forward-word -1) (point))) to C-<backspace> instead of backward-kill-word, and similarly for other kill commands... but this is not the Emacs way.
Instead, like dalanicolai points out, the easiest way to paste what you initially copied is to first press C-v to paste (yank) the last kill and then press M-y to rotate through the kill ring (yank-pop) until you're back at the text you want. You can also use M-y directly to select from the kill ring using completion.
Another approach is to enable delete-selection-mode and then just select the text you want to replace, e.g. using C-SPC and M-b, before replacing it using C-v.

ctrl+backspace overwrites copy buffer


iPhone Contacts app Cross-References Facebook?

Question: I just added two contacts to the contacts app on my iPhone (iOS 9.1) and after each I had a dialog asking me to enter my Facebook password, presumably so it could cross-reference this with my Facebook account. I didn't enter my password and instead went looking for a setting that links the Contacts and Facebook apps together but could not find anything. Is there such a setting? If so, where? If not, is Contacts sending data to Facebook?
Answer: On iOS 9, if you go to the iPhone Settings app > Facebook (that's in the 7th "block" of settings as you scroll down, with social media accounts like Twitter, Flickr and Vimeo—whether you have an account or not), there is a disclaimer:
*Photos and user names are automatically updated for Facebook friends. Choose "Update All Contacts" to temporarily provide Facebook with email addresses and phone numbers from your contacts to update photos and user names for all matching contacts."
There is an "Update All Contacts" button. In addition, you can control there whether Contacts.app has access to your Facebook account (if you have one) on that same settings panel. You can control whether the Facebook app has access to your contacts through Settings > Privacy > Contacts (I think that's the same on iOS 8 and 9).
Comment: Facebook is not among the apps that Contacts.app has access to interestingly. Also, in settings > Facebook, I have no disclaimer, possibly because I am not logged into Facebook through the OS... I'm assuming this is why I keep being asked to log into Facebook when I update my contacts. So possibly iOS is still trying to share my contacts with Facebook despite Facebook's absence from my Contacts privacy setting.


Deploying CodeIgniter (or any PHP projects) to the live site?

Question: What's the ideal way of deploying CodeIgniter projects (or any PHP projects for that matter) from your local machines to the live site?  I've been using subversion for checking out and updating the code from live sites for quite some time now.  But there are others who say that this practice is not good since you do not need the svn metadata in the live site.  I've also read a couple of articles where they use Capitrano to deploy PHP projects.  What's your practice in PHP project deployment?
Answer: I use Phing for all my building needs.
I've created several tasks like, prod, staging, debug. When i want to push all data to my production server, i just use phing prod. This will checkout all code from my repo, do some config changes, run all static files like css and javascript through a minifier etc.
More info on Phing here:
Phing.info
http://www.slideshare.net/hozn/phing-building-with-php
Answer: I asked a similar question and a lot of people seemed to like Phing:
What is your preferred php deployment strategy?
I took a look at it and the config files were pretty intimidating. I'm interested to hear more on this subject.


What is the difference between representation and embedding?

Question: As I searched about this two terms, I found they are somehow like each other, both try to create a vector from raw data as I understood. But, what is the difference of this two term?
Comment: Explained in the first five parts: https://developers.google.com/machine-learning/crash-course/embeddings/video-lecture or see:  https://www.toptal.com/machine-learning/embeddings-in-machine-learning  https://analyticsindiamag.com/machine-learning-embedding/ - embeddings *group* the representation (the data set) into categories seperated by varying distances, often with partial overlap between individual embeds.
Comment: Have you read https://datascience.stackexchange.com/a/54045/58034 and page 2 of: https://arxiv.org/abs/1905.06147 and https://cloud.google.com/architecture/overview-extracting-and-serving-feature-embeddings-for-machine-learning - You are allowed to answer your own question.
Comment: @Rob
thank you Rob, I read both of them now, and still it is complicated, I still think their definitions are like each other, can you give me a hint? any short answer can be really helpful.
Answer: Vector representation is a generic term used to talk about any type of feature encoding, embedding vectors are instead a special case of vector representation.
When talking about vector representation the only underlying assumption is that every variable was encoded into numerical values, without any restriction regarding the numbers or the vector itself.
Embedding vectors instead are specifically continuous vectors of fixed dimensions obtained trough matrix factorization techniques or deep learning models. They originally proposed to encode text in the Word2Vec paper, and since then they acquired more and more popularity due to the high generalization potential of the proposed method in other AI branched rather than natural language processing.
Answer: To the best of my knowledge:
A latent representation, or code, $\mathbb{z}$ is a learned continuous vector representation of some input $\mathbb{x}$. E.g., we might have a code of an image.
An embedding is a type of code which specifically represents a discrete variable $\mathbb{x}_\text{discrete}$. One popular example is a word embedding, where words are encoded discretely using one-hot encoding.


How do I transfer iTunes on a PC to my new iPhone 6?

Question: When I connect my iPhone 6 to my PC in order to transfer my music, I am told that the I need the newest edition of iTunes. When I try to download the newest edition of iTunes, I am told that the update is for Windows7 or higher. (I have Windows XP.) Microsoft no longer offers support for Windows XP. How else can I get my music from my PC to my iPhone 6?
Answer: If you can't upgrade from Windows XP you could use iExplorer, however I'd strongly recommend upgrading to a newer OS and using iTunes.
Answer: I'm afraid you're stuck.
The latest iTunes will not run on anything lower than Windows 7.
For many reasons, not least your own security, your solution is to be on Windows 7 at least.


Highlighting syntax errors in Sublime Text 2

Question: In Sublime text 2 when I make an error like forget a <code>;</code> or add an extra closing or opening tag there is no highlighting that tells me that I have made a mistake. Only after running the code will I know that a mistake was made. Is this normal for Sublime Text 2 or is it just me? If this is normal, is there any extension to fix this?
Answer: I use SublimeLinter which highlights potential errors in a number of languages when you save a file.
Comment: for this to work,you first have to install SL,then php library on your system(written in the docs).. is there any simple package that marks error on the go,without having to do to much.something like php storm..
Answer: use one of this http://scottksmith.com/blog/2014/09/29/3-essential-sublime-text-plugins-for-node-and-javascript-developers/
I prefer jshint, hope to help!


Wordpress security on LAMP

Question: What can I do to make my Wordpress on LAMP installation more secure?
Answer: A few steps you can take that should help a fair amount (all are detailed further in the Codex's article on hardening):

Change the name of the admin account - it's hard to brute-force that password if you have the wrong user name.
Change the table prefix from the default of wp_
There's a plugin called WordPress Firewall that blocks a variety of items, including attempts at submitting requests including suspicious strings like "wp_" (the default database table prefix) and "../../../../". I've seen this cause problems with one plugin that was named with a leading wp_ (most use wp- instead), but I've also received multiple email notifications from the plugin of attack attempts.
Run regular backups, daily or weekly depending on how frequently your content changes. If you're using the standard backup plugin, it can email those backups to you. Keep in mind that depending on the tool you use the backups may not be encrypted; for encrypted backups you may have to do more fiddling in the guts of scripts.
Answer: There's a good article on this over at the WordPress Support, especially the bits about protecting the /wp-admin directory and wp-config.php.  Some more handy tips here, and here's a few other hints:
Make sure you're running the latest version, and keep it up-to-date.  WordPress has suffered from a number of exploits and security problems of late, so make sure you keep abreast of new releases and bug reports; the WP developers' blog is a good source for that sort of thing.
That last point applies to your Apache/MySQL instances as well; keep 'em patched!
Set strong root/admin passwords and change them regularly.
Disable access to as many other services on your box as you get away with; the less there is to attack, the less chance of it happening to you.
Comment: Yup, I see a new wordpress vulnerability every week on lwn it seems like.
Comment: Oh, it's slowed down, then?
Answer: Here are some points:

Join mailing lists for being notified in time when someting needs to be
updated.
Keep things up to date.
Reduce the attack surface as much as possible
Harden your setup using chroots or jails to reduce the impact of a possible intrusion.
Monitor file system changes and your logs.

Hope this helps.

Wordpress security on LAMP


Why is generating Certificate Signing Request (CSR) supposed to be platform/machine specific?

Question: I've seen questions Is it true that certificates requested with a specific CSR can only be used on the machine where the CSR was generated? and CSR generation origin? and Generate CSR code on local machine ; I've also seen https://serverfault.com/questions/471289/must-csrs-be-generated-on-the-server-that-will-host-the-ssl-certificate  - but these answers don't explain why majority of instructions for generating CSRs insist that the generation is performed on the specific platform/machine (e.g., look at https://knowledge.rapidssl.com/support/ssl-certificate-support/index?page=content&id=SO6506 or https://nz.godaddy.com/help/windows-generate-csr-for-code-or-driver-signing-certificate-7282 , and many others).
If this were, as I assume, only for convenience sake (i.e., to use specific instructions/tolls available on a platform), it'd be understandable - but, e.g.,  the godaddy instructions (one of the links above) explicitly says, for a signing certificate, "It's important that you generate the CSR from your local machine and not from the web server you're using to host the file" - why would that matter?
As far as I understand, all that matters is the possession of the private key.  So - are these platform/box-specific instruction just for convenience sake and to ensure the security of the private key is not compromised while moving it between machines?
Comment: I think you are misinterpreting the instructions from GoDaddy. These  instructions refer to a code signing certificate and not a web server certificate. And of course you should not put the private key used for signing your code on the web server where you host the signed file for download but instead sign the code locally on your machine and keep the key only there.
Comment: I understand the difference in purpose for signing and SSL/TSL certificates. GoDaddy instruction that I referred to is indeed for signing - but whether I require a signing or SSL certificate, there is no need, as far as I can see, for the CSR to be generated on the machine that will use the private key for signing. It could be generated anywhere and then imported into whatever keystore on the machine that will use it. So my question still stands.
Comment: Hi Steffen; just to clarify - yes of course you'd not want to keep the private key anywhere other than on the machine that will use it, but this does not mean the key and the CSR have to be generated on that machine. So I guess the intention behind GoDaddy instruction can be interpreted in the way you suggest. But I'd rather all these CAs explicitly said "Generate CSR in whatever way you want and on any platform and host, but make sure the private key is securely moved to and kept on the host that will use it. And install the certificate on that host if needed". That would remove the "magic".
Comment: I think there are "power users" who understand the concepts and know not to use the private key in the wrong place. These users know how to generate a CSR usually anyway and does not need the instructions. And then there is the average user who has no understanding of the concepts. The instructions are targeted at these users and try to make it simple for them, and the simplest case is to generate and keep the private key at the machine where it is actually needed. Telling them that it could be done otherwise and why and how is just too confusing for these and likely leads to more problems.
Comment: Thanks, Steffen. I guess this is indeed the case. Too bad that in cases when certificates are needed in high-availability clustered environments, such instructions could lead people to believe they need a different CSR and different certificate and private key for each load balancer (if that's where SSL is terminated) and host (which may need it for both SSL and signing) in the cluster.
Comment: That might be an unintended but positive side effect from the perspective of the CA selling the certificates. But maybe administrators which manage such higher value systems should also have a deeper knowledge of what CSR, private key etc is and especially how to minimize the risk when the same private key is used on multiple systems.
Answer: Generating CSR is not platform specific, it's true as you say, that you only need the primary key and private key isn't tied to a specific machine.
However, especially in a beginner's tutorial, there are a couple of reasons why this advice can be sensible:

It limits the private key to just the machine that will use it. You won't have copies of the key lying around in machines that shouldn't have them, which can become another avenue of key leaks.
It increases the likelihood that you'll be generating the key in the right format for the software that's going to use them. If you have openssl on the server, the key generation tool from openssl will generate pem files instead of pkcs12. While it's not too difficult to convert between formats, this reduces friction for less knowledgeable users.

Telling people to generate keys at the place it's going to be used achieve these goals while being fairly simple for less knowledgeable customers to follow and produce good security for them.
Comment: Thanks; this covers that case. I wish I could also accept as an answer comments Steffen and John have made, as all point in the same direction.
Answer: A CSR is just a signing request, as long as you have the private key used for the CSR, the signed certificate you get via that CSR and they key can be used anywhere on any machine.
By telling users to do all of those things on the same machine, they are less prone to use the wrong combination of keys and certs, which means less support calls for the CA.
Comment: Thanks, Johh; I understand that - the links from this site and from serverfault that I referred to in my question confirm this. I was just wondering whether the reason for instructions on RapidSSL, Digicert, GoDaddy and many others that talk about generating CSRs on the plarform/host where they will be used just for convenience sake and security of the private key.
Comment: It's for people that don't know how servers, PKI or anything else works. This way, the key will always remain on the server where they end up installing the cert, so in theory it will work better for people with less knowledge, thus lightening the load on the CA's call centers for support.


Is it possible to emulate a flash drive via a USB "A to A" Cable?

Question: I have a modified Nintendo Wii that can run backup game files (via external media, IE; flash drive, sd card, external HD) and an always on PC that sits right beside it with tons of storage. I'd like to just run a USB A to A between the two from a drive (or partition) on the computer that's set to emulate a flash drive/external hard drive via the USB port. Is this possible?
Comment: @David Schwartz
So in other posts and on the one you linked, there are users referencing the file transfer type USB cables and the special drivers and commands associated with them. I wonder if there's not a way to take advantage of this for the purposes I'm seeking.
Answer: You would need a PC with a device USB port. I've never seen them on laptops or desktops, only on tablets or phones. See this answer for more information.


ActiveRecord query for coaches a client has bookmarked

Question: I'm trying to figure out the best way to set up an ActiveRecord query.

Models
There are three relevant models involved:
class Client < ActiveRecord::Base
  has_many :bookmarks, dependent: :destroy
  has_many :saved_coaches, through: :bookmarks, source: :bookmarkable, source_type: "Coach"
end

class Bookmark < ActiveRecord::Base
  belongs_to :client
  belongs_to :bookmarkable, polymorphic: true

  scope :type, -> (type) { where(bookmarkable_type: type.to_s.capitalize) }
end

class Coach < ActiveRecord::Base
  has_many :bookmarks, as: :bookmarkable, dependent: :destroy
  belongs_to :user
end

The problem
I need a performant query to access to the coaches a client has bookmarked, the coach's user model, and the id of relevant bookmark.
I can think of two approaches:
@client = current_user.client

# option 1
@coach_bookmarks = @client.bookmarks.type(:coach).includes(bookmarkable: :user)

# option 2
@coaches = Coach.includes(:bookmarks, :user)
  .where(bookmarks: { bookmarkable_type: "Coach", client: @client })

Option 1 seems clearer, but produces a collection of bookmarks, when most of the data I need is on the associated coach. Option 2 gives me a collection of coaches, but the query is a little less clear, and the SQL output is huge. (I've included that below.)
Is one of these solutions better than the other? Is there a third, better solution (maybe through @client.saved_coaches)?

SQL output
Option 1
Bookmark Load (1.3ms)  SELECT "bookmarks".* FROM "bookmarks" WHERE "bookmarks"."client_id" = $1 AND "bookmarks"."bookmarkable_type" = $2  [["client_id", 3], ["bookmarkable_type", "Coach"]]
Coach Load (2.3ms)  SELECT "coaches".* FROM "coaches" WHERE "coaches"."id" IN (1)
User Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" IN (3)

Option 2
SQL (6.3ms)  SELECT "coaches"."id" AS t0_r0, "coaches"."user_id" AS t0_r1,
"coaches"."questionnaire_submitted" AS t0_r2, "coaches"."validated" AS t0_r3,
"coaches"."verified" AS t0_r4, "coaches"."membership_type" AS t0_r5,
"coaches"."new_coach" AS t0_r6, "coaches"."created_at" AS t0_r7,
"coaches"."updated_at" AS t0_r8, "coaches"."title" AS t0_r9,
"coaches"."image_url" AS t0_r10, "coaches"."experience_years" AS t0_r11,
"coaches"."specialties" AS t0_r12, "coaches"."session_types" AS t0_r13,
"coaches"."session_type_other" AS t0_r14, "coaches"."meeting_types" AS t0_r15,
"coaches"."meeting_type_other" AS t0_r16, "coaches"."cancellation_policy" AS
t0_r17, "coaches"."bio" AS t0_r18, "coaches"."price_options" AS t0_r19,
"coaches"."quote" AS t0_r20, "coaches"."current_screen" AS t0_r21,
"coaches"."address_raw" AS t0_r22, "coaches"."business_phone" AS t0_r23,
"coaches"."address_city" AS t0_r24, "coaches"."address_state" AS t0_r25,
"coaches"."address_area" AS t0_r26, "coaches"."latitude" AS t0_r27,
"coaches"."longitude" AS t0_r28, "coaches"."categories" AS t0_r29,
"coaches"."keywords" AS t0_r30, "coaches"."ace_up_handles" AS t0_r31,
"coaches"."stripe_account_id" AS t0_r32, "coaches"."bank_account_info" AS
t0_r33, "coaches"."offer_free_consult" AS t0_r34,
"coaches"."free_consult_length" AS t0_r35, "coaches"."sessions_start_every" AS
t0_r36, "coaches"."max_daily_sessions" AS t0_r37,
"coaches"."minimum_scheduling_notice" AS t0_r38,
"coaches"."buffer_after_session" AS t0_r39, "coaches"."num_reviews" AS t0_r40,
"coaches"."onboard_professional_background" AS t0_r41,
"coaches"."onboard_certifications" AS t0_r42, "coaches"."onboard_challenges"
AS t0_r43, "coaches"."onboard_promoting" AS t0_r44,
"coaches"."onboard_referral_source" AS t0_r45, "coaches"."onboard_interests"
AS t0_r46, "coaches"."onboard_submitted" AS t0_r47, "coaches"."coach_url" AS
t0_r48, "coaches"."timezone" AS t0_r49, "coaches"."average_review" AS t0_r50,
"coaches"."coach_order" AS t0_r51, "coaches"."onboard_business" AS t0_r52,
"coaches"."onboard_services" AS t0_r53, "coaches"."videos" AS t0_r54,
"coaches"."card_highlights" AS t0_r55, "coaches"."edit_requested" AS t0_r56,
"coaches"."specialties_edit" AS t0_r57, "coaches"."session_types_edit" AS
t0_r58, "coaches"."meeting_types_edit" AS t0_r59,
"coaches"."cancellation_policy_edit" AS t0_r60, "coaches"."bio_edit" AS
t0_r61, "coaches"."quote_edit" AS t0_r62, "coaches"."keywords_career" AS
t0_r63, "coaches"."keywords_life" AS t0_r64, "coaches"."keywords_leadership"
AS t0_r65, "coaches"."keywords_business" AS t0_r66,
"coaches"."keywords_communication" AS t0_r67, "coaches"."keywords_executive"
AS t0_r68, "coaches"."qualifications" AS t0_r69, "coaches"."education" AS
t0_r70, "coaches"."target_clients" AS t0_r71, "coaches"."highlights" AS
t0_r72, "coaches"."client_review_link" AS t0_r73, "coaches"."consent" AS
t0_r74, "coaches"."qualifications_edit" AS t0_r75, "coaches"."education_edit"
AS t0_r76, "coaches"."target_clients_edit" AS t0_r77,
"coaches"."highlights_edit" AS t0_r78, "coaches"."text_notifications" AS
t0_r79, "coaches"."email_notifications" AS t0_r80, "coaches"."companies" AS
t0_r81, "coaches"."address_raw_edit" AS t0_r82, "coaches"."longitude_edit" AS
t0_r83, "coaches"."latitude_edit" AS t0_r84, "bookmarks"."id" AS t1_r0,
"bookmarks"."client_id" AS t1_r1, "bookmarks"."bookmarkable_id" AS t1_r2,
"bookmarks"."bookmarkable_type" AS t1_r3, "users"."id" AS t2_r0,
"users"."email" AS t2_r1, "users"."encrypted_password" AS t2_r2,
"users"."reset_password_token" AS t2_r3, "users"."reset_password_sent_at" AS
t2_r4, "users"."remember_created_at" AS t2_r5, "users"."sign_in_count" AS
t2_r6, "users"."current_sign_in_at" AS t2_r7, "users"."last_sign_in_at" AS
t2_r8, "users"."current_sign_in_ip" AS t2_r9, "users"."last_sign_in_ip" AS
t2_r10, "users"."confirmation_token" AS t2_r11, "users"."confirmed_at" AS
t2_r12, "users"."confirmation_sent_at" AS t2_r13, "users"."unconfirmed_email"
AS t2_r14, "users"."failed_attempts" AS t2_r15, "users"."unlock_token" AS
t2_r16, "users"."locked_at" AS t2_r17, "users"."encrypted_otp_secret" AS
t2_r18, "users"."encrypted_otp_secret_iv" AS t2_r19,
"users"."encrypted_otp_secret_salt" AS t2_r20, "users"."consumed_timestep" AS
t2_r21, "users"."otp_required_for_login" AS t2_r22, "users"."personal_phone"
AS t2_r23, "users"."name" AS t2_r24, "users"."created_at" AS t2_r25,
"users"."updated_at" AS t2_r26, "users"."google_token" AS t2_r27,
"users"."google_refresh_token" AS t2_r28, "users"."last_calendar_refresh" AS
t2_r29, "users"."google_expires_at" AS t2_r30,
"users"."google_calendar_refresh_tokens" AS t2_r31, "users"."acquisition" AS
t2_r32, "users"."icalendar_urls" AS t2_r33, "users"."admin" AS t2_r34,
"users"."banned" AS t2_r35, "users"."email_subscriber" AS t2_r36,
"users"."intermediate_reminder_sent" AS t2_r37, "users"."final_reminder_sent"
AS t2_r38 FROM "coaches" LEFT OUTER JOIN "bookmarks" ON
"bookmarks"."bookmarkable_id" = "coaches"."id" AND
"bookmarks"."bookmarkable_type" = $1 LEFT OUTER JOIN "users" ON "users"."id" =
"coaches"."user_id" WHERE "bookmarks"."bookmarkable_type" = $2 AND
"bookmarks"."client_id" = 3  [["bookmarkable_type", "Coach"],
["bookmarkable_type", "Coach"]]

Answer: if you don't need the bookmarks instances then I would be inclined to go for something like:
@coaches = Coach
             .joins(:bookmarks).includes(:user)
             .where(bookmarks: { bookmarkable_type: "Coach", client: @client })

though I would wrap that in a scope. You could probably also get away with excluding the bookmarkable_type: "Coach" condition since the join will enforce that.
Comment: Unfortunately, I need their IDs. I didn't realize I could drop the "bookmarkable_type," though, and wrapping it into a scope was a good idea. I created a `Bookmarkable` concern to hold the `has_many :bookmarks` association and a new `bookmarked_by` scope.
Answer: @coaches = Coach
             .includes(:user)
             .joins(:bookmarks)
             .where(bookmarks: { bookmarkable_type: "Coach", client: @client })
             .select("coaches.*, bookmarks.id AS bookmark_id")

After this query you can do the following:
@coaches.first.id # returns coach id
@coaches.first.bookmark_id # returns the relevant bookmark_id
@coaches.first.user.name # returns the user's name of that coach.

This approach has one advantage over including the collection of bookmarks that it won't load the whole objects of bookmarks into memory when you need only bookmark_id.


Why did the reanimated Nagato and Madara have Rinnegan?

Question: When Madara was near death he gave the Rinnegan to Nagato, and Nagato's eyes were stolen. You can say "DNA" but in that case Nagato wouldnt have it so why did the reanimated Nagato and Madara have Rinnegan?
Comment: Madara had Rinnegan in his DNA..
Comment: Ok so why nagato had rinnegan
Comment: reincarnated Madara did not have rinnegan. he awakened it later due to his genetics. and when he was released from the jutso and brought back to life fo real, he lost his eyes so he had to take back the rennigan from obito
Comment: I would ask why reanimated Madara did not possess rinnegan but EMS?
Answer: Source

The Summoning: Impure World Reincarnationbinds the soul of a deceased person to a living vessel, restoring them as they were when they were alive in order to do their summoner's bidding.
A reincarnated individual will have all the abilities they had during their life, including kekkei genkai and kekkei tōta. They are physically restored as they were at the time of their death, including any physical handicaps they may have possessed, such as Nagato's damaged legs. Exceptions exist: illnesses they had will not be preserved, nor will any physical damage that contributed to their death. There is some inconsistency of whether or not foreign body matter will be restored as well: Hanzō retains the poison gland of the black salamander, but Madara Uchiha does not have access to Hashirama Senju's genetic material and thus Kabuto must artificially reproduce it for him.

So, Nagato had his eyes at time of death, so as at reincarnation.


Does anyone know how Slic3r determines its infill adjacent strand spacing, instead of using fill density?

Question: I'm doing research on changing the fill density into the air gap width, adjacent strand spacing, or whatever, instead of using the fill density, as it will give me more precise controls.
Question 1:
All I can work out is from Slic3r's the source code in ~/Slic3r/xs/src/libslic3r/Flow.cpp,
Link to Flow.cpp source code
/* This method returns the centerline spacing between an extrusion using this
   flow and another one using another flow.
   this->spacing(other) shall return the same value as other.spacing(*this) */

float Flow::spacing(const Flow &other) const {
   assert(this->height == other.height);
   assert(this->bridge == other.bridge);

   if (this->bridge) {
      return this->width/2 + other.width/2 + BRIDGE_EXTRA_SPACING; //Line A
   }
   return this->spacing()/2 + other.spacing()/2;                   //Line B
}

If I am right, will changing Line A or Line B, be the right way to change its infill adjacent strand spacing?
Question 2:
And since we're on this topic, what does the bridge variable represent?
Answer: This answer should have been a comment, except I have included the relevant code.
To answer question 2, at a guess, bridge is simply a boolean (bool) that specifies whether there is a bridge or not.
From Flow.hpp line 32
/// Represents material flow; provides methods to predict material spacing.
class Flow
{
    public:
    float width, height, nozzle_diameter;
    bool bridge;

    Flow(float _w, float _h, float _nd, bool _bridge = false)
        : width(_w), height(_h), nozzle_diameter(_nd), bridge(_bridge) {};

Additionally lines 68-73, may also be of interest:
    private:
    static float _bridge_width(float nozzle_diameter, float bridge_flow_ratio);
    /// Calculate a relatively sane extrusion width, based on height and nozzle diameter.
    /// Algorithm used does not play nice with layer heights < 0.1mm.
    static float _auto_width(FlowRole role, float nozzle_diameter, float height);
    static float _width_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge);

However, your best bet, to get an accurate answer to both of your questions, is to contact Alessandro Ranellucci - alexrj, and ask him - as he is is the designer of the Slic3r code. When you get a reply, maybe you would like to post the answer here... it may be useful for someone else.


I lost my videos, how will I retrieve them?

Question: I have a problem on retrieving my files from my phone to my PC. I have 'moved' my DCIM folder from my phone to my PC. Will i be able to retrieve them? help please...
Comment: Can't you just move (or copy) them back? Where have they gone? What exactly is the problem? You'll need to provide more details if you're to get any useful answers.
Comment: my videos are gone
Answer: If you moved them onto your computer you can just copy the DCIM folder back onto the sdcard or internal storage of your device.
If this isn't the case there are several tools to recover lost data on your harddrive here is a good one: https://www.piriform.com/recuva


How to use 2 TSOP1738 (infrared sensor) in one circuit?

Question: Attached picture shows my circuit. In it I use only one IR sensor (TSOP1738) but now I want to add another IR sensor (TSOP1738) to my circuit. So my questions are:
1. Is it possible?
2. How (parallel or series)?
Thanks.
Comment: The capacitor shown may stop the unit from working. It should be between VCC and Gnd. The absolute maximum sink current for the output pin is 5mA.
Comment: Can you confirm all you need the circuit to do is flash an LED when it sees an infrared signal? If so, for the 2nd sensor, do you want to add a 2nd LED or do you want the same LED to flash with input from both Sensors?
Comment: Yes I only need LED flash. and I want the same LED flashs with input from both sensors.
Answer: Yes, both are common emitter output and can share 1 pullup R.
But your supply voltage AC noise ought be < 1mV  for best range. ok?
That means the LED may need a separate V+   path to source and ground path must not drop mV to avoid long range Rx noise during detection.
Add a low ESR bulk e-cap to Vcc,Gnd,  100uF?
But 100uF load wont work well on output as the cap will draw large currents.
Ic=CdV/dt
 You need a transistor on outputs to boost current or better CMOS 1 shot to buffer IR Rx then stretch pulse with diode, 1uF, 1Meg decay  then output 330 to 1K from CMOS Inverter to LED.
Comment: Thanks. So can you propose new circuit based your answer.
Comment: common emitter => open collector: a common emitter output can still be part of a totem-pole.
Comment: Hosein, I did propose a new circuit that does not draw high current with a time delay, read again until you understand


"…, als er sich es anders überlegte"-incorrect order?

Question: Here is a sentence:

Er hatte schon fast die Nummer von daheim gewählt, als er sich es anders überlegte

Grammar checkers invert the order of "es" and "sich". Why is that? Why is my version incorrect?
Answer: The simplest explanation is that "sich" is dative in this case and for pronouns the order is usually accusative then dative. (The opposite is true for (regular) nouns, and pronouns generally go before nouns.) That "überlegen" takes a dative reflexive pronoun can be found in a dictionary, but it's the kind of thing you need to memorize when you learn the verb. Wiktionary gives the example "Ich überlege es mir." = "I'll think about it."
Answer: Sich can stand anywhere in the middle field, so either is fine.
(Duden 1359)
This is one reason to remember well that "sich" is the only reflexive pronoun, and all other commonly called "reflexive pronouns" are just recycled other pronouns, used for reflexive purpose...
For other unstressed pronouns, you have Nominativ > Akkusativ > Dativ and the pronoun follows the left verb bracket, where only the the subject can optionally be put between the two.
Answer: This is a difficult one and here are two example sentences (both in their "most natural" word order) to illustrate the problem:

Ich überlege es mir.
Ich überlege mir das.

Aside from all the general "Akkusativ before Dativ"- and "anywhere in the Mittelfeld"-rules mentioned in other answers there is the fact that the unspecified "es" has to be put in front of "mir" whereas the specified "das" has to be put behind.
I cannot quote a rule for that, but if there was one, it should go like this:
When a "reflexives Verb" takes an "Akkusativobjekt" and this "Objekt" is represented by a "Pronomen", then the "Indefinitpronomen" goes last (behind the "Reflexivpronomen") whereas the "Definitpronomen" goes first (before the "Reflexivpronomen").
Like this:

Er machte es sich unmöglich.
Er machte sich das unmöglich.

My (unfounded) suspicion is, that "es" can act as a Korrelat and what "es" specifies can be put behind, whereas "das" doesn't have this power. For instance:

Er machte es sich unmöglich, die Prüfung zu wiederholen.
Er machte sich das Wiederholen der Prüfung unmöglich.
Answer: Google string search "als er sich es": 182000 (raw) hits. It also doesn't sound wrong to me intuitively.


how to remove Yosemite installer?

Question: I had begin the update and left it overbite for download, it downloaded completely but then failed. I started the download again and this time it had finished successfully but I didn't notice it and thought it had failed again so started the download again. When it downloaded about 3 GB I saw the Yosemite installer and upgraded. But now the second upgrade icon is still there. How do I remove it and its data?
Answer: Nevermind, got it.
App Store -> Purchases -> Press Option and you will see cancel.

how to remove Yosemite installer?


Solution of thermal analysis using finite element

Question: I want to solve a thermal analysis using finite elements. The governing equation is $$C \frac{dT}{dt}+K T = Q$$.
When using backward differencing for time, the resulting equation is quite straight forward.

When I now try to solve this equation for a number of time steps, I can see that the results can oscillate a lot and even yield negative temperatures in unit Kelvin which is physically not correct.

I have seen that commercial codes like MSC Marc perform recycles inside a time increment.

My question now is, what is being done when a recycle is performed? What is changed in the matrices and right hand side etc?
Comment: We don't know what the term "recycle" means, and what exactly MSC Marc is or does. You'll have to provide more details.
Comment: The problem for the heat transfer analysis is, that even with an implicit time discretization, the method is not unconditionally stable. How the time step size should be chosen is usually given in the manual.
Answer: The numerical oscillations that you're seeing are most likely due to a too coarse time-step. For instance for the explicit Euler scheme there is a maximum time-step to avoid oscillations which is given by $Fo \leq 1/4$ in 2D problems and $Fo \leq 1/6$ in 3D problems where $Fo$ is the Fourier number of the smallest element. The derivation is given in chapter 4 of the book "Finite Element Simulation of Heat Transfer" by Bergheau and Fortunier 1. I've never used MSC Marc but my first guess would be that those "recycle" mean using a smaller time-step.


Inverse of perspective matrix, for what?

Question: I dont understand for what i need the inverse of the perspective Matrix in Computer Graphics and how do i calculate it?Maybe someone has an explanation for me.
Comment: Could you add a bit more to the context? It's not clear what you need.
Comment: just about any matrix math library worth it salt will have an inverse operation.
Comment: If you don't need it, why do you want to calculate it?
Comment: @ratchetfreak right. but it's not the only thing there is to it. one needs not to forget the division by w stage, which is a bit tricky to invert, you need to choose an arbitrary w because it gets "lost in projection". and then multiply with the inverse matrix.
Answer: The inverse projection matrix can be used for mouse/ray picking (letting you click an object in the world)
For more info: How do you determine which object/surface the user's pointing at with lwjgl?
Answer: An inverse projection matrix is used to invert coordinates from the projected space to either world or local space, i.e. You can use the inverse projection matrix to find out where a pixel is in relation to game objects.
This can be extremly useful for postprocessing effects like deferred rendering.
Calculating it can be a bit tricky and requires knowledge in linear algebra, if you have an API handy I suggest using it. Or google around for a while.


Probability that Both Player and Dealer are not Dealt Blackjack

Question: Let us say we have a rather simple blackjack game between one dealer and one player with a single 52 card deck. We want to compute the probability that neither the dealer nor the player is dealt blackjack (initially). Let $A$ be the event that the player is dealt blackjack, $B$ the same, except for the dealer. We will compute:
$$
1 - \mathbb{P}(A \cup B) = 1 - (\mathbb{P}(A) + \mathbb{P}(B) - \mathbb{P}(A \cap B))
$$
We see that:
$$
\mathbb{P}(A) = \frac{{{16}\choose{1}} {{4}\choose{1}}}{52 \choose 2}
$$
As we have that out of the total number of hands we can be dealt, there are 64 possible hands that give us blackjack. Now, we compute the probability for the dealer, $\mathbb{P}(B)$. It seems that by symmetry, we may say this is the same as the probability for the player. However, my question here is, why is that so? Namely, would the order of dealing not matter? I.e if the dealer deals my cards first (which is usually the case, I think) would I not have to condition on the event that I am dealt blackjack first and use the fact that the dealer is working with a smaller deck?
Answer: The probabilities $P(B)$ and $P(A)$ are indeed equal, but $A$ and $B$ are not independent. After all, there are only four aces in the deck, and we can see two of them if both the player and the dealer have blackjack. We should expect $P(A\cap B)$ to be strictly less than $P(A)\cdot P(B)$.
As for the order - we just dealt out four cards face up, two to the player and two to the dealer. Do we really care what order we laid the cards on the table? No; what matters is which two cards the player got, which two cards the dealer got, and that the cards are all different. Either way you condition it to account for the smaller deck, the probability of double blackjack will be the same.
Comment: +1, though note that if the deck only had four cards (two Aces and two Kings) then we would have $P(A\cap B)$ strictly greater than $P(A)\cdot P(B)$.
Answer: You will find that

$\mathbb P(A)=\frac{32}{663} \approx 0.048265$
$\mathbb P(A^c)=\frac{631}{663} \approx 0.951735$
$\mathbb P(B \mid A)=\frac{9}{245} \approx 0.036735$
$\mathbb P(B \mid A^c)=\frac{7552}{154595} \approx 0.048850$ - a complicated calculation but no matter

Note that the player failing to get blackjack increases the conditional probability of the dealer getting blackjack since $0.048850 \gt 0.036735$.  This in fact exactly offsets the  player getting blackjack reducing the conditional probability of the dealer getting blackjack, since $$P(B) = \mathbb P(B \mid A) \mathbb P(A) + \mathbb P(B \mid A^c) \mathbb P(A^c) =  \frac{32}{663}$$ and this is the same as $\mathbb P(A)$.  The symmetry argument gets you to $P(B) = \mathbb P(A)$ more quickly.
Comment: You then get $P(A^c \cap B^c) =  P(A^c \mid B^c) P(B^c) = (1-P(A \mid B^c)) P(B^c)$  or alternatively $1 - P(A) -P(B) + P(B \mid A)P(A)$
Answer: $B$ is the event in which the dealer makes black jack, so the probability of $B$ is the same of $A$, but in the problem clearly you have to consider the whole situation, and indeed you have to calculate $\mathbb P (A \cap B)$


Will having two versions of the same program cause any security or stability issues or is it perfectly fine?

Question: [Ubuntu Unity 16.04.5 / Cairo Dock] e.g. two clickable and runnable Opera buttons side-by-side in my Start Menu? I tried uninstalling the Opera version I don't use (Opera v12), the terminal says I have two versions of Opera installed (but says "cannot find" when I try to uninstall the old Opera), and the software center says I only have one version installed (Opera-Stable v55) despite two Operas (12 and 55) being on my Start menu and both being fully operational.
Answer: I once ended up with 2 minecraft launchers with the same problem of software saying I had only one, but both worked, and I had no problems and my computer ran like that for a few months until windows 10 wiped my drive on accident. You should not have any stability or security issues if there are two of the same program different versions


How to control 4 motors which are conected to a flight controller using Raspberry Pi?

Question: I just started a project to make a drone without a radio controller. I want to control 4 brushless motors connected to a flight controller KK 2.1.5 using Rpi 3 B+. Obviously, the motors are first connected to the separate ESCs and then to the flight controller. What I am not getting is how can I control each motor separately?
I would appreciate any help. Thank you.
Comment: Using a pi as a flight controller is a very bad idea.  Use a traditional MCU based flight controller to do the flying, either an existing one or something along similar lines.  If an embedded Linux system is going to be involved (but still not a pi, which is far too flaky for this) it should decide *where* to go, but leave the actual flying to a simple, robust, realtime MCU, **which means the linux system does not control the motors**, the flight controller's MCU does in response to commands of *intent* (like "we want to go thattaway") from the Linux side.
Comment: "*... the motors are first connected to the ESC ...*" Are you trying to get independent control of four motors connected to the one ESC? Hit the edit link under your question. Ask a specific question or it will likely be closed as "too broad".
Comment: No. Motors connected to separate ESCs and those ESCs are connected to a single flight controller.
Answer: It seems that the KK 2.1.5 flight controller has four separate, "old fashioned" PPM inputs, while most modern controller use a serial link with the receiver, such as DBUS.
Your best bet would be to first implement a way for the raspi to generate the four PPM signals. This can surely be done with a ton of different, already written and proven libraries. Your interface would then just be a file, where you write the value you want the PPM signal to go to, and this can be done with pretty much anything you want on the raspi.
So basically your program on the raspberry would not run the control loop, that stays on the FC, but just some sort of autopilot, high level control loop, that would send just "wanted attitudes" to the FC, pretty much like you would do with a standard TX/RX setup.
disclaimer: bear in mind that the raspberry pi is not a real time system. This can lead to a number of problems, inherent to the system you want to setup, on top of the "normal" problems like software bugs, or hardware failures.
It is your primary responsability to make sure your system is safe for you, for others, and for everything that is around you. Also, make sure to adhere to your local regulations about UAVs.


Didn't King Fred want to know why Herringbone 'Retired'?

Question: Why doesn't king Fred want to know the reason why Herringbone "retired"? He doesn't inquire about this either. Or did he imagine a reason? If yes, what kind of reason would that be?
Answer: The chief advisor's retirement is announced to the king with indirect speech, so we cannot rule out that king Fred did indeed question why, but Spittleworth smooth-talked his way out of it:

When King Fred woke next morning and was informed that his Chief Advisor had retired at this critical moment in the country's history, he was furious. It came as a great relief to know that Lord Spittleworth would be taking over, because Fred knew that Spittleworth understood the grave danger facing the kingdom.
The Ickabog, Chapter 20 - Medals for Beamish and Buttons

Other than that, consider that Fred is a rather foolish king, and seems to eat out of Spittleworth's hand. The fact that someone he thinks he can trust, was there at the time of the ickabog's attack, and "[understands] the grave danger facing the kingdom" seems to alleviate his immediate concerns for the chief advisor. (He had more pressing issues, like keeping peace and breakfast).

Chapter 22 has recently been released, which addresses this question from the perspective of the other advisors:

But what, you might ask, of the eleven other advisors, who'd worked under Herringbone? Didn't they think it odd that the Chief Advisor had resigned in the middle of the night, and never been seen again? Didn't they ask questions, when they woke up to find Spittleworth in Herringbone's place? And, most importantly of all: did they believe in the Ickabog?
Well, those are excellent questions, and I'll answer them now.
They certainly muttered among themselves that Spittleworth shouldn't have been allowed to take over, without a proper vote. One or two of them even considered complaining to the king. However, they decided not to act, for the simple reason that they were scared.
The Ickabog, Chapter 22 - The House with No Flags

So it seems like his failure to question where the Chief Advisor went could be attributed to Fred's suggestibility and naïvety.


recovering the original secret of secret sharing

Question: What is the specific process of recovering the original secret of secret sharing? Is the parties with secret shares communicating with each other and exchanging secret shares, and if the number of secret shares greater than or equal to the threshold is collected, the secret will be recovered, or a third party will collect the secret shares to restore the secret, how is it generally done in the current scheme , what are the advantages and disadvantages of these two methods.
Comment: Looks like homework and may be off topic
Comment: relevant (answers half the question) https://crypto.stackexchange.com/questions/84143/shamir-secret-sharing-with-no-dealer
Comment: This is not homework, I'm just wondering when secret recovery is required, should parties holding secret shares communicate with each other, exchange secret shares held, and perform secret recovery when at least k secret shares are obtained; or The holder of the k secret share uploads the secret share held by the hand to a third party for secret recovery.
Answer:
What is the specific process of recovering the original secret of secret sharing?

That depends entirely on what you intend on doing with the secret.
Secret sharing is rarely done as the entire cryptosystem; instead, it is usually a component in something larger.  For example, if the shared secret is an AES key that a specific unit needs to decrypt, we might end up sending all the shares to that unit (and it may recover the secret).
In addition, sometimes no one explicitly recovers the secret; instead, the secret recovery is done implicitly as a part of the operation.  If this sounds mysterious, consider this relatively simple scenario:

We secret share a secret exponent $\alpha$, and we want to perform a joint computation $z^\alpha \bmod p$, given a value $z$

We use a Shamir Secret Sharing scheme to distribute $\alpha$ over a number of shares $(x_1, y_1), (x_2, y_2), ..., (x_n, y_n)$

When we want to compute the value $z^\alpha$, we select $t$ willing share owners, and send $z$ to each of them.  Each one computes $z^{y_i I_i}$ (where $I_i$ is the interpolation coefficient $\prod_{m=0, m\ne i}^{m<t}x_i/(x_m - x_i)$), and publishes it

The group coordinator takes all the published values, and multiplies them together; the result is $\prod z^{y_i I_i} = z^{\sum y_i I_i} = z^\alpha$

That is, we did computation based on the shared secret, while never explicitly recovering it.
Comment: Thank you for your answer!


What's a smart way to count the number of days since X?

Question: I started working at my current position since November 17th 2014. I would like to know how many days have run up to now. Any ideas on how to use Linux to come up with a simple and nice solution?
Comment: Time arithmetic has lots of fiddly special cases. While simple things like subtracting UNIX timestamps and dividing by 86,400 will give you an approximate answer, you are better off using a specialized time library that takes into account the special cases, for example Python's `dateutil`.
Comment: Some of the answers in [Quickly calculate date differences](http://unix.stackexchange.com/questions/24626/quickly-calculate-date-differences) may help here too.
Comment: I ended up doing something similar in a perl script; I used the timelocal() function to get the number of seconds from the epoch to the given date (Nov 17, 2014 for example), then subtracted that from the current epoch-date-in-seconds, then divided by 86400 (seconds in a day). I'm sure someone will come through with a shell-only solution :)
Comment: http://24.media.tumblr.com/tumblr_m4bph9tiPe1r9kuhvo1_250.gif
Comment: @msh210 you are banned for life and sentenced to prison for 1 month while serving community as code cleaner for ancient COBOL code.
Answer: echo $(( (`date +%s` - `date +%s -d '2014/11/17'`) / 86400 )) days ago

Comment: This gets leap seconds wrong.  I mean, that hardly matters *now*, but in [10k years or so](http://longnow.org/about/) the accumulated error could be enough to matter.
Comment: The probability leap seconds will trigger an error in about .000001%. This is negligible compared to the wrong number of days this method will give with locales where daylight saving time is observed: 2% of the cases ...
Comment: @Kevin: If he wants to know how many days he worked somewhere, we can (until further advance in cryogenisation or medicine) not bother too much about this ^^
Comment: @jlliagre: %s is Unix time, which is always UTC, which lacks DST.
Comment: Chances are he will be wondering about the number of days employed while idling behind his desk at work. As that's probably not around midnight but somewhere between 8am and 5pm (and `date -d 2014/11/17` gives a timestamp of midnight as there's no time mentioned) DST doesn't matter.
Comment: @Kevin the fact `date +%s` works in UTC doesn't change at all the fact the result will be sometimes incorrect in location where DST is in use. "The number of days since X" is timezone dependent, one cannot ignore that fact with pretending to be in UTC.
Answer: Well, on the face of it:
$ date --date="-239 days"
Mon Nov 17 15:25:40 CET 2014

In a script (not very efficient, but... maybe it handles leap seconds? ;) )
i=0
result=""
while [ "$result" != "20141117" ]
do
    i=$((i+1))
    result=$(date --date="-$i days" +%Y%m%d)
done
echo "$i" days have passed since "$result"

Comment: @DigitalTrauma too bad it's not localized. E.g. `LC_ALL=ru_RU.utf8 date --date="239 дней назад"` gives me the same result as `date --date="239"`.
Comment: Even `ago` is understood: `date --date="239 days ago"`
Comment: @Ruslan indeed :)
Answer: I tried python on the command line.
$ python -c "import datetime; print datetime.date.today() - datetime.date(2014,11,17)"
246 days, 0:00:00

Answer: Here is example with PHP:
<?php
$o1 = date_create('2014-11-17');
$o2 = date_create();
$o3 = date_diff($o2, $o1);
echo 'days: ', $o3->days, "\n";

Result:
days: 1927

https://php.net/function.date-diff


Overheating. Chevrolet Cruze

Question: I have an old Chevy Cruze. 2010 Oct. LT variant. It developed an overheating problem in 2016, when I was turning on the A/C on mountain drive. I thought, nothing of it. It went fine. Then in 2020 It suddenly overheated, when I was not looking. I on the advise of a mechanic poured bottled mineral water into it one bottle after another, like 10 bottles. The Engine seized. I had the head changed. Then the water pump went bad, changed that . Then, the Oil pump went bad, changed that. When the oil pump light came up, there was not a over heating problem, though. Now, I had the radiator fixed, water pump fixed again, there is no Thermostat valve in Cruze LT.Again, it overheats at speeds over 40km/hr. This is driving me insane. I have spent 2000USD on this, to no end result. What remains to be checked?
Answer: The next check would be a compression test to see if this engine isn't damaged beyond affordable repair. If the engine passes this test then it would be time to install a thermostat and do a cooling system pressure test.

Overheating. Chevrolet Cruze


Can I freely use this image?

Question: So I met this talented guy who designs graphics for apps and such and I asked him if he can make a background image for my app..He agreed and made one for me and I asked him if it was ok if I use the image for my app and he said yes..Now the question is, does it mean I can freely use the image in my app WITHOUT crediting him or paying him?
Comment: You haven't mentioned: Have you given "this guy" *anything* of value in exchange for this verbal license?  If not then you probably have [no valid contract](http://law.stackexchange.com/tags/contract-law/info).
Answer: You have a verbal contract right now to use the image for the app, but if you have questions about the scope and duration of the agreement - and you should, because it's obvious that the contract is not clear when it comes to what you are concerned about, namely what sounds like unlimited commercial use of the artwork - you should to work it out now with the artist now before you use it and both of you have regrets later.
As pointed out, if you haven't given anything in exchange for the use of the graphic, you may not have a valid contract. See What is a contract and what is required for them to be valid?
The simplest thing to do is be up front and ask him about credit and payment for use: how much, how can I use it, do I need to credit you, etc. These are all fair questions, and I doubt he will be annoyed. If he is commercial artist, he will be familiar with such agreements. If he is just starting out in the field, he should learn about these kinds of agreements and not keep them so casual. And you should learn about use of graphics and copyright laws, too.
Arrive at an agreement and either keep it verbal - not the greatest idea:

Despite popular belief, oral contracts are enforceable. They usually
  are not in your best interests, and end in a "he said, she said"
  battle. - See more at:
  http://blogs.findlaw.com/law_and_life/2011/10/are-oral-contracts-enforceable.html

Or write it out in simple English, both sign it and date it. You don't need to get a simple contract notarized or have a lawyer draw one up. If you do want a written contract that covers all the bases, a quick Google search will give you free templates for graphic art usage contracts from websites that specialize in the business of graphic arts.
Comment: @BlueDogRanch...he lives in a different country so we can't have a written contract..I haven't given him anything in exchange for the verbal license
Comment: Sure you can have a written contract; email can be a written contract (possibly depending on the country.) The country where he lives may not require any exchange to have a valid contract. In any event, it's in your best, long term interest to get the terms nailed down.
Answer: A promise to credit the artist could be valid consideration for a non-exclusive license, if you both agree. For the mater of that, a license is basically permission to use a work, and need not be a valid contract. It can be just a gift. Most CC licenses are not contracts at all, because there is no specific agreement between the licensor and the licensee, and perhaps no consideration.
While you could rely on your current verbal license, you would in my view be much wiser to tie down the terms a bit, getting the artist to say under what conditions you may use the work, whether you are expected to pay (and if so hoe much), and what form of credit, if any you are expected to give, and any other terms. For example, are you expected to include a copyright notice for the art?
You could write a letter and ask the artist to write back or sign and return your letter, or exchange email -- either would result in a written agreement.
By the way, in the US at least a contract to transfer (by sale or gift) a copyright must be in writing, but a license need not be.

Can I freely use this image?


How do I need to tag different (but a little similar) entities with Entity-Component-System pattern

Question: I have some count of weapons - pistol, shotgun, rifle. And I have one system which deals with all weapons, and another system which deals only with pistol. So I need to create both components "weapons" and "pistol", and I add them both to the entity - "Pistol". So now we have next components - "Weapons", "Pistol", "Rifle", "Shotgun", becase probably I will need to have separate system for different weapons in future.
Then in the same reasons I create next Components - "Character", "Player", "Enemy", "Friend" (maybe more types of Enemies and Friends), "Ammo", "AmmoForPistol", "AmmoForRifle" ...
And there are too much different components only for tagging different entities regarding to the types.
How can I avoid this amount of Components?
Comment: Why not have the weapon component specify what type of weapon it is and what / how much ammo it has?
Comment: And then system which need to deal only with an entity - "Pistol" (or Shotgun ...), will have to work with all weapons-entity instead only one entity- "Pistol". Under "will have to work" I mean that an update cycle will have to go through all weapons on the level to find "Pistol".
Comment: What does the system that is specific to the pistol need to do different? i.e. what makes a system handling the general weapon component incapable of what is specific to a 'pistol entity'? As for your Character, Player etc component, you need to wonder whether these should be components itself in the first place, or whether the entities aren't simply a composite of already existing components (e.g. a player has a collider and  an enemy too, so they are handled by the same system). Try to find the parts entities will have in common
Comment: @Athosvk Pistol it is for example)) There will be something like grenade launcher. ) But thanks I understand your thought? so try to find out solution.
Comment: Something tells me that the foundations of your ECS design is a bit shaky. Characters, Players, Enemy, Friends, etc seem to me as they should be _entities_, not _components_. Same goes for Weapons and Pistols.
Comment: @AlexandreVaillancourt yes, I know that) But also I can use "empty components-classes" for tagging different entity. For example if entity has "Weapons_component" it means that this entity is some weapons etc.
Comment: Oh, empty component classes as tags! That's interesting!
Comment: @AlexandreVaillancourt Do you think is bad idea?
Comment: I don't know :) You try it and tell us the results :)
Answer: There is really no harm in adding a single WeaponComponent which holds a TYPE attribute to describe whether it's a Pistol, Rifle, Shotgun, Knife, etc.
Nothing dictates however that you must store all WeaponComponent instances in the same list inside your WeaponSystem either.  In fact, to avoid branching on specific use cases, it might be advantageous to store each  WeaponComponent in a type-specific list and simply iterate over multiple lists as part of your update loop.
I also don't believe that Character and Player make sense to be represented as components.
In order to determine hostility vs friendly could simply be derived by checking whether the entity in question has a specific type of component, perhaps HostileComponent.  The assumption here being that all entities are friendly unless that component exists.
There are plenty of ways to split / tag things through components without going overboard.
Answer:
How can I avoid this amount of Components?

You can't.
ECS are made to decouple and specialize your game logic. You'll want your components to represent something specific. By doing so, you won't have a choice: you have many tiny components.
Comment: A component is meant to represent a cohesive junction of data for a specific feature.  That doesn't imply that a component represents something so specific that you end up with hundreds or thousands of tiny components.  As my answer points out, you have lots of choices with how you interact with components.  A single component can represent multiple ideas that are shared and it becomes the responsibility of your systems to take advantage of programming paradigms to use those components efficiently and effectively without overburdening the user of such ECS frameworks.
Comment: @Naros _"[...] you have lots of choices with how you interact with components."_ There you go. It really depends on how you view your ECS, how you've built it. The main reason I see of using an ECS architecture is to not overburden components with what you don't need, keep them as lean as possible in order to maximize what you get from it. I guess making a good software with ECS is an art, though.
Comment: @Naros I don't disagree with your answer, though :)


Disabled my camera app. Can't find it anymore!

Question: I disabled the camera app on my phone because the front-facing camera wasn't working. I had intended to re-enable it in a minute or two but when I went to my home screen it was not there, and it wasn't in the setting-all apps place either. I went to the play store and did not find the same camera that was previously on my phone either. Where did it go and how can I get it back??
Comment: What type of phone do you have? Was it the original camera app that came as default on your phone when you got it?
Answer: Open Settings> Apps> Disabled& find the Camera app. You can enable it there. This is the common way to enable disabled apps on all android phones. Comment if any problem persists.
Comment: I'd like to add that if you try this method but you see the camera as enabled, disable it and enable it once again.You should see your camera after that.


(Fast?) Fractional Discrete Fourier Transform

Question: Is there a simple algorithm for computing the fractional discrete fourier transform analog to the FFT algorithm or even naive DFT matrix multiplication?
I am kind of new into signal processing. For my own understanding I built this tool in order to grasp an intuitive understanding for the relation between time and frequency domain.
I was intrigued by the 4-cyclic behavior of the FT operation. I stumbled upon the idea of fractional fourier transform and would love to include it in my tool to play around with.
But I only found very few papers about fractional fourier transforms mostly focusing on the math side of things and ignoring an algorithmic implementation.
This paper discusses various possible implementations but relies heavly on CAS like matlab to do the heavy lifting like determining eigen values.
So my question is if there are any straight forward self contained implementations for fractional discrete fourier transform.
Update I accomplished to use the matlab code provided here as reference. The Python implementation from Ashs answer is also based on this matlab code.
Translating the matlab implementation into Rust and compiling to WASM allowed me to build this interactive visualization (video demonstration)
Comment: Thanks for the update! I've shared the visualization with some interested students.
Answer: That's a really cool visualization, well done! Here is a Python implementation of the Fast FrFT, with a link in the code to the MATLAB version as well:
https://github.com/nanaln/python_frft/blob/master/frft/frft.py
Some implementations I have tested have bugs in them, but this one seems to work well.


Impact of many zeros in LightGBM Regressor training set

Question: I have a LightGBM Regressor model with 15 features. 5 of these features have 98.7% NA for the training set. All five of the features are NA for each row. I impute the missing values with zero before I feed into the model. The testing set has 90% NA for the same five features.
As a general question, how does this impact the decision making of the tree and the prediction from the model?
Since the testing set also is missing the majority of these 5 features, does it not have much of an effect on the model?
It is my understanding that the model chooses the most important features for each prediction. Thus, I would assume that it uses the 5 features for instances that have them, and does not for the instances that do not.
Comment: What do the non-missing values in those columns look like?
Answer:
All five of the features are NA for each row. I impute the missing
values with zero before I feed into the model.

By setting them 0, the model will actually learn that the values are zero. I would consider you dropping these columns altogether.


What would the night sky look like after 200 years?

Question: It is research for a book I am writing. The year is 2200. Assume the volume of items in orbit has increased dramatically from today's numbers. We go to war and blowup all the satellites. Four hundred years later, what would the night sky look like?
Comment: The US Federal Communications Commission recently passed a rule that requires a satellite orbiting at less than 2000 km altitude to reenter the atmosphere within five years after the end of the satellite's useful life.  For orbits at high but still LEO altitude orbits (600 km up to 2000 km), achieving this will require a reentry engine firing, so this rule may not be useful for satellites that are intentionally destroyed.
Answer: Objects in low orbits tend to be slowed by atmospheric friction and other interactions, falling down relatively quickly. The deorbiting timescale for satellites under 800 km altitude is 100-150 years, so they will all be gone. Stuff above that altitude will remain, although lighter dust and grains will tend to disappear too (they get subjected to light pressure and electric charging). So if there are rings, they will start at a few hundred kilometers and extend outwards.
There might be stability problems if the mass up there is big enough, but in this case this is unlikely unless there is a lot of big objects.
The big problem for rings is the Moon, which exerts tidal forces that likely would make them far more diffuse than the neat Saturn-like ones in these renderings.
Together, this suggests that the rings are unlikely to be grand like Saturn's. Even if there was a lot of highly reflective objects up there, as they grind down to fine dust light pressure and lunar tides makes them drift away. The bigger objects remain, but probably as a more diffuse cloud and (since the surface to volume is smaller) less shiny than the dust.
Comment: It sounds like I am on the right track. I wasn't so much as thinking rings, but rather that you'd see the debris. Two more questions though: In 400 years, would the items that remain have time to form rings, or any structure at all? And from the ground would it be colorful, or likely just white like the moon? My thought was, since satellites tend to be covered in thermal shielding of some sort, the pieces would act something like a broken CD and glint color. Thanks for your help!
Comment: @Ken - I think 400 years is enough for hazy rings (it is after all many thousands of orbit periods of the components, and most start in the equatorial plane). I suspect the colour would be boring, since even individually colourful pieces would be too small to see and blend together into a haze. A few big pieces might cause glints, but after centuries most surfaces will be pretty dull due to erosion.


How can I install and use the Magento Test Framework (without using pear to install phpunit, on Linux Mint 17)

Question: I am trying to set up some sort of automated application testing for Magento stores using the MTAF package described at these links: Guide, Docs
These guides tell you to install PHPUnit using pear, but this method is disabled as of Dec 2014.
I was finally able to get PHPUnit installed using the commands from this answer and now I can actually check my phpunit --version, which is
PHPUnit 4.6.7 by Sebastian Bergmann and contributors.
The error that I am getting stuck at now is this:
require_once(): Failed opening required 'SymfonyComponents/YAML/sfYaml.php'
This SO Answer says that the test framework is wanting to use the Symfony 1 version of the YAML module. I cannot find this old version anywhere, so it made me wonder if there isn't something I'm overlooking.
I have already tried the Official SVN repo but it just times out.
Edit: I guess there was some issue with their servers yesterday. Today it is working and I was able to install the necessary YAML module using this command:
sudo pear install symfony/YAML
I'm not really sure if this could be considered a "question" anymore, but I feel it is a good reference for others who might want to install the test framework.
Answer: These are the commands that I ran to install the dependencies:
PHPUnit:
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit

Symfony YAML module:
sudo pear install symfony/YAML


Getting the space key to act like the return key

Question: I come from a Windows background and I have gotten into the habit of hitting the Space key every time there's a popup on my screen that I want to close.  But on the Mac, it doesn't do anything, but hitting Return does.  Does anyone  know how I can get Mac to let the space key act like the Return key on modal dialogs?  I tried to find something in the Keyboard preferences but don't see anything related to popups.
Comment: You could try a key remapping program. At lifehacker (http://lifehacker.com/5882684/the-best-keyboard-remapper-for-mac-os-x) the KeyRemap4MacBook (http://pqrs.org/macosx/keyremap4macbook/) is recommended. I've not tried it, but it might work for you.
Comment: i think the issue is not that space needs to be return, but that space should be able to interact with dialog boxes
Comment: Can we improve things to get you to indicate which answer works to solve your question?
Comment: Unfortunately none of the proposed solutions does exactly what I asked for, but I have to assume that getting the exact functionality won't be possible at this point in time.
Comment: It sounds like you're after the Windows method *because* its the Windows method. With most things Mac vs Windows, the same will be achievable with much the same efficiency, but you'll need to 'Think Different' as they say. The interface or method will be a little different, and if you try to make one *just* like the other, you'll be disappointed. If you can manage to drop the expectations of one behaving exactly like the other (and it goes both ways!) then you'll find efficient, but slightly different, ways of working on either system.
Comment: The Windows method (of invoking selected button on Enter) is also how things behave on the Web and Linux. So it's not just the Windows method. If one could swap the behaviors of 'Enter' and 'Space' on the Mac, that would be really helpful.
Comment: You don't see anything... because what you call "popups" are *dialogs*.
Answer: Press ctrl+F7 to enable Full Keyboard Access. This setting is also available in the System Preferences under the Keyboard preference pane:

By selecting 'All controls', you can tab around keyboard focus between the various widgets in dialog boxes, including buttons like OK or Cancel. It's slightly different from Windows, in that return is like pressing the fully highlighted button, while space is like pressing the selected / outlined button.
This image shows the difference between the two:

In this example, the Cancel button has focus (from tabbing) while OK is the default. So pressing space would select Cancel, while return would select OK.
And for completeness, this one can be accepted by either space or return:

It's worth noting that some OS X dialog boxes (I've noticed this especially with dialogs asking whether it's OK to overwrite a file) will come up with, for example, Don't Overwrite as the default for return, and Do Overwrite as the focused item for space. This makes it a single key either way to do what you want, but you need to be sure you've got the right one!
Comment: Awesome! This is precisely THE way to get that functionality.
Comment: Selecting this answer, but note that it is not the exact behavior of Windows since I do have to tab around before I can hit the space, where as in Windows tab was typically not necessary since the focus was usually on the main button of interest (like OK or Save).  But I have a feeling this is the closest we can get.
Comment: I believe this behaviour is changed in macOS Ventura - do you agree?  Now when I get a dialog there is no highlighted button, just a selected button (highlighted border like "Cancel" in pic above).  Does anyone have a solution to get macOS to revert to previous behaviour?


What's the impact of Catch Assist?

Question: I saw a shared video of someone with a buddy with catch assist. It seems like a normally wasted ball (landed during the 'attack' of the wild Pokémon) is being headbutted back, delivering a 'Great throw' (I personally think it would be an awesome combo). Are the normal catch chances applied? Is this assist always there? Does the original circle matter for the type of throw, or would it always be great?
Answer:
Are the normal catch chances applied?

Yes, the normal catch chances still apply. Pokémon can still break free if your buddy throws the pokéball back, so it's safe to assume normal catch rates still apply (source needed).

Is this assist always there?

No, this does not always apply. Much like Critical Captures in Pokémon Go, it is a random chance for Catch Assists to trigger.

Does the original circle matter for the type of throw, or would it always be great?

It will not always be a great throw. There is evidence for Nice and Excellent throws as well. Based on my experience and other threads I've seen as well, the catch bonus (if any) will typically be based on what the original throw would have been.
So if you throw a Pokeball and it would be outside the circle, you likely wouldn't receive a catch bonus despite it being knocked back into the center. Otherwise, it would be generally be nice, great, or excellent relative to the size of catch circle.
Curve ball bonus' also still stick! If you apply a curve throw, miss, and your buddy throws the pokéball back, you will be awarded the circle ball XP bonus if the Pokémon is caught
Comment: "Based on all the videos I've seen, Catch Assists will always be Nice, Great, or Excellent." I've had several catch assists that weren't even Nice (but they would have missed the circle anyway). I've also had several that got a bonus but clearly would have missed normally. So whatever is going on is more complicated than that.
Comment: Based on my admittedly minimal observations, Catch Assist kicks in when the ball is bounced back toward you by the target pokemon, but not if the ball ricochets off to the side or behind the target. I haven't seen any bounced toward me since gaining it that weren't headbutted back.
Comment: @AllisonC The Catch Assist will force the bounceback to be straight back at you. I've seen some throws where the bounce should have gone to the side but the ball flew back at me for my buddy to do Catch Assist. So it's not based on where/how you hit the target, it just forces a specific bounce as part of the animation.
Comment: @Kadima I didn't say it was. I said that it works when the ball bounces back toward you. Balls can still go off to the side; I've watched several of them do that and not kick in a catch assist, but if it bounces back toward you, then that's going to be a CA bounce

What's the impact of Catch Assist?


Synchronize files across different Linux distributions

Question: I have been digging around and can't really figure out which software can synchronize files automatically to other web servers. Just like Facebook. they have many servers but when you upload something, it's accessible from almost every server. I need like to synchronize a new file that has been added from the current server to other servers, so that they have the same file as it is on the current server.
Comment: Another options is disk level read/write replication other the network i.e. through drbd but this may be "overkill" depending on the rate of read/write and perhaps not an ideal solution if servers are sitting remotely on the Internet.
Comment: Look into using something like rsyncd
Comment: doesnt work automatically
Comment: You'll have to describe exact files types. You can use rsync or lsyncd for static files. Keeping databases in sync, will have many additional approaches + require some deep design consideration. Another tack you can take is running LXD on all your machines + syncing entire LXD containers, which may be easier.
Comment: inotify and rsync can be used for that.  inotify will trigger an event when something changes on the filesystem and rsync will then react to that event by syncing the file(s).
Answer: That is not a simple question, it is really complex and there are many way to achieve this, not all of them has the same performance.

To share static files like images, you can use file server and put
the data that you want to share between the servers in that folder
and mount that folder in all the servers,
To sync code, you can use git hook, like the github one, and use some thing for deploy this code for example (jenkins), then github hook, will run task in jenkins, and you can configure the jenkins task to deploy the code to multiple servers

The question is really big and each part of it could be a blog or book


Check Firebase login state

Question: I'm playing with Firebase and i'm making simple app with 3 ViewControllers. First - Sign Up, second - Sign In and third - profile. I already made registration and loggining. I don't know how to check user login state. Profile view controller is initial view controller. How to check user login state when app opening and if user is not logged direct him to login page.
Answer: To check the current user's sign-in state, you can either get it directly with:
Auth.auth().currentUser

You'd typically use this in synchronous code that needs to know if there currently is a user, and if so who it is.
You'll usually also want respond to changes in the current user (in fact, this is the more common usage). For that you do:
Auth.auth().addStateDidChangeListener { (auth, user) in
  // ...
}

The code inside this gets called whenever the authentication state changes. So when the app starts and there was previously a signed in user, it will fire as soon as that user has been validated. That is usually a great point to update your UI, e.g. directing unauthenticated users to the sign-in view of your app.
For more on this see the Firebase documentation on getting the currently signed in user.
Answer: FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
    // User is logged in, now you can access uesr's properties as followings
    String name = user.getDisplayName();
    String email = user.getEmail();
    Uri photoUrl = user.getPhotoUrl();
} else {
    // User is not logged in, so redirect the user in hrere.
}

Check Firebase login state


ASCII biggest number value

Question: When I hold values bigger than 255 (decimal) and print the ASCII character, the program prints some characters. Why? 254 isn't the biggest number in ASCII? Same thing happen when I hold negative numbers (eg: -6), but is not working for -1 and 0. Why?
Comment: You probably shouldn't try to use this in any "real" code, but especially if you're just learning C now I think that it's great that you're exploring the limits of the language, figuring out not only what's possible but also why.
Answer: What happens depends on your machine.
Values that go beyond the maximum representable usually wrap around. So, for example, if you hold 256, it will wrap around to 0, 257 will give you 1, etc, or, if your machine uses signed characters, instead of 256, max value will be 127, and 128 wraps around to the most negative value (that is, -128 with 8 bit characters, assuming a 2's complement representation). If these values happen to represent a valid printable character, then that's what you get.
Note that it is generally not safe to assume that overflowed values wrap around: the C standard doesn't require this to happen, so, technically, a program relying on that trick has undefined behavior.
Comment: Setting 8-bit char to 256 would wrap to 0, not -128.
Answer: This is undefined behavior, and the exact result will depend on some combination of your programing language/compiler/computer etc. Sometimes you'll get an exception or crash, and sometimes you'll get a character. In the case of the character, what you're most likely seeing is an overflow. The standard char type is a single byte, made of 8 bits that can be 0 or 1. The details will vary depending on your system, but what happens is something like this:
You try to assign 256, the binary representation of which looks like this:
 1 0000 0000 (a one with 8 zeros)

to a char, which can only hold 8 bits. Thus, the first bit gets truncated, leaving you with this:
 0000 0000 (8 zeros)

which is equivalent to the value 0. So, if your system happens to work like I described you'd end up printing out whatever ascii character is associated with the value 0. There are a couple of different ways the above can play out depending on system details like endianness.
Answer: When you do %c to print a character, it will access 1byte print the content of that 1byte. Maximum unsigned numbers that can be represented using 8bits = 1byte is 255 (0 to (2pow(8-1))-1) i.e 0 to 255
i.e from
0000 0000

to
1111 1111

When you try to print 257 in binary (1 0000 0001) using %c, it will see only 1 byte i.e 0000 0001. Corresponding character for 0000 0001 is printed.

ASCII biggest number value


Actual double slit

Question:
I can't understand what is given here.
How is the double slit pattern a interference a two single slit and double slit. If we say it is interference of two single slit then it makes sense. But the graph looks different from double slit pattern. Please explain
Comment: Related? https://physics.stackexchange.com/q/382799/104696
Answer: The "double-slit interference pattern," as defined in this passage, is what you get when you shine light on two slits of infinitesimal width. In reality, you can't ever make slits of infinitesimal width, so whenever you actually perform this experiment, you must account for the fact that your slits have finite width. Shining light through a slit of finite width gives a single-slit interference pattern. So the "actual double-slit interference pattern" (i.e. the pattern you will get in every double-slit experiment you could possibly perform) is a combination of the "double-slit interference pattern" (the ideal one, with infinitesimal slit widths) and two single-slit interference patterns.
Comment: So since the widths are not Infinitesimal we are getting the effects of the single slit pattern
Answer: Reading the words carefully, I think the text is right.
This is the diffraction pattern from the left slit:

This is the diffraction pattern from the right slit:
right diffraction pattern
And this is the superposition of both diffraction patterns, just the sum of the previous two:

Up to here it is the classical expected behevior.
But then there is the double-slit interference pattern:

Combine these two last images (multiply them, I think) and you'll get the one from your book.
The last paragraph about $a$ being much smaller than $d$ is so that the interference pattern is much narrower than the diffraction pattern. If they are of the same magnitude (or $a$ greater than $d$) then the quantum effect is not clearly visible, which is the point of this experiment.

Actual double slit


Ramsey model condition

Question: Why are transversality conditions and no-ponzi game conditions needed in the Ramsey model? And why do we assume that is a CIES utility function?
Answer: First of all, a sharp conceptual distinction must be made between transversality conditions and  no-Ponzi game condition.
The transversality conditions are purely mathematical conditions, and they are optimality conditions, that is conditions that must be fulfilled when looking for an optimum of the maximization problem.
They are conditions that must be imposed in any kind problem of optimal control (with some particular mathematical features, some class of problems)  irrespective of  the fact it deals with economics,  the flight of an airplane or the trajectory of a rocket.
In economics problems, it is usual to give them, in the second instance,  some economic significance, a content interpretation in terms of economic theory.
But, anyway, it remains only a condition of optimality, in the sense that it doesn't impose further constraints on the behavior of agents, and its rationale is mathematical.
In contrast, the no Ponzi game condition is an economic assumption,  it is a constraint on the behavior of individuals, and it is not a mathematical condition needed for optimization.
It is a consequence of the assumptions on the budget constraint of the consumer, of how the budget constraint is formulated.  Its economic content can be illustrated as follows:

Expressed in this form the budget constraint states that the present
value of the household's asset holdings cannot be negative in  the
limit.
Equation $(2.10)$ is known as the no-Ponzi game condition. A Ponzi
game is a scheme in which someone issues debt and rolls it over
forever.  That is, the issuer always obtains the funds to pay off debt
when it comes due by issuing new debt. Such a scheme allows the issuer
to have a present value of lifetime consumption that exceeds the
present value of her or his lifetime resources.$^1$

For a discussion of this distinction between transversality conditions
and no Ponzi game see also the answer by Alec Papadopoulos to a
similar question: No Ponzi game condition and transversality condition are the same?
$$***$$
To have an idea of the   nature of the transversality condition  (the technicalities are very complicated) one must forget in the first instance the economic content of a model.
The Pontryagin maximum principle, which  is used in optimal control problems,$^2$
is a whole class of theorems,  relative to problems with different mathematical assumptions, finite or infinite horizon problems, fixed end or open end,  initial states and target states that can be points or sets, and so on.
In some classes of optimal problems (not all) transversality conditions are needed, and they arise from mathematical, in particular geometrical,  considerations about optimality conditions.
And they are the same, irrespective of the field of application. $^3$

$^1$  Romer, Advanced Macroconomics, McGraw-Hill, 2012, p. 53.
$^2$  The other possible approach is calculus of variations but, when the calculus of variation is applicable, the results are the same, and Pontryagin Maximum principle is applicable under more  general assumptions.  See, for example, Takayama, Analytical Methods in Economics, Michigan University, 1993.
$^3$   To have an idea of the mathematical aspects of this complex subject  and of trasversality conditions one can see for example Liberzon, Calculus of Variations and Optimal Control Theory. A Concise Introduction, University of Illinois at Urbana-Champaign. Consider that in the original work by Pontryagin, The mathematical Theory of Optimal Processes, the proof of the first theorem  only is forty pages! The book of Takayama I quoted above is also a good reference, as to economic applications.
Comment: See for example  https://economics.stackexchange.com/questions/15290/transversality-condition-in-neoclassical-growth-model  : "The intuition of the transversality condition is partly that "there is no savings in the last period". But as there is no "last period" in an infinite horizon environment, we take the limit as time goes to infinity".(in the answer by Herr K.)
Comment: What is the economic significance of transversality conditions in Ramsey model?

Ramsey model condition