Is the Violin a difficult instrument to play for a beginner?

Question: I am sorry if this question is too opinionated. I have thought about it and feel that an answer could provide terms and concepts that could enable people wanting to learn the violin, to go into it on strong foundations.
The truth is, I have just booked my first violin lesson for next week. I played the piano for 17 minutes in school once.....

EDIT:
For clarity, I played the piano for a year. Although compared to my life of 26 years, it was 17 minutes.

....and know a bit/enough of theory (even though Time Sigs still trip me up) but that is it. After reading some online, I am beginning to think I may have perhaps, bitten off more than I will be able to chew.
There is so much hype and difference in whether the violin is advanced or not. I was hoping an answer here would give me a definitive answer.
This S.E question here is useful, but it is a specific problem. Personally, I couldn't see how you could ever expect to learn something without some form of a professional teacher but hey, that is not my question. The question was well received.
When researching initially on Google, I have found a good webpage which gives tips for beginners who are thinking about pursuing the stringed masterpiece. It does not really explain anything technically but it was a good starting block. It states:

You won't sound like the violins in movie soundtracks for some time

I totally understand this. It is like anything. When you learn the piano; Beethoven inside of you will take a while to shine through.
However, it does mention that your violin will sound noisy and scratchy to start with.

Is this down to your 'bow technique'? How you are holding it, or is there something else that causes this?
One article said that adults learn faster than children, as Adults are stronger. I can not see what this would have to do with it? Are they not particularly heavy instruments are they?
I am guessing (as I say, I haven't even started yet) that one's wrist will need to be worked on? What exercises are available that can help with this?

Aside from the technical
Perhaps, it is the theory behind it. Working out what note is what that is the most challenging. Is that right?
Articles online suggest that the French Horn, the Bagpipes and the Harp are harder; this is all opinion. Back to my original question: Is the violin really something that shouldn't be entered lightly?
There is also the care that a violin requires. This is not a problem. I have read about this, and have no doubts or questions regarding looking after it.
I have no doubt, providing the lesson goes well, I will most likely go out and buy one. An online article suggests that a beginner should start by:

Scales (obviously)
Bowing a single string
Bowing two strings (double stop)

I feel like, or rather, it sounds like the above will take me weeks to master? Even the basics of scales. Is that right?
I am most grateful for any help.
Comment: I just want to point out that I knew exactly what you meant by "17 minutes".
Comment: It will take a lifetime to **master** bowing a single string, but you can be competent enough to be playing notes and even short pieces in a few weeks to a few months. I think **all** beginners should start with at last one song or piece that is not hugely difficult and that they enjoy listening to. As they work on the piece, they will slowly start to hear it take shape and having the music they love coming from their own hands is usually the best motivation to work on scales and techniques and all the "boring" stuff.
Comment: I used to be a percussionist, with "17 minutes" invested, like you. I have started playing saxophone in my twenties as well and was terrified before my first lesson and for the first few days. Loving an instrument is important. If you are prepared to dedicate yourself to it - do so. Only you can make an informed decision, and only after you've spent at least a few months of practice sessions 2 times a day (~60 minutes cumulatively each day, morning and evening).
Comment: When I started the violin in second grade (so adjust the durations accordingly), my teacher had me play only pizzicato (plucking strings, no bow) for three months.
Comment: it's LOUD !  and right in your ear.
Comment: @Fattie I did read a lot of violinists go deaf in the left ear...
Comment: The violin is one of the most beautiful instruments to play and one of the most challenging aspects of Learning. hope this article will help you http://blogidentity.com/violin-guide-for-beginner/
Answer: It certainly takes most people quite a long time to achieve the kind of fine bow control that's required to make a smooth sound. It's not straightforward at all - you've got to dig in enough at the start to make the sound full, but not so much that you start each note with a scraping sound; you've then got to master the complex balance of bow speed and pressure that will keep the note under control (this is where 'being stronger' may help). You might get the idea within weeks - but it takes most people years to get good.
The left hand is not that easy either - tiny differences in finger position make a big difference to the note intonation, so it takes a while to internalize where each note is and master the art of making fine adjustments (all while keeping that tricky bow under control!). So as Stallmp says - quite a steep learning curve.
There can also be a potential motivational problem in that while you can play complete pieces on your own on the guitar or piano, with violin you'll usually need to find others to play with to actually make satisfying-sounding music. If the idea of joining an orchestra or other ensemble excites you, no problem there. (Todd's excellent answer has more to say on the subject of motivation!)
Comment: @davvv the margins are certainly small, and with bowing, the difficulty is that you have to control it in 3 dimensions. I imagine people vary a lot in how fast they learn, but https://takelessons.com/blog/how-long-does-it-take-to-learn-violin-z08 agrees that it could take 3-4 years to get good - I don't think I'm being dramatic!
Comment: The part about satisfying sounding is just opinion... in my opinion. There is plenty of solo literature for violin.
Comment: I've always had fun with my monophonic instruments... but I have to admit there may be a few people who give up recorder playing before they reach a level where they have much choice of interesting literature. :)
Comment: @topomorto Does the comparison matter when there is much more than you are realistically ever going to learn?
Comment: @topomorto Right, okay, if that's a phrase... _steep_ certainly does sound like more work ha!
Comment: Years...wow! Is that because the margin between it sounding good and bad is the width of an eyelash?
Comment: That's assuming you learn it correctly.  The most difficult part of the violin is you cannot see both of your hands easily, nevermind both at the same time!  (Outright impossible).  It is very easy to mess up learning something if you can't look at what you are doing correct/incorrectly.  The proper bow angle is nearly impossible for the player to notice during normal play.
Comment: @Nobody ...compared to the amount there is for piano or guitar?
Comment: If the learning curve was steep, wouldn't that mean you learn a lot about playing in little time?
Comment: @speedymcs that depends on the axes of your graph! In English, 'steep learning curve' is normally taken to mean *difficult*, perhaps because a 'steep' hill is difficult. To see this 'steepness' on a graph, you'd have to put effort on the y-axis, and attainment on the x-axis, which from a maths point of view might be counter-intuitive. It is perhaps a better model of a hill though!
Comment: @Nobody I guess not actually. But the suggestion I was making in my answer was not that there isn't a lot of repertiore for solo violin, but that playing a (mostly) monophonic instrument on its own might (subjectively) not be much fun. An opinion, definitely, and one just based on my observations - I know a lot more people who have given up flute, trumpet and violin than have given up guitar and piano.
Comment: @topomorto and i've never met anyone (past middle school band) that gave up any band instruments. Some are still playing as a hobby after 30 years now. On the other hand everyone and their mother has tried guitar (IN MY EXPERIENCE haha) and less than an eighth have kept it up. As you point out, it's all subjective and perspective-based.
Comment: @speedymcs Steep learning curves usually look like [this](https://www.desmos.com/calculator/ueamjmovgn). You spend time not learning very much, then get to a point where you are advancing very quickly, then slow down again once you start getting to the top level.
Answer: While different instruments all have different types of challenges, and there's some reason to assess some instruments as being objectively harder than others, I think worrying about that is not at all helpful.
I have spent at least a little time learning the basics of several instruments, including piano, guitar, bass, drums, harmonica, trumpet, trombone, recorder, violin, cello, and clarinet. Personally I found the trumpet impossible because the required amount of breath and the necessary embouchure is very difficult for my particular mouth and lungs. I could play a major scale on the clarinet in a few weeks, by comparison.
Based on my experience, I suggest that beyond the necessary physical capability, there is only one parameter that determines the "difficulty" and success or failure to learn an instrument:
Love
If you love it, you will learn it. If you hate it, you won't. If you're somewhere in between, you might muddle on it for several years and never really get to a point of competence.
If you love it, it won't matter one bit whether it takes you ten months or ten years before you can play your favorite passage on the violin. You'll get there and you'll enjoy the process and the hardships along the way.
Note that even if you love it, it will most likely take five to ten years to achieve semi-pro competence on any of the major instruments. I've taught a young man with perfect pitch to play better than I in some ways in about three years, and I know another young man who literally would sleep with his guitar and play it instead of doing anything else besides schoolwork. He became an amazing guitarist in "only" five years. The harmonica (and I'm sure many other simpler instruments) can be learned in a shorter time - after only one or two years I was playing Led Zeppelin harmonica parts (e.g., "Bring It On Home" and "When The Levee Breaks").
If you love violin music, then you have a good chance that you'll love playing it. Rent or borrow one for a month or so. If you can't imagine not having one of your own, buy one and keep at it. If you find you are reluctant to pick it up and play it, no matter how badly, maybe it's not for you.
One piece of advice I would give to anyone looking to learn an instrument: don't practice, play. Play as in have fun with the instrument. Make funny noises. Invent your own tunes. Start to slowly attempt your most favorite pieces, no matter how challenging. Don't be convinced you have to spend hours and hours playing random scales or exercises. Ideally you would mix more "serious" practice with fun play, just make sure you allow yourself to have as much fun as necessary to keep at it. After all, if you're not doing it for fun, why are you doing it at all?
Comment: The advice about "love" is true.  Any instrument is going to take a lot of practice to get good at, and it won't always be fun.  The devotion that is born of love makes it easier (or perhaps even possible) to bear the burden of all that practice so that you get to the point where your playing is pleasing to yourself.  At that point, motivation gets easier because you can always punctuate your scales and exercises with pleasing music.  But love for the music keeps you going during that difficult period when you can't actually make the music yet.
Comment: Fantastic answer very motivating
Answer: The violin is one of the most difficult instruments to learn for beginners, although this is subjective. This is because the learning curve of the violin is much bigger than other instruments. As a beginner, you need to master the basic elements first which is pretty difficult, such as bow hold, bow pressure, learning where to put your fingers etc. When you play the piano, it is much easier for beginners since pressing a key gives you the right note. However, the piano becomes gradually more difficult. The violin is difficult at the beginning and becomes gradually less difficult after years of playing, because you have mastered the important elements of the violin already. So in short, the basic elements of the violin is much harder to master than the other instruments, but after the huge learning curve it won't be as difficult as for example difficult piano pieces, because the learning curve of the piano isn't as big and is more delayed. Hope this helps !
Answer:
Is the Violin a difficult instrument to play for a beginner?

Yes.

I am sorry if this question is too opinionated.

...yes..?

The truth is I have just booked my first violin lesson for next week.

Great, why not, anyhow.

I played the piano for 17 minutes in school once and know a bit/a lot of theory but that is it. I am beginning to think I may have perhaps, bitten off more than I can chew.

17 minutes?? You can't seriously take anything from that short amount of time.

There is so much hype and difference in whether the violin is advanced or not. I was hoping an answer here would give me a definitive answer.

Nobody can give you a definitive answer, except you yourself.

Personally, I couldn't see how you could ever expect to learn something without some form of a professional teacher but hey, that is not my question. The question was well received.

Frankly, for any musician it's obstructing if you never trust your ability to learn something without some assistance. But if you're not such a self-learning person, violin may not be the worst choice, because then technique and other rigidly teachable aspects will be more important than improvisation etc., unlike e.g. with guitar.

"You won't sound like the violins in movie soundtracks for some time"I totally understand this. It is like anything. When you learn the piano; Beethoven inside of you will take a while to shine through.

Beethoven is not somebody who's inside lots of people, so if you expect anything on that prepare to get dissapointed anyhow. If you did have Beethoven in you, you probably wouldn't be asking this question.
The more realistic issue is the next point:

it does mention that your violin will sound noisy and scratchy to start with.

Absolutely. It will sound completely and utterly horrible, worse than anything you could ever produce on piano without deliberate effort.

Is this down to your 'bow technique'? How you are holding it, or is there something else that causes this?

It certainly has to do with technique, but most of all with feeling. The bow responds very sensitive to tiny pressure variations; a good tone is only produced if you always match bow speed, pressure, contact point and bow angle in a quite narrow window. This is not something you can just grok through theory or "planned motion", but only through practice until it's fully ingrained in your arms' reflexes.

One article said that adults learn faster than children, as they are stronger. I can not see what this would have to do with it? Are they not particularly heavy instruments are they?

I don't think that claim is true. Adults who already know other instruments may learn faster than children, and an adult who practices two hours daily will learn faster than a child who does five minutes a weak. But in principle I think children are faster, especially at highly delicate motoric excercise like violin.

I am guessing (as I say, I haven't even started yet) that one's wrist will need to be worked on?

Wrist, and elbow, and shoulder, and back, and fingers, and neck, and...

Aside from the technicalPerhaps, it is the theory behind it. Working out what note is what that is the most challenging. Is that right?

No.

Articles online suggest that the French Horn and the Bagpipes are harder. But this is all opinion.

I do think French horn is damn hard, but I don't think one can say that violin is easier.

Is the violin really something that shouldn't be entered lightly?

It's something one shouldn't enter with illusions that it will be quick and easy to learn.

I have no doubt after my lesson I will most likely go out and buy one. An online article suggests that a beginner should start by:

Scales (obviously)
Bowing a single string
Bowing two strings (double stop)

I feel like, or rather, it sounds like the above will take me weeks to master? Even the basics of scales. Is that right?

No, it will take you years to master. In fact it will probably take you months to even get some grips with all of these. But if you're persistent, you will eventually get there.
I think it's a worthwhile investment, but only you can decide if it's right for you.
Comment: @davv it certainly doesn't read like a joke.
Comment: This answer was kind of helpful. The only helpful sections were your bow technique and wrist paragraphs. Also... grab a sense of humour. They are free. 17 minutes was a 'joke'. Ha! I played it for around a year. Compared to my life of 26 years though, it is 17 minutes. If it is too opinionated, vote to close. This site is for good questions only. Not bad ones.
Answer: There are some really good answers here. I wanted to add my personal experience in case it might help you out. I played piano and synth for about 25-30 years, and even studied it as my major in college for a few years before switching to an unrelated field. Eventually I got a job and life where I had limited time to play an instrument.
About 7-8 years ago I came into a cello. I also started to have some more free time in my life and decided I would try to learn to play it. I already had the theory down pat, and could read and compose music, and was comfortable playing in a band and even improvising live on stage. The only thing in my way was physically learning and practicing the instrument.
I knew it would start out slow. The first few weeks were kind of fun because it's new and different. As the weeks went on, the progress was so much slower than with the keyboard. (That is, it was slower than what I had recently learned on the keyboard. Truth be told, I don't remember how fast or slow it was when I first picked it up as a kid. That was literally decades ago!)
The hardest parts were:

Knowing how bad I sounded. As a kid playing the piano, I probably sounded just as bad, but I sure didn't know it! I thought I was great! Nobody else my age in my school played any better, so how bad could I be, right? As an adult, you know exactly how bad you are.
Watching younger students make much better progress despite my far more advanced knowledge of music in general. When I played piano at that age, I could play the notes fairly well but didn't really understand the structure of what I was playing. And now it was the opposite. Sitting outside the room waiting for the previous student to finish, I'd often think, "Wow! That sounds good! I hope I can play that well someday." Then some kid that was smaller than their instrument would come out, struggling to stay upright as they dragged their hard-shelled case behind them. It takes some humility to put yourself through that week after week.

They say it takes 1,000 hours of deliberate practice to become proficient at something and 10,000 hours to become an expert at it. I don't know how accurate that is, but if you practice an hour per day, you'll have your 1,000 hours in about 3 years. (And of course, note all the caveats of that rule.)
At about the 3 month mark, I almost considered stopping entirely. I don't know what motivated me, but I decided to stick it out a little longer, and sure enough, by month 4 or 5 I felt like I was starting to make music. I ended up continuing to take lessons for 5 years before life intervened again.
I say, go for it. It will be difficult at first, and there will probably be some very slow point where you want to quit. If you stick with it, I suspect that you'll get past that point and start to really enjoy it.
Comment: Thanks for this. Very helpful, and for the resources. Cheers!
Answer: There are some good answers already, but I don't see any that mention this kind of direct experience: I play violin; I started at the age of 6, and I had violin lessons more or less continuously from that point until I was about 17. I continued playing regularly for some years after that; I'm 28 now and still play occasionally but I have less time for it, sadly. At any rate, I know how long it took me to learn, and I have testimonials from my parents (and later from my flatmates) regarding the general quality of the sounds produced by someone learning to play the violin.
I can say, fairly categorically, that violin is not a beginner-friendly instrument.
For a time, you likely won't be playing recognisable tunes; it's much easier to focus on a particular skill with drills and exercises before moving on to add the next. This "training-wheels" approach will help you get to grips with all the required skills faster, but you won't be able to play actual tunes until you've got them all down. For example, when you're learning to control the bow - the right amount of pressure, the right speed, the right place on the string, the right angle, how far to move it, how to vary the speed and pressure during a stroke, how to switch strings cleanly - you'll find it easier to stick to exercises that let you ignore the fingering, which means you'll be using only four notes. That sounds boring, but until you get your bow control sorted out, any notes you do play will be scratchy, or faltering, or poorly-timed, or interspersed with random clashing as you accidentally catch the other strings, so you're really better off getting the hang of it before trying to carry a tune.
Another aspect of violin that makes it difficult is that it has a smooth fingerboard. A guitar has frets, which gives you an inch or so in which to place your finger and be sure of getting the right note. On a violin, the position of your finger has to be exactly correct - the difference between a natural and a sharp or flat is about the width of your finger (perhaps a little less) and the difference between a note and a nasty-sounding near miss is significantly less than that. Beginners often stick small coloured spots t the fingerboard to help them find the right positions, but then you have to spend time looking at your fingers and not at the sheet music, which limits you to simple tunes so you can remember where you are. Again, this sounds boring, but it's something you'll need to figure out in order to play anything fun. Find some exercises; there's plenty of simple tunes designed to hop between a handful of notes to help you fix in your mind the correct place for your fingers.
Up to this point, it sounds like these are all things that you can learn on your own, and to a certain extent you can. I had practice recordings (on cassette tape, back then; these days they're on iTunes and YouTube...) that will let you hear the correct notes and timing so you can self-correct. However, there are a lot of things that really require you to have a teacher to watch and correct. As with many skills, practising for too long without a knowledgeable teacher will only cement bad habits. I went a year or so without having any violin lessons so that I could focus on my studies at school, but during that time I continued playing several times a week, on my own and in an orchestra, so I figured I'd keep my skills up to scratch. When I went back to lessons, I was surprised to find that the tutor was pointing out all sorts of bad habits and technique issues, some of which were things that I used to do properly and had simply started to slip on. Some of these things seemed small and unimportant, so I was initially annoyed that the tutor was focusing on them, but very quickly I started to see that they tied into other things that I was only starting to learn. For example, what I thought was a silly nitpick about how I held my wrist and thumb turned out to be very important in allowing me to use vibrato without ending up with a strained wrist or seriously disturbing the way I held the violin.
It's at this point that it becomes apparent that violin has a great deal of interconnected aspects. The way you hold the bow affects your ability to apply the right pressure and to make sure it contacts the strings in the right place; your elbow position affects whether you can change strings fluidly and control your bowing speed, your wrist affects how smoothly your bow will change direction and your other wrist affects how well your fingers can move around the fingerboard. Your chin, neck, and shoulder help to support the weight so that your arm is free to move up and down to allow your fingers to reach the notes, your back and general posture allow you to keep your arms, head, and neck in that position for extended periods of time, and if you're playing standing up, then the position of your feet helps you to keep your balance and support that posture comfortably.
Once you have the correct posture, you have to think about the speed, position, angle, and pressure of your bow, the position and pressure of your fingers on the fingerboard, and occasionally other things like whether you're bowing an upstroke or a downstroke (which is sometimes important) or whether you're shifting position (where you slide your left hand so that the first finger is in the position usually occupied by the third, or a hypothetical fifth, or seventh...).
So then, while continuously monitoring yourself for the correct position of your feet, back, chin, left shoulder, both elbows, both wrists, all your fingers and thumbs; and controlling your bow's speed, angle, position, pressure, and direction; and while checking your the position of your left hand and fingers... then you can start thinking about the music itself; its time signature, key signature, actually reading the music and working out which notes correspond to which strings and finger positions and whether you need to be sliding up or down to a different position... There's a lot going on, and unlike some other instruments, with a violin most of those things are required - if you're not doing all of those things and getting the majority of them correct, then at best you're going to sound like an unskilled player; at worst, you'll sound pretty awful.
Having said all that, I would encourage anyone who feels put off by my answer so far to go and listen to a few beautiful violin pieces and remind themselves that with effort and dedication, you'll end up being able to play what is, in my (probably somewhat biased) opinion, one of the most versatile, most beautiful, and most thoroughly rewarding instruments I know. Even now, when I pick up the violin after a little time away, or when I try to play a new piece for the first time, there is always a period of time where I sound like a hesitant learner again, until I remember the technique or I become familiar with the piece - but at that point, when you can let your muscle memory and experience handle playing the music and free up a small part of your brain to actually listen to what you're producing... that feeling is one of the best I know.
Yes, it is difficult. Yes, it will take a long time to master. Yes, it is absolutely worth it.
Comment: This was a good read. I have read the posture is important, so will take this forward with me. Thank you.
Comment: I actually did mention I have direct experience learning the violin and I am able to compare that experience directly with learning several other instruments. To me the violin is no harder than clarinet or trombone, easier than trumpet, and about the same difficulty but in a very different way from piano. Guitar maybe is a bit easier than all of those. On piano it's dead easy to make a single note that sounds ok, but overall playing of a piece can become difficult in ways that are not common in other instruments. Violinists generally don't play polyrhythms, for example.
Answer:
For clarity (as some people have no Wit), I played the piano for a year. Although compared to my life of 26 years, it was 17 minutes.

This statement was supposed to be for clarity, but if anything, I think it made things less clear.

....and know a bit/enough of theory (even though Time Sigs still trip me up) but that is it.

If you're still struggling with time signatures...I'm trying to find a polite way of contradicting the assertion that you know "enough" theory...nothing comes to mind other than simply refuting it. Counting, timing, beat, and the structure of music is one of if not the most fundamental aspect of music. It all comes with time, but it seems like you don't know what you don't know.

Is the Violin a difficult instrument to play for a beginner?

I worked in a music store selling and renting band and orchestra instruments and supplies for around six years or so. To answer your actual question, any instrument has its own set of difficulties:
Woodwinds: learning the right amount of pressure to use on the mouthpiece/reed combo to produce sound without squeaking; learning the right amount of air to use; learning the fingerings for around 20 notes, including multiple alternate fingerings.
Brass: learning how to buzz different partials; learning the right combinations of the 3-5 valves at your disposal; learning breathing control.
Piano: learning how to independently control three limbs (two hands for keys and a foot for pedals); learning how to play multiple notes at the same time; learning how to have competing ideas playing in either hand.
Percussion: learning how to play dozens of different instruments well; learning how to have four different limbs do four different things (drumset).
Strings: bow technique, intonation...
All of these are in addition to learning music theory, correct performance techniques, posture, breathing (still important for string players), how to play by yourself, how to play with others, etc.
See what I'm getting at? They're all challenging (and thus, they're all rewarding). Any variance in the amount of difficulty from one instrument to the next should be ignored.
THAT BEING SAID
I did notice that some people have an inherent aptitude for one type of instrument or another. I can play (or at least make a sound on) just about any woodwind instrument you set in front of me. Brass instruments...not so much. I was better with low brass, but it took years before I could make any sounds on the trumpet (not trying very hard, mind you, just picking one up every now and again in the store).

The truth is, I have just booked my first violin lesson for next week.

This is by far the best thing that you said. Assuming that your teacher is not terrible (there are terrible teachers; if you find you're not progressing and they can't seem to find a logical reason as to why, maybe shop around), this is the single most valuable tool in the toolbox of new learners. Even if you only do a few lessons, they can save so much time and frustration in preventing bad habits and instilling good ones. That being said, if you really want to succeed, regularly attending lessons is the way to go, even if "regularly" is once a month.
Important to remember: if you find that violin is not for you, that doesn't mean that all non-piano instruments are not for you. Try other string instruments (cough cello cough), or woodwind, or brass.
One final thing: people sometimes say the practice makes perfect; this is not true. Practice makes permanent. If you practice something the wrong way for hours and hours on end, that's not going to magically make it the right thing, but it will make it THE way you do it from then on.
Answer: I've taught beginner violin students, and I've played since the age of 8 years old.
The violin is a strange thing.  Although I have all the knowledge to play the instrument, if I switch hands, I sound like a complete beginner.  That tells me that more than just knowledge is needed.
When I taught my beginning students I used to tell them that it was hours on the instrument that mattered the most, not trying hard, or love for the instrument.  Its like piloting a plane, if you have a certain amount of hours in the air then you become a pilot.  Without those hours you never get to fly by yourself.
It is the same with the violin as with piloting airplanes.  Patience with yourself is key, because learning the violin is one of those things that only works if you keep at it regularly for an extended period of time.
That being said, learning violin is tough until you get used to the instrument.
Answer: I'm no expert on violin but I'm a little familiar with stringed instruments; my mains these days are bass and guitar.
As others have already indicated, there are two hard problems with violin - bow control in the right hand and intonation in the left. You get to solve those both at once. Some years ago I was playing drums at a church service and there was also a string quartet playing that consisted of kids in I suppoer their mid-teens. I expect that they had all been playing for years by then yet still...they were terrible. Understand that when I say "terrible" all I mean is that their intonation was off just enough to be instantaneously objectionable to anyone with half an hear and/or had been used to hearing professional string players in a quartet setting. Were they all playing fretted guitars instead, all else being equal - wouldn't have been anything like that trainwreck. So they had years of hard practice ahead of them still if they were going to sound like anything.
But don't let that stop you. If you naturally have or can develop a really good ear/brain/hands feedback loop and can hear the difference between dead-on and crap-poor, then you can at least get good enough to have fun whether it's with other string players, players of other instruments (check out the original Mahavishnu Orchestra!), or just you and recordings.
I would recommend that you be very precise - and consistently so - about your open-string tuning. Buy a good tuner, and probably with the help of a keyboard to determine this, only play along with recordings that are in tune (easier to do with recordings from the all-digital era). Your skill with intonation will have everything to do with developing a kinesthetic memory for making your fingers land just so.
Answer: The main difficulty with most instruments is to correctly play a bunch of notes together. The interface isn't necessarily hard to use (push a key on a piano, hit a cymbal with your drumstick, blow in your flute). Sometimes the interface offers some difficulties (playing a basic guitar chord isn't as straightforward as a basic piano chord), but you can pretty much skip the "interface 101" part to start learning real music.
The issue with Violin (and other non-fretted instruments) is that the interface is very hard. At first, it's very hard to play a note correctly, because there aren't any shortcuts (frets, like you have on guitars). So in the case of such instruments, the learning part is divided into two parts:

First, you learn to use the instrument to play notes.
Then, you learn music with that instrument.

When I was a teenager I was playing a lot of instruments, and that's the thing that stuck out after I played a bit of violin for several weeks: with other instruments I could start by learning a song. With violin, I had to spent much time practicing only hitting notes correctly.
Answer: It is not difficult if you have a desire, talent and a good teacher, of course. When I was learning to play the piano, my teacher used to say that 99% of success depends on a student, but I used to state that 1% that is left is sometimes the most important as a good expert teacher will always put you in a right direction.
Answer: Yes, violin is one of the 'harder' instruments. Clarinet is often quoted as one of the 'easiest'.  Given the same amount of application, you'll be a useful member of a band or orchestra on clarinet while the student violinist is still way behind the demands of the repertoire.    But you'll get there!


Why does the US Open have a tiebreaker for the fifth set?

Question: The Australian Open, French Open, and Wimbledon do not use a tiebreaker in the fifth set for men and third set for women.  They play that final set until someone gets a 2-game lead, no matter how many games are required.  But the US Open still uses a tiebreaker in the fifth set for men and third set for women.  Why doesn't the US Open forgo the tiebreaker in the final set like the other 3 Grand Slam tournaments?
Answer: Ah, the old debate about the 5th set tiebreaker. Some love it, some hate it. If you were to ask the players themselves, I think most would prefer the 5th set to end in a tiebreak so that you don't potentially end up with a 5th set score of something like 20-18 and play an extra 2 or 3 sets worth of games to decide the winner. Personally, I think it's better for fans and people watching matches to not have really prolonged matches that can become boring and lose interest from the fans.
When it really comes down to it though - the real answer involves stuff like television and media scheduling. The US Open has had their "Super Saturday" thing for a long time - where the 2 men's semifinals are played along with the women's final on the second Saturday of the event. In order to make sure the matches conclude in a "timely" manner - the 5th set tiebreak is used to help make sure the men's semifinal matches don't go on for too long and mess up the schedule for the day. Seems like kind of a silly reason but, it is what it is.
If you ask those involved in running the tournament (USTA) you usually get an answer like "it's what makes the US Open unique" or some other PR-scrubbed answer but in actuality it really just boils down to keeping the schedule running smoothly.
Interestingly enough, the US Open introduced the 5th set tiebreak in 1970 - a few years before the other 3 majors switched to playing out the 5th set. Wimbledon's current 5th set rules were changed in 1979, The Australian Open's in 1971, and the French Open in 1973 - to what you see in use today by those events.
Comment: I agree with most of this, however as a fan there is nothing more I like to watch than two exhausted athletes who keep digging and digging into their reserves.  In tennis this is often when we can actually see "normal" tennis - instead of a rocketfest.  I would gladly watch a 25-23 5th set.


copy constructor can't be called when call object o=13;

Question: Object::Object(int x);
Object::~Object;
Object::Object(const &object);

when calling:
Object o=13;

I think it split 2 steps;
Object temp(13);
Object o=temp;

So it will call copy constructor,but I print the info:
there is no any copy constructor be called.
So can somebody help to explain it?
I think it should has no relations with NRVO or RVO.
Comment: possible because of the optimization of the compiler
Comment: See here : http://stackoverflow.com/questions/3905869/isnt-return-value-optimization-rvo-a-bug
Answer: There is elision of the copy constructor in your example.
From the c++ Standard:

This elision of copy/move operations, called copy elision, is
  permitted in the following circumstances (which may be combined to
  eliminate multiple copies):

...

— when a temporary class object that
  has not been bound to a reference (12.2) would be copied/moved to a
  class object with the same cv-unqualified type, the copy/move
  operation can be omitted by constructing the temporary object directly
  into the target of the omitted copy/move

Also there is an important note:

[ Note: This two-stage overload resolution must be performed
  regardless of whether copy elision will occur. It determines the
  constructor to be called if elision is not performed, and the selected
  constructor must be accessible even if the call is elided. —end note ]


Solução para transição de telas

Question: Tenho um site one-page que vai seguir o seguinte padrão:

Para fazer a transição de telas, geralmente eu uso o scrollTop, porém eu tenho que informar a posição de cada section em px. E não é isso que eu quero.
Tem alguma forma de eu fazer scrollar direto para a id desejada, ou algo do gênero?
O que uso atualmente:
$('.home').click(function () {
    $('html, body').stop().animate({
        scrollTop: '0'
    }, 700);
    setHistory('MEUSITE- Home', site + '/home');
});
$('.empresa').click(function () {
    $('html, body').stop().animate({
        scrollTop: '855px'
    }, 700);
    setHistory('MEUSITE- Empresa', site + '/empresa');
});

Answer: use $(this).offset().top. offset() vai obter a coordenadas do elemento, enquanto $(this).offset().top vai pegar a distância do elemento clicado na posição vertical. No animate você usa o offset do elemento para mover a tela. Fiz um jsfiddle para ilustrar.
$('.home').click(function () {
    $('html, body').stop().animate({ scrollTop: $(this).offset().top }, 700);
    setHistory('MEUSITE- Home', site + '/home');
});
$('.empresa').click(function () {
    $('html, body').stop().animate({ scrollTop: $(this).offset().top }, 700);
    setHistory('MEUSITE- Empresa', site + '/empresa');
});

Você pode fazer de forma mais simples usando a combinação ID e CLASS. Quando clicar no
 ele vai animar até a div correspondente sem precisar definir item por item. Para essa forma fiz outro jsfiddle
$('section').click(function () {
    section = $(this).attr( 'id' );
    $('html, body').stop().animate({ scrollTop: $('.' + section).offset().top }, 700);
    setHistory('MEUSITE- Empresa', site + '/empresa');
});

// botões

home

empresa

// conteúdo

home

empresa

Answer: (http://jsfiddle.net/NadirZenith/ocopr9kb/1/)
pode usar este script jquery que faz um scroll até a ancora na mesma pagina
$('a[href*=#]:not([href=#])').click(function() {
                                  if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
                                        var target = $(this.hash);
                                        target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                                        if (target.length) {
                                              $('html,body').animate({
                                                    scrollTop: target.offset().top - 70//offset from top fixed menu??
                                              }, 1000);
                                              return false;
                                        }
                                  }
                            });

com este tipo de ancoras

home

empresa

mapa

contato

e usar suas secçoes da mesma forma:

Solução para transição de telas


Do "Perfect Pitch Programming" tracks actually work?

Question: This is super similar to some other popular questions concerning perfect pitch, but I thought that it was specific enough to avoid closing.
The idea of having perfect pitch has always appealed to me, and, on a whim, and at 10:30 PM, I googled "learn perfect pitch." Instantly, all of these videos with "perfect pitch programing" in the title popped up.
Yeah, it's disturbing:

But I wonder how effective this method for "learning" perfect pitch is. I mean, there's plenty of people who vehemently believe that perfect pitch is genetic. But, well, I don't know... I can sort of see this working, but it is kind of annoying. Like super annoying.
Do these types of time wasting, psychosis inducing brain-cell killing sludge buckets of music and poorly synthesized voices actually have any documented success, or is it just a bunch of you tubers with a MIDI program?
Comment: I could rather see this working if it evoked some sort of synæstesia in a sophisticated way. That video seems to just link all note names to "annoying square synth sound". But dunno... perhaps the annoying monotonicity is precisely what should cause the brain to learn really detecting pitch alone, without interval connotations.
Comment: Genuinely can't see how this sort of thing can be successful. I can sing an accurate C note, and find others from there, and that's good enough for me. Waiting to get feedback from folk who have attained absolute pitch from this sort of idea.But sceptical...
Comment: I am going to give it a try this week. It cannot hurt. The problem I have with other trainings/software is that it never gives you the sounds tied to the notes ahead of time. It's always a trial and error thing. I am pretty good at this point, but will try this and see if it improves my scores in other training.
Answer: Perfect pitch is not something that you can "learn." Having perfect pitch myself, here is my advice. In my opinion, those courses are a bunch of garbage and don't help you at all. To be honest, I don't think I could stand more than a minute of hearing "F....F.....F....F". It would drive me bonkers. I discovered that I had perfect pitch when I was in 4th grade (age 8) and I was in the Grace Cathedral Choir of Men and Boys. I think that the first step, if you want to get perfect pitch is to play an instrument or sing a lot. I have played piano since I was in 1st grade, so that definitely helped. The first thing that I noticed, after playing piano for a while was that I could sing a C on command. Now, if you have one note that you know really well, then you can find all other notes based off of that one, which is what I did. If you practice and exercise this, e.g. practicing finding an A off of a C a lot, then gradually, you will start to remember more and more notes until you have perfect pitch. I hope that this was helpful to you.
Answer: Lots of practice MIGHT help you develop perfect pitch.  It will certainly help you develop relative pitch - the ability, once given a framework, to recognize notes and intervals.
If you are skilled at this already, probably no need for the course.


Problems encountered when developing apps with Android 14

Question: I found that after my app reached a fair size (e.g. by adding multiple libraries), running the app threw java.lang.SecurityException: writable dex file '.../code_cache/.overlay/base.apk/classes2.dex' is not allowed.
If I then remove most of the libraries leaving only those that were added by default, and run again, it could work. But then if I add a tiny bit of code, like a log, it could fail with the same error.
If I want it to run without this error, I have to uninstall the app and then run again from Android Studio. This is very inconvenient, because every time I make some changes, I have to uninstall the app. I wouldn't imagine anyone would like to develop Android apps like this.
Does anyone know a solution to this problem?
Comment: @Lino Because the problem I am having is only on Android 14. Earlier Android versions work fine. Android 14 hasn't been released until August this year.
Comment: Maybe try using MultiDex?
Comment: why did you tag android-14? is this something specifically related to that OS?
Comment: @WeiWen : Are you using Dynamic Code Loading (DCL) in your project or can you get info if the libraries are using this feature ?
Comment: @avinash I didn't use DCL. And I don't think any of the libraries that I included uses DCL. All of them are Android or google libraries, like navigation, lifecycle, material, etc.
Comment: Try turning off "build automatically " in settings. https://slack-chats.kotlinlang.org/t/518884/question-1-i-m-starting-to-receive-this-error-more-and-more-#2d02f618-8363-43f8-993c-bef6cb2715ba
Comment: Did you ever get to the bottom of this? I've been seeing it non-deterministically. The call chain seems to originate from native android OS code.
Comment: @Smalls No. I haven't found a solution. I am not actively developing any app on Android 14, just want to see what features there are. I am hoping google will find out the issue and fix it.
Comment: The issue seems to not be reproducible for me anymore without updating any of the libs I was using so the issue may have been resolved on the Android side.
Comment: Not sure if you have resolved the issue but in my case the issue was that I needed to update to java 11 and update the dependencies versions to newer ones.
Comment: @DPE  I updated Source Compatibility and Target Compatibility to version 11, and updated all the libraries to the latest. But still, even if I just add a print in code, I still get "Writable dex file is not allowed error".
Comment: same issue here, It's getting to the point that I feel I must update one dependency at a time and perform 3 hours of troubleshooting.
Answer: I was also having this problem, so I took a look at this documentation DexClassLoader, and decided to do this.
package com.example

import android.app.Application

class BaseApp : Application() {
    override fun onCreate() {
        super.onCreate()
         val dexOutputDir: File = codeCacheDir
         dexOutputDir.setReadOnly()
    }
}

Just putting dexOutputDir.setReadOnly() in my application solved the problem
Uninstall and reinstall the app again
Comment: This does not appear to fix the issue when the latest official play ads library writes a .jar file into /cache
Comment: Upgrade Android Studio version Android Studio Hedgehog | 2023.1.1 Patch 2 and this should be resolved.
Answer: I have the same error when testing my app on android 14 emulator. DexClassLoader is only allowed to use a readonly dex file. So I add File("path/to/abc.dex").setReadOnly() before DexClassLoader to solve my issue.
From your log ../code_cache/.../classes2.dex, some kind of dex loading probably used in your code or dependencies. So you should make these dex files readonly before they are loaded.
Comment: Seeing a similar error when building with Iguana 2023.2.1 - the error appears  in the pre-launch report and the app is apparently writing a jar to the app's /cache folder.  No idea what that is about as no jar is being explicitly written by the app but may be written by com.google.android.gms.policy_ads_fdr_dynamite (?!)
Comment: where do I add the code: File("...").setReadOnly()?
Comment: before where you use DexClassLoader or just at Application / Activity onCreate.
Comment: I updated Android Studio. When I had the problem, I used Android Studio Chipmunk 2021.2.1. Now I updated to Android Studio Giraffe 2022.3.1 and I no longer have the problem. Maybe after I installed the old Android Studio version back, I will test your suggested solution.
Comment: @bilabila I tested adding your suggested code, but I still got "Writable dex file is not allowed" error. I tried to add the code in onCreate method of both the activity and the application classes. But neither one worked. The path I tried is something like this: ../code_cache/.overlay/base.apk/classes2.dex, assuming the full path that Android Studio pointed to is: /data/data/com.example.testandroid14/code_cache/.overlay/base.apk/classes2.dex
Comment: did anyone solved it?


Split and add Text EXCEL VBA

Question: I would like to split some text and then add "_@" to the split text
Eg.
S106-137-800_BOMS_0.xls >          S106-137-800_BOMS_@           0

here is my code so far :
    k = InStr(str, "_")
    j = InStr(k + 1, str, "_")
    i = InStr(j + 1, str, ".")

    rw.Offset(0, 1) = Left(str, j - 1)
    rw.Offset(0, 2) = Mid(str, j + 1, i - j - 1)

Is there a way to split and Add "_@ as shown in the e.g ?
Comment: Your question is not very clear because this is only half the code we see. Do you mean something like `rw.Offset(0, 1) = Left(str, j - 1) & "_@"`? You can also have a look at the [Split Function](https://msdn.microsoft.com/en-us/library/6x627e5f(v=vs.90).aspx). Always add to your questions: What your code actually does (example of your actual result) and what you expect as result.
Comment: @Peh Sorry, i though that code would be sufficient, but yes that is what i was looking for Thanks! Please write that in an answer so i can register it as an answer.
Answer: You can use the InStrRev Function to get the position (from the right) of the first _ from the end:
i = InStrRev(Str, "_")

rw.Offset(, 1).Value = Left(Str, i) & "@"
rw.Offset(, 2).Value = Mid(Str, i + 1, InStr(Str, ".") - i - 1)

Comment: Of course I'm totally fine! You got my vote for suggesting `InStrRev`. Always good to see different solutions.
Comment: This time you won ;)
Comment: @Peh I'm not against yu, right ? with you helping new guys stepping into VBA, and also learning new stuff
Comment: @Peh I remember using it because I saw it here on another post a while ago

Split and add Text EXCEL VBA


Attempting to center navigation in wordpress skeleton them

Question: I'm using the Skeleton theme to create a responsive wordpress site.  I'm attempting to center the top navigation but to no avail.
Here is the link:
http://bit.ly/13e2tIX
This is what I'm trying:
<code>#navigation ul li {
position: relative;
display: inline-block !important;
text-align:center;
width: 100%;
color:#666;
text-transform: uppercase;
</code>
}
But this will center and stack all of the navigational items.  Any help would be greatly appreciated.
Comment: Do you want the list items to display side-by-side, in a centered UL or do you want them stacked and centered as a list?
Comment: I would like them to display side by side, not in a list like the are currently.  Just centered to the page.
Answer: Try this:
<code>#navigation ul {
    text-align:center;
}
#navigation ul li {
display:inline;
list-style:none;
position: relative;
color:#666;
text-transform: uppercase;
}
#navigation ul li a {
    display:inline-block;
}
</code>
You can see the jsfiddle here: http://jsfiddle.net/sb4NH/
Comment: Thank you kindly for your help.  It still does not seem to move the navigation.  I've worked your solution into my code, its too long for the comment. This is the fiddle: http://jsfiddle.net/MLS1984/9qD9E/
Comment: I checked your site link and it looks right - did you figure it out? Sharp looking site design, by the way! :)
Answer: This answer didn't work for me, but this did:
<code>.menu-header
{
   display:inline-block;
}

#navigation
{
   margin:0 auto;
   text-align:center;
}
</code>
Only tested in chrome inspector, but it seems to center the navigation menu of skeleton theme for wp.


How to set user and admin on different dashboard url in laravel

Question: I'm working on a project where user and admin are two different login. I want to redirect user and admin to their respective dashboard pages.
I'm not getting how to do this. In database, I created roles column (1 for admin, 2 for user).
I'm not getting how to set send to a different dashboard.
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Validator,Redirect,Response;
Use App\User;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Session;
use Socialite;

class AuthController extends Controller
{

    public function index()
    {
        return view('login');
    }

    public function registration()
    {
        return view('registration');
    }

    public function postLogin(Request $request)
    {
        request()->validate([
            'email' => 'required',
            'password' => 'required',
        ]);

        $credentials = $request->only('email', 'password');
        if (Auth::attempt($credentials)) {

            // Authentication passed...
             return redirect()->intended('dashboard');
            // return redirect($this->redirectPath());
        }
        return Redirect::to("login")->withSuccess('Oppes! You have entered invalid credentials');
    }
}

Currently on successful login going only same dashboard. I want to change that and send redirection according to roles.
I have created middleware also, but not getting what exact need to do.
<?php

namespace App\Http\Middleware;

use Closure;
Use App\User;

class RoleMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {

            $auth = Auth::user()->roles()->first();

            switch ($auth->role) {
                case 'admin':
                        return  redirect()->route('admin');
                    break;
                case 'user':
                        return  redirect()->route('user');
                    break;

                default:
                    return  redirect()->route('login');
                    break;
            }

         }

        return $next($request);
    }
}

and routing will be following
Route::get('login', 'AuthController@index');
Route::post('post-login', 'AuthController@postLogin');

Comment: `return redirect()->intended('dashboard');` change this not in middleware  we use middleware to protect route not for redirect in your case it will be in unlimited loop if you apply that midlleware
Answer: First of all, you don't need to create a middleware for redirecting users based on their role.
Just check the role of user after successful login attempt and do your redirect.
public function postLogin(Request $request)
{
    $request->validate([
        'email' => 'required',
        'password' => 'required',
    ]);

    $credentials = $request->only('email', 'password');

    if (Auth::attempt($credentials)) {
        // Authentication passed...

        // Set redirect route/path based on user role.
        $to = $request->user()->role->name === 'admin' ? 'admin' : 'user';

        // Redirect user to a named route.
        return redirect()->route($to); // or return redirect($to);
    }

    return Redirect::to('login')->withSuccess('Oops! You have entered invalid credentials.');
}

Comment: I am getting this error "Call to undefined method App\User::roles()"
Comment: How do you fetch the roles of a user? Are you using a package to manage user permissions and roles? If so, what package are you using?
Comment: I am not using any librabry or package. Just created role table with migration
Comment: Then, can you post your User model and show how you fetch roles?
Comment: ,below is my User and role model
class User extends Authenticatable
{
    use Notifiable;
    public function role()
    {
        return $this->belongsTo('App\Role');
    }
}
 class Role extends Model
{
    public function user()
    {
        // return $this->belongsTo(User::class);
        return $this->hasMany('App\User');
    }
}
Comment: Just updated the answer. You should use `$request->user()->role` to get the user's role. Then you can access the `name` property of the **Role** model like this: `$request->user()->role->name` (if the `name` field exists in your scheme).
Comment: In role model i have role id and name. and in user table i have role_id so i want to fetch role_name from role table .
Comment: Then you can get the role name like so: `$request->user()->role->name`.
Answer: You can Manage different different dashboards for User and Admin URLs Easily using Gates method also in Laravel.
refer and Try to understand this Example,


Pass information out of html to python

Question: I'm very new to python and html and I've been trying to run a simplehttpserver using python (with cgi). From this server I can run a location.py file which displays a users geolocation. I'd like to then take this location and write it into a text file on my pc but I don't know how to do this. Currently my location.py is really a html5 page which is loaded by python but i don't know how to extract the required information from my this page.
P.s. the inspiration for this is to have my iphone and my laptop sharing the same wifi network (adhoc portable hotspot) and then for my laptop to use my iphone's more accurate gps in google earth. This I eventually want to write into a kml file which constantly updates with my current lat and long. There are probably easier ways to do this but I thought learning a bit of python would be a good idea.
My location.py file
#!/python

print( "Content-type: text/html\n\n")
print( """\

Test:

""")

And my server file (webserver.py)
import http.server

def main():

    server_address = ("", 8000)
    handler = http.server.CGIHTTPRequestHandler
    handler.cgi_directories = ['/python']
    server = http.server.HTTPServer(server_address, handler)
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.socket.close()

if __name__ == '__main__':
    main()

Answer: You need to send a request back to your sever with the location and then use cgi.FielStorage on your script to get the data. To send the request you have to modify your javascipt code a little.
I show you an example sending static data back (cause I dont have geolocation on my Pc :P), you need to change it to send the correct lat,lon data (maybe inside the function showPosition?)
Next, changes on your python script (please check that there are also chnages on the javascript!):
#!/usr/bin/env python

import cgi

form = cgi.FieldStorage()

lat = form.getvalue('lat')
lon = form.getvalue('lon')

with open('location.txt','wt') as f:
    if lat:
        f.write(lat)
    f.write("\n")
    if lon:
        f.write(lon)

f.close()

print( "Content-type: text/html\n\n")
print( """\

Test:

""")

If you run the code you will see that on the file location.txt you have the coords.
Of course you can split the process on two scripts (almost sure the right approach!) and send the request to your second script (save_location.py perhaps?).
Comment: You can move all the saving part to a script called (for example) **save_location.py** and put in on the cgi dir, then on your call from javascrit you need to change `req.open('GET', 'location.py?...);` for `req.open('GET', 'save_location.py?...);`. You should keep in mind that this call is performed using AJAX so it is asynchronous and you will not see any output at least you used it. I recommend you to check this http://www.w3schools.com/ajax/ajax_intro.asp or http://www.webmonkey.com/2010/02/ajax_for_beginners/ to learn AJAX, best regards
Comment: This solved it exactly. I moved the extra javascript to the showposition function and replaced the numbers with ' +  position.coords.latitude+ '. It worked like a dream. If you don't mind would you explain a little more about having two scripts. I tried (probably very naively) simply putting the new python in a second script and running that once I'd run the first but that didn't seem to work. Also, I imagine that you are thinking of a cleaner was than having to manually run a save script everytime! Do I need to reference my save script in my other script?

Pass information out of html to python


Publish/Export Independent Modules in Angular

Question: I am having a business problem where i have multiple small applications running on Angular. Now Business wants to have one common Shell/application to open these small applications as modules. To be more specific i want to design a system where multiple small applications can be launch/hosted from one common application, for ex, i have Weather application, News Application and Music application built on Angular, now i want these small applications to be open from one common application much like in portlet and portal manner.
I am looking for approaches on how i can create and publish only modules from Angular and is this a good approach to implement Portlet-Portal concept in Angular.
Any reference/work/suggestions would be appreciated.
Thanks
Nitin
Answer: I think you just make it a site, and all of your existing smaller applications become different pages in your Single Page Application, they would each be a component. You could use angular client side routing to go from page to page.


Link a field in content types to the user profile

Question: I want to link the output of a field (e.g. "Written by:Name" or "Photographed by:name") in the content type (e.g. Article) to the user profile.
Can anyone help me with it?
Answer: First, you should make sure that the default author relationship isn't sufficient to satisfy your needs. Every content type has a creating user; this relationship can usually be used to create any necessary links between the content and the user in Views, Panels, or other modules.
However, sometimes you need to have multiple users associated with content. Your "photographed by:" example sounds like a good example of this use case. In that instance, I would use the User Relationships module to add a User Relationship field to the content type.


How to repeat  tags in Polymer 2.x?

Question: In Polymer 1.0 I'd repeat the <option> tags inside the <select> tag like this:

<select>
  <template is="dom-repeat" items="{{items}}">
    <option value$="[[item]]">[[item]]</option>
  </template>
</select>

But in Polymer 2.x it's recommended to use the <dom-repeat> tag:

<select>
  <dom-repeat items="{{items}}">
    <template>
      <option value$="[[item]]">[[item]]</option>
    </template>
  </dom-repeat>
</select>

But this does not work. So how to repeat <option> tags in Polymer 2?
Comment: since the dom-repeat element is not fully completed and has many reported bugs it is propably better to work with is="dom-repeat". you can propably post this on github as issue, but i am not sure, if it is bug. There have to be some workaround
Answer: This issue looks similar to the one reported for <dom-repeat> inside
.
The workaround for now is to use "hybrid mode", where the 2.0 <dom-repeat> wraps a <template is="dom-repeat">:
<select>
  <dom-repeat items="[[items]]">
    <template is="dom-repeat" items="[[items]]">
      <option value="[[item]]">[[item]]</option>
    </template>
  </dom-repeat>
</select>

codepen
UPDATE: @DocDude (Arthur Evans from the Polymer team) noted in Slack that using <template is="dom-repeat"> will still be supported inside a Polymer 2.0 element. You only need to use the element wrapper from outside the element (e.g., in index.html).

@KevinShaaf from the Polymer core team has also confirmed this in GitHub:
Comment: The [Polymer 2.0 About page](https://www.polymer-project.org/2.0/docs/about_20#type-extension) states that "Apple has said it will not implement `is`, we will not be encouraging its use to avoid indefinite reliance on the custom elements polyfill". So I think this probably is the short-term correct way to do this (I'm accepting this as the correct answer), but I hope there will be some more standards-compilant way to do this in the future.
Comment: @jehna1 That's true that Apple won't support `is` *natively*, but the polyfills will continue to support it in the meantime (while the bug in `` is being worked on). The 2.0 code that you originally questioned is indeed standards-compliant, so that will work after the bugfix lands.

How to repeat  tags in Polymer 2.x?


Can someone please explain the truncated back propagation through time algorithm?

Question: I am reading about RNNs and how to train them and I understood how back propagation works. I have the following model:
$$
h_t=f(Ah_{t-1}+ B x_t),\\
\hat{y}_t=g(C h_t).
$$
For a given sample $(x_1^T,y_1^T)$, my loss function is $L_2$-loss given by $L=\frac{1}{2} \sum_{t=1}^T \|\hat{y}_t-y_t\|^2$. My understanding of back propagation through time(BPTT) is that we can compute the gradients $\frac{\partial{L}}{\partial h_t}$ recursively as follows:
\begin{align*}
\frac{\partial{L}}{\partial h_T}=C^\top((\hat{y}_t-y_t)\odot g'(Ch_T) ),\\
\frac{\partial{L}}{\partial h_{T-1}}=C^\top((\hat{y}_{t-1}-y_{t-1})\odot g'(Ch_{T-1}) )+\frac{\partial{L}}{\partial h_T} \frac{\partial{h_T}}{\partial h_{T-1}}.
\end{align*}
Thus proceeding backwards in time one can compute $\frac{\partial{L}}{\partial h_t}$ in terms of $\frac{\partial{L}}{\partial h_{t+1}}$ for all $t=1,\ldots,T-1$. We can find the parameter gradients using:
$$
\frac{\partial{L}}{\partial A}=\sum_{t=1}^T \frac{\partial{L}}{\partial h_t} \frac{\partial{h_t}}{\partial A}=\sum_{t=1}^T (\frac{\partial{L}}{\partial h_t} \odot f'(Ah_{t-1}+Bx_t) )h_{t-1}^T.
$$
How does the truncated backpropagation algorithm fit into this framework? Can anyone explain it clearly?
Answer: I am sure you have found your answer by now, but for others. The truncated part of Truncated Backpropagation through Time simply refers to at which point in time to stop calculating the gradients for the backpropagation phase.
Lets say you truncate after $k$ steps then the difference is you calculate the below instead.
$$
\frac{\partial{L}}{\partial A}\approx\sum_{t=T-k}^{T}\frac{\partial{L}}{\partial h_{t}}\frac{\partial^{+}{h_{t}}}{\partial A}=\sum_{t=T-k}^{T}(\frac{\partial{L}}{\partial h_{t}}\odot f'(Ah_{t-1}+Bx_{t}))h_{t-1}^{T}.
$$
Where $\frac{\partial^{+}}{\partial{A}}$ is the "immediate" partial wrt A, i.e. the one that assumes all terms other than an explicit A are constant.  Essentially you are truncating the sum in Equation (4) of Pascanu, Mikolov, and Bengio.
At least this is my understanding of it judging from Ilya Sutskever's psuedo-code in his thesis.
<code>Truncated BPTT is given below:
 1: for t from 1 to T do
 2:   Run the RNN for one step, computing ht and zt
 3:   if t divides k1 then
 4:     Run BPTT (as described in sec. 2.5), from t down to t − k2
 5:   end if
 6: end for
</code>
Comment: Yeah basically if you understand BPTT, truncated BPTT is the exact same thing but instead of propagating to the beginning of the sequence you only propagate backwards k steps.


Sequencia de fibonnaci

Question: Dado a sequência de Fibonacci, onde se inicia por 0 e 1 e o próximo valor sempre será a soma dos 2 valores anteriores (exemplo: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34...), escreva um programa na linguagem que desejar onde, informado um número, ele calcule a sequência de Fibonacci e retorne uma mensagem avisando se o número informado pertence ou não a sequência.
IMPORTANTE:
Esse número pode ser informado através de qualquer entrada de sua preferência ou pode ser previamente definido no código;
#estou conseguindo fazer a sequencia, porem não consigo armazenar a sequencia gerada em uma lista para depois fazer a comparação com o valor de entrada :(
Answer: <code>n = int(input())

a, b = 0, 1

while a < n:
    a, b = b, a + b

print(a == n)
</code>

Sequencia de fibonnaci


Using USB-Intent filter for multiple activities

Question: I currently have two activites. One is a login activity that after successful login leads to a main activity that contains multiple fragments.
I currently have a USB intent filter and broadcast receiver that checks to see if a USB device is plugged in. Once it detects it a device and I set to be the default app for the device it will relaunch the app even if I am currently in the main activity. The problem is that it bypasses the log in screen activity and crashes as it does not contain the data for the 2nd activity as no log in has occured.
My problem occurs on the fact that app relaunches and resets connection. Is there a way I can make the app not relaunch or just reload the last fragment within the 2nd activity?
<code><application
        android:theme="@style/AppTheme"
        android:allowBackup="true"
        android:name=".MainApplication"
        android:icon="@drawable/icon"
        android:label="@string/app_name">

        <activity
                android:name=".LoginActivity"
                android:theme="@style/Theme.Dark">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
        </activity>

        <activity
                android:name=".DeviceRegistrationActivity"
                android:theme="@style/Theme.Dark"/>

        <activity
                android:name=".navDrawer"
                android:theme="@style/Theme.Dark">
                <intent-filter>
                    <category android:name="android.intent.category.DEFAULT" />
                    <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
                </intent-filter>

                <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                    android:resource="@xml/device_filter" />
</code>
Comment: Why not move the USB intent to the LoginActivity, and when that is launched, you can skip it and launch Main if you have a valid session.
Comment: I plan on moving the Login activity to the NavDrawer fragment. So the problem will still persist. Need to know if there is a way to stop the refresh and return to the last fragment shown
Answer:
The problem is that it bypasses the log in screen activity and crashes as it does not contain the data for the 2nd activity as no log in has occured.

Then you should not be having the login process be in a separate activity. Have the login process be a fragment that is shown by the same activity as the one that is being started by the USB event. If, when that activity starts, it determines that it does not have the authentication information — for whatever reason — it shows the login fragment.

Is there a way I can make the app not relaunch

Not really. Android devices do not have infinite RAM. Your process will be terminated eventually, and anything that you have cached in static data members or other singletons, such as authentication data, will be gone.

or just reload the last fragment within the 2nd activity?

You are certainly welcome to have the 2nd activity show whatever you want it to. However, if you do not have your authentication data, "whatever you want it to" had better be the fragment to get that data.


What's this strange error during entity_creation?

Question: I'm trying to create a (no bundle) entity from a feed using entity API, but I keep running into strange issue. The code for the entities is this:
function my_entity_provision() {
  $a = entity_create('entityType', array(
    'pid' => NULL,
    'aid' => 1,
    ...

  ))->save();
}

But when running it I run into these errors:
Warning: class_implements() [function.class-implements]: object or string expected in entity_create() (line 420 of ...../sites/all/modules/entity/entity.module).
Warning: in_array() expects parameter 2 to be array, boolean given in entity_create() (line 420 of ...../sites/all/modules/entity/entity.module).

I've tried looking on drupal and drupalcontrib for the correct implementation, but all code blocks show no text? :s
My code looks similar to Create Entity Programmatically in Drupal which does seem to work. (Since I have no bundle, I didn't define the type in the array, I read somewhere it can be omitted . But that made no difference anyway).
My entity info is as follows:
/**
 * Implements hook_entity_info().
 */
function my_entity_entity_info() {
  $return = array(
    'entityType' => array(
      'label' => t('entityType'),
      'controller class' => 'EntityAPIController',
      'base table' => 'entityTypes',
      'fieldable' => FALSE,
      'entity keys' => array(
        'id' => 'pid',
      ),
      'static cache' => TRUE,
      'view modes' => array(
        'full' => array(
          'label' => t('Full Entity'),
        ),
      ),
      'views controller class' => 'EntityDefaultViewsController',
    ),
  );

  return $return;
}

Comment: "in_array() expects parameter 2 to be array, boolean given" - looks like something that you should create as an array, is not an array. Sorry but can't see what is it at first glance
Comment: It is triggered by the my_entity_provision() function (it does not give an error if I don't call it). And the errors apply to entity_create. But I'm pretty sure the 2nd parameter is an array...
Comment: 2nd parameter of entity_create is, but where is that in_array used? What is passed to in_array as it's second parameter? That's the point.
Answer: Argh, it seems the two different entity modules (core & contrib) have confused me once again.
The EntityAPIController I chose as controller class has no method save(). It uses entity_save($entity_type, $entity); instead.
So the function had to be:
function my_entity_provision() {
  $a = entity_create('entityType', array(
    'pid' => NULL,
    'aid' => 1,
    ...

  ));
  entity_save('entityType', $a);
}

Comment: You might have been thinking of entities that have been extended using an `EntityMetadataWrapper`...they _do_ have the `save()` method. I believe `FieldCollection` also implements the same method on the entity controller too (maybe some other contrib modules do too)


Are questions about returning to your home country on-topic?

Question: If I have questions related to ending my time as an expat, should I ask them on Expatriates?
To be clear, these would be issues that are caused by both of the following (not just one of them):

having been an expat in the past
not going to be an expat anymore

Would such questions be off-topic because I will be a non-expat, living in my native country?
Answer: If it's an issue that only an expat faces or will face, then yes.  And similarly moving home is like being an expat for the second time.
For example, recent-expats may have questions about filing tax return from overseas if they still need to do so, now that they're no longer living in that country.
However, rather than a blanket statement, as there's always likely to be exceptions, basically - once again, follow the guide of - if the problem faced is not unique to an expat, it's possibly off topic.  Of course no harm in asking, it can always be closed if off-topic as the site evolves.  There's also the chat to ask in, if you don't feel it's suitable for the site, although it's not as busy a chat room as some of the other sites...yet.


Tracking Code Into a PDF or PostScript File

Question: Is there a way to track when a PDF is opened? Perhaps by embedding some script into the pdf itself?
I saw the question below, and I suppose the answer is "no" for javascript, but I am wondering if this is possible at all.
Google analytics tracking code insert in pdf file
Answer: The PDF standard includes support for JavaScript but as @Wes Hardaker pointed out, not every PDF reader supports it. However, sometimes some is better than none.
Here's Adobe's official Acrobat JavaScript Scripting Guide. What's probably most interesting to you is the doc object which has a method called getURL(). To use it you'd just call:
app.doc.getURL('http://www.google.com/');

Bind that event to the document's open event and you've got a tracker. I'm not too familiar with creating events from within Adobe Acrobat but from code its pretty easy. The code below is a full working VS2010 C# WinForms app that uses the open source library iTextSharp (126.96.36.199). It creates a PDF and adds the JavaScript to the open event.
Some notes: Adobe Acrobat and Reader will both warn the user whenever a document accesses an external resource. Most other PDF readers will probably do the same. This is very annoying so for this reason alone it shouldn't be done. Personally I don't care if someone tracks my document opens, I just don't want to get a prompt every time. Second, just to reiterate, this code works for Adobe Acrobat and Adobe Reader, probably as far back as at least V6, but may or may not work in other PDF readers. Third, there's no safe way to uniquely identify the user. Doing so would require you to create and store some equivalent of a "cookie" which would require you writing to the user's file system which would be considered unsafe. This means that you could only detect the number of opens, not unique opens. Fourth, this might not be legal everywhere. Some jurisdictions require that you notify users if you are tracking them and provide for a way for them to see what information you are collecting.
But with all of the above, I can't not give an answer just because I don't like it.
using System;
using System.Text;
using System.Windows.Forms;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //File that we will create
            string OutputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Events.pdf");

            //Standard PDF creation setup
            using (FileStream fs = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                using (Document doc = new Document(PageSize.LETTER))
                {
                    using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
                    {
                        //Open our document for writing
                        doc.Open();

                        //Create an action that points to the built-in app.doc object and calls the getURL method on it
                        PdfAction act = PdfAction.JavaScript("app.doc.getURL('http://www.google.com/');", writer);

                        //Set that action as the documents open action
                        writer.SetOpenAction(act);

                        //We need to add some content to this PDF to be valid
                        doc.Add(new Paragraph("Hello"));

                        //Close the document
                        doc.Close();
                    }
                }
            }

            this.Close();
        }
    }
}

Comment: Wow, this is the answer I was hoping for but didn't expect. Thanks!
Answer: The problem with technologies like that is that they can never be absolute.
First, it's a security violation to trigger an external event and the software writers likely wouldn't support it (or, at least I hope not).
Second, its dependent on things like the network.  What happens when someone downloads it and then reads it while offline on a plane, for example?  You won't get the notification.
Third, there are multiple ways to read PDF files.  Some people read them with readers you've likely not heard of (my favorite is a linux application that I like much better than the Adobe's AcroRead).
So even if you could do it (and I'd argue you shouldn't, but that's not answering your question), the real answer is "no" but even if the software supported it, it still wouldn't be reliable in the first place.
Comment: Obviously there are privacy and reliability concerns with any type of tracking. I'm not debating that. But why do you say "the real answer is 'no.'"  Don't the newer pdfs have dynamic content? I think they have some sort of scripting capabilities which may support something like this.
Comment: Not all readers support all possible content of PDF files. As Wes pointed out, just because you can do something with Acrobat doesn't mean it'll work in Foxit, Ghostscript, MuPDF, etc, etc.
Comment: And the "no" is because, though I admit I'm not a true PDF or PS expert, the current support of the PDF language does *not* provide support for the language to query external entities (ie, you can't say "go grab this pixel image from this remote website so I can track you).  PDFs are, by designed, supposed to be self-contained.
Answer: Given that PostScript is a fully capable programming language, there shouldn't be any reason that it should not be possible to track when it is viewed/run.
I should think the difficult part in that would be finding the libraries (or making the functions yourself) to do the networking portion of the logging.
One quick note, however, on functionality like this it is probably best if you make things still-accessible on failure; the reason being people tend to get upset when their media suddenly becomes unavailable which is exactly what would happen if you forced termination on failure. (Can you guarantee that your logging-domain will never change? That it will always be available? What happens in the case where the internet is not available in the user's situation?)
Comment: (a) The title explicitly mentions PostScript, and (b) the relation between PostScript and PDF is essentially that PDF is [the result of] PS run through its processing/program; this thread on stackexchange is really informative: https://tex.stackexchange.com/questions/217511/why-do-people-still-use-postscript
Comment: The question is about PDF and your answer is about PostScript. Does PostScript actually run within a PDF? Do you have any source with more information about their relation?


Como resgatar grande quantidade de variáveis enviadas por POST e usá las?

Question: Estou com um problema ao resgatar grande quantidade de variáveis enviadas pelo método $_POST. Estava usando esse código anteriormente:

import_request_variables("gp", "rvar_");

Mas o mesmo foi descontinuado e meu script parou de funcionar, tentei fazer através de um loop, mas não obtive sucesso ao tentar usa lo, fiz assim:
foreach( $_POST as $NomeCampo => $Variavel)
{
   $VarNome = "$" . $NomeCampo . "='" . $Variavel . "';";
   eval($VarNome);
}

Código do Form:
  <form name="form1" method="post" action="containerFormulario.php?conteudo=instrucao/rh_forms/AutorizaoContratacaoImpre.php">

Autorização para Contratação de Pessoal

                    Unidade Requisitante

                       <select name="Unidade" id="Unidade">
                          <?php
                             do {
                             ?>
                          <option value="<?php echo $row_rcs_unidades['IdUnicoop']?>"><?php echo $row_rcs_unidades['Nome']?></option>
                          <?php
                             } while ($row_rcs_unidades = mysql_fetch_assoc($rcs_unidades));
                                 $rows = mysql_num_rows($rcs_unidades);
                             if($rows > 0) {
                                 mysql_data_seek($rcs_unidades, 0);
                                 $row_rcs_unidades = mysql_fetch_assoc($rcs_unidades);
                             }
                             ?>
                       </select>

                    Nome do Candidato

                       <input name='Candidato' type=text id="Candidato"  size=50>

                    Endereço Residencial

                       <input name='Endereco' type=text id="Endereco"  size=50>

                    Bairro
                    <input name='Bairro' type=text id="Bairro"  size=50>

                    Telefone
                    <input name='Telefone' type=text id="Telefone"  size=50>

                    Cargo
                    <input name='Cargo' type=text id="Cargo"  size=50>

                    Seção
                    <input name='Sessao' type=text id="Sessao"  size=50>

                    Subseção
                    <input name='Subsecao' type=text id="Subsecao"  size=50>

                    Salário Inicial
                    <input name='SalarioInicial' type=text id="salarioIncial" size=8 maxlength="10" onBlur="soma()">
                                Código
                       <input name='CodigoInicial' type=text id="codigoIncial" size=8 maxlength="10">

                    Salário Após 90 dias
                    <input name='SalarioApos' type=text id="SalarioApos" size=8 maxlength="10" onBlur="soma()">
                                Código
                       <input name='CodigoFinal' type=text id="CodigoFinal" size=8 maxlength="10">

                    %
                    <input name='Calculo' type=text id="Calculo" onFocus="soma()" onBlur="valida()" size="8" maxlength="10" readonly>

                    Data de Admissão

                       <input name="Data" type="text" id="Data" onKeyUp="formataData(this)" size="10" maxlength="10">

                    Contrato Experiência - Dias

                       <input name='Contrato' type=text id="Contrato"  size=3>

                    Horário de trabalho

                       <input name='Horario' type=text  id="carga2" size=35>
                        Código
                       <input name='CodigoHorarioTrabalho' type=text id="codigoIncial2" size=8 maxlength="10">

                    Jornada de Trabalho

                                <input name="Opcoes" type="radio" value="Turno 12 x 36" checked>
                                Turno 12 x 36

                                <input type="radio" name="Opcoes" value="Banco de Horas até 19:00 - proibido trabalhar de Sábado">
                                Banco de Horas até 19:00 - proibido trabalhar de Sábado

                                <input type="radio" name="Opcoes" value="Horas Extras - horário operacional - Sábado">
                                Horas Extras - horário operacional - Sábado

                                <input type="radio" name="opcoes" value="Compensação de Jornada - proibido trabalhar de Sábado">
                                Compensação de Jornada - proibido trabalhar de Sábado

                                <input type="radio" name="opcoes" value="Outros Horários">
                                Outros Horários
                                <input name="OutrosHorarios" type="text" id="OutrosHorarios">

                    Grau de Instrução

                       <select name="Instrucao" size="1" id="Instrucao">
                          <option>Grau de Instrução - Selecione</option>
                          <option value="Primário">Primário</option>
                          <option value="Primário - Incompleto">Primário - Incompleto</option>
                          <option value="Primeiro Grau">Primeiro Grau</option>
                          <option value="Primeiro Grau - Incompleto">Primeiro Grau - Incompleto</option>
                          <option value="Segundo Grau">Segundo Grau</option>
                          <option value="Segundo Grau - Incompleto">Segundo Grau - Incompleto</option>
                          <option value="Terceiro Grau">Terceiro Grau</option>
                          <option value="Terceiro Grau - Incompleto">Terceiro Grau - Incompleto</option>
                          <option value="Pós-Graduação">Pós-Graduação</option>
                          <option value="Pós-Graduação Incompleta">Pós-Graduação Incompleta</option>
                       </select>

                    Estado Civil

                       <select name="EstadoCivil" size="1" id="EstadoCivil">
                          <option>Estado Civil - Selecione</option>
                          <option value="Solteiro">Solteiro</option>
                          <option value="Casado">Casado</option>
                          <option value="Viúvo">Viúvo</option>
                          <option value="Separado">Separado</option>
                          <option value="Outros">Outros</option>
                       </select>

                    Idade

                       <input name="Idade" type="text" id="Idade" size="19">

                    Trabalhou anteriormente na Cocari

                             <input name="Trabalhou" type="radio" id="radio" onClick="visivel5('1')" value="Sim" checked="checked" />
                                Sim, informar local
                                <input name="Trabalhou" type="radio" id="radio2" onClick="visivel5('0')" value="Não" />
                                Não
                                                     <input name="Local" type="text"  id="Local" class="corpoDocumento" size="30" maxlength="30" />

                    Em que período?

                       <input name="Periodo" type="text" id="Periodo" size="19">

                    Em que função?

                       <input name="Funcao" type="text" id="Funcao" size="47">

                    Motivo da Saída

                       <input name="Saida" type="text" id="Saida" size="47">

                    Especificar Motivo

                                <input name="Motivo" type="radio" value="Contratação" checked>
                                Contratação

                                <input type="radio" name="Motivo" value="Recontratação">
                                Recontratação

                                <input type="radio" name="Motivo" value="Substituição">
                                Substituição

                                <input type="radio" name="Motivo" value="Safra (Employer)">
                                Safra (Employer)

                                <input type="radio" name="Motivo" value="Rotatividade">
                                Rotatividade

                    Nome do Substituto

                       <input name="Substituto" type="text" id="Substituto" size="47">

                    Observações
                    <textarea name="Observacao" cols="70" rows="5" id="Observacao"></textarea>

                       <select name="dia" class="style1" id="dia">
                          <option selected="selected">1</option>
                          <option>2</option>
                          <option>3</option>
                          <option>4</option>
                          <option>5</option>
                          <option>6</option>
                          <option>7</option>
                          <option>8</option>
                          <option>9</option>
                          <option>10</option>
                          <option>11</option>
                          <option>12</option>
                          <option>13</option>
                          <option>14</option>
                          <option>15</option>
                          <option>16</option>
                          <option>17</option>
                          <option>18</option>
                          <option>19</option>
                          <option>20</option>
                          <option>21</option>
                          <option>22</option>
                          <option>23</option>
                          <option>24</option>
                          <option>25</option>
                          <option>26</option>
                          <option>27</option>
                          <option>28</option>
                          <option>29</option>
                          <option>30</option>
                          <option>31</option>
                       </select>
                       <select name="mes" class="style1" id="mes">
                          <option>Janeiro</option>
                          <option>Fevereiro</option>
                          <option>Março</option>
                          <option>Abril</option>
                          <option>Maio</option>
                          <option>Junho</option>
                          <option>Julho</option>
                          <option>Agosto</option>
                          <option>Setembro</option>
                          <option>Outubro</option>
                          <option>Novembro</option>
                          <option>Dezembro</option>
                       </select>

                          <select name="ano" class="style1" id="ano">
                             <option>
                                <?php setlocale(LC_TIME,"portuguese"); echo strftime("%Y"); ?>
                             </option>
                          </select>

Gerente
                          da Unidade
                          Gerente Recursos
                          Humanos
                          Superintendente

     <input type="submit" name="Submit" value="Preparar Impressão" onClick="valida()">

Porque o resultado acima não está me trazendo os todos os valores informados no formulário?
Comment: `extract($_POST)`, as chaves definirão os nomes das variáveis e, portanto, devem ser todas nomes válidos.
Comment: Qual a quantidade de campos que o seu POST tem?
Comment: Olá @KayoBruno, aproximadamente 30 campos.
Comment: Estranho o PHP tem o max_input_vars mas essa quantidade ai ainda está muito longe do máximo, verifica se todos os inputs estão com o name setado.
Comment: Tem como colocar o código do formulário para analisarmos?
Comment: Inserido o código do form @AdemirMazerJr-Nuno.
Comment: Como você identificou que não estão chegando todos os valores? Você executou `var_demp($_POST)`? Se sim, qual foi o resultado? Se não, execute-o.
Comment: O var_dump está trazendo todos os campos informados no formulário @AndersonCarlosWoss.
Comment: Já tentou utilizar a função `extract`? Ela faz basicamente o que o seu `foreach` deveria fazer.
Comment: Quando verifico a variável $VarNome ela só me traz o último campo do form, ai que está minha dificuldade.
Comment: Poderia colocar um exemplo de como ficaria @AndersonCarlosWoss?
Answer: Precisei de um negócio parecido ontem, resolvi assim:
<form action='eumesmo.php' method='post'>
<input type='text' name='a'>
<input type='text' name='b'>

<input type='SUBMIT' VALUE='ENVIAR'>

</form>

<?php

foreach ($_POST as $key => $valor) {
    //Defina $var pelo $key
    echo $key;
    $var = "$".$key;
    //Nomeia a var com o nome, e insere valor do _POST relacionado.
    $$var = $_POST[$key];
    //Escreve o valor do post;
    echo $$var;
}

Answer: Consegui resolver de forma simples, seguindo uma dica do Anderson Carlos Woss o código ficou assim:

extract($_POST, EXTR_PREFIX_SAME, "c");

O código acima,se existir uma variável com o mesmo nome, adiciona um prefixo ao nome da variável definido pelo argumento prefix.


Passing variable from preprocess block to the block body

Question: There is a block which its body is produced by PHP Code. I need to set a variable before loading the block and use it in it. This is my code
function THEME_preprocess_block(&$variables){
    $variables['var']="some text";
}

when I open the block configuration page and in its body I write
<?php print $var;?>

it prints nothing. How do I can pass variable from block template page in to the block body in the block configuration page?
Comment: If you're using PHP filter to put code in the body, it is (thankfully) executed in isolation, not in the same scope as the template file. Variables are only available in the context of a template file's execution, so you'll need to find a different way to solve this
Answer: Your variable will be available in block.tpl.php. Consider making your own block like described on How to theme a custom block?. (You probably do not need hook_theme().)
Using PHP directly in blocks (via UI) is not the best practice: It slows your site down, as the block needs to be rendered with every request, when it comes to caching.
Comment: The block contains lots of html, css classes and php code. you mean I should implement it in .tpl file?
Comment: no - i would suggest to make a custom block