What technique was most likely used when demonstrating how a mariachi group played rapidly?

Question: Sometime when I was around nine years old, my music teacher brought in an audio-visual aid into our classroom and showed us a half-hour film documentary about what made up a mariachi band. I=The narrator introduced several members of the band and what they played. He demonstrated things like how the strings and brass often complemented each other on melodies and harmonies, while the guitar and vihuela often provided the rhythm and accompaniment, and how the guitarron provided the bass foundation, while the vocalists simply sang when the brass and string sections were at rest.
Somewhere in the middle of that presentation, I heard the guy who was one of the guitar players say how he strummed a G-chord at an eighth-note pace, at a quarter note BPM of 100. He said something like how there was a slight delay between the first guitar player playing those eighth notes and the other one, so that it would sound something like this:

Since this technique is present throughout the whole piece, I did not include time, sufficient to say that starting about ten seconds, the guitars really start to pick up speed. The idea was for it to sound like sixteenth notes, so when I was a little older, I tried doing that on a guitar by rapidly strumming up and down at that pace, but it was difficult to do. If I knew where that documentary was, I could go back and listen to it, but unfortunately I don't know what it's called.
If anyone here has mariachi experience and can provide me with a better explanation of what was going on, I would really appreciate it.
Comment: Please indicate the video timing of the sound you're asking about.
Comment: So, this kind of thing? [Mariachi strumming pattern](https://www.youtube.com/watch?v=tjoojOmFMNQ&t=1m35s)
Comment: Maybe, I was too little to really pay attention to what they were talking about. I had always grown up thinking that they simply had two guitar players, each one playing strums on eighth notes, but just delayed by a sixteenth of a beat, sort of like how delayed phasing would work.
Comment: Okay, I think I understand. You're looking for the name of the technique that sounded like 16th notes (at q=100), possibly played by two guitars alternating strums. Yes?
Comment: Yes, if that's how I remembered it, yes If I misunderstood the video, and it was only one guitar player, then maybe that was it.
Comment: There may be a more contextually appropriate term, but one word, from medieval choral context, would be [hocket](https://en.wikipedia.org/wiki/Hocket), for any time that multiple voices "interlock" to form one line.
Answer: It seems like an appropriate term for the context might be maniqueo(s). The path that led me here was:

The world-music textbook Music of the Peoples of the World discusses son jarocho (and draws a distinction between it and mariachi):

Although often overshadowed by the ever-popular mariachi style, the traditional music of the Veracruz fandango dances is the son jarocho. The core jarocho ensemble is made up of three instruments: the jarana, a five-course guitar slightly smaller than the Spanish guitar; the requinto, a small guitar; and the arpa, a diatonically tuned harp. [the quote notes that it lacks the trumpets characteristic of mariachi.]
Although the son jarocho also lacks percussion instruments, the rhythmic and percussive use of the instruments of the ensemble more than makes up for it. The jarana and guitar players create these rhythms by alternating patterns of up and down strums called maniqueos or rasgueado. Rasgueado also refers to one of the most distinctive strokes in which the fingers unfold over the strings as the wrist moves down, creating a long emphasized strum.

I would be cautions about using the term rasgueado for the alternating effect we're talking about here, since that "spread-fingered strum" meaning is much more prevalent, including in flamenco contexts.
When I look for a definition of maniqueos, I get a lot of mention of the religion Manichaeism, which emphasizes duality and dichotomy; I think maybe maniqueos can carry a meaning of "contrast" or "black-and-white."

The term maniqueos perhaps appears in the article "From Veracruz to Los Angeles: The Reinterpretation of the Son Jarocho"; I lack the JSTOR access to read it, but this is a snippet that reads "... stroke maniqueos on each quarter-note beat of the 3/4 meter, which results in a continuous eighth-note strumming effect." That seems like exactly the meaning that you're describing.

Maniqueo appears in a survey of the words used by mariachi musicians, Estudio lexicológico del vocabulario del mariachi de Puebla. I can't get much meaning from it, but p. 75 seems to equate it with rasgueo. It also appears in a transcription of an interview on p 183; the speaker doesn't explain the maniqueo thoroughly, but he identifies it specifically with the sones jarochos, refers to it as "a rhythm," says it's technically challenging, and involves the playing of "the guitarists or vihuelists."

It's also discussed in Convergencias: Encuentros y desencuentros en el jazz latino. Google Books omits part of the quote, but links it to African polyrhythmic practices, which also often construct rhythms from the interlocking of multiple instruments. My (amateur) translation is:

... rhythms are represented in the maniqueo or muñequeo of the jaranas, of the vihuelas in the case of mariachi (in all the mariachi of the south of Jalisco and the north of Michoacán), en the polyrhythm the are produced between a guitar, a jarana, and a requinto. Here we find the Africanism.

Although the Loza snippet talks about exactly the use case you're describing—alternating equal-duration notes to create a doubled rhythm—I get the impression that the term can also be used for more complex alternations to create other rhythmic patterns.
Comment: Also _rasgueo_ should be a valid term to mention, generally, this techniques, as its meaning could be inferred as "action or effect of playing the guitar strumming multiple string at the same time", and undestanding "strumming" as a synonym of _rasguear_ (for futher info, check: https://dle.rae.es/rasgueo and https://dle.rae.es/rasguear#VBa8tgl and https://www.collinsdictionary.com/dictionary/spanish-english/rasguear).
Comment: Bravo! FWIW, you can sign up for a free individual JSTOR account. It permits access to a limited number of articles per month.
Comment: @Aaron Thanks, I didn't know! I just said "oh well" when I stopped teaching for universities. What I really miss is Grove, though...
Comment: Great research! Good point about been cautious to mention _rasgueado_, as nowadays have became a keyword to represent a similar technique (maybe the technique that is subject of this post might comes in some way from this source...).
Answer: I don't think that alternating notes between two players is a common thing in mariachi music.  I have experienced that kind of alternation in a fast orchestral piece, the Sabre Dance by Khatchaturian, where one group plays on the beat and another group plays all the off beats and the tempo is quite fast.  It's hard!  Oom-pa oom-pa for pages and pages.  It's so tempting to start playing the other group's part because your ear might follow that line instead of your own.  Kind of like an optical illusion, where you see two different things, depending on what you focus on.  Once you lose the proper alternation, it's hard to get it back.
Also, I listened to the video you provided.  Since I'm a string player, not a guitarist, I confess that my ear was more focused on the violins than the guitars, etc., but I really did not hear any alternation.
There is a way of playing separate notes very fast, called tremolo.  This is done on string instruments, and I don't know whether it's also done on guitar and the other special instruments of the mariachi.  Could they have been talking about that in the documentary?
The Wikipedia article about mariachi music in Spanish lists all the different sub-genres.  I suggest that you get to know each one, and then maybe something will fit with your vague and tantalizing memories.  I jumped around and read bits of Andy's article (book?) in Spanish, Estudio Lexicológico, and I noticed that in the transcribed interview, the musician comments that the various specific techniques are specifically associated with certain sub-genres.
I suggest you pay particular attention to the overlapping genre, música veracruzana, as I think you will find fast plucked notes, for example in its flagship piece, Huapango.  What I can say about that style of piece is that it takes years of practice to be able to play the pizzicato parts on a string instrument, e.g., the violin, as fast as is traditionally done.  (I was never able to master this on the cello.)  Note that the string players who do this well put their bows down so they are less constrained in their fingers (right hand).  Try to find a video of the arpa veracruzana played this way -- it's amazing.
Note that there are many, many different regional styles of traditional music in Mexico, and getting acquainted with all of them would take at least a lifetime.  And there are sub-regional variants of all of them.  I hope you will sample one of my personal favorites, the marimba with the buzzers.  You can hear this in Chiapas, in the Yucatán, and anywhere those musicians wander to try to make a living.  Three people on one marimba.  Heaven.
Suggested field trip: If you ever have the opportunity to visit Mexico City, I guess you would be on Cloud 9 if you visit the Plaza Garibaldi.  Side note: if you do, hopefully you will still find in the restaurants around the edges of the square a refreshing, unusual non-alcoholic drink called granadina (pomegranate juice).
Comment: Hi @aparente001, good work, seems that you have passed spend some time in México ;) Just two notes: for the armenian/georgian famous composer, I guess the right surname (when writing in English) is "Khachaturian", and on the other hand, I suppose the drink you mention is _granadina_ ("grenadine" in English), which is a nonalcoholic drink made from pomegranade, am I right?
Comment: @AndyBonner - Is it just me, or is the Sabre Dance really hard for an orchestra to do well?  Thrilling to play, when it works, but rather stressful. / To me, if the men are wearing the trousers with the big studs going up the sides, then it's mariachi.  I don't remember what the women wear.  If the men are wearing guayaveras (the best apparel for the heat close to the seaside), then it's *música veracruzana*.  Maybe that's an oversimplification, but it's always worked for me.
Comment: Thanks! I agree, it seems like this technique is associated specifically with certain genres (like *son jarocho*), and some sources use the word *mariachi* more broadly or narrowly, to include or exclude those. (Including to describe the musicians themselves!) And yes, similar features appear in other genres and cultures; besides African polyrhythms, one of my early comments mentioned medieval vocal "hocket"; and, for that matter, the opening of the popular 2nd mvt of the [Ravel string qt](https://youtu.be/ZhN0RRlLhDg)—or, arguably, [Clapping Music](https://youtu.be/lzkOFJMI5i8)


Either $f$ is a polynomial or $|f(z_j)| > e^{n|z_j|}. $

Question: Me and a friend of mine didn't manage to solve the following problem.

Let $f: \mathbb{C} \to \mathbb{C}$ be an intere holomorphic function having a finite number of zeroes. Then either $f$ is a polynomial or there is a succession $\{z_j\}$ such that $z_j \to \infty$ and there exist $r$ such that eventually $$|f(z_j)| > e^{r|z_j|}. $$

Attempts
Let's call $h = \frac{f}{g}$, where $g$ is the polynomial that vanishes on zeroes of $f$ with the same multiplicity of $f$.

We tried to look at $\frac{h'}{h}$, the logarithmic derivative of $h$ , but without good ideas.
One can observe that $h$, when it's not constant, must have an essential singularity at infty.
Comment: First step is good. Then consider that $\log h$ is a nonconstant entire function, hence grows at infinity at least linearly.
Comment: Elaborating Michelle's point, notice that any entire function is either polynomial or grows super-polynomially. (In other words, any entire function that grows at most polynomially is indeed a polynomial.) This should be enough for your claim.
Comment: Could you please expand this to an answer? We honesty did not manage to.
Answer: If $f$ is not a polynomial, then $h$ is a nonconstant entire function without zeros. Therefore, $\phi = \log h$ is a nonconstant entire function. So its derivative at some point $z_0$ is nonzero. By the Cauchy integral formula,
$$
\phi'(z_0) = \frac{1}{2\pi i}\int_{|z-z_0|=r} \frac{\phi(z)}{z^2}\,dz
$$
which implies that $\max_{|z-z_0|=r}|\phi(z)| \ge r|\phi'(0)|$. Translated back in terms of $h$, this yields
$$
\max_{|z-z_0|=r}|h(z)| \ge e^{r|\phi'(0)|}
$$
Comment: See [If h is a holomorphic non-vanishing function in the complex plane then h is the exponential of another function.](https://math.stackexchange.com/q/1183905)
Comment: Why does $log(h)$ is entire?!


Não consigo tirar o resultado None deste código

Question: Estou tentando retirar esse None, já botei else, já botei add2 e depois defini add = add2 mas ainda não consegui tirar.
Como fica:

Qual fruta você quer adicionar à lista? morango
Quer adicionar mais fruta? talvez
Por favor digite sim ou não:
None (e a caixa de texto pra digitar)
(mesmo problema nos dois ifs)

frutas = []
novafruta = input('Qual fruta você quer adicionar à lista? ')
frutas.append(novafruta)
add = input('Quer adicionar mais fruta? ')

if add != 'sim' or add != 'não':
    add = input(print('Por favor *digite sim ou não: '))

while add == 'sim':
    frutas.append(input('Qual fruta você quer adicionar à lista? '))
    add = input('Quer adicionar mais fruta? ')
    if add != 'sim' or add != 'não':
        add = input(print('Por favor digite sim ou não: '))

Answer: A lógica é muito complicada e redundante. Eu até mudaria um pouco a forma de responder ao usuário para simplificar o código, mas não sei se pode então vou manter assim.
O maior motivo do erro é que tem um input() sem necessidade encapsulando o print(). Isso não faz sentido e torna a lógica falha porque a pessoa só tem uma chance de errar, depois dá problema. Então tem que tirar isso, mas tem que consertar todo o resto da lógica.
frutas = []
add = 'sim'
while True:
    if add == 'sim':
        frutas.append(input('Qual fruta você quer adicionar à lista? '))
    add = input('Quer adicionar mais fruta? ')
    if add == 'não':
        break
    if add != 'sim' and add != 'não':
        add = print('Por favor digite sim ou não: ')
print(frutas)

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.


Should I practise chords as a beginner?

Question: I've been playing guitar for two months now. I'm able to play some basic chords, a couple of simple songs, etc. A little bit of everything, really (or nothing). My goal is to play lead guitar and rhythm guitar, in hard rock/metal songs (by Avenged Sevenfold, Disturbed, and Eluveitie).
However, my question is: can I, as a beginner, just get to work on my hand accuracy, hammer ons, pull offs, power chords, etc. (typical lead/rhythm techniques), or should I practise chords first?
Because that's what everybody seems to suggest, to start with chords and practise some songs with them. I don't want to invest time in that however, because that's not the style I'm going for. I know they're important to learn, but right now, I want to practise stuff that I enjoy playing.
Comment: If you learn to play songs you like, you will learn the techniques you need for that kind of music. You'll find that almost every genre includes playing of chords, single notes, two finger power chords, etc., so it's hard to avoid learning most of the basics even if you focus on one genre. At the same time, it's better to branch out, sooner or later, to all kinds of music that you like, and your tastes are likely to change over the years. If you're playing for fun (which I recommend), play what is fun! Don't force yourself to learn something boring because you think you have to.
Comment: If you've got the cash, and equipment, I found Rocksmith to be an amazing way to learn, you can spend a little time playing random songs, and a little time playing the songs you love (Avenged Sevenfold & Disturbed, both dlc).
Answer: It depends somewhat on whether you want to be a one-trick pony. There are so many guitarists out there who only learnt certain narrow style stuff, that can only do that stuff.
Harsh, maybe, but as far as chords are concerned, the guitar is one of very few instruments that can play chords, so it's good to be able to do just this. Also, so much lead playing emanates from the chord shapes, so not knowing them will effectively slow down your progress. You mention the goal to be a rhythm guitarist as well - not particularly easy if you can't play chords!
My students always learn to play both lead and rhythm (chords) in parallel, so they will be able to switch easily as needed. Yes, it takes longer initially, but the progress is superior leading to a more rounded player. One day you may feel the need to play other sorts of music, and starting from scratch will slow you down.
Comment: +1 and I especially agree that chord shapes & positions are a handy way to visualise scale shapes and intervals on the fretboard. (Also helps the hand strength, in my opinion.)
Comment: I have always taught *songs*, selected by the student, presumably that they really like, to help with motivation. Most songs have a mixture of chords and single-note work or double-stops, etc. Only for specific problems or techniques have I recommended or provided exercises that are not actual music. So I agree, learning both sides is important, with one way to do that to learn entire songs. +1
Comment: Thanks for your reply, really helped :) there's just so much to learn, that i didn't really know where to start, or what was important.
Comment: @ToddWilcox - yes, most teachers tend to teach songs. It's something I have  tended to shy away from, though. Instead, I'll go through an intro, verse, chorus, etc., and may once in a while go through the whole song. Working on the premise that if verse 1 sounds good, the next virtually identical one will too. Putting it all together is left to the student, except where we're reading through, and D.S or D.C. become important. So, learning a whole song is rare for my students. Sort of - if you can change  E to A to B7, then you should be able to at least strum along to any 3 chord tune in E...
Answer: I have two words for you: sweep picking. Or as it's more generally known, arepeggios / broken chords.
This is when you hold a chord with your fret hand and play individual notes with your pick hand. Yes fingerpickers do this, but metallers do it too and they call it sweep picking. Its a very important technique metallers use to play fast.
If you try and copy a tab and don't know about chords, you will find yourself positioning your fingers awkwardly and having to move them often. If you understand chords, then you will be able to position your hand in a chord shape and play with less movement of your fret hand, even if you're only playing individual notes.
Do what everyone does. Learn chords. Learn scales, starting with the pentatonic. Otherwise you'll just make life hard for yourself.
Answer: The most accuarte answer I can give you is just do what feels right. I hope that playing guitar is a hobby, something you enjoy. So you should enjoy every minute of it.
I know some people will say that you need to start with basic chords and basic songs. Well they are not wrong per se. They just started that way and it felt right for them.
My example is different. I am a big Led Zeppelin fan so first thing I started with was learning Stairway to Heaven. As you may suspect it was far too big feat to pull off as a begginer. But I wanted to learn StH so that is what I did. After four years of playing I still didn't master that song but gradually I perfected my technique and naturally applied StH wisdom to other songs.
On the other hand I had periods of staying away from electric guitar and playing simple songs with simple chords and singing along. That felt great so that is what I did.
So to summarise. Do what you want, don't let anyone tell you that their way of playing is superior. Jimmy Hendrix didn't know how to hold a guitar and nobody dared telling him that what he was doing was wrong. Ultimately you will learn to play chords, hammer-ons, pull-offs and more specific techniques, but you should always begin with the thing that gives you the most fun.
Comment: Couple of points - had you learned other things, they would have probably helped StH, rather than the other way round. Jimi actually learned to play right-handed, but preferred the other way, much to his Dad's disgust, and could play just as well either way. Not a matter of 'didn't know'.
Comment: Stairway offers nice strumming chord progressions used in many songs beyond it's intro. The solo is a great example of how to utilize the whole neck for scales.  I think it is an appropriate choice, but other tunes like Heartbreaker, Whole Lotta Love, and Communication Breakdown can be easily understood for riffs too.
Comment: @rlo From technicall point of view, learning easier songs would speed up StH learning process, but forcing myself to learn easier stuff would be counterproductive. I may be mistaken with Hendrix. I read somwhere that he learned by ear, and as a result held guitar the way it felt right.
When I started learning StH I had problems with my fingers colliding with each other on the intro. Bar chords where punishing for my fingers. I would probably benefit from learning House of the Rising Sun but it wouldn't be as fun as pretending I'm Jimmy Page. ;)
Answer: Do you think the guitarists from Avenged Sevenfold, Disturbed, Eluveitie can play chords? I'm pretty sure they can. If you don't learn them now, you are going to have to go back and learn them later to progress. The shapes of the fundamental chords crop up everywhere, in every form of music, not necessarily as strummed clean chords but also in riffs and solos. Power chords themselves are derived from  E shape and A shape barre chords.
Comment: Good advice...those guys started off with basics. You would have to if playing fast and clean is the goal. They have also put in a lot of work and they are very disciplined to play that style.
Answer: When children go to grade school they learn two main subjects among many others: Math and Reading/Writing. These subjects have some crossover, but are obviously separate. As you become advanced students the ability to do both skills is merged in some advanced subjects.
I recommend students start with guitar by studying multiple subjects in every practice, where the subject categories are (roughly) are rhythm (chords, arpeggios, fingerpicking, and strumming) and lead (scales, reading tabs, arpeggios, and reading music). Merging these skills more and more as you become more skilled is an indication that you are becoming more advanced.
This is more or less what @Tim seems to be saying. He is right: Guitarists who know both lead and rhythm are better at both.
This is not to say that you should avoid anything. @Todd Wilcox is right. You should learn what you like. I also recommend in addition that you should spend some time working on basic skills that you might miss, to help you become well rounded. Don't avoid things because they are hard, or you don't like them. It takes a long time to learn guitar, and eventually you may want to be able to do some other style than the one you want to do now. All the work on your journey will improve all your skill to some degree, and at the same time you can be held back by any basic skills that you did not bother with.
I would argue that it does not take longer to learn both. It takes a long time to learn guitar, but working in parallel like this multiplies the value of your practice time.
Answer: Sounds like you have a specific goal in mind, so the idea of playing what you want when you feel like it will not work. The bands you mentioned are highly technical and worked very hard to get there.  Learn chords and scales.  Get tabs of the songs from a published book or magazine and find how they executed the riffs.
I started by looking at tabs of Randy Rhoads and it was intimidating at first, but with lessons I understood where these riffs and licks were coming from. I practiced the tabs and the lessons my teacher gave me. Be goal oriented in your playing. Start with basic chords and master them. This will build technique in the hands that can be applied to the riffs from those bands eventually. Maintain a log book of what you do to track progress.
You will always need basic chords and scales. Practice them well. It is the foundation of all playing.
Answer:
I'm no good with chords. I'm horrible with chords. - B.B. King

B.B. King could say that, because he was B.B. King. He was a very unique player, and that made him one of the all time greats.
You, on the other hand, should learn chords and work on chords until your dying day. Because chords are really the starting point for everything else you do on the guitar.
Now, you don't need to work your way through Ted Greene's Chord Chemistry book, but you do need to know all the basic chords in several positions. And if you want to play rock, make sure you learn the E7#9.
Comment: yes the E7#9 lol  - but I mostly use that when playing "Funk".

Should I practise chords as a beginner?


Why do some trombone players put their index finger over the mouthpiece while playing?

Question: I've recently started playing the trombone for fun (read: I'm not taking lessons). I've noticed when watching many trombonists on video and in pictures that they often put their index finger over the top of the mouthpiece while playing.
I've tried this myself to see if it had any affect on my playing, and I only noticed that it made it harder to hold up the instrument for me.
Is there any benefit to this finger placement? What is the purpose?
Comment: As a side note: take one lesson, maybe two. I'm all for being self-taught, but a private instructor will be able to help you develop good habits and/or correct bad habits before they become so engrained that they're impossible to grow out of.
Answer: This is only for comfort. The part where you hold the trombone is not very ergonomical so we search for as comfortable position as possible, with control of the instrument. Try various hand positions yourself to see which works best for you. Ideally you should not lift you left shoulder at all (do check in a mirror, lifting left shoulder will with time lead to a lot of pain), the full weight and control should be in your left hand and the slide should not support the trombone weight and it should slide totally freely. (Ideals are one thing, reality a different). Whatever works for you.
I used to play the bass trombone and had a 2+2 hand positioning: 2 fingers in front of the bar and two behind. Index finger on the mouthpiece. This made the movement of the two valves controlled by left hand more free as well as getting a better balance.
There are varius devices available that improve the ergonomics. Some are extra support bars mounted on the instrument.
Answer: I just asked a trombonist; the answer was, that it is a convenient place to press against, so the instrument does not tilt, since it requires less effort than more forceful grip.
Answer: Some players do this to avoid using too much pressure. Paul Tanner was a prime example.


How to use RLimitCPU

Question: How I can Limit cpu usage of apache2 php scirpts using
 RLimitCPU  seconds|max [seconds|max]

Please show me an example.
e.g RLimitCPU 2 2 ? whats that mean ?
I know its cpu seconds but question is how to convert GHz to seconds.
One php for video streaming script sometimes is taking 100% CPU usage on 2 cores.
http://httpd.apache.org/docs/2.2/mod/core.html#rlimitcpu
Answer: 1 GHz is 1,000,000,000 CPU cycles per second - so a 2.6 GHz CPU is going to go through 2,600,000,000 cycles in one second. How many instructions actually get executed in a cycle is going to vary with the CPU - they'll all take a certain number of cycles to actually complete an instruction.
2 CPU seconds is "the CPU is completely maxed out for two full seconds or the equivalent". So if your program uses the CPU at half capacity for 4 full seconds that's 2 CPU seconds.
For your app, if you have a 2.6 GHz CPU and you run at 2 CPU seconds, you'll have executed 5,200,000,000 CPU cycles. How many instructions that is harder to work out, and how many instructions you actually need for your "video streaming script" is going to be incredibly hard to work out (and is going to vary with the length of the video).
I'd advise just running the script for the biggest video you'd ever send, seeing how many CPU seconds you use (top -u apache-usr will let you see the PHP process running, "TIME+" column is CPU time) and then tripling that as your RLimitCPU.
Bear in mind that RLimitCPU is just going to kill your PHP script when it takes more CPU time than the limit. It's not some magical tool that means your script will take less CPU time, it's just a limit on the maximum time the script can take.
Answer: Apache Reference: http_core, RLimitCPU
RLimitCPU
Resource Limit on CPU Usage

Syntax: RLimitCPU soft-seconds [hard-seconds]

Example: RLimitCPU 60 120

Since: Apache 1.2

This directive sets the soft and hard limits for maximum CPU usage of a process in seconds. It takes one or two parameters. The first parameter, soft-seconds, sets the soft resource limit for all processes. The second parameter, hard-seconds, sets the maximum resource limit. Either parameter can be a number, or max'', which indicates to the server that the limit should match the maximum allowed by the operating system configuration. Raising the maximum resource limit requires the server to be running as the userroot'', or in the initial start-up phase.
http://www.apacheref.com/ref/http_core/RLimitCPU.html

How to use RLimitCPU


Memcache basic configuration

Question: I have installed memcache for a Drupal site with the memcached pecl extension. It's all running fine but I'm still struggling with the configuration settings.
For instance , following advice on drupal.org
You should probably lock down the memcache server so that it only listens for
connections from the hosts that need to be served, as the default is that
memcache listens to connections from all addresses.
So, to close that hole, edit /etc/sysconfig/memcached with:

OPTIONS="-l ${HOSTIP}"

Problem is that I don't have  this file on my server, in any case not at this location.
Some other articles have mentioned /etc/memcached.conf but I can't find this file either.
Considering that the /etc/sysconfig/memcached or /etc/memcached.conf do not exit on my server, can I safely create them?
Is it possible for these files to be situated somewhere else, in which case where should I look or is there any way to find that info?
Finally , any resources, tutorials or documentation links would be greatly appreciated. I've browsed thru memcache's site Wiki, and could only find a couple of relevant articles for beginners.
Comment: The drupal instructions are incorrect.  The `-l` option regulates to which interfaces memcached will listen to, _not_ which hosts will be served.
Answer: You did not tell us about your OS/distro. Also, you did not tell us how you installed memcached.
Usually, you will get a sample config file under /etc/ when you install memcached using apt-get under debian-based systems and rpm or yum under redhat, fedora or centos.
If you installed it from source, you may not get a sample file under /etc/ (I did not install memcached from source myself). However, you can look for a sample config file in the unpacked source folder.
Anyway, you can use locate memcached.conf to look for one in your system. You need to do sudo updatedb before that to update the search cache.
Here is the config file from my system. You can use it:
# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d

# Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log

# Be verbose
# -v

# Be even more verbose (print client commands as well)
# -vv

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 64

# Default connection port is 11211
-p 11211
# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u memcache

# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
-l 127.0.0.1

# Limit the number of simultaneous incoming connections. The daemon default is 1024
# -c 1024

# Lock down all paged memory. Consult with the README and homepage before you do this
# -k

# Return error when memory is exhausted (rather than removing items)
-M

# Maximize core file limit
# -r

You can also pass the same options from the command line.
Comment: Debian GNU/Linux 5.0.9 (lenny) / memcached 1.4.10 .I went thru so many steps in order to install memcache that I can't remember for certain how I did it. It may have been compiled from source since these config files are missing. I know for certain the pecl extensions were installed from source, simply because using pecl didn't work. Looking at the source folder, I couldn't tell what would be the sample config file...
Comment: @PatrickS: I updated my answer.
Comment: I've ended up creating /etc/init.d/memcached using the above command line options to configure memcache
Answer: The default (CentOS) /etc/sysconfig/memcached:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

The init script (CentOS) /etc/init.d/memcached:
...
if [ -f /etc/sysconfig/memcached ];then
        . /etc/sysconfig/memcached
fi
...

The above amounts to, if the file exists, 'source' it (i.e. read and evaluate its contents).
As far as I know, memcached does not have a configuration file. It uses command line parameters, for example (from a RHEL/CentOS init script):
daemon --pidfile ${pidfile} memcached -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS

(You'll note that the variables defined above, are used here).
The bottom line, therefore, is:

Check your init script - if it contains a section similar to that above (the if statement) then certainly, create the matching file, and place the appropriate variables in it.
There is no configuration file - don't create one as it won't be used.
Answer: If you can't find on CentOS /etc/init.d/memcached try this:
nano /usr/lib/systemd/system/memcached.service

and change:
ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS

to:
ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -I $MAXITEMSIZE -c $MAXCONN $OPTIONS

After add in /etc/sysconfig/memcached
MAXITEMSIZE="128m"

Restart memcached
service memcached restart

To check if parameter is added try:
ps aux | grep memcached

Memcache basic configuration


Is it possible customize user login page on Adaptive Theme?

Question: I tried many solutions for change my mysite.com/user page. I want, only login-register-forgotten form is visible, other block hidden. But what i try a solution, don't working.
Is it possible? How can i do this?
This is my past question: https://drupal.stackexchange.com/questions/65475/error-when-creating-a-custom-page-in-d7
Answer: If you wish to hide blocks, go to the block configuration page (/admin/structure/block), celect 'configure' for the blocks you wish to hide, and under 'Block Visibility Settings' on the 'Page' tab select 'All pages except those listed '. Then if your login url is '/user/login', enter 'user/login' in the box. If you enter 'user/*' it will exclude the block from all pages matching the pattern.


Adding Image in Datagrid

Question: This is my datagrid i want to display an image in the grid column but its is showing me text System.Windows.Media.Imaging.BitmapImage, instead of displaying an Image.
How to add an image in a datagrid column?
This is what I have tried :
Dictionary dict1=new Dictionary < string,object>();

string keyimage="Image";

object a1 = new BitmapImage();

a1=Imaging.CreateBitmapSourceFromHIcon(SystemIcons.Information.Handle, Int32Rect.Empty, null);

dict1.Add(keyimage, a1);

This dict1 serves as Itemsource for the datagrid...........how to make an image to be displayed in a datagrid column?
Comment: What column type are you using to display an image?
Comment: that was my question..........what column type should i use to display an image?
Comment: What will you have in this dictionary, only Images?
Comment: No not only images.i just want to add a Image column in datagrid in c# code and not in xaml
Answer: Make sure you use a DataGridTemplateColumn and put an image into it.
Since you are using a dictionary, bind the value, something like:
<Image Binding="{Binding Height="25" Width="50" Source="{Binding Value}" />

Answer: I suppose your Column datatype mismatches with itemsource datatype. You have to make equal datatype Image for both Grid Column and itemsource.
In my WPF project I made my column data template with Images:
DataTable dtab = new DataTable();
dtab.Columns.Add("imageColumn", typeof(BitmapImage));
//Uploading dtab with Images from DataBase

FrameworkElementFactory factory = new FrameworkElementFactory(typeof(Image));
Binding bind = new System.Windows.Data.Binding("imageColumn");
factory.SetValue(Image.SourceProperty, bind);
DataTemplate cellTemplate = new DataTemplate() { VisualTree = factory };
DataGridTemplateColumn imgCol = new DataGridTemplateColumn()
{
  Header="image",
  CellTemplate = cellTemplate
};
DataGrid dg = new DataGrid();
dg.Columns.Add(imgCol);
dg.ItemsSource = dtab.DefaultView;

Hope this help
Answer: Add any image to your Project on Resource folder
After that try the below coding in DataGrid Bind event. Here i have add the image logo...
DataGridViewImageColumn imageColoumn = new DataGridViewImageColumn();
        imageColoumn.HeaderText = "Img";
        imageColoumn.Image = null;
        imageColoumn.Name = "DataPic";
        imageColoumn.Width = 150;
        dataGridView1.Columns.Add(imageColoumn);

        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            DataGridViewImageCell cell = row.Cells[1] as DataGridViewImageCell;
            cell.Value = (System.Drawing.Image)Properties.Resources.logo;
        }

Comment: DataGridViewImageColumn does it have any namespace or something and more over i am using wpf datagrid and not datagridview
Comment: ok then you just try this link.... http://stackoverflow.com/questions/7938779/image-column-in-wpf-datagrid...
Comment: i have set AutoGenerateColumns="True" since i have a very good dataset and i could easily bind it with the datagrid but now i am trying to add a image in the dataset which the datadrid is not showing......no changes in xaml only thing i could do is to do something in c# code ..........

Adding Image in Datagrid


Correcting spelling errors in OCR texts

Question: Situation

customer contracts available as scanned images were turned into text files using OCR software
the resulting texts contain spelling errors that occurred during OCR, e.g. words like "useful" were mistaken as "u5eful"

Question
What are current best practices for correcting these OCR spelling errors as a post-processing step?

for standard vocabularies, i.e. correcting common words
for specific vocabularies, i.e. correcting specific product names, customer names, special terms etc.

Thanks!
Answer: The best solution would probably be to re-OCR the documents using a better OCR, ideally with a language model that is specifically tuned for the domain of the documents.
Otherwise, you can use a spell-checker with an additional custom vocabulary, there are several Python packages for that, e.g., pyspelling has an interface for both Hunspell and Aspell. The advantage of existing spell-checkers is that they have optimized algorithms for retrieving correct similar words. The disadvantage is that they treat all edits equally.
To get around this, you can get more spell-checker suggestions than you would normally display to a user and re-score them. The simplest way is designing a weighted edit distance where errors that are frequent in your data would get a low cost (e.g., substituting s and 5 should be a cheap operation). There are also several Python packages for that, weighted-levenshtein should be pretty fast. If you want a really fancy solution, you can re-score the suggestions using a language model.

Correcting spelling errors in OCR texts


javascript innerhtml does not change content on source code

Question: I don't know how to solve this. I want to change the (DOM)source code on some event, like this:
script:

html:

Hello world!

<input type="button" onclick="ChangeText()" value="Change text" />

well, this works fine when I click the button. but when I view the source code.it still looks the same like this:

Hello world!

        <input type="button" onclick="ChangeText()" value="Change text" />

instead of:

New text!

        <input type="button" onclick="ChangeText()" value="Change text" />

Comment: That's the way it is. The source code does not change.
Comment: ok, I thought I could change the source code. all suggestion are considered. thank you very much, guys.
Answer: Your source code does not change.
Just the DOM
So if you are using firebug or chrome, you could use inspect element to see the change.
See here: http://jsfiddle.net/maniator/eVw7Y/ (this is using your example)
Comment: Check out Firebug Lite: http://getfirebug.com/firebuglite - it lets you use a scaled-down version of Firebug in any browser (Including IE)
Comment: Firebug is dead
Answer: view source only shows you the source code that was delivered to the browser. It doesn't show you the source POST page load. So you're not going to see anything rendered by JS (as the JS isn't changing the source file from the server...it's just changing the DOM in the browser).
To see that, you need to install something like FireBug which will let you view rendered source which will reflect all changes made to the DOM via JS.
Answer: Using Firefox, install the Web Developer toolbar. Then under View Source, click View Generated Source.
Using Firefox with Firebug installed, or Google Chrome, right click on the document and choose Inspect Element. On the HTML tab, you can see the source code update instantly as the DOM changes.
In IE, you can also install the Web Developer toolbar and follow the instructions above.
Answer: Besides the solutions based on Firefox extensions and explanations already posted, you can also get the source code after Javascript modifications typing this in your browser:
javascript:document.write("<xmp>"+document.documentElement.innerHTML+"</xmp>");

Make sure you still have the javascript: part if you use Copy/Paste.
I tested this in Chrome and IE11 (Windows 7). Some browsers (like Apple Safari) might require you to enable the "Allow JavaScript in the Address Bar" setting.
When you select "View Source", you view the HTML (not the DOM) as a direct response of the HTTP request to the server (before any Javascript is loaded). The DOM, on the other hand, is the same HTML structure that has been modified by JS. More info here: https://developer.apple.com/library/ios/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/ResourcesandtheDOM/ResourcesandtheDOM.html


Find all lineary dependent subsets of vectors

Question: I have vectors in such form
<code>(1 1 1 0 1 0)
(0 0 1 0 0 0)
(1 0 0 0 0 0)
(0 0 0 1 0 0)
(1 1 0 0 1 0)
(0 0 1 1 0 0)
(1 0 1 1 0 0)
</code>
I need to find all linear dependent subsets over Z2.
For example 1,2,5 and 3,6,7.
Comment: And what have you tried? Also, homeworks should be tagged so.
Comment: @Boris Stitnicky, I thought about brute force, but hope there something better. Gauss elimination may not help because of i need all.
Comment: Gee this is such a standard task... and I am so dumb today...
Comment: @Boris Stitnicky, give me hint please, what i should read?
Comment: Got it, they call it dynamic programming, IINM. http://en.wikipedia.org/wiki/Dynamic_programming
Answer: OK, my 5 cents, brute force, IINM, is iterating over all subsets of the set of vectors. So, instead, you go from the bottom, where singleton sets of each vectors are obviously linearly independent.
In the next step, for each singleton set, you make a list by trying to add each of the remaining vectors in the set, and see which of such pairs are independent, taking note of those pairs, you've already tested, to prevent repetitive effort.
In the 3rd step, for each independent pair, you'll try to add each one of the remaining vectors to make triples, you test the new vector for independence, and mark the triples you've already tested.
This should provide much saving over brute force, with the worst case being a set of all independent vectors.


Is there a netstat -s equivalent for windows?

Question: I know that netstat -s exists on Windows, but it displays way less informations than on Linux/OS X.
It only gives 8 counters about TCP, while on Linux it's more than 50.
I'm looking for any TCP-related counters such as:

Linux: TCPDSACKOldSent, DelayedACKLocked, TCPOFODrop or TCPDSACKIgnoredNoUndo.
You can get the whole set of counters via cat /proc/net/netstat.
BSD/OS X: rcvbyteafterwin, rcvduppack or rcvoobyte.

Is there a built-in tool to achieve this ?
Or maybe there is a system call that would allow me to retreive such informations ?
Comment: `netstat -s -e` might be what you are after...
Comment: On Windows 7, -e only adds the interface stats and no more about TCP.
Answer: No for built-in tool. Only way I can think of is to use the winpcap/npf library to build your own tool to make up stat that you need.
In windows the network stack is stripped compared to the Linux/BSD's side. Thus the need for winpcap&npf driver.
I would add that even the windows firewall is a pseudo-stateless firewall (layer 4 and it just check tcp traffic, no icmp inspection, etc.. (layer 3)), not a full stateful layer 3 firewall like a Linux or BSD's box can be. So it explain why the built-in tool list lot less data.
Answer: Short of using a 3rd party product...
netstat -s -e
or you could use WMI
Such as:
wmic path Win32_PerfFormattedData_Tcpip_NetworkInterface
wmic path Win32_PerfFormattedData_Tcpip_TCPv4
wmic path Win32_PerfFormattedData_Tcpip_IPv4
the above will need to be used with the GET parameter to zero in on the objects you want, but you can run them as is to see what the choices are.
Comment: There's not one short of a 3rd party tool or possibly a complex PS script.  If you want deep dive tracing something like Wireshark can be used.
Comment: Wireshark is nowhere near equivalent to netstat -s.
Comment: `netstat -s -e` is way too general. I need many TCP error counters, and sequence number related counters. The WMI suggestion is better but not enough, I would need an extended version of that.
Answer: netsh interfaces ipv4 show {tcp,ip,udp}stats gives you some additional information over netstat, but it might not be enough.
MS Technet article on netsh ipv4
Answer: Windows does not report on the TcpExt properties.  The reason is because Windows does not TOE by default.  You can verify this by running netstat -nt and the offload column will likely be InHost.  In contrast, Linux uses TOE (TCP Offload Engine) by default and tools are built to query the TcpExt properties.
The data you're wanting is completely dependent on the driver built for the OS to expose that data.  There also needs to be a Windows provider created so you can query the data (could be a driver assembly).  In windows open up the Device Manager and check out the advanced tab of the properties to the Network Adapter.  You can see there what types of data are supported for collection in windows and whether or not it's enabled.
I realize others have advised that Windows cannot do it by default and have recommended other tools (like pcap).  Though I thought you'd want to know why.
Answer: For anyone else that stumbles across this like I did, here are a couple more options
# List all TCP Connections
netstat -tanob
# List all Connections
netstat -anob

# List all TCP Connections with FQDN
netstat -tafob
# List all Connections with FQDN
netstat -afob

But I prefer a PowerShell way to get the information that is very helpful.
Get-NetTCPConnection |
    Where-Object {$_.State -eq "Listen"} |
    Sort-Object LocalPort |
    Format-Table -AutoSize `
        LocalAddress,
        LocalPort,
        RemoteAddress,
        RemotePort,
        State,
        @{l="Process/Application";e={$(Get-Process -PID $_.OwningProcess | Select-Object ID,ProcessName).ProcessName}}

There is a nice writeup about the PowerShell way at https://sysnetdevops.com/2017/04/24/exploring-the-powershell-alternative-to-netstat/


What does data about kWh in the French Open "shots of the day" videos mean?

Question: The French Open publishes on its YouTube videos with "shots of the day" - the most impressive plays from a particular day at the tournament.
At the end of the point, an information about kWh is shown.
For instance after this lob of Ramos in the match against Sock, the following data are shown:

41 forehand winners, 184,5 kWh.

What is this information supposed to represent? It would be especially nice if some official source about this can be found. (By "official", I mean from Roland Garros' website, the video sponsor, or the stats provider.)
Comment: These kWh messages are obviously a message from the sponsor, [ENGIE](https://en.wikipedia.org/wiki/Engie). As far as I can tell, they seem to honestly believe the kWh values show some kind of "value" of the sport performance, cf. [their page](http://www.engie.com/en/news/engie-the-french-open-events/) promising "Once the game is over, [the visitor's] movement speed will be converted into kWh."
Answer: To extend Fillet's information... to hit a winner, ΔKE would be Δ1/2mv^2, or a total of mv^2 (if players hit at similar speeds).  I see suggestions [1] that typical shots are in the 60-80 mph range in men's tennis, and some winners get near 100 mph.
So .057*30^2 (for 70ish mph) is 50ish Joules per winner.  41 winners would only be 2 kJ or 0.0006 kWh.  Even 100 mph for every winner, that's only 5 kJ = 0.001 kWh.  So that doesn't work as anything significant.
I'm not sure what Fillet was taking from cyclingweekly (seems to be basically W/kg and to get to kWh, so you'd need to multiply out by mass and then hours expended to be useful)... but alternatively [2] shows 300-600 Calories per hour is a reasonable amount exerted playing tennis.  That'd be 1/3 to 2/3 of a kWh each hour per player.  So a three hour match easily could burn 3-4 kWh combined between the two players.  Can probably get to around 10 kWh in a long pro match, but still an order of magnitude off.
One thing Fillet didn't consider is the total shots in the match.  I found http://www.tennisabstract.com/charting/ and looked through quite a few... most I got was the Djokovic-Murray 2012 US Open, with just under 2000 shots (add the listed total of shot types for the two each players).  At the 70 mph earlier estimate, we're still only talking about 0.02 kWh.  Still no useful contribution (makes sense, considering how light a ball is).  Seems we're usually tired at the end from running, not from swinging our arm.
So, I too can find no way to get near the values they show.
The only guess I can think of is that they actually mean kW (power) rather than kWh (energy).  I saw rough estimates that the impact of a shot lasts a few milliseconds [3].  That seems reasonable.  A 70 mph winner could thus be about 13 J/0.004 seconds, ~ 3 kW.  133 kW total for 41 winners.  Finally a number\unit that sounds similar to their answer... though that would vary hugely by speed and contact time, and be tough to reasonably calculate?
Long story short, I'm as confused by it as Fillet.
Comment: Yes, I think (in)efficiency is the difference. According to wikipedia "The efficiency of human muscle has been measured (in the context of rowing and cycling) at 18% to 26%", https://en.wikipedia.org/wiki/Muscle . 460W is  the power transmitted to the bicycle, but the athlete will need to burn 4-5 times more energy to achieve this.
Comment: I was using mainly the sentences from the article such as "460W upper limit suggested above [for Lance Armstrong] for an hour-long effort", to justify that 1KW is beyond what a tennis player could ever output.
Comment: Certainly is a confounding set of info...
The more I've searched, the more I've seen sites interested in comparing running and bicycling (even http://bicycles.stackexchange.com/questions/9764/how-many-miles-of-riding-require-the-same-effort-as-one-mile-of-running)... but most seem more interested in emphasizing the skill of one or the other.

But appears the focus on your site and most of the other is on the OUTPUT.  Running, cycling, whatever, have inefficiencies... and I think think they're focusing on result rather than effort.
Comment: 1 kWhr = 860 Calories. A lot, but doesn't seem crazy for an hour?  http://www.bicycling.com/training/weight-loss/cycling-calories-burned-calculator shows a 200 pound man cycling 14-16 mph burns that in an hour. And quite a few forums suggest 15 mph is a reasonable rate for a starting cyclist. http://www.mensjournal.com/health-fitness/nutrition/the-tour-de-france-diet-how-to-consume-8-000-calories-a-day-20140710 seems to match the running and cycling possibilities of burning a fair part of a kWhr each hour. So only guess I've got is your article focuses on the cycle's Watts rather the person's?
Answer: I'm not sure if this should really be an answer, but it was too long for a comment.
Given a tennis ball mass of 57g, it is not the kinetic energy of 41 forehand winners.
Given 184.5kWh you have enough energy to accelerate 41 tennis balls to a velocity of 53000 mph.
It is also not the energy expended by the players in the match, as 1 kW is more than an athlete can output over an extended time, and the match can't have been going for hundreds of hours.


Recursive to explicit form involving Fibonacci

Question: I have a recursive formula for a sequence O: $ O_n = O_{n-1} + O_{n-2} + F_{n-1}$ where $F_n$ is the n-th Fibonacci number, $O_1 = 1$ and $O_2 = 2$.
After playing around with it, I found a new formula that might be easier to convert to the form I search: $ O_n = F_{n-3} * O_1 + F_{n-2} * O_2 + \sum_{k=2}^{n-1} F_{n-1-k} * F_k$.
Now what I am searching for is an explicit formula for $O_n$ that doesn't include a summation.
I also tried filling in Binet's formula and simplify, to no avail.
Here's a similar post, but the math is too hard for me, so I can't transform it to fit my problem.
An interesting property I found is that $\lim_{x\to\infty} \frac{O_x}{O_{x-1}}$ is equal to the golden ratio.
Comment: As another approach, it follows immediately from your definition that $O_n$ satisfies $O_n=2O_{n-1}+O_{n-2}-2O_{n-3}-O_{n-4}$ and the associated characteristic polynomial factors as $(x^2-x-1)^2$.
Comment: Try a term like $nF_n$
Comment: This is [A029907](https://oeis.org/A029907).  There is some discussion on the linked page, in particular you can find the claim that $O_n=\frac {(n+4)F_n+2nF_{n-1}}5$ which should be easy to verify.
Answer: I calculated a few terms and got $(O_n)=(1,2,4,8,15,28,51...)$.
I looked this up in OEIS and found this formula, which could be made explicit with Binet's formula:
$O_n=\dfrac{(n+4)F_n+2nF_{n-1}}5.$


how to save the state of the activity when user pressed select?

Question: i have created dynamic table-layout. in that layout in each row have four buttons.one  button is use to navigate from one activity to another. my problem is when i switch from 1st activity to second activity  by pressing button and i come back from 2nd activity to 1st activity clicked button loose its state.
Ex. 1) in 1st Activity i click button 1 and check the check box and go to 2nd activity after doing some operation  i come back to 1st activity and i see the button1  and check box are unclicked and unchecked.
so how to maintain states of buttons
Answer: obviously it would be happen because i have to maintain the check box state when its come on the on resume() ..u can take a shared preferance to mantain the check box state .
Answer: Use variables and store the values in the variable when u clicked the button. Store that variable values in the Bundle object using the  bundle.putExtras...() method. send this bundle object to the other activity using Intent.putExtra...s();. In the same manner ,if u need the those values then resend that bundle object and get that bundle object using Intent.getExtras....();. And finally restore the values from the bundle object.
This information may solve your problem.
Comment: thanks for answer but if u have some code for it please send me.thanks


Unifying the treatment of discrete and continuous random variable

Question: I have been working on the reconciliation of the treatment of discrete and continuous random variable in a measure theoretic sense. But I found myself blocked on fundamental results.
We know that If $X$ and $Y$ are respectively discrete and continuous we have the marginals :
\begin{align}
P(A) = \sum_i P(A,X_i)\\
p(A) = \int_{\Omega_Y} p(A,t)dt\\
\end{align}
I am trying to find the equation that generalize these results and by derivation find those actual results.
Since the discrete case involve measures and the continuous case involve densities I don't know where to start.
I could use the density of the discrete variable using Dirac but then again I am stuck because to derive the continuous case we need the Radon-Nikodym theorem which is not available because $X$ is not absolutely continuous to the lesbegue measure.
1) Do I need to consider a special measure for the discrete case ?
2) Do I miss any layer of abstraction here that would allow me to derive these results ?
Thank you for any pointer !
EDIT:
Part of my question is also how to define the marginal of a joint distribution if we don't know if the second random variable is discrete or continuous. If it is discrete we can define it in term of sum and if it is continuous we can define it in term of an integral of the joint density.
But in the general case how do we define it ( not knowing if discrete or continuous ).
Above notation :
$P(A) = P(a\in A, x \in \Omega_X)$ so $P$ is a probability distribution
$P(a \in A) = \int_A p(x)dx$ so $p$ is a density
Comment: Indeed, this is possible; could you just clarify your notation? Let's say you are given a joint distribution $\Bbb P$, what is $P(A)$, $P(A,X_i)$, $p(A)$ and $p(A,t)$ in terms of $\Bbb P$?
Comment: Thank you for your answer. I put some additional comments on my original question.
Comment: I was more concerned with the functions of two arguments that appear behind the sum and integral, please be precise with them
Comment: that would be the joint probability distribution and the joint density respectively.
Answer: Your notation is still a bit imprecise, but the message is pretty much clear. Let $\Bbb P$ be a product distribution, that is some probability measure on the product space $\Omega\times \bar\Omega$. The marginals of $\Bbb P$ on each factor spaces are given (be definition) as
$$
  \mathsf P(A):=\Bbb P(A\times \bar\Omega)\qquad \bar{\mathsf P}(B) := \Bbb P(\Omega\times B)
$$
for all measurable $A$ and $B$. Now, is the factor spaces are nice measurable spaces (e.g. $\Bbb R^n$ with Borel $\sigma$-algebra) then there always exist conditional distributions such that
$$
  \Bbb P(A\times B) = \int_\Omega\kappa(B|\omega)\mathsf P(\mathrm d\omega) = \int_{\bar\Omega}\bar\kappa(A|\bar\omega)\bar{\mathsf P}(\mathrm d\bar\omega) \tag{1}
$$
for all measurable $A$ and $B$, and $(1)$ determines $\Bbb P$ uniquely since to construct the product measure we have to define it (in a consistent way) just on measurable rectangles.
Consider now the two special cases that you have.

The fact that the first variable is discrete means that $\mathsf P = \sum_i\mathsf P(\omega_i)\delta_{\omega_i}$ for some countable collection of points $\omega_i\in \Omega$. In that case the conditional distribution does always exist, so the formula $(1)$ boils down to
$$
  \bar{\mathsf P}(B) = \int_\Omega\kappa(B|\omega)\mathsf P(\mathrm d\omega) = \sum_{i}\mathsf P(\omega_i)\kappa(B|\omega_i) = \sum_{i}\mathsf P(\omega_i)\kappa(B|\omega_i) = \sum_i \Bbb P(\{\omega_i\}\times B).
$$
For the continuous random variable, we have $\bar\Omega = \Bbb R$ and $\bar{\mathsf P} \ll \lambda$ where $\lambda$ is the Lebesgue measure, so let $\bar p$ be its density. From $(1)$ we obtain:
$$
  \mathsf P(A) = \int_{\Bbb R}\bar\kappa(A|\bar\omega)\bar{\mathsf P}(\mathrm d\bar\omega) = \int_{\Bbb R}\bar\kappa(A|\bar\omega)\bar p(\bar\omega)\lambda(\mathrm d\bar\omega)
$$
which recovers your second formula. So, that's why I was wondering what does "$p(A,t)$" mean in your case: the joint density (w.r.t Lebesgue measure) may not exist: for sure it does not exist if the first variable has discrete distribution. Not to say that density does not have  set-valued arguments. So in fact we are talking about conditional distribution multiplied by the density of the second variable. If both variables are continuous and the joint density $q$ does exist, then your "$p(A,t)$" is $\int_A q(s,t)\lambda(\mathrm ds)$.
Comment: Thank you for your answer. I have couple questions :

1) I am not familiar with the (1) formula. I am aware of the definition of product measure as an integral of a two parameters measurable function but not in term of conditional distribution. The result I know is :
\begin{align}
\lambda(AxB) = \int_A f_x(B)\mu(dx)
\end{align}

Could you provide me some intuition or reference on where to derive this result with a conditional probability distribution ?

I am still trying to work out the rest ....
Comment: @user149705: you just wrote exactly the formula $(1)$; what is $f_x(B)$ you  think?
Comment: as i understood it, it would be a function of two parameters. i dont understand where the constraint of it being conditional comes from. Or is it just a notation issue ? Anyways i will continue to work out the end of your answer :)
Comment: I just finished figuring out your explanation. Let me say that you helped a lot, if you read this thank you ! I was able to derive every case discrete/discrete, discrete/continuous, continuous/discrete and continuous/continuous. I just need to find out why if the spaces are measurable we get for sure the equation (1). Thank you again !
Comment: @user149705: glad to be of help. Your last point is not really trivial. Given a marginal $\mathsf P$ and a conditional distribution function $\kappa$ you can construct the joint $\Bbb P$: this is easy to prove, e.g. see the "Probability" by Ash. However, getting $\kappa$ from $\Bbb P$ is much harder: this is called the problem of existence of *regular conditional probability* (RCP) and it only holds for nice spaces (like Borel subsets of $\Bbb R^n$).
Comment: OK ! I was aware of how to get the joint P starting from marginal and conditional, but not the other way around. I will continue my search on this. Thank you !


Bayesian posterior pmf for weighted dice with uniform prior

Question:

We want to find posterior probability mass function for dice tossing with uniform prior.

We are interested in rolling of weighted dice. The outcome is 1,2,...,6.
We assume that prior probability mass function is uniform (all 1/6).
Assume that we observed 10 samples (dice tosses).
Say 6 were 1 and 2 were 2 and 2 were 3. Outcomes 4 5 6 were not observed.
As far as we know, the Bayesian posterior for this case is
Dirichlet(6+1,2+1,2+1,1,1,1)
Now by using code in website
https://people.sc.fsu.edu/~jburkardt/m_src/asa266/asa266.html
We get
dirichlet_mean(6,[6+1 2+1 2+1 1 1 1])
 = [    0.4375    0.1875    0.1875    0.0625    0.0625    0.0625]
So Bayesian posterior estimation would be exactly the same as histogram calculation, with only difference being the initial values of 1 1 1 1 1 1.

Is this correct? I suppose that if are more confident in prior probability mass function then initial values could be for example [10 10 10 10 10 10]?

We do not understand what the randomness in the dirichlet means. How can posterior probability mass function be random?
By using code in the above website we can get for example
as dirichlet_sample (depends on the seed)
[0.6816     0.1176     0.0271     0.0079     0.1077 0.0581]
Its roughly similar to the dirichlet mean but not the same.

Our question is that what is this randomness?
Or is the solution for posterior probability mass function simply the dirichlet_mean?

Thanks for all answers/comments!
Edit: pdf = > probability mass function / pmf
Comment: @MichaelChernick: this is the posterior distribution on the probabilities of the six sides.
Comment: This data set does not come from a continuous distribution. so you must be referring to a probability mass function rather than a pdf.
Comment: Okay I missed what your hypothesis was.
Answer: It seems that you are confusing the pmf of the multinomial random variable $X$ given a parameter vector $\boldsymbol\pi:=\{\pi_1,\pi_2,\pi_3,\pi_4,\pi_5,\pi_6\}$ with the prior pdf on the parameter vector $\boldsymbol\pi$ itself.
Your assumptions give that the pmf of $X$ given $\boldsymbol\pi$ is $\Pr(X=k|\boldsymbol\pi)=\pi_k$, with $k=1,\ldots,6$. There is nothing random about $\Pr(X=k|\boldsymbol\pi)=\pi_k$ itself, it is just a function. In fact, if you are thinking like a Bayesian, $X$ itself is usually no longer considered random, since it has been observed at the point you are fitting the model. Usually $\Pr(X=k|\boldsymbol\pi)=\pi_k$ is called the 'likelihood', and this term is used for both continuous or discrete $X$s.
Rather, it is the probability vector $\boldsymbol\pi$ that is random in this Bayesian context. The Bayesian perspective is to update some base knowledge about $\boldsymbol\pi$, which takes the form of a prior distribution, with the additional knowledge we learn from observing $X$. The $\pi_k$s are continuous but subject to the constraint $\pi_k\geq 0$ for all $k$ and $\sum_k \pi_k = 1$. The Dirichlet distribution a natural choice for the prior distribution because it enforces this constraint and for reasons of 'conjugacy' (https://en.wikipedia.org/wiki/Conjugate_prior).
The Dirichlet distribution is given by $p(\boldsymbol\pi)\propto \prod_{k=1}^6\pi_k^{\alpha_k-1}$, with $\alpha_k>0$.  (see https://en.wikipedia.org/wiki/Dirichlet_distribution). It seems that the software you linked to uses a nonstandard parametrization of the Dirichlet distribution, since it requires that the $\alpha_k$s be

positive quantities which are required to sum to 1.

(https://people.sc.fsu.edu/~jburkardt/m_src/asa266/asa266.html) whereas the typical parametrization requires that $\alpha_k>0$. This may be one source of your confusion. We're now equipped to address your questions.

We get dirichlet_mean(6,[6+1 2+1 2+1 1 1 1]) = [ 0.4375 0.1875 0.1875 0.0625 0.0625 0.0625]

Yes, this is the mean of the posterior distribution of $\boldsymbol \pi$ after observing your ten dice rolls, and under a Dirichlet prior on $\boldsymbol\pi$ having $\alpha_k=1$

Is this correct? I suppose that if are more confident in prior probability mass function then initial values could be for example [10 10 10 10 10 10]?

Yes, this is possible. Your prior distribution presumably reflects your prior knowledge about the data generating system. In this case, there is an easy and intuitive interpretation: each $\alpha_k$ corresponds to a prior number of rolls showing side $k$ out of a $\sum_{k=1}^6\alpha_k$ total prior rolls, e.g. from some previous experiment.

We do not understand what the randomness in the dirichlet means. How can posterior probability mass function be random?

This is a posterior distribution function, or just the posterior distribution, of $\boldsymbol\pi$. Don't confuse the inherent uncertainty (what I believe you are calling randomness) in rolling dice with the uncertainty about the underlying parameters. Even if you rolled a million $X$s, there would still be uncertainty in predicting the million+1th roll. On the other hand, you would have near perfect certainty about the underlying probabilities of that roll being 1, 2, 3, 4, 5, or 6. In other words, you are nearly 100% certain that $\pi_1 = 0.6$ (for example), but that doesn't mean you know $X$ will be 1 next time. And you won't know any better with a million more rolls.

By using code in the above website we can get for example as dirichlet_sample (depends on the seed) [0.6816 0.1176 0.0271 0.0079 0.1077 0.0581]

This is highlighting the second type of uncertainty I described above -- uncertainty about $\boldsymbol \pi$. You have sampled from the posterior distribution of $\boldsymbol\pi$ itself. If you did this a large number of times and calculated the element-wise average, you would get [ 0.4375 0.1875 0.1875 0.0625 0.0625 0.0625]. However, continuing my example above, if you plugged in a hypothetical set of dice rolls of [600000, 200000, 200000, 0, 0] and compared the dirichlet mean to individual draws using the dirichlet sampler, you will see that they are both nearly identical. Thus, you are very confident that $\pi_1=0.6$, $\pi_2=0.2$, etc...


setup of subdomain for email processing

Question: We use Win2003 Server with MS DNS.  Fairly new to DNS and can't seem to figure this out.
We have a client who has an A record pointed at an IP with a 3rd party service.  Now they want to be able to send & receive email via email@example.com using our service.
Currently his domain has a mx record pointing at our mail server and I want to know if I can set it up so that the will work through our service.
I have copied the record in here and changed the names etc to hopefully get some insight
Zone records - domain.com
;
@                       A   111.222.333.444
@                       MX  10  mail.emailhost.com.
abc                     A   999.888.777.666
www                     A   111.222.333.444
So the 3rd party is   abc.domain.com   and everything else is hosted through us.  He wants to know if he can have us setup email  email@example.com and run it through our service at mail.emailhost.com.
Answer: Set up a new zone for abc.domain.com.
Add MX records into this zone which point to the mail server on your system.
Remove the abc A record from the zone for domain.com, and put it in this new zone file (for the sake of tidiness).  Obviously it will be @ A ... rather than abc A when homed in this subdomain.
Answer: Yes, he can. You have to add a MX record for  abc.domain.com that point to you mail.emailhost.com.
abc MX 10 mail.emailhost.com

setup of subdomain for email processing


What is the name of this instrument with 2 strings?

Question:
Hi,
I bought this instrument in Kabul and the seller told me it was a dutar. But now that I'm looking at some pictures online, it looks different. Can you tell me what it's called?
Thanks.
Edit:
I'm going to add a couple of more pictures.
The length is about 1 meter and it weighs around 700gr. The back is closed and it is wooden except the surface which looks like some sort of skin. The strings are nylon.
Comment: I'm voting to close this question as off-topic because instrument identification questions are off-topic.
Comment: "dutar" is literally "du  - tar" meaning "two  -  strings" in... I wanna say Persian languages?  Well, "du" is proto-indo European two anyway: think *deux, dos, dois dozen*
Comment: The dutar is a type of lute, with a lute-shaped wooden body. Your picture looks more like a two-stringed banjo, though we can't see if the instrument has a back or not.
Answer: Looks like it's supposed to be a ghichak, which can optionally have a skin face or be a solid box.
But checking Google image search, apparently ghichaks having the pegs be on the front like that is not conventional - ghichaks have sideways pegs – and possibly unheard of.  I think of vertical pegs being more conventional of African rather than Asian instruments, though I wouldn't swear to it; a quick google search of African banjos shows vertical pegs, but usually coming in from the back.
Also, a ghichak is supposed to have more than that one has of a stick pointing out of the bottom, which is functional – like the foot of a cello.  By resting the instrument on that point, it gets the body up off the floor or the player's lap, so the box can resonate freely.
Ghichaks come in a wide variety of body shapes, the most famous being the double-bowl, but, really, any box on a stick will do.
Yours is awfully pretty, but it seems pretty odd.  If it is supposed to be a ghichak, perhaps it is meant as a display-only item.
P.S. Also see gusle (Serbian) which at least has vertical pins, though coming in from the back, and morin khuur (Mongolian).
Answer: That probably is indeed a dutar, due to the number of strings. Its peculiar shape mirrors a variation found in the tambur. There are two kinds, the plucked mızraplı tambur, which has a fully wooden body and a heavily rounded back; and the bowed yaylı tambur, which has a skin head and a shallow back, like your instrument. So, it looks like you found a "yaylı dutar".


Python wheel not supported on this plattform

Question: I tried to install the mysqlclient-module for python 3.8. I ran into several problems while doing so that are described in other posts. I then tried to install it on another pc where it worked. On the first one it downloaded the mysql.tar.gz file and tried to build the file by itself(failed due to another error). But on the other pc it instead downloaded the 1.4.6-cp38-cp38-win_amd64.whl file and installed it correctly. Both machines run Windows 10 and when running platform.architecture() i receive the same result on both. I even tried installing the wheel manually on the first machine where i got the "not supported wheel on this plattform". The only difference i found in the systemversions is the build which is 17763 on the one it worked and 18363 on the one it didnt work (although i believe this shouldnt be the source)
Answer: After trying around a bit i realized this error only occurs while beeing in the virtual enviroment in pycharm on the first machine. I was able to install it outside of the virtual enviroment and then copy the created files manually to the virtual enviroment.


java.lang.IllegalArgumentException: attempt to create delete event with null entity

Question: Eu tenho uma classe de modelo simples de Fabricante apenas com o atributo 'descricao'. O meu banco de dados está populado e o método salvar e editar estão funcionando normalmente. Porem quando vou excluir gera no console o seguinte erro:
java.lang.IllegalArgumentException: attempt to create delete event with null entity
at org.hibernate.event.spi.DeleteEvent.<init>(DeleteEvent.java:48)
at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:896)
at br.com.drogaria.dao.GenericDAO.excluir(GenericDAO.java:48)
at br.com.drogaria.bean.FabricanteBean.excluir(FabricanteBean.java:62)

GenericDAO
public void excluir(Entidade entidade) {
    Session sessao = HibernateUtil.getFabricaDeSessoes().openSession();
    Transaction transacao = null;

    try {
        transacao = sessao.beginTransaction();
        sessao.delete(entidade);
        transacao.commit();
    } catch (RuntimeException erro) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw erro;
    } finally {
        sessao.close();
    }
}

Classe Bean, porem a lógica de negócio futuramente irei colocar em uma classe de Service:
public void excluir(ActionEvent evento) {
    try {
        this.fabricante = (Fabricante) evento.getComponent().getAttributes().get("fabricanteSelecionado");

        FabricanteDAO fabricanteDAO = new FabricanteDAO();
        //this.fabricante = fabricanteDAO.buscar(fabricante.getCodigo());

        fabricanteDAO.excluir(fabricante);
        this.fabricantes = fabricanteDAO.listar();

        Messages.addGlobalInfo("Fabricante excluído com sucesso!");
    } catch (RuntimeException erro) {
        Messages.addGlobalError("Ocorreu um erro ao tentar excluir um Fabricante.");
        erro.printStackTrace();
    }

xhtml

        <f:attribute name="fabricanteSelecionado" value="#{fabricante}" />

Answer: Na verdade as classes estão corretas, conferindo depois com calma percebi que o erro estava no xhtml no confirmDialog, eu coloquei o f:attribute dentro do p:confirm, errado: E o correto é como abaixo.

        <f:attribute name="fabricanteSelecionado" value="#{fabricante}" />


How will I get success in Postman?

Question: Using Fiddler,
I'm able to get the used params and Filename. Same thing I want to run in Postman. How can I do tjhat?
Fiddler:

Please note that I'm getting 200 in Fiddler. In postman I'm getting 400.
See How I'm passing in Postman:
Inside Postman -> Body -> row:
Inside Postman -> Body -> binary -> Select File: I'm attaching the same file.
File name is: dummy.pdf
But in Fiddler name is coming dummy.pdf2_6_2020.pdf
Postman Response:
{
    "head": {
        "StatusValue": 400,
        "StatusText": "Failed"
    },
    "body": {
        "Error": [
            {
                "status_value": 0,
                "status_text": "Invalid File"
            }
        ]
    }
}

Answer: You can probably use form data in postman for this purpose. I have highlighted it in snapshot. Give name and value as you have given in Fiddler. I hope this helps.

How will I get success in Postman?


How can a Singleton be used to allow communication between various view controllers?

Question: I have been suggested to use the Singleton model at:
http://www.galloway.me.uk/tutorials/singleton-classes/
Some of the questions I have are:
where do I declare the singleton?
Do I release it anywhere or does it terminate with the application?
Any tips in terms of the Singletons in apps?
Thanks
Answer: It is just a class having only one object. That's why its called singleton.
We don't release it. It gets when the app terminates.
Answer: Singleton object can be accessed from any where in your application.
You initialize it at the first time get call (via static method). Then the instance will remain in the memory.
You releases it when the application terminated.
Answer: A Singleton is a construct allowing a class to be instantiated only once.
I am not an expert in iPhone programming, but Singleton doesn't mean the object is accessible from anywhere in your application imho.
You can still manage it's accessiblity through visibility. And you definitely should.
Overuse of the Singleton can lead to tight coupling of your classes to a static instance (your Singleton) and that is usually what you are trying to avoid in object oriented programming.


Could you say that in an orchestra some instruments talk to each other?

Question: I'm asking this question in regards to a website project we're starting about a classical orchestra. I'd like to know if there's a sort of conversation between instruments/musicians in a symphony, for example, and if you could give specific examples. The general idea would be to show this conversation/exchange on a website, visually and through other methods if possible. I'm staying vague as the project is in its early stages.
Thank you!
Alain
ps: Thank you for your amazing answers. Unfortunately we can't reply to answers and thank people personally here but I hope that editing the original question is accepted.
Comment: @alephzero Can you explain some more how the seven liberal arts connect to this "conversation"?
Comment: If you mean sharing melodies then yes, you could say so.
Comment: This sort of "conversation" was one of the basic principles of classical music (if by "classical" you mean the time period of say 1750 - 1830). In the educational system of the time, the foundation subjects of a liberal arts education (the "trivium") were grammar, logic, and rhetoric, and the second level (the "quadrivium") consisted of arithmetic, geometry, music, and astronomy.
Answer: Edward Klorman, a music theorist at McGill University, has been researching this exact question. For a nice introduction to his thought process, check out this 10-minute video, a brief description of which is:

Comparisons between the string quartet and artful conversation have flourished since the genre's birth. If a quartet performance resembles stylized social intercourse, each player may be understood to enact the role of an individual persona engaged in the discourse.

He's also got a book, the website for which can be found here.
Answer: Perhaps the best place to start would be with the fugue form, in which a theme is first introduced and then repeated and developed across two or more voices. In some instances, there can be a recapitulation, or the piece can simply return to the initial theme in the original (tonic) key. While the best-known examples are some of the keyboard compositions by J.S. Bach (such as Das Wohltempiert Klavier), Haydn used the form as well (see, for example, the String Quartets, Op.20). On an even grander scale, you could look at Haydn's composition, The Creation, with the fugue form being used in Verzweiflung, Wut und Schrecken.
Answer: Every orchestral group or instrument has its role, its voice, and creating a conversation between these voices makes a music. This of course does not work with some types of modern or contemporary music, where this conversation is intentionally destroyed ;-)
Listen to the beginning of the New World Symphony:

After the introduction played by strings there is an interruption by the french horn around 1:00 and then the melody is taken by the winds. Definitely a conversation between two groups.
Or you can find composers who were deriving their music directly from human's speech. My favourite is Leoš Janáček ;-)


Custom template for displaying inner blog contents

Question: I am trying to create a custom layout for my blog listing and blog content display pages.
The following url will display all the latest blogs based on the conditions that I have set.
http:///general-blog
When I click on the 'Read more' button corresponding to a button, it will display the full blog contents in another page.
Sample format : http:///general-blog/tourist-details
I am able to modify the layout of the page corresponding to blog listing. For this, I have created a custom tpl file : page--general-blog.tpl.php.
What I want is to create a new template file for displaying the contents of individual blogs.
The individual blog content display page is not entering - page--general-blog.tpl.php file. It's always using the template - page.tpl.php.
I tried creating separate tpl files like :
page--general-blog--%.tpl.php
But, the changes in this template is not getting effect in the individual blog content display page.
How should I move forward. Has someone had any similar situations?
Comment: did you flush the cache? it's a very important step! otherwise your new template file won't be recognized.
Answer: Declare your template using 'theme_suggestion` in your page preprocess function. like the following:
function THEMENAME_preprocess_page(&$vars){
  // Page template suggestion based on node type
  if (!empty($vars['node'])) {
    $node_type = $vars['node']->type;
    $vars['theme_hook_suggestions'][] = 'page__node__' . $node_type;
  }
}

if your node type is blog then your template will page--node--blog.tpl.php
Don't forget to clear cache after adding this code and your tpl file


Javascript create dynamic object inside object and access its properties

Question: I am getting the name of the user everytime the script is called and storing it in a variable called name
And I have a object which is initially null and I want it to be populated based on the name that I read.
I have this object
var usernames = {
    name1: {
        name: "ajey",
        room: 1,
        isStudent: true,
        isTeacher: false
    },
    name2: {
        name: "ajey-teacher",
        room: 1,
        isStudent: false,
        isTeacher: true
    },
    name3: {
        name: "batman",
        room: 2,
        isStudent: true,
        isTeacher: false
    }
};

Later I would print all the objects along with its key and value in the usernames object
like,
for(var i in usernames) {
 console.log(i.name1.name);
}

Here is the fiddle I am working on but I am having some issues.
Demo
Answer: Use
for (var i in usernames) {
    console.log(usernames[i].name);
}

DEMO
Comment: Got it. And how do I create the name1, name2, name3 objects and so on dynamically ? based on the variable name
Answer: The loop should be:
for (var i in usernames) {
    console.log(usernames[i].name);
}

When you use for-in, the variable is set to the property name. To use a dynamic property name, you have to use bracket syntax; dot syntax is only for literal properties.
You can also use bracket syntax to create properties dynamically:
usernames['name'+i] = {
    name: "batman",
    room: 2,
    isStudent: true,
    isTeacher: false
};

Comment: Actually I am building a chat application in node and socket. So initially when the client connects to the chat, I am storing all the details like name, room no, role inside an object(which is his username) and this object is stored inside a global usernames object.
So with this later I can process in which room or role the user belongs to.
Is this a good approach ?
Comment: OK, that makes sense. These names were just examples, in real life they wouldn't have a pattern like this.
Comment: Got it. And how do I create the name1, name2, name3 objects and so on dynamically ? based on the variable name
Comment: Added explanation of that.
Comment: Although I wonder why you're using an object. Usually when you find yourself using names with consecutive numbers like this, you should actually be using an array.


Is the positive cone of $L^p(\Omega)$ weak-closed?

Question: Let $(\Omega,\mu)$ be a $\sigma$-finite measure space. Suppose $1 \leq p< \infty$. Consider the cone $L^p(\Omega)_+$ of positive functions of $L^p(\Omega)$.
Is $L^p(\Omega)_+$ weak-closed in $L^p(\Omega)$ ?
Answer: For $p>1$, $L_p$ is reflexive and this set is convex so it is weakly closed because it is norm-closed (Mazur's lemma).
In $L_1$, suppose that $(f_n)_{n=1}^\infty$ is a sequence of non-negative functions converging weakly to $f$. Suppose that $f$ is strictly negative on a set $A$ of positive measure. Let $g$ be the indicator function of $A$. We have
$$\int\limits_\Omega f_n g = \int\limits_A f_n \to \int\limits_\Omega f g= \int\limits_A f < 0.$$
This is impossible as $f_n$ are non-negative. This argument will work in $L_p$ too, so Mazur's lemma is not quite necessary.
Comment: It seems to me that your first proof is correct for hausdroff locally convex vector spaces. The reflexivity seems useless.


multiple (two at least) user registration forms

Question: I have built a registration form with a few custom fields, works fine. Now I need to another registration form, but with a dozen or so more fields. Both need to force drupal into its user registration/validation process.
it has to be done this way, I cannot just redirect a user to register first then fill out a survey.
Alex
Comment: So what's your question?  What's not working for you?
Comment: possible duplicate of [Adding more fields to the registration process](http://drupal.stackexchange.com/questions/5478/adding-more-fields-to-the-registration-process)
Answer: You can achieve this using Profile 2 and Profile2 Registration Path module.
Profile 2

Multiple profile types may be created via the UI (e.g. a general
  profile + a customer profile), whereas the module provides separated
  permissions for those

Profile2 Registration Path

This module enables administrators to set unique registration paths
  per Profile2 profile type
Comment: I eventually found that module(s) but I am still not clear on whether that solves this specific problem.

There are no two profiles, just one, a member sign ups. The caveat being, if they click one link to sign up, they get the standard details collection. If they should click the other link, they get the same form but with a dozen "survey" type fields.

This process is a little confusing, but this is what the boss has requested.

Any ideas?
Answer: if you want to add data to the user, add fields here (admin/config/people/accounts). see here
webform is a very nice module, where you can create forms via the UI, also offers stats etc.
Comment: We cant include webform in profile fields.
Comment: Can't use webform, that is what I am using now, until it was requested that a user be able to sign up and/or signup and fill out a survey all in the same form/page. I tried negotiating a registration first and redirect to survey but that doesn't work for her I guess.


How do I programmatically generate an entity form?

Question: I need to programmatically generate the entity form for my custom entity - basically get the same output that happens when you call
\Drupal::formBuilder()->getForm('form namespace')

When I try to do that with my entity form I get the error:
Call to a member function getEntityTypeId() on null in Drupal\Core\Entity\EntityForm->getBaseFormId() (line 77 of core/lib/Drupal/Core/Entity/EntityForm.php).

Really stumped on how to proceed.

Here's an obfuscated version of code I'm using
Entity Definition:
/**
 * Defines the My Entity entity.
 *
 * @ingroup my_module
 *
 * @ContentEntityType(
 *   id = "my_entity",
 *   label = @Translation("My Entity"),
 *   handlers = {
 *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
 *     "list_builder" = "Drupal\my_module\MyEntityListBuilder",
 *     "views_data" = "Drupal\my_module\Entity\MyEntityViewsData",
 *     "translation" = "Drupal\my_module\MyEntityTranslationHandler",
 *
 *     "form" = {
 *       "default" = "Drupal\my_module\Form\MyEntityForm",
 *       "add" = "Drupal\my_module\Form\MyEntityForm",
 *       "edit" = "Drupal\my_module\Form\MyEntityForm",
 *       "delete" = "Drupal\my_module\Form\MyEntityDeleteForm",
 *     },
 *     "access" = "Drupal\my_module\MyEntityAccessControlHandler",
 *     "route_provider" = {
 *       "html" = "Drupal\my_module\MyEntityHtmlRouteProvider",
 *     },
 *   },
 *   base_table = "my_entity",
 *   data_table = "my_entity_field_data",
 *   translatable = TRUE,
 *   admin_permission = "administer as my_entity entities",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "name",
 *     "uuid" = "uuid",
 *     "uid" = "user_id",
 *     "langcode" = "langcode",
 *     "status" = "status",
 *   },
 *   links = {
 *     "canonical" = "/admin/structure/my_entity/{my_entity}",
 *     "add-form" = "/admin/structure/my_entity/add",
 *     "edit-form" = "/admin/structure/my_entity/{my_entity}/edit",
 *     "delete-form" = "/admin/structure/my_entity/{my_entity}/delete",
 *     "collection" = "/admin/structure/my_entity",
 *   },
 *   field_ui_base_route = "my_entity.settings",
 *   constraints = {
 *     "CustomContraint" = {}
 *   }
 * )
 */
class MyEntity extends ContentEntityBase implements MyEntityInterface {

Form namespace
namespace Drupal\my_module\Form;

use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form controller for My Entity edit forms.
 *
 * @ingroup my_module
 */
class MyEntityForm extends ContentEntityForm {

Okay, so this is what I've found so far. User oknate's answer partially works; I also had to add a dummy function to my container form class to get around a callback error, which looked like this:
 public function processForm($element, FormStateInterface $form_state, $form)
  {
    return $element;
  }

This is probably not the right way to do this, but it does result in a form object that will render in another form.
Comment: See: http://drupal.stackexchange.com/questions/182405/how-to-render-form-in-drupal-8
Comment: According to the docs the argument must either be the form ID or the class implementing the form. That form must implement FormInterface. https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!FormBuilder.php/function/FormBuilder%3A%3AgetForm/8.2.x
Comment: Ex. \Drupal::formBuilder()->getForm(Drupal\mymodule\Form\FormName)
Comment: Yes, like I said I tried that.
Comment: My form does extend from the ContentEntityForm class, which implements the ContentEntityFormInterface, which extends the EntityFormInterface, which extends the BaseFromInterface, which extends the FormInterface, like you said.
Comment: Can you post the actual code then that you are using?
Comment: this is for register form in block in this
[link](https://drupal.stackexchange.com/a/244651/19943)
Comment: this is for register form in block
[link](https://drupal.stackexchange.com/a/244651/19943)
Answer: You can use the entity form builder service.  I was able to load the user form this way (with $entity being the current user):
$entity = User::load($uid);
$user_form = \Drupal::service('entity.form_builder')->getForm($entity, 'default');

If you want to get the user register form (which is basically an entity form without a saved entity), you can just use the create method on your entity class before passing it to the form:
$entity = User::create();
$user_form = \Drupal::service('entity.form_builder')->getForm($entity, 'default');

Comment: Okay, this answer has gotten me the closest. When I try doing it, the page loads, but all that shows up is a warning that the form class I'm trying to inject the entity form into doesn't have a 'processForm' method.
Comment: The 'processForm' function seems to live in the \Drupal\Core\Entity\EntityForm class.
Comment: Since the function just returns one of the arguments it receives ($element), I created a dummy version of that function in my container form class. After doing that, the entity form DOES render. I don't know what the consequences of bypassing that call are though.
Comment: @oknate, Thanks for your code, it works perfect, But, I want to attach #after_build method for ajax operations. The #after_build method is not firing/calling, Have you come across with this situation? or anyone has a solution to attach #after_build method
Comment: If you are using a build array to hold the form and you are using a template that renders the form properly, then it should work fine.  If you are having trouble with ajax not loading, you may be pre-rendering the form and then it's getting cached in the template, where it didn't properly signal to add the javascript on subsequent page loads.
Comment: Js is working, But hook_form_alter is not affecting, Suppose, I have added a callback function on #after_build ( _custom_after_build_method) , this method is not triggering after ajax call, Ajax call is working. but functionality which is specified in _custom_after_build_method is not affecting.,
$user_form = \Drupal::service('entity.form_builder')->getForm($entity, 'default');
is rendering a plan form befor hook_form_alter, Now question is How to applay form_alter changes to Renderd form output?
Comment: https://drupal.stackexchange.com/questions/238712/rendering-a-form-using-drupalserviceentity-form-builder-getformentity

Please check this question, I have explained my problem
Comment: What if you don't have a uid and just want to load the registration form?
Comment: Then use User:create() instead of User::load().  I have updated the answer with an example.
Comment: For the user registration example you might also want to use the 'register' form rather than the 'default' form, so the example becomes:
`$user_form = \Drupal::service('entity.form_builder')->getForm($entity, 'register');`
Answer: Entity forms don't work without an entity. If you want an empty form then use a newly created entity instance. You can use this example from the node entity:
/**
 * Provides the node submission form.
 *
 * @param \Drupal\node\NodeTypeInterface $node_type
 *   The node type entity for the node.
 *
 * @return array
 *   A node submission form.
 */
public function add(NodeTypeInterface $node_type) {
  $node = $this->entityManager()->getStorage('node')->create(array(
    'type' => $node_type->id(),
  ));

  $form = $this->entityFormBuilder()->getForm($node);

  return $form;
}

The entity form builder is injected in the controller base class. So usually you use a controller to build entity forms.
When creating a node you need to define a bundle (content type), for which the entity form will be built. If your entity has no bundles you can use an empty array.

Comments
Comments need more work, because they are attached to an entity field.
Example how to build a form for the comment field of a node:
$comment = $this->entityTypeManager()->getStorage('comment')->create([
  'entity_type' => 'node',
  'entity_id' => $node->id(),
  'field_name' => 'comment',
]);
$build = $this->entityFormBuilder()->getForm($comment);

Or the same outside of a controller without injected services:
$comment = \Drupal::entityTypeManager()->getStorage('comment')->create([
  'entity_type' => 'node',
  'entity_id' => $node->id(),
  'field_name' => 'comment',
]);
$build = \Drupal::service('entity.form_builder')->getForm($comment);

Comment: Thanks for sharing, if we altered a form and added #after_build.
#after_build method is not working. Do you have any solution?
Answer: Just to clarify, the below code does work for me in Drupal 8.2.x:
$form = \Drupal::formBuilder()->getForm(Drupal\user\Form\UserLoginForm::class);

Comment: When I tried your code it initially didn't work, but adding a \ in front of 'Drupal\user\Form\UserLoginForm::class' made it work. When I tried doing it with my custom class, I got the same error though. I've tried updated my question with my entity definition - my guess is that I haven't implemented something that I'd need to implement for your code to work.
Comment: Okay, I finally noticed that the example form you used *isn't* an entity form, it just extends from FormBase. I need to render an entity form (Specifically a content entity, something that extends from ContentEntityForm)
Comment: Yes, for my use case this is wrong.