Nuget for PowerShell Projects in Visual Studio

Question: How can I install nuget packages for my PowerShell Projects in Visual Studio 2015? I have tried to do it with both the PowerShell Module Project and PowerShell Script Project. I have installed PowerShell Tools for Visual Studio 2015.
When I open these projects, the Default project in the Package Manager Console is empty. Here is a screenshot of what I mean.

When I try to install a nuget package, e.g. Pester, I get the following error.
Comment: Any Advance? I am ring to run tests, but I get:"Failed to load Pester module. The specified module 'Pester' was not loaded because no valid module file was found in any module directory."
Comment: @XtianGIS Unfortunately I don't have any updates on this question. Your comment may be a different question altogether.
Comment: you are correct, but looking for solution to my issue, I face the same issue that you faced. either way I already raised my hand and ask the proper question. Thanks anyway
Answer: I know this thread might be outdated and is rather old but my older article with some possible solutions might help here. I tested current state and still, no support inside VS 2015 for PowerShell project and NuGet packages together.
the current state is :

go with https://chocolatey.org/ and install it on your dev box (and CI) => you install pester globally with : choco install pester and update it if needed.
use old packages.config and update by hand version number and run nuget restore (nuget update will no longer work for this type of solution).
version whole pester into repo and call it directly. you can use nuget install pester for this (if you have nuget in path somewhere)

The link : http://rostacik.net/2015/12/16/how-to-use-nuget-packages-even-with-powershell-projects-with-visual-studio-2015/
Comment: well it won't, its my page. :) but I agree with you. my bad.

user can just read the essential information here and doesn't have to hit my page , sure.

so in a nutshell :
1. either you go with [https://chocolatey.org/](https://chocolatey.org) and install it on your dev box (and CI) => you install pester globally with :
**choco install pester** and update it if needed.

2. **use old packages.config** and update by hand version number and run **nuget restore** (nuget update will no longer work for this type of solution).

3. version whole pester into repo and call it directly.


I know these are sixteenth sextuplets, but I was wondering what these are called when they share the same staff? And how they're played?

Question:
I am trying to figure out what they are, I've searched on YouTube but I don't think I have the correct keywords to find out what I'm looking for... Are they played like double stops or played differently?
Comment: One phrase that describes these is "needlessly complicated."
Comment: What piece and composer?
Comment: @phoog My money is on the MuseScore website.
Comment: @Aaron really?  The typography looks a bit more refined than what I'd expect from MuseScore.
Comment: @phoog The red highlight is a dead giveaway for the website, and it matches the alignment in MS3.
Answer: You're right that the vertically aligned notes are meant to be played at the same time, but if this is an ensemble piece, the part is almost certainly intended to be played divisi (divided), where half the section plays the upper voice and the other half plays the lower.
The giveaways include how difficult it would be to play non divisi (in this case, extreme enough to override pretty much every other consideration, including composer intent) and the fact that they're notated as separate voices even though the rhythm is the same. The composer will usually write divisi when it applies and can also write non divisi to reinforce the default.
Answer: As I suppose is clear by now the question isn't so much about the sixteenth sextuplets but about the two voices happening simultaneously.  As you say, you know that they are sixteenth sextuplets.
In support of the answer from the-baby-is-you, double stops would normally be written with a single stem having two noteheads (at least for the last couple of centuries).  As a consequence of each double stop having a single stem, there would be one beam instead of two.  So even without knowing how difficult these would be to play as double stops, we can see that they aren't double stops.
Normally, downward-pointing stems belong to the lower voice and upward to the upper voice, so the fact that the parts "cross" here is confusing.  It requires the noteheads to be offset slightly.  I would first ask whether the parts should be swapped -- have the firsts play the higher notes -- to avoid this.  Perhaps it was done this way to allow the beams to be closer to the staff.
Another possibility is that this does not represent a divided cello section but rather divided cellos and basses.  In this case, all the cellos play the upward-pointing stems and all the basses the downward-pointing stems.  There should be a notation indicating this at the beginning of the division, but if the two sections are on the same staff and there is no such notation then you should probably assume that this is what it means.
Regardless, the score would be clearer if the two parts were put on two staves.


Dynamic menu with latest Article in drupal7

Question: I'm a bit new to Drupal environment. I'm trying to develop a demo site for CMS application. Now I'm facing a difficulty to create a dynamic menu for showing taxonomy-wise latest Article. Can I do it with any existing module (Muchomenu, OM Menu etc.,)
Thanks....
Answer: I am sure there is a module do to something like that, but you could also create your own.
You could use hook_menu() to query for the items you want and return the correct menu structure. You would need to also make sure the menu cache is rebuilt on a node save.
hook_menu should return an array of menu items, often these are pretty static however there is nothing wrong with these arrays being dynamically generated.
So you can query the node table to get a list of nodes you want, loop through these items and dynamically create an array which contains the correct menu items.
very roughly:
<code>function example_menu() {
  $result = db_query('select * from node where ...'); // put in your own select items and where clause
  $menu = array();
  while ($row = db_fetch_object($result)) {
    $menu['my_path/' . $row->nid;] = array(
      // See hook menu docs for what to put here.
    );
  }
  return $menu;
}
</code>


Accurate understanding of the physics of sound?

Question: I'm trying to learn theory. I'm starting with the physics of sound as the base. Here is what I (think I) know. Is this accurate?
Music is sound. Sound travels in waves. Sound waves have two properties: amplitude and frequency. Amplitude is the height of the sound wave and determines how loud something is. Amplitude has basically nothing to do with note differentials (i.e. A, B, etc.). Frequency measures sound wave cycles per second in hertz (Hz) and has everything to do with note differences. Each note has its own frequency. The general reference point with guitars is A = 440Hz. The audible spectrum for most humans is from 20Hz to 20000Hz. A 20 fret guitar with standard tuning ranges from 82.4Hz (E) to 1318.51Hz (E).
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/92380/discussion-on-question-by-gc123-accurate-understanding-of-the-physics-of-sound).
Answer: I went down a similar road. There is an entire branch of physics related to sound that is called acoustics. Starting to look for books and more information on "acoustics" will help you find more and better materials as you move forward.
The subject of acoustics is pretty broad - there are many aspects of acoustics that are not directly applicable to understanding music. All music is sound, but not all sound is music. You might further narrow searches by looking for "musical acoustics".
Finally, there is a branch of science that isn't exactly psychology, physiology, or physics, but the branch deals with the intersection of all of those, and that is called psychoacoustics. Psychoacoustics is very relevant to the musical experience for the listener, and its findings can be very edifying to the musician, composer, and other musical creatives. It's basically the study of how humans generally interpret different sounds.
With that out of the way, let's address what you're trying to understand right now.

Music is sound. Sound travels in waves. Sound waves have two properties: amplitude and frequency. Amplitude is the height of the sound wave and determines how loud something is. Amplitude has basically nothing to do with chord differentials (i.e. A, B, etc.).

That's a pretty good grip on things up until the last few words. I think what you really mean by "chord differentials" is just "different notes". While it's 99% true that the amplitude or intensity of a sound wave does not affect the pitch (the scientific term for the perceived note) of a sound wave, it turns out that there is a very minor shift in pitch perception of the human ear between louder and softer sounds. Generally, we don't worry about this at all, because it's far too minor, but if you really want to know the science, then it has been observed that sound intensity affects pitch perception. As a musician, you can pretty much ignore that when composing or performing, at least for now.

Frequency measures sound wave cycles per second in hertz (Hz) and has everything to do with chord differences. Each chord has its own frequency.

Replace the word "chord" in that sentence with the word "pitch" and you'll be getting a lot close. From your question, I wonder if you might leave alone the idea of chords for right now, and focus on single notes or pitches. Remember, pitch is the scientific word for the perception of a note. The word "perception" is critical here, because a frequency or frequencies doesn't become a note until it is heard and decoded (perceived) by a human ear and brain. The thing is, the human ear and brain are not prefect scientific instruments - our perceptions can be funny sometimes.
Generally, yes, every pitch we perceive is based on a specific fundamental frequency. At the same time, actual musical sounds are almost always composed of many frequencies of sound all playing at the same time. Even a single note played on a instrument will produce many frequencies. The reason why we perceive several simultaneous frequencies as a single pitch or note is because those frequencies all have a mathematical relationship with each other. An example of a musical sound composed of many frequencies that are not related to a pitch is a crash cymbal. The frequencies of sound created by a crash cymbal do not have a mathematical relationship to each other, so instead of hearing a pitch or a note, we hear a kind of noise. That noise is still a musical sound (usually), but it's not a pitch or note. So the relationship between frequencies and notes is very important, but it's not very simple.

The general reference point with guitars is A = 440Hz. The audible spectrum for most humans is from 20Hz to 20000Hz. A 20 fret guitar with standard tuning ranges from 82.4Hz (E) to 1318.51Hz (E).

As others have noticed, the reference of 440 Hz for the A above middle C is a standard across all instruments, but it's not a universal standard. It is most popular in the USA (if I understand correctly). Some musicians and ensembles around the world that use what I will call "western" instruments (e.g., strings, brass, woodwinds, guitar, piano and the like) may tune to other standards like 435 Hz. Non-"western" instruments (e.g., sitar, gamelon, even bagpipes, etc.) may have entirely different and not at all standardized tunings.
The rest of the last quote above is correct, although there has been some dispute about how reliable the 20 - 20,000 Hz figure is.
Comment: @GC123 That's a good point I had forgotten can be confusing: Notes and chords can sometimes share the same names. For what it's worth, when a chord has a name that looks like a note, such as "an A chord", that means that the chord has the note of the same name as one of its notes. So an A chord has an A as one of its notes, and a Bb chord has a Bb as one of its notes. Also, notes can never be major or minor or diminished or 7th all on their own, so as soon as you see anything after the letter, like Am7, you know it's a chord, and not a note.
Comment: Yes, I said chord but meant note, thanks. My vocabulary is a bit limited still. It gets confusing because both notes and chords are measured in octaves from A to A. In theory (no pun) it would be easier if the components (notes) and product (chords) didn't have the same alphabetic and octave classifications.
Comment: As a matter of interest, when you teach, what percentage of the time is spent on this side of lessons?
Comment: @Tim I'm a little confused by the phrase "this side of lessons", but I don't think this stuff has come up before. I'll teach a student anything they want to know, even if I don't know it (yet) myself, and I generally let the student guide where we go. So every student learns different things. I don't think a student has ever taken us too far down the road of acoustics before.
Comment: I meant how much of a lesson would you normally spend on this facet of music with a student, given that it's done so well for you, as you say. I'm wondering whether you as a teacher deem it as an important part of the learning process, from what's in your answer. It's fairly obvious that I'm on the other side of the coin (from my answer!), but it's interesting to hear other teachers' takes on what gets included in lessons - and since this aspect appeared important, I wanted to know if it was in fact included in your lessons.
Comment: @Tim I don't have set lessons. I spend each session with each student working on and talking about a combination of what the student wants to know and what the student needs to know to accomplish their goals. I have had students who prefer the technical approach, and like to know the details of the physics, acoustics, electronics, etc. about music and their instrument. Other students want to focus on sounding just like Daron Malakian, or jazz improv, or songwriting. I cater each session with a student to the student and the situation.
Comment: @Tim Maybe it will be clearer if I note that studying the acoustics and psychoacoustics of music was a very important part of **my** learning process. Since everyone has different goals and everyone learns differently, just because something was important (or unimportant) for me doesn't mean it will be for anyone else. I find the natural curiosity of every student is an excellent guide to what knowledge will help them the most, so I endeavor to answer **every** question a student asks and I have **never** said anything like, "you don't need to know that".
Answer:
I'm tired of rote memorization.

You should not think your choice is between rote memorization (of something, I suppose you mean music theory) versus acoustics which is the science of sound - the hertz, waveforms, etc. you mention.
The acoustics info you put into your question is already more than you need to know to study music theory.
The vast bulk of music theory doesn't require acoustics knowledge. The overtone series is about the only thing comes up to (try) explaining the perception of consonance/dissonance.
The non-rote approach to music theory is all about pattern recognition and relative relationships. Even some things that seem like rote knowledge - key signatures, interval names, etc - can be broken down into categories and patterns.

I want to understand why say a pentatonic is constructed the way it is. TO understand that I need to understand the fundamental blocks.

These kinds of question come up a lot. Stuff like 'why are triads the basic kind of chord', 'why does major sound happy', 'where did the major scale come from', etc.
There are usually two kinds of answers:

because it sounds good
the intervals involved are acoustically resonant which is perceived as sounding good

Perfect fifths are very consonant and stable. They are super important in music theory. If you stake up four perfect fifths...
C G D A E
...you get a pentatonic scale.
That would be a typical music theory explanation of why a pentatonic scale is constructed as it is. But, as you can see, that explanation didn't really require any acoustical science.

EDIT
I want to make an addition after reading this comment on another answer from the OP:

Also, theory is confusing. There are 12 notes in an octave from A to A. But octave is Latin for 8. Most skip the flatts/sharpes. Unless you start in a different key. These then are used to make chords. Chords also span octaves. So it is like level 2 of octaves. Chords are combined in different ways to make songs. Typically I IV V but not always. Then there are scales. Seemingly these can be chords and tones/notes. And these can be subdivided into pentatonics if you remove 4 and 7th or 2nd and 5th depending on major or minor. It is, to me, a confusing mess.

I want to elaborate on just one point to illustrate what seems to me an incomplete, lackadaisical attitude about theory which will not be remedied by applying acoustics.

There are 12 notes in an octave from A to A. But octave is Latin for 8.

You didn't really complete the thought. I think you meant to ask "why doesn't an octave contain 8 tones instead of 12?" The information you need to understand the answer is a combination of music history, etymology, and cardinal versus ordinal numbers.
Historically western musical scales used 7 diatonic tones which repeated "at the octave." Each tone was represented by a letter. In modern English the letters are A B C D E F G. to show the repeating at the octave let's use scientific pitch notation and write two octaves A4 B4 C5 D5 E5 F5 G5 | A5 B5 C6 D6 E6 F6 G6 | A6.
In music theory an octave is the distance between A4 and A5 or A5 and A6. In muisc theory those distances are called intervals and the interval names are based on the ordinal number in the tone series. A4 is first, there isn't no distance with only one tone, it is called a unison. B4 is second, the distance from A4 to B4 is called a second. As we continue up the series A5 is eighth and the Latin word for eighth is octavus from which the name of the interval is derived: octave. (The Latin cardinal for the quantity is octo, etymologically it is not the origin of the word octave.) Octave does not represent 8 as a quantity it represents the ordinal number eighth!
From a quantitative perspective an octave contains 7 tones, 7 pitch classes (heptatonic, Greek origin.) Historically, as music evolved chromatically, tones were added by half step between certain letters and indicated with sharps and flats. There are 12 chromatic tones in an octave. The common tonal system used today can be described as diatonic system modified with chromaticism. The 12 chromatic tones didn't replace the 7 diatonic tone system and music theory reflects that. Many theory concepts are in reference to the 7 tone diatonic system.
Notice that acoustics will provide absolutely nothing helpful to understanding these concepts. The reason is because music theory is it's own field of study! Like any other serious study it requires time to develop deep understanding.
Comment: But all of this is a kind of philosophical distraction to just studying music and learning theory terms. You only need to ask these "why does it sound good" questions if you somehow doubt what your ears tell you. But, I get the desire for an answer. I asked the same questions too. You just don't need a lot of acoustics knowledge to get the basic answer. Then when you ask other questions about harmony - why minor - the acoustic completely fails us and is revealed as not all that relevant to music as an _art_.
Comment: I would agree that one doesn't **have** to master any of the sciences to excel as an artist, but I strongly believe that no one should ever be dissuaded from taking a scientific approach to the arts. There's nothing wrong with doing so, and everyone has to take their own journey.
Comment: Using perfect fifths to explain the pentatonic scale leads me to immediately wonder, why are perfect fifths "very consonant and stable"? Certainly the fields of acoustics and psychoacoustics can speak to that subsequent question.
Comment: Read my third sentence re. overtone series. Again, that's about the only acoustic science idea that seems necessary or the Pythagorean interval ratio explanation.
Comment: I have used scientific understanding of all kinds of things to help me be a better artist, from acoustics for music to color theory for the graphic arts. While I'm not a dancer, understanding the sciences related to how our bodies work is certainly helpful. And we should not forget the many, many artists who took scientific approaches and produced compelling works of art. Georges Seurat springs to mind immediately. The arts do not stand alone in human thought. they are linked to science, philosophy, politics, psychology & medicine, etc.
Comment: Definitely agree with that! You should always try to add, expand, support with a wide understanding. But the OP seems to want to _start_ with acoustics. That's kind of backwards IMO. They should at least hear that it probably isn't necessary to _start_ that way.
Comment: I was just thinking of all the ways my studies of guitar, violin, and especially clarinet have been *greatly* aided by my understanding of the acoustics and mechanical physics of those instruments. Knowing the acoustic properties of the clarinet has helped me learn both embouchure and fingering. It's much easier to remember fingering when the fingering actually makes sense from an acoustic standpoint. Same is true for embouchure and understanding the process of initiating and maintaining a vibrational regime in the air column. **I started with acoustics**. It definitely worked for me.
Comment: I think OP already knows that acoustics isn't the way most people start - they've just become frustrated with the "normal" way and have decided to try a different approach. They specifically commented that they are tired of doing it the typical way and they are seeking a different kind of understanding.
Comment: Yes. I don't think it helps me much on piano. But I shared stuff about harmonics and the tube length/values re. trumpet with my son, so he would have a basic knowledge of how it produced pitches. So I get the idea. But don't put the cart in front of the horse. He didn't need that to start playing and progress.
Comment: @MichaelCurtis Thank you for the info. The one thing most seem to agree on is everyone has to take their own path to theory. To me, that points toward unnecessary complexity and a field asking to be simplified. Maybe that's possible and maybe not since theory in the end seems a bit arbitrary. Why is an A and A. Couldn't A be B. A = 440Hz unless it doesn't.
Comment: @MichaelCurtis There seems to always be a "but" with music theory. But, sound is sound. It is measured in Hz. That much seems universal from the laws of physics and thus a good "stable" starting point. From there, it all seems to become an arbitrary hodgepodge of centuries of methods and anything can be changed. We could just say oh this octave should have 24 half steps or someone decides no A is 436.927 Hz. However, there has to be some stable baseline from which to grow understanding. If its all unstable and arbitrary, what's the point?
Answer: You are generally correct, but you have a few errors.

When you say "chord" is think you actually mean "pitch." A chord contains multiple pitches.
A = 440 Hz is standard for all Western instruments, not just guitar.
The highest note on a 20 fret guitar would be a C = 1046.5 Hz

Lastly, these facts have more to do with the field of acoustics, than with music theory. Music theory tends to deal more with the pitch names (A, B, C, etc.), than with pitch frequencies.
Comment: @GC123 -- I don't have any good web resources for you because I don't really use them. Even some of the websites that I have looked at that seem pretty good contain some mistakes, and these sorts of mistakes can be really confusing for learners. Good books have editors, and hopefully fewer mistakes. You can find some recommendations for books by searching the site. I really like the videos Jens Larsen has been posting at YouTube, and Rick Beato has a lot of good videos which might be worth checking out. Both of these, especially Jens, are mostly focused on guitar.
Comment: Thank you. As I understand it, pitches span an octave. I personally cannot hear octave equivalence. I wonder if I might be tone deaf the same way people are color blind. As to this being irrelevant, I disagree. An octave spans from A to A which corresponds to a doubling of Hertz. So music theory in terms of pitch names (A, B, C) correspond almost exactly to hertz frequencies.
Comment: Why does this matter? To me, tone deaf to octave equivalence, I at least understand why theory repeats A, B, C, etc over and over. It certainly isn't logical. But it equates to Hz. From there, I can understand the repetition. And that serves as a baseline for trying to understand 12 pitch octaves vs octave usually being 8 vs scales and ultimately pentatonics. Without an understanding of the parts, I'm not sure its possible to get beyond rote memorization. At least in my case.
Comment: @GC123 -- pitch names do not "correspond almost exactly" to frequencies. Beyond the fact of octave equivalence there are different temperaments, and pitch names are an abstraction that allow temperament to be ignored in notation. An over-concern with the physics of sound production is in most ways the wrong path for a musician.
Comment: David, could you explain why this is not correct then? https://www.liutaiomottola.com/formulae/freqtab.htm
Comment: @GC123 -- if you want to ping someone, prepend their username with the @ symbol. The table you linked to uses [Scientific Pitch Notation](https://en.wikipedia.org/wiki/Scientific_pitch_notation), which is an absolute pitch standard, but that is only one convention. Historically, many temperaments were used, and even today orchestras and string players in particular use different temperaments. In these [other temperaments](https://en.wikipedia.org/wiki/Musical_temperament) different frequencies correspond to the note names.
Comment: @DavidBowling Thx. And this kind of speaks to why I went the physics route. Sounds are waves. Instruments make sounds. Theory is a confusing bolted on clusterf. 90% of musicians I believe just avoid it because it is too confusing (see this post). I'm trying to become a better player by understanding fundamental rules of how the convoluted topic that is theory works in modern times. I welcome any guidance on a better approach to learn. Not afraid to do the research, just find most materials are confusing and make quantum leaps. Most people/teachers really don't understand.
Comment: @GC123 -- it takes awhile to absorb theory, but you have to take it on its own terms. That said, music theory is not really one thing: there are many differing approaches. It has evolved in different contexts to serve specific needs. If you think that most teachers don't understand theory, you need to be talking with a better class of teacher. Players need a _working_ understanding of theory, which might be none at all for some players. Learn theory _as you need it_ on your journey to become a better player. Certainly on the internet there is plenty of confused misinformation, though.
Comment: @DavidBowling "confused misinformation" is correct. Can you recommend a reliable source? I'm hoping to find a book/website/whatever that goes from A to Z and allows me to understand enough to at least have a vocabulary to explain myself well.
Comment: 440 is a generalized standard at present, but many groups, from garage band to Berlin Philharmonic choose some other value for A.
Answer: When one starts to learn about the theory of music, one never starts with the physics behind it. Physics is a science, and music is an art. One cannot use one to understand the other.
That apart, knowing the info. you point out - which is not all accurate - has no great relationship with music theory. Music theory is a set of ideas that have been found to work over centuries, and listed/explained in theory books for others to understand what can and does work. It is reflective rather than a set of laws which must be obeyed in order to make 'good music'.
Strongly suggest you ditch the idea, and read about some theory, whilst learning an instrument. Better still, find a (good) teacher, and put yourself in their hands.
Comment: Tim, not trying to argue but I disagree. I have several teachers, each seems to have a slightly different understanding of theory. I've yet to find someone who can explain it in a way I understand or that seems to have a comprehensive grasp. Given probably 90% of guitar players I meet don't seem to have a clue either, I don't think I'm the exception to the rule.Below I added some comments on why I care about Hz and such if you care and where I'm trying to go with all of this. Thanks
Comment: -1, not for the opinion on usefulness of physics as a starting point for music theory (mind, I sure enough do disagree with you there, but that's subjective), but for answering with a comment that doesn't answer the asked question.
Comment: When I started learning about music, **I** started with the physics behind it (i.e., acoustics), and I'm doing just fine, thank you. "*Physics is a science, and music is an art. One cannot use one to understand the other.*" I don't think I've seen anything on Music.SE I disagree with more strongly than that statement.
Comment: @GC123, you seem to think that physics will eliminate the different oppinons regarding theory.  As a physicist and musician I can say you are mistaken.  Ambiguities in music theory are more likely due to (1) not having a good education, (2) forgetting the basics, (3) making stuff up.  Helmholtz tried to use physics to understand why certain combinations of notes (harmony) are more pleasing than others.  His work was somewhat successful but there are cultures that think dissonant intervals are pleasant while consonant intervals are unpleasant.
Comment: @ToddWilcox -- I am going to have to get behind Tim on this a little bit. I don't at all think that an understanding of physics is useless for a musician (I was once a physicist, after all). But looking at the physics of music has almost nothing to do with the practice of playing music; i.e., it doesn't really help me to understand why a chord substitution works, or what scales I might play over a chord, or what turnarounds are idiomatic to the blues, or how passing notes are used in bebop, or why Art Farmer had such great phrasing. But there is no royal road to music....
Comment: @ToddWilcox -- you are absolutely right that physics (and acoustics and pshchoacoustics) are useful and can help us to understand certain aspects of music. Helmholtz has long been a hero of mine. I'm not sure that we _need_ physics to understand orchestration, but why ignore a good tool, and maybe new insights come with that. I do doubt the utility of beginning a personal musical journey (for most learners) at the science of sound production. I think that the most important musical questions lie in a different domain, and a scientific approach comes with risks of reductionism.
Comment: @GC123, continued... Helmoltz's premise is based on Western brainwashing.  It is interesting that somehow physics theory helped explain it but it possible that the connection is a coincidence.  One could argue that cultures that enjoy dissonance over consonance are somehow less evolved.  That is a dangerous path to follow (and I am sure Europeans did in the 1800s - early 1900s, perhaps always).  In short Physics does not explain or describe Music the way that you seem to think it does.  It does explain how instruments work, mechanics etc.  But not why 7-->8 and 4-->3, or why we like that.
Comment: I disagree it cannot explain differences in music theory, for many reasons.
Comment: @AlbrechtHügli Studying female anatomy has definitely improved my sex life. Studying color theory has improved my work as a visual artist. Studying grammar, etymology, linguistics, Latin, Russian, and Japanese have all improved my abilities as a writer and poet. Regarding whether it's a fake question, in the USA, there is **zero** acoustics taught in public schools. Musical acoustics is not even taught to all music students in universities in the US. Just because you learned it at a young age doesn't mean that anyone else did. I learned it in my 20s through self study.
Comment: @GC123 -I understand the problem (I think), but relating notes,whether in name or pitch,to Hz gets complicated.Most are not whole numbers, due to the maths involved,so I don't see how that aspect is going to help.You can't feel the Hz (or can you?), but I think eventually (and that's the case with most) that listening and playing will make more sense.There are a lot of guitarists out there who don't know or use theory - it does seem a common thing with guitarists, having played with hundreds - and I'm not sure why.That in itself doesn't hold a lot of them back, so don't think I'm knocking; ...
Comment: ...I play and teach guitar! It's just that there are already systems that work well for most prople, and are accepted. So, even if you go down this route, which in my opinion is already flawed, no-one else is going to be talking the same language as you. Ia having *several* teachers a good idea? Most here would probably agree with me saying no. You must be getting conflicting ideas, which as a beginner you'll not be able to sort the wheat from the chaff.
Comment: Thanks Tim. Can't we all feel hertz?! Half joking, we feel sound waves and sound waves are hertz so. I truncated down my original post which had a lot more depth. The somewhat short version is, I do play guitar (reasonably well) and I realize not knowing theory hurts me. I can memorize pentatonic "boxes" but if I shift to an alternate tuning I'm lost without the internet telling me what to do. I'd like to truly understand why certain chords/tones work together.
Comment: That's fine. My left nipple vibrates at 440Hz. That gives me a sort of absolute pitch. Just joking! But understaning how certain notes blend together isn't going to be helped by being aware of their frequecies - even though that does have a lot to do with the phenomenon. Put another way - would knowing what the ratios of the gears in your car's gearbox make it easier to drive?
Comment: Also, theory is confusing. There are 12 notes in an octave from A to A. But octave is Latin for 8. Most skip the flatts/sharpes. Unless you start in a different key. These then are used to make chords. Chords also span octaves. So it is like level 2 of octaves. Chords are combined in different ways to make songs. Typically I IV V but not always. Then there are scales. Seemingly these can be chords and tones/notes. And these can be subdivided into pentatonics if you remove 4 and 7th or 2nd and 5th depending on major or minor. It is, to me, a confusing mess.
Comment: @DavidBowling But acoustics and psychoacoustics do help us understand how the Balinese gamelon are tuned and played and why they sound the way they do. They can help us understand why using the damper pedal on piano sounds different from merely holding down the notes we want to sustain, why different temperaments work for different situations, why you don't want to write fortissimo for four trombones at the same time you have mezzo-forte for 20 violins (or ever, really), and so many other things.
Comment: I understand, to a degree, the naysayers. But what about when the OP tries to understand, using Hz, when A=440Hz gets changed to, say, A= 435Hz. He's juggling with numbers, and to me at least, that's going to throw a spanner in the works. And, since music is basically shared aurally, how are numbers going to help? To musicians, even if the whole orchestra or band is tuned to a different A, it matters little as far as producing good music is concerned. Perhaps to those with absolute pitch...
Comment: Seems like Gary Burton for one thinks that understanding the difference between 440 Hz and 442 Hz is musically significant: https://music.stackexchange.com/questions/40605/why-is-a-442-the-common-tuning-for-percussion-instruments
Comment: @ggcg I don't think physics/acoustics will eliminate different opinions at all. I think it could serve as a stable "base" upon which to understand differences in theory.  My understanding is any sound will produce a unique frequency. Whether a given culture calls that A or C will vary. But you cannot deny the frequency equivalence.  It is like a law of nature right?
Comment: @GC123 - I think you're right, but it's a small part of theory, not generally known, and if you continue thinking in terms of frequency, unless you start writing that out - and few will understand - then eventually, you'll meet the notes as most of us know them. At which point, how much better off are you, having spent a long time as a 'voice in the wilderness'. That's more my concern than is it a good idea or not; but that leads back to my answer.
Comment: @ggcg - I'd be interested in your answer. Maybe I'm missing some points.
Comment: Vote up for Tim! It's the only correct answer to a weird question like: *will I have better sex after studying gynecology?* Honestly I don't understand the attention that is paid to this question. What OP says about acoustics I've learnt in the 8th class of secondary school and is subject of the first trimester of each music student.  In my opinion this question is a fake of a13 years old pupil who had some lessons by amateur guitar teachers - who is octave deft as he says and tiered of rote memorizing. Understanding and learning of music has little to do with rote memorization but with love.
Comment: @Todd: this is really surprising to me. Each music book I have in German starts with the basics of acoustic. I must apologize for my skepticism against OP. His opening phrases have been the reason that I was sure this was a joke. And I honestly didn't understand why and how the idea to measure physically the own voice  range and the correlation with the pitch of songs to find out which songs would fit best for singing ... how this idea could evoke such a broad discussion about physics and music.
Answer: To add to the other answers, sound waves don't really have a "height".  They are actually waves of high and low air pressure that radiate outwards from whatever is making the sound.  Or, equivalently, the air molecules that are subjected to the sound wave vibrate backwards and forwards, rather than up and down.
People tend to draw sound as if it were "up and down" waves, just because that's a lot easier to draw.
Comment: They certainly do have a height: plot pressure vs. time.  For that matter, if you were to propagate a pressure wave down an elastic tube, you would see the tube expanding where the pressure wave is greater than 1 atm and collapsing where it's less than 1 atm.
Comment: That expansion, if it is really there, is due to the strain on the material of the tube.  It does not imply "height" or that there is a transverse component to the acoustic wave in the air.  Waves in fluids (air, water) are purely longitudinal.
Answer: Ok, first there is no music, or sound for that matter without air, and water. the sound vibrates the water molecules in the air, this carries the sound along. thicker the air is with water vapor, the farther the sound is carried. that's why speakers will produce sound that carries great distances underwater. Dolphins, Whales can be heard singing for miles underwater. acoustic dynamics is fluid dynamics. withoutout them you hear nothing.
Comment: Sound propogates just fine in dry air (which is a compressible medium: exactly what is needed to propogate sound waves).


Can this note be analyzed as a non-chord tone?

Question:
I know that post-tonal and popular music can't always be analyzed through the same methods as the Common Practice Period, but I still like to see how people would try analyzing things.
This is a chord progression from a song that came out last year that I love ("Fragile" by Yes).
In the second chord (C/D), would that simply be analyzed as IV/pedV? I don't know if the D is a pedal tone since in the next chord it moves down to the G, and it's not really a suspension since it doesn't resolve to anything there.
Is this simply too different from tonal practice methods to be analyzed the same way classical pieces from the past would have been?
Comment: For what it's worth, to my antiquarian-habituated ears this is just a perfect cadence decorated with a plagal cadence. To me it has a softening rather than an intensifying effect. The G in the second chord is an anticipation, which contributes to this softening effect.
Comment: What do you do with the results of such analysis? If it's for a theory class or something, then you should ask your teacher. :) But if you want to understand the essence of the chord progression for something practical, in order to find ways to handle or utilize it in e.g. soloing on it or making arrangements, then I recommend experimenting with its applications. You suspect the C/D works as a V chord, so try replacing it with other known V role chords. Then try using this new chord in other songs as a V chord, to see how it changes things there. Then you learn to _actually_ know the chord.
Comment: Why is C/D not a suspension? I think it's quite similar to D7sus4.
Comment: you can interprete it as you want: as suspended tone, as non chord tone or as  IV/V.  Mind that all the systems of analysis are only abstractions and also inventions of musicians or even non-musicians, so no one can say: this is the only correct analysis. You could only say referring to the theory of  Riemann or RNA or pop music this chord could be analysed as ...
Answer: I would personally view this second measure as its own chord that embellishes the previous measure. In popular music, it's very common to have a IV chord over scale-degree 5 in the bass. Some call this a "rock dominant," and it's basically just a particular voicing of a V11 chord. (See also Is there a specific name for the use of IV chord over the V in the bass, e.g. F/G in the key of C)
Looking at this chord in context, it just adds some extra dissonance above the already tension-filled dominant chord to help lead to the succeeding tonic even more strongly.
Answer: It's a very common chord progression. The C/D works as a milder or more ambivalent substitute for D7. You could think of it as having a sus4. Other chords that work similarly are D11, Dsus4, D7sus4.
When you have a "can this be analyzed as an X chord" question, why not treat it like a hypothesis and then try to prove or disprove it? If you think the C/D chord could be seen as serving a V chord function, take existing songs that have a V chord (just about any song will do, because almost all songs have a V chord somewhere), and replace the V chords with IV/V chords. How does it change things? When does it work and when does it not work?
Answer: If the bass is held and considered the non-chord tone, I think the only traditional non-chord tone labels available are suspension or retardation, but those technically require resolution which doesn't happen in the example.
You could flip your non-chord tone labeling and call the bass tone the consonant tone and the treble voices the non-chord tones.
Dropping some voices to simplify and shifting some metrical placement we can get the following which is a basic escape tone.

Shift those notes metrically to get back to your example...

...add the additional voices and you might consider this some kind of accented, triple escape tone group...

Personally, I think my explanation above is trying to shoe-horn the music into a traditional non-chord tone identity, but I thought it might be valuable to try identifying an appropriate non-chord tone.
(One might grope further and find a combination anticipation in the G and passing tones in the C E.)
While an escape tone might - kinda, sorta - fit on paper, I don't think this provides a satisfactory explanation.
Why isn't it satisfactory? Because we first need a notion of what is dissonant and that is a matter of style!
Slight digression: in basic blues we use primary triads I, IV, V but all harmonized as dominant-seventh chords where there is absolutely no need to resolve the sevenths. In other words you can say the sevenths in those chords are not considered dissonances. I think you can also say the tritone isn't dissonant in blues harmony, certainly not in the common-practice era sense.
Perhaps we can approach this music example in a similar way.
I think in some pop music styles there is a kind of primary chord superimposed harmony where just about any pattern outlining the primary chords of a key can be combined with another such pattern without the two patterns necessarily aligning vertically. Any such combination is deemed consonant. It's sort of like pandiatonicism except it focuses on the primary chords. I don't know any musical term to describe it.
In the example we clearly have V IV I in the treble part over dominant and tonic tones in the bass. Both patterns separately are simple, direct outlines of the primary harmonies of G major. The fact that the middle bar has a "mis-aligned" C chord over a D in the bass doesn't represent a dissonance. Any combination of the primary harmonies will be considered consonant.
I suppose if we are trying to escape from using Roman numeral analysis or jazz symbols on this (and I think we should) instead of writing V I or D C/D G or something like that, it would just be G major and then the analysis focus might shift to rhythm or changes to the overall tonal center.
This isn't my own original idea. I first read it somewhere as an explanation of harmony in African Highlife music. It makes sense to me as a description of that musical style and I think it can also apply to rock and other pop music.
Answer:
Can this note be analyzed as a non-chord tone?

you can interprete it as you want: as suspended tone, as non chord tone or as  IV/V, as Richard says: a V7911.
Mind that all the systems of analysis are only abstractions and also "inventions" of musicians or even non-musicians, so no one can say: this is the only correct analysis. You could only say referring to the theory of  Riemann or RNA or pop music this chord could be analysed as ...

In the second chord (C/D), would that simply be analyzed as IV/pedV? I don't know if the D is a pedal tone since in the next chord it moves down to the G, and it's not really a suspension since it doesn't resolve to anything there.
Is this simply too different from tonal practice methods to be analyzed the same way classical pieces from the past would have been?

There have been many errors in music theory and methods of analysing:
it's nonsense to analyse

Gregorian Chant by counterpoint rules of Fux

Palestrina and other contemporary music by classicle harmony practice

12 tone music with RNA or figured bass

Romantic piano compositions by the counterpoint rules
etc. etc.


Bessel functions and PDE steady state temperature

Question: If $u = 0$ at $r = 10$ and $u = 100$ at $z= 0$, how can we find $u$ at $r = 5$, $z = 10$.
So the situation is for a steady state temperature in a cylinder where coefficients $c_m = 200/(k_m J_1(k_m))$ of the series $u = \sum_{m = 1}^\infty c_m J_0(k_m r) e^{-k_m z}$ where $J_0$ denotes the Bessel function of first kind.
This is from Boas Mathematical tools physical science, not homework, but a practice question
Comment: Are you suposed to get an analytical solution, or a numerical one?
Comment: numerical one with an expression
Answer: For the condition at $r=10$, you have
$$k_m = \frac{j_{0,m}}{10}$$
where $j_{0,m}$ is the $m$th zero of $J_0$.  Because you have already specified your coefficients, I am not sure of the use of the condition at $z=0$; you should check to see if this condition and the values specified for the coefficients are consistent.
Given the values of the $k_m$ and $c_m$, you need to evaluate that sum numerically for $r=5$ and $z=10$.  You should specify some precision so you know when to stop summing.  You will need a table of zeroes of that Bessel function as well.


Differentiability of $f(x)=\sum\limits_{n=1}^\infty \frac{1}{n} \sin\left(\frac{x}{n}\right)$

Question: Thanks a lot for your help for the previous question: Let $f(x)=\sum\limits_{n=1}^\infty \frac{1}{n} \sin(\frac{x}{n})$. Where is $f$ defined? Is it continuous? Differentiable? Twice-Differentiable?
$f(x)=\sum\limits_{n=1}^\infty \frac{1}{n} \sin\left(\frac{x}{n}\right)$
So I've fully understood how the function is defined for all $x\in\mathbb{R}$ and continuous (through the concept of the uniform convergence using the Mean Value Theorem and the Weierstrass M-Test), but I'm now stuck at its differentiabiltiy and twice-differentibility.
I first naively assumed something similar to Differentiability of a Uniformly Convergent Series; my basic idea is that if a series is uniformly convergent then it's also differentiable, using *Term-by-Term Differentiablity Theorem, but the answer above the posting says that it cannot be generalized.
How should I prove $f(x)$ in my case is differentiable (and/or twice-differentiable as well)?

* Term-by-Term Differentiability Theorem: Let $f_n$ be differentiable funcitons defined on an interval A, and assume $\sum\limits_{n=1}^\infty f'_n(x)$ converges unifomly to a limit $g(x)$ on A. If there exists a point $x_0 \in [a,b]$ where $\sum\limits_{n=1}^\infty f_n(x_0)$ converges, then the series $\sum\limits_{n=1}^\infty f_n(x)$ converges uniformly to a differentiable function $f(x)$ satisfying $f'(x)=g(x)$ on A. In other words, $f(x) = \sum\limits_{n=1}^\infty f_n(x)$ and $f'(x)=\sum\limits_{n=1}^\infty f'_n(x)$
Comment: Well ... what is the series of derivatives?
Answer: Sketch: The cool thing here is that you don't have to prove the series defining $f$ is uniformly convergent, or even pointwise convergent, everywhere. Since the series obviously converges at $x_0=0,$ we are off to a good start in using the differentiation theorem.
Now the series of derivatives is
$$\sum_{n=1}^{\infty}\frac{\cos (x/n)}{n^2}.$$
That series converges uniformly on $\mathbb R$ by an easy application of Weierstrass M. Thus, invoking the differentiation theorem, we have the series defining $f$ uniformly convergent on every bounded subinterval of $\mathbb R$ as well as the result
$$f'(x)= \sum_{n=1}^{\infty}\frac{\cos (x/n)}{n^2},\,\,x\in \mathbb R.$$
The series of second derivatives now awaits your consideration.
Comment: Also, the link I referred says that uniform convergence doesn't necessarily imply its differentiability, but it seems as you're using the fact that the series converges uniformly by Weierstrass-M Test to invoke the differentiation theorem (which I don't exactly know what it is); is it all right to do so?
Comment: Hi, thank you for the answer. Please understand that I haven't had a chance to have a formal math education so I'm self-teaching math for some reason, mainly for health concerns (I guess I need to write this comment ahead every time I post a question). I don't fully understand how I can use the differentiation theorem given the fact that the series converges. Can you please explain further by editing the answer and refer to the formal name of the differentiation theorem (if it's different than ordinary differentiation rules such as continuity, function value = limit value, and so on)?


Consulta trazendo itens duplicados + o código do produto

Question: Olá, estou realizando uma consulta SQL no meu servidor Firebird.
Eu fiz a consulta utilizando a seguinte sintaxe:
select ds_produto_servico, count(ds_produto_servico) from tb_produto_servico
group by ds_produto_servico
having
count(ds_produto_servico) > 1

Ou seja ele está pegando todas as descrições dos produtos que estão duplicados. Porém gostaria de trazer na tela o código desses produtos duplicados. É possível ?
O campo do código é: CD_PRODUTO_SERVICO
Valeu.
Answer: Use a consulta de verificação como subquery para trazer os resultados:
select CD_PRODUTO_SERVICO, ds_produto_servico
from tb_produto_servico
where ds_produto_servico IN (
    select ds_produto_servico from tb_produto_servico
    group by ds_produto_servico
    having
    count(ds_produto_servico) > 1
)

Comment: Fechou mano. Deu certinho aqui. Valeu.
Answer:
select codigo_produto_servico
from   tb_produto_servico
where  ds_produto_servico in (
   select ds_produto_servico
   from   tb_produto_servico
   group  by ds_produto_servico
   having count(ds_produto_servico) > 1
)

Comment: Não deu certo. Ele trouxe somente os códigos e não mais as descrições.
Comment: Neste caso, basta acrescentar o campo ds_produto_servico no select, como na resposta do Rafael. Aliás, nossa resposta foi praticamente idêntica, eu só enviei por que não tinha visto a resposta dele (enviamos no mesmo horário).


Papers on the risks of using regular subsets

Question: I'm working on my Masters thesis and am using exhaustive search (also called regular subsets) for linear models.  There was an answer on CrossValidated, I believe by whuber, which talked about the risks of using regular subsets and had a link back to a page with several papers discussing this risk.  Unfortunately, I have been searching for this post and I can't find it.
If anyone could point me toward this post, or papers on the limitations/risks/problems with using exhaustive search for linear models, I would be very grateful.
Comment: Sometimes Google is your friend. I'm not sure which previous question or answer that you're referring to, but [a search like this](http://www.google.com/#q=all+subsets+regression+whuber+site:stats.stackexchange.com) might be a good start. :)
Comment: I don't know the link to whuber 's comment, but there is lots of literature on this. One good book on model selection is [Burnham and Anderson](http://www.amazon.com/Model-Selection-Multi-Model-Inference-Information-Theoretic/dp/1441929738/ref=sr_1_1?ie=UTF8&qid=1349454878&sr=8-1&keywords=burnham+and+anderson).  Another is by @FrankHarrell [Harrell](http://www.amazon.com/Regression-Modeling-Strategies-Applications-Statistics/dp/1441929185/ref=sr_1_1?s=books&ie=UTF8&qid=1349454942&sr=1-1&keywords=regression+modeling+strategies).
Answer: Found a few papers:
Mendenhall, W. (2003). A Second Course in Statistics: Regression Analysis 6th (sixth) edition.

Forward-Selection (FS), Backward-Elimination (BE), and Exhaustive Search (ES) are all meant to be Variable Screening methods - i.e. only the first step in the model building process
Using these techniques one is more likely to either include variables that are unimportant (Type I Error) or exclude variables that are important (Type II Error)
If you don't include higher order or interaction variables in the search, the final model will be a first-order, main effects model, which excludes non-linear affects and thus may not be realistic.
Even if you do include higher order and interaction variables in your search, the results can be nonsensical - for example including an interaction term while excluding the main effect or including a higher order term while excluding the first-order term.

Hocking, R. R. (1976). A Biometrics Invited Paper. The Analysis and Selection of Variables in Linear Regression. Biometrics, 32(1), 1. doi:10.2307/2529336

Using these techniques the best subsets can be missed

Gorman, J. W., & Toman, R. J. (1966). Selection of Variables for Fitting Equations to Data. Technometrics, 8(1), 27. doi:10.2307/1266260

There are probably several equally good subsets
The "best" subset should provide insight to the data

Miller, A. J. (1984). Selection of Subsets of Regression Variables. Journal of the Royal Statistical Society. Series A (General), 147(3), 389. doi:10.2307/2981576

The simple process of starting with highly correlated variables, examining scatterplots, adding higher order terms, transforming, and removing outliers as necessary is an extension of FS but it can "provide some protection against the selection of what might be considered stupid models".


Save a CSV file that's too big to fit into memory into a parquet file

Question: My development environment is a single-user workstation with 4 cores but not running Spark or HDFS. I have a CSV file that's too big to fit in memory. I want to save it as a parquet file and analyze it locally using existing tools, but have the ability to move it to the Spark cluster in the future and analyze it with Spark.
Is there any way to do this row-by-row without moving the file over to the Spark cluster?
I'm looking for a pure-python solution that does not involve the use of Spark.
Comment: Possible duplicate of [How to save a huge pandas dataframe to hdfs?](https://stackoverflow.com/questions/47393001/how-to-save-a-huge-pandas-dataframe-to-hdfs)
Comment: Not a duplicate, as I want to do this without spark and without HDFS.
Comment: Have a look into this thread, it may answer your question
https://stackoverflow.com/questions/42900757/sequentially-read-huge-csv-file-in-python
Comment: Can you please mention why are you concerned about moving the file to the Spark Cluster?
Answer: There is no issue with reading files large than memory. Spark can handle cases like this, without any adjustments, and
spark.read.csv(in_path).write.parquet(out_path)

will work just fine, as long as you don't use unsplittable compression for the input (gzip for example).
Comment: Yes, but we're trying to do this locally, without spark.
Comment: So why is it tagged [apache-spark]? :)
Comment: @alperttucker - I removed the Spark tag
Answer: In addition to the response of the ostrokach answer in question "How to convert a csv file to parquet" ,
and also based on the approach of Zelazny7  in question "Get inferred dataframe types iteratively using chunksize".
The approach to converting a CSV bigger than RAM to a parquet file, is in summary:

Read the csv in chunks with a certain limit of RAM consumption in megabytes
Create a parquet file from the schema optimally inferred from the entire CSV file
Increment the parquet file by chunks of CSV data

This approach reads the entire CSV file to detect the most optimized data type for each column.
Then identifies the impact on RAM reduction and adjusts the chunksize that will be preserved in the parquet file as row_groups.
This approach, despite reading and writing the parquet file in chunks, is secure in terms of writing schema consistency and optimized in choosing the data type for each column.
Mitigated schema risk
Since the first chunk of data can have a column showing only integer data, the column will be identified as int64. If the schema of the parquet file is created by this first chunk, the assumed premise is that all other data in the csv file has an identical schema to the first chunk. But if in the last chunk, this same column has some missing data, the increment of the parquet file will result in a schema error because the int64 format does not support empty data.
To avoid the risk of a schema error, it is necessary to analyze the entire dataframe and identify each column by the broadest data type among all the data read.
Convert csv bigger than RAM to parquet

import numbers
import warnings
from pathlib import Path
from typing import Optional

import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
from pandas.errors import DtypeWarning

warnings.filterwarnings("ignore", category=DtypeWarning)

def get_chunksize_by_max_ram_mb(
    file_path: Path, max_ram_mb_per_chunk: int
) -> int:
    """Returns the amount of rows (chunksize) of a CSV that is approximately
    equivalent to the maximum RAM consumption defined.

    Args:
        file_path (Path): csv file path
        max_ram_mb_per_chunk (int): maximum consumption of RAM in mb

    Returns:
        int: chunksize
    """
    mb_size = file_path.stat().st_size / (1024**2)
    num_lines = sum(1 for _ in open(file_path))
    rows_per_chunk = (
        int(max_ram_mb_per_chunk / mb_size * num_lines / 3.5 / 10000) * 10000
    )
    return rows_per_chunk

def auto_opt_pd_dtypes(
    df_: pd.DataFrame, inplace=False
) -> Optional[pd.DataFrame]:
    """Automatically downcast Number dtypes for minimal possible,
    will not touch other (datetime, str, object, etc)
    Ref.: https://stackoverflow.com/a/67403354
    :param df_: dataframe
    :param inplace: if False, will return a copy of input dataset
    :return: `None` if `inplace=True` or dataframe if `inplace=False`

    Opportunities for Improvement
    Optimize Object column for categorical
    Ref.: https://github.com/safurrier/data_science_toolbox/blob/master/data_science_toolbox/pandas/optimization/dtypes.py#L56
    """

    df = df_ if inplace else df_.copy()

    for col in df.columns:
        # integers
        if issubclass(df[col].dtypes.type, numbers.Integral):
            # unsigned integers
            if df[col].min() >= 0:
                df[col] = pd.to_numeric(df[col], downcast="unsigned")
            # signed integers
            else:
                df[col] = pd.to_numeric(df[col], downcast="integer")
        # other real numbers
        elif issubclass(df[col].dtypes.type, numbers.Real):
            df[col] = pd.to_numeric(df[col], downcast="float")

    if not inplace:
        return df

def get_dtype_opt(csv_file_path, sep, chunksize, encoding):
    """
    Identifies the optimized data type of each column by analyzing
    the entire dataframe by chunks.
    Ref.: https://stackoverflow.com/a/15556579

    return: dtype dict to pass as dtype argument of pd.read_csv
    """

    list_chunk = pd.read_csv(
        csv_file_path,
        sep=sep,
        chunksize=chunksize,
        header=0,
        low_memory=True,
        encoding=encoding,
    )

    list_chunk_opt = []
    for chunk in list_chunk:
        chunk_opt = auto_opt_pd_dtypes(chunk, inplace=False)
        list_chunk_opt.append(chunk_opt.dtypes)

    df_dtypes = pd.DataFrame(list_chunk_opt)
    dict_dtypes = df_dtypes.apply(
        lambda x: np.result_type(*x), axis=0
    ).to_dict()
    return dict_dtypes

def get_chunksize_opt(
    csv_file_path, sep, dtype, max_ram_mb_per_chunk, chunksize, encoding
):
    """After dtype optimization, analyzing only one data chunk,
    returns the amount of rows (chunksize) of a CSV that is
    approximately equivalent to the maximum RAM consumption.
    """

    for chunk in pd.read_csv(
        csv_file_path,
        sep=sep,
        dtype=dtype,
        chunksize=chunksize,
        low_memory=True,
        encoding=encoding,
    ):
        chunksize_opt = chunksize * (
            max_ram_mb_per_chunk
            / (chunk.memory_usage(deep=True).sum() / (1024**2))
        )
        break
    return int(chunksize_opt / 10_000) * 10_000

def write_parquet(
    csv_file_path, parquet_file_path, sep, dtype, chunksize, encoding
):
    """Write Parquet file from a CSV with defined dtypes and
    by chunks for RAM optimization.
    """

    for i, chunk in enumerate(
        pd.read_csv(
            csv_file_path,
            sep=sep,
            dtype=dtype,
            chunksize=chunksize,
            low_memory=True,
            encoding=encoding,
        )
    ):
        if i == 0:
            # Guess the schema of the CSV file from the first chunk
            parquet_schema = pa.Table.from_pandas(df=chunk).schema
            # Open a Parquet file for writing
            parquet_writer = pq.ParquetWriter(
                parquet_file_path, parquet_schema, compression="gzip"
            )
        # Write CSV chunk to the parquet file
        table = pa.Table.from_pandas(chunk, schema=parquet_schema)
        parquet_writer.write_table(table)

    parquet_writer.close()

def convert_csv_to_parquet(
    csv_file_path,
    parquet_file_path,
    max_ram_mb_per_chunk,
    sep=",",
    encoding="utf8",
):
    """Converts a CSV file to Parquet file, with maximum RAM consumption
    limit allowed and automatically optimizing the data types of each column.
    """

    chunksize = get_chunksize_by_max_ram_mb(
        csv_file_path, max_ram_mb_per_chunk
    )
    dict_dtypes_opt = get_dtype_opt(csv_file_path, sep, chunksize, encoding)
    chunksize_opt = get_chunksize_opt(
        csv_file_path,
        sep,
        dict_dtypes_opt,
        max_ram_mb_per_chunk,
        chunksize,
        encoding,
    )
    write_parquet(
        csv_file_path,
        parquet_file_path,
        sep,
        dict_dtypes_opt,
        chunksize_opt,
        encoding,
    )

Usage
convert_csv_to_parquet(
    csv_file_path='input_big_csvfile.csv',
    parquet_file_path='output_parquetfile.parquet',
    max_ram_mb_per_chunk=100, sep=",", encoding="utf8")

Explanation
As the CSV file does not fit in RAM memory, the approach will respect a maximum allowed RAM consumption.
The steps:

Finding the optimal chunksize for the first CSV scan.
Identify the most optimized dtype for each column, respecting the defined maximum RAM consumption.
After optimization, identify the number of rows that correspond to the defined maximum RAM consumption to serve as a basis for creating "num_row_groups" in the parquet file.
Write parquet file respecting the defined maximum RAM consumption.

So, even if you only have 500mb of RAM available, you can convert a 10_000mb CSV to parquet and on top of that optimize the columns data types, which improves the reading speed and reduces the final file size even more.
Read parquet file in chunk equivalent
def read_by_row_group(parquet_file_path):
    parquet_file = pq.ParquetFile(parquet_file_path)
    for row_group in range(parquet_file.num_row_groups):
        yield parquet_file.read_row_group(row_group).to_pandas()

for df in read_by_row_group(parquet_file_path):

    # parsing
    pass

Futher improvements
Implement data optimization of "object" dtype column to "categorical" dtype column, similar to what was implemented in data_science_toolbox , but in a chunk approach.
Answer: The pyarrow.parquet function write_to_dataset() looks like it may do this.
https://arrow.apache.org/docs/python/parquet.html#writing-to-partitioned-datasets
However I can't find detailed documentation for this function at the moment - you may need to look at the source code to see what it does.
https://github.com/apache/arrow/blob/master/python/pyarrow/parquet.py, line 1154 at time of writing.
The pyarrow.parquet.ParquetWriter object might also do it..


Data Services Update for .NET 3.5 SP1 breaks clients, any ideas on rollback?

Question: Ok... serious problem.
I did the update, thinking that I could continue to use the CTP2 version of Microsoft.Data.Services.Client the library to connect till they updated the Silverlight bits. No go. Ok, I can live with that.
I rolled back the service to the CTP2 libraries ( Microsoft.Data.Services + Microsoft.Data.Services.Client ) recompiled and then updated the service reference in silverlight.
At this point, the service AND the SL3 client are all using the CTP2 bits. Should be fine right? Wrong. Very, very wrong.
System.Data.Services.Client.DataServiceCollection' does not contain a constructor that takes '2' arguments
This is a serious show stopper, and it was not mentioned that this update would break CTP2 functionality. The warning about the SL dll was not, honestly, enough :)
Any ideas on how to resolve this? Should I try and uninstall the update or can I specify an older library in in a config file someplace?
Help! :)
Ken
Comment: please provider the full stack track of your error. but it seems you have having problems with the application picking up the wrong assembly at run time. append the full stacktrace to you post hopefully with we can sort this out.
Comment: There is no trace, this is a compile time error. It is clearly picking up a bad implementation of 'System.Data.Services.Client.DataServiceCollection' but my references are to the CTP.
Answer: Firstly the problem is that one of your project is picking up the wrong assembly it may be the service but most probably it is the client application.
The available constructors in the CTP 2 v1.5 for the DataServiceCollection are:
private DataServiceCollection();
internal DataServiceCollection(IEnumerable<T> items);
protected DataServiceCollection(DataServiceContext context, string entitySetName, IEnumerable<T> items, Func<EntityChangedParams, bool> entityChangedCallback, Func<EntityCollectionChangedParams, bool> collectionChangedCallback);
internal DataServiceCollection(DataServiceContext context, string entitySetName, Func<EntityChangedParams, bool> entityChangedCallback, Func<EntityCollectionChangedParams, bool> collectionChangedCallback, IEnumerable<T> items);

The Constructors available in the RTM release (the update you installed) KB976126 are:
public DataServiceCollection();
public DataServiceCollection(IEnumerable<T> items);
public DataServiceCollection(DataServiceContext context);
public DataServiceCollection(IEnumerable<T> items, TrackingMode trackingMode);
public DataServiceCollection(DataServiceContext context, string entitySetName, Func<EntityChangedParams, bool> entityChangedCallback, Func<EntityCollectionChangedParams, bool> collectionChangedCallback);
public DataServiceCollection(IEnumerable<T> items, TrackingMode trackingMode, string entitySetName, Func<EntityChangedParams, bool> entityChangedCallback, Func<EntityCollectionChangedParams, bool> collectionChangedCallback);
public DataServiceCollection(DataServiceContext context, IEnumerable<T> items, TrackingMode trackingMode, string entitySetName, Func<EntityChangedParams, bool> entityChangedCallback, Func<EntityCollectionChangedParams, bool> collectionChangedCallback);
internal DataServiceCollection(object atomMaterializer, DataServiceContext context, IEnumerable<T> items, TrackingMode trackingMode, string entitySetName, Func<EntityChangedParams, bool> entityChangedCallback, Func<EntityCollectionChangedParams, bool> collectionChangedCallback);

I suggest if you want to use the CTP dlls, that you check your references on your client application and any other application that makes use of the System.Data.Services.Client.dll and change to Microsoft.Data.Services.Client.dll (located in program files in the the ADO.NET Data Services V1.5 CTP2 folder).
I have installed the latest version also and am am currently running both versions on my PC which it is working.
Another important thing is to check the global assembly cache since both versions will be installed there (with the CTP 2 ddls having an version number of 188.8.131.52).
Something I have done is for the CTP dlls I added the references from the ctp folder instead of the global assembly cache.
Regards
Daniel Portella
Update: Soulhuntre it must be the EntityClassGenerator that the web service reference is using, the service reference must be using the GAC system.data.services.client dll to generate the classes instead of the old CTP ones.
There is two things you can do really one is to do what I said above and the other is to remove the updated (uninstall the KB) that should revert the changes done. You could even try removing the old service reference and creating it again while making sure it uses the CTP dlls to generate the classes.
It works on my solution because I have written my own implementation of the DataServiceClientGenerator, to do magical things that the one shipped by MS doesnt do that must be why i can run both installations with out problems.
End of Update.
Comment: Yeah, it looks like the issue is the EntityClassGenerator - it is pickign up the GAC version instead of the one from the CTP. This is causing all sorts of problems. I'll need to uninstall the update I guess to get it working as I see now way to specify the generator path.

Ken


Javascript parsing?

Question: I'm coding something in extendscript for adobe after effects, which ends up being javascript.
I have an array and I would like to do a search for just the word "assemble" and return the whole jc3_RIG_008_masterLayer assemble string
var comps = ["_MAIN", "jc3_RIG_008_masterLayer assemble","jc3_RIG_008_masterLayer contact sheet", "[Z] source", "MM004 source"];

I'm not sure what the best/ most efficient way to achieve this is, but any thoughts would help.
Thanks.
Comment: There is no performant way, it's always O(n) except if you have a predefined set of strings and you will only search for those strings, then it could be optimized by creating maps.
Comment: Just to clarify: you have the array `comps`, and you want to find the element from that array that contains the word "assemble"?
Answer: @josegomezr has the right idea using a simple loop. I updated that idea to return the string that the poster is looking for.
var comps = ["_MAIN", "jc3_RIG_008_masterLayer assemble","jc3_RIG_008_masterLayer contact sheet", "[Z] source", "MM004 source"];
var compWithAssemble;
for(var i in comps){
    if(comps[i].indexOf("assemble") > -1){
        compWithAssemble = comps[i];
        break;
    }
}
// compWithAssemble has the string you are looking for.
console.log(compWithAssemble);

Comment: I updated my answer to use a simple loop like josegomezr. Mine returns the string that the poster is looking for.
Comment: Thanks for the heads up. I'll change it to `indexOf`, that's what I usually use anyway.
Comment: According to [MDN](https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Array/filter) `Array.filter` exist since ECMAScript standard 5.1, and according to @Frxstrem ExtendScript only accomplish ECMAScript standard 3.
Comment: Just a note: If this was a big array, using `indexOf` would perform better. `search` is generally used when you want to use regular expressions. In this scenario it obviously doesn't matter though.
Answer: A normal for-loop should do the trick. This is the fastest way according to some sources. Also using indexOf() is faster than using search()  according to other sources:
for (var i = 0, len = comps.length; i < len ; i++) {
   if (comps[i].indexOf('assemble') > -1) return comps[i]; //or store and break
}

var comps = ["_MAIN", "jc3_RIG_008_masterLayer assemble","jc3_RIG_008_masterLayer contact sheet", "[Z] source", "MM004 source"];

    comps.forEach(function(el) {
       if (el.indexOf('assemble') > -1) document.write('loop 1: ' + el + '
');
    });

    for (var i = 0, len = comps.length; i < len ; i++) {
       if (comps[i].indexOf('assemble') > -1) document.write('loop 2: ' + comps[i]);
    }

I'll keep this here as reference:
Something like this would work for anything with ECMAScript5 support (but according to sources, and @frxstrem, this is not available in ExtendedScript):
comps.forEach(function(el) {
   if (el.indexOf('assemble') > -1) return el;
});

Comment: According to [this answer](http://stackoverflow.com/a/22537459), as of last year ExtendScript did only comply with the ECMAScript 3 standard. I don't think Adobe has updated ExtendScript since then.
Comment: `array.forEach` doesn't  return an array, but you can break the loop early.  [Source](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach). To return an array of filtered elements use `array.filter` or `array.map`.
Comment: "_...which ends up being javascript_" I assumed it would be more up to date. It looks like ECMAScript3 + some features from 4 is all that is available.
Comment: @josegomezr I'm not trying to return an array. The OP asked for a string.
Answer: If it is plain JS you can do this:
var found = false;
for(var i in comps){
    if(comps[i].search("assemble") != -1){
        found = true;
        break;
    }
}
if(found){
    // your code if found
}else{
    // your code if not.
}

Javascript parsing?


Reference request: Set of n-Multisets of elements in $\mathbb{N}$ is countable set

Question: Let $n \in \mathbb{N}$ be fixed. I need a reference for the statement, that the collection of multisets of length $n$ with elements in $\mathbb{N}$
\begin{equation}
M_{\mathbb{N}} = \{ \{a_1, ..., a_n\} \mathrm{~is~multiset}| a_i \in \mathbb{N} \}
\end{equation}
is a set and is countable.
Comment: There is a surjection from the finite sequences onto multisets.
Answer: There is a bijection $\mathcal{M}_{\mathbb{N}} \rightarrow \bigcup_{k=0}^{\infty}\mathbb{N}^k$. Now each $\mathbb{N}^k$ is countable and countable unions of countable sets are again countable.


When not given a link, use URL node

Question: For a slideshow with banners, i've added the fields overlay-text and link-to. The link-to is the URL you go, if you click on the banner. It's al done & working in Views & Views Slideshow.
The user adds a node and has to set the URL by hand in the field link-to. Sometimes however, the banner has to point to a different URL or node.
How can i set the URL of the node when the field link-to is empty?
Comment: Can't you rewrite the output in the view field options?
Answer: You can use No results behavior on the field. Include the path field and use the field path token.

If there are no results, it picks the node URL.

When not given a link, use URL node


Parsing timestamp with timezone in java?

Question: I'm trying to parse a string of format timestamp with timezone obtained from a DB. The String is as follows :
   SimpleDateFormat mdyFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSZ");

    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    Date d1 = mdyFormat.parse("2014-04-01 15:19:49.31146+05:30");

    String mdx = sdf.format(d1);

    System.out.println(mdx);

Problem is, I get an error saying :
Exception in thread "main" java.text.ParseException: Unparseable date: "2014-04-01 15:19:49.31146+05:30"
    at java.text.DateFormat.parse(DateFormat.java:357)
    at com.karthik.Timestampvalidate.main(Timestampvalidate.java:31)

Does anyone know how to fix this ?
Answer: You need to use X instead of Z:
SimpleDateFormat mdyFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSX");

See the javadoc for more info.
Note: only available in Java 7+.
Comment: Thanx a lot ! Its working. I guess I was looking at an older version of documentation.
Answer: If you get to use the new JSR 310 date/time APIs in Java 8, you can use the XXX format to parse the timezone. You need three Xs to get the specific colon-separated offset that you're using.
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSXXX");
TemporalAccessor dateTime = formatter.parse("2014-04-01 15:19:49.31146+05:30");
// returns: {OffsetSeconds=19800},ISO resolved to 2014-04-01T15:19:49.311460


Is there any modern compiled language with manual memory management?

Question: Is there any modern (generics, closures, object oriented) language with manual memory management? And with a compiler, either to machine code or to another language like c.
I haven't read of any. All new languages are garbage collected, and most of them interpreted or run in a vm.
EDIT: sorry, I know c++0x now has many new features, but I can't see it as a modern language. It's too ugly and illegible to me. And the way closures are used makes it worse.
By modern I meant something cleaner than c++.
Comment: Ugliness is a) completely subjective and b) not related to age or "modernness".
Comment: Sure, that's why I said "to me" :)
Comment: Objective-C, as used by Apple.
Answer: If you use a C++0x version of C++ compiler (like the last gccs) then it does provide all the features you need. The C++03 (current version) does have generics, object orientation, have closures implementation (functors) but not the syntax (that is provided in C++0x, as "lambdas" - available in VS2010, gcc4.5 and other recent versions of compilers) and is all about manual (but easy) memory management (using RAII-the badly named idiom- and smart pointers where necessary).
Don't rely on c++ birth's date : what we call "modern C++" is clearly more easy and powerfull thant the original version of C++. (but it have a very long timing between new versions)
The only other alternative that I can think about is D, that is thought to be a system programming language too, that is similar to C++ in core principles but tries to avoid some of it's "problems" and provide some other features missing in C++.
Comment: @sepp2k: What he's really talking about is C++0x's lambdas. They do require you to specify the objects you want to capture (and how -- by reference or value), but do allow you to extend their lifetime to that of the lambda expression itself. As it happens, the lambda expression does produce an unnamed functor, but that part is only vaguely relevant.
Comment: "have closures implementation (functors)" How do functors close over anything? I'm also not sure that C++0x qualify as they do not affect the life-time of the closed over objects (which at least according to wikipedia is one of the defining characteristics of a closure).
Answer: C++ (Don't laugh)
http://en.wikipedia.org/wiki/C%2B%2B0x
Rust - Not sure if its GC but it looks interesting
https://github.com/graydon/rust/wiki/Language-FAQ
Comment: rust has both garbage collection and manual memory management. [this blog post](http://pcwalton.github.io/blog/2013/03/18/an-overview-of-memory-management-in-rust/) that talks about it in more detail!
Answer: Well, how modern is modern ?
Delphi requires that you manage your Memory, but provides simple and elegant ways to do that, it also has a pluggable architecture for memory management, and compiles to native code.
Delphi is still actively developed, nowadays by Embarcadero but was created originally in 1995 by Borland software, and even then was the successor to Turbo Pascal, so modern might be a subjective term for Delphi as its history is long.
Comment: Delphi ([1995](https://en.wikipedia.org/wiki/Delphi_(software)#History)) is more modern than Python ([1991](https://en.wikipedia.org/wiki/History_of_Python#Early_history) or [1994](https://en.wikipedia.org/wiki/History_of_Python#Version_1), depending what you view as the first release). I guess Python is considered a "modern" language, and therefore Delphi is more so!
Answer: There is an experimental language BitC. It is quite low-level, compiles to a portable C, and have a lot of neat modern features.
A good old Ada also worth mentioning.


Calculus 3 Integration

Question: Just wondering if anyone could help me sort out this old exam question:
$\ \vec F (x,y,z) = xe^{x^2+y^2} \vec i + ye^{x^2+y^2} \vec j +e^z \vec k $
(A) Let C denote the path
$\ (1 + cost, 2 + sin t, 3), 0 ≤ t ≤ 4π. $
Evaluate
$$\ \int_C \vec F . \vec {dr} $$
Justify your answer
(B) Find a function $\ ϕ : R^
3 → R $ such that $\ \vec F = ∇ϕ. $
(C) Evaluate
$$\ \int_Γ \vec F . \vec {dr} $$
Justify your answer
where Γ is the path
$\ (1 + cost, 2 + sin t, 3), 0 ≤ t ≤ π^2 $

I tried parameterization and ended up with this nasty yoke:
$$\ \int_0^{4 \pi} ((1+cos(t)) e^{(1+cos(t))^2+(2+sin(t))^2}) \vec i +(2+sin(t)) e^{(1+cos(t))^2+(2+sin(t))^2}) \vec j +e^3 \vec k )(-sin(t) \vec i +cos(t) \vec j + 0 \vec k $$
Which couldn't possible?
I was thinking if I substituted $\  (1+cos(t))^2+(2+sin(t))^2 $ for u but I have no idea what to do (I'm only new at cal 3 so I'm still at the basics)
Any help would be hugely appreciated!
Comment: Please check your $F$ it is not a vector like you defined it.
Comment: @MrYouMath thanks I fixed it there
Comment: I still don't see any unit vectors in your expression for $F$.
Comment: Is $\vec F$ $\vec F =(xe^{x^2+y^2},ye^{x^2+y^2},e^z)$?
Answer: If
$$\vec{F} (x,y,z) = xe^{x^2+y^2}\vec{e}_x + ye^{x^2+y^2}\vec{e}_x+e^z\vec{e}_x $$
The vector $\vec{F}$ is a gradient, as we can show in
B) $\vec{F}=\nabla \phi$, where $\phi=\frac{1}{2}e^{x^2+y^2}+e^{z}$. You can check this by calculating the gradtient of $\phi$.
If a vector is a gradient the integral along the path $\gamma$ is pathindependent and you can calculate the integral using the following equation.
$$\int_{\gamma}\vec{F}d\vec{r}=\phi|_{\gamma(t=t_0)}^{\gamma(t=t_1)}$$
Where $\gamma(t=t_0)$ denotes the point where your path starts and $\gamma(t=t_1)$ denotes the point where your path ends.
For A) $\gamma(t=t_0)=(2,2,3)^T$ and $\gamma(t=t_1)=(2,2,3)^T$.
$$\int_{C}\vec{F}d\vec{r}=\phi(\gamma(t=t_1))-\phi(\gamma(t=t_0))$$
$$=\phi((2,2,3)^T)-\phi((2,2,3)^T)=0$$
For C) $\gamma(t=t_0)=(2,2,3)^T$ and $\gamma(t=t_1)=(1+\cos(\pi^2),2+\sin(\pi^2),3)^T$.
$$\int_{C}\vec{F}d\vec{r}=\phi(\gamma(t=t_1))-\phi(\gamma(t=t_0))$$
$$=\phi((1+\cos(\pi^2),2+\sin(\pi^2),3)^T)-\phi((2,2,3)^T)$$
$$=\frac{1}{2}e^{(1+\cos(\pi^2))^2+(2+\sin(\pi^2))^2}+e^{3}-(\frac{1}{2}e^{(2)^2+(2)^2}+e^{3})$$
Comment: I'm sorry I still don't understand what to do thank you for your reply though!
Answer: It pays to treat $(B)$ first. If $\vec F=\nabla\phi$ for some scalar function $\phi\>{\mathbb R}^3\to{\mathbb R}$ then
$$\phi_x=xe^{x^2+y^2},\quad\phi_y=ye^{x^2+y^2},\quad\phi_z=e^z\ .$$
This shows that the first two components $(\phi_x,\phi_y)$ make up  the $(x,y)$-gradient of the function $(x,y)\mapsto{1\over2}e^{x^2+y^2}$, and the third component $\phi_z$ is independent of $x$ and $y$. This leads to the conjecture that the function
$$\phi(x,y,z)={1\over2}e^{x^2+y^2}+e^z$$
does the job, and it is easy to verify that for this $\phi$ one indeed has $\nabla\phi=\vec F$.
Now to (C): It is a basic fact of vector analysis that for a gradient field $\vec F=\nabla\phi$ one has
$$\int_\Gamma \vec F\cdot d\vec r=\phi(q)-\phi(p)$$
for any curve beginning at $p$ and ending at $q$. It follows that your integral ha the value
$$\phi(1+\cos\pi^2,2+\sin\pi^2,3)-\phi(2,2,3)=\ldots\quad.$$
Finally $(A)$: The curve $\gamma$ in question is a circle in space drawn twice. The principle alluded to above then immediately implies that the integral in question is $0$.
Answer: The other answers have covered the solution quite well, but I'll give you a slightly different take on it.
When you're asked to integrate a messy-looking vector function like this, it pays to see if it represents a conservative vector field. You can do this without first finding a scalar potential by checking to see if $\nabla\times F=0$ (equivalently, that the matrix $d\vec F$ is symmetric). We know that this must be the case, anyway, because part B asks us to find this potential, but it doesn't hurt to double-check.
Now that you know that $\vec F$ is conservative, i.e., that $\vec F = \nabla\phi$ for some real-valued $\phi$, part A becomes trivial: the integral is independent of the path, and $\int_\Gamma \vec F\cdot d\vec r = \phi(b)-\phi(a)$, where $a$ and $b$ are the start and end points of the path $\Gamma$, respectively. In part A, the endpoints coincide, so you know without doing anything else that the value of the path integral is zero. You also know from this that the answer to part C is going to be $(\phi\circ\Gamma)(\pi^2)-(\phi\circ\Gamma)(0)$.
There are a few ways to find a suitable scalar potential $\phi$. The usual method involves integrating the components of $\vec F$ individually and matching them up to eliminate the "constants" of integration. You can also find an antiderivative of $\vec F$ by evaluating a single integral, which I'll demonstrate here. Let $\vec F=A(x,y,z)\,\vec i+B(x,y,z)\,\vec j+C(x,y,z)\,\vec k$. Then $$\phi(x,y,z) = \int_0^1 xA(tx,ty,tz)+yB(tx,ty,tz)+zC(tx,ty,tz)\,dt$$ satisfies $\nabla\phi = \vec F$. (Note that this requires that $\vec F$ be defined in a star-shaped region about the origin.) If you work through this integral for the given $\vec F$, you end up with $$\phi(x,y,z) = \frac12 e^{x^2+y^2}+e^z-\frac32,$$ which differs from the function in the other answers by a constant of integration that you can drop because it'll cancel when you subtract the values of $\phi$ at two points from each other.
For the curve $\Gamma$ of part C, $z$ is constant, so the $e^z$ term, too, will cancel. This leaves evaluating $\frac12 e^{x^2+y^2}$ at the end points of $\Gamma$. Converting to cylindrical coordinates at this point might be fruitful.

Calculus 3 Integration


Move all namespace declarations in source xml to root node in output

Question: With a source xml like this:
<top>
  <middle xmlns:first="http://test.com">
    <inner xmln:second="http://somthing.com">
      Hello
    </inner>
  </middle>
</top>

I'm attempting to produce
<top xmlns:first="http://test.com" xmlns:second="http://somthing.com">
  <middle>
    <inner>
      Hello
    </inner>
  </middle>
</top>

And I have other templates in the xslt changing other aspects of the document. Is this possible? I want to pull all namespace declarations from everywhere in the source and put them at the root.
Comment: Your code block showing what you want to produce is not well-formed XML.
Comment: Please state which version of XSLT your processor supports.
Answer: Try something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="/*">
    <xsl:copy>
        <xsl:copy-of select="//namespace::*"/>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Note that the result can vary depending on which processor you use. Also, if some of the namespaces are default namespaces (with no prefix), you might get results that differ from what you expect.
A better option would be to declare the namespaces at the root element explicitly - provided you know them in advance:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="/top">
    <top xmlns:first="http://test.com" xmlns:second="http://somthing.com">
        <xsl:apply-templates select="@*|node()"/>
    </top>
</xsl:template>

</xsl:stylesheet>

Ultimately, the exact placement of namespace declarations is insignificant and there should be no need to perform this exercise.
Comment: Note this will give an error if the document contains bindings of two different namespaces to the same prefix - including default namespace declarations, which is the most likely case. (At least it's defined as an error in XSLT 2.0. I haven't checked 1.0).


Variable value has not changed in Ajax.reload datatable

Question: I have a problem in my code. I can't change the year values in my Datatable
This code gets the actual year:
var yearDate = new Date();

var year = yearDate.getFullYear();

My datatable method:
$(document).ready(function() {

    januaryTable = $('#january').DataTable({

        "processing": true,
        "serverSide": true,
        "order": [],

        "ajax": {
            "url": "<?php echo site_url('gastos/ajax_list/')?>" + year+'-01-01' +'/'+ year+'-01-31',
            "type": "POST",

        },

        "columnDefs": [
            {
                "targets": [ -1 ],
                "orderable": false,
            },
        ],

    });
}

This code reloads my datatable
function reload_january_table()
{
    januaryTable.ajax.reload(null,false);

}

I change the var year with a select method and it calls the function reload_january_table(), but for example, when I select the value 2016, the table doesn't get values from 2016, it keeps the 2017 values.
Can someone help me ? And sorry for my english if it isn't good.
Comment: How is your _select method_ implemented?
Comment: It has changed the var year value, because i use it in a function.
Comment: function Redirect(obj){
var yearO = obj.value;
year = yearO;
reload_january_table();
reload_january_total_invoice();
}
Answer: The problem is that the ajax.url is only being evaluated when the table is initialised, so the first value of your year variable gets "burnt" in to the url.
The solution is to set the new url for DataTables when the value of year changes like so:
dataTable.ajax.url('NEW_URL').load();

You will find the related part of the DataTables documentation under ajax.url().
In your specific case, you could pass in the new value of year as an argument into the reload_january_table(year) function call and have that function use that like below.
function reload_january_table(year) {
    var newUrl = "<?php echo site_url('gastos/ajax_list/')?>" + year  + '-01-01' + '/' + year + '-01-31';

    januaryTable.ajax.url(newUrl).load();
}


Selecionar a linha anterior caso esteja nulo

Question: Tenho a seguinte tabela em Oracle e quero preencher valor que estiver nulo na coluna Activity com o valor da linha anterior. Como fazer usando Oracle?
Answer: Conforme documentação sobre LAST_VALUE:

É uma função analítica. Ele retorna o último valor em um conjunto de
  valores ordenados. Se o último valor no conjunto for nulo, a função
  retorna, a NULL menos que você especifique IGNORE NULLS. Esta
  configuração é útil para densificação de dados. Se você especificar
  IGNORE NULLS, então LAST_VALUE retorna o valor não-nulo do punho no
  conjunto, ou NULL se todos os valores são nulos.
 Tradução via google translate

Assim aplicando ao seu caso, temos:
SELECT t.activity_no
      ,t.locationcode
      ,t.act_start_date
      ,last_value(t.activity ignore NULLS) over(ORDER BY t.activity_no) somecol
  FROM tabela t

Fiz um exemplo utilizando o LiveSql da oracle: https://livesql.oracle.com/apex/livesql/file/content_E1EDQGXFCBCHG5GLBCEYS75BZ.html

Edição para Oracle 9i:
Encontrei uma resposta em outro forum aplicado ao Oracle 9i,
e fazendo alguns ajustes, e aplicando ao seu caso, ficaria algo assim:
SELECT t.activity_no
      ,t.locationcode
      ,t.act_start_date
      ,MAX(CASE
             WHEN t.activity_no = activity_carrydown THEN
              t.activity
           END) over(PARTITION BY activity_carrydown) activity
  FROM (SELECT MAX(CASE
                     WHEN t.activity IS NOT NULL THEN
                      t.activity_no
                   END) over(ORDER BY t.activity_no ASC) activity_carrydown
              ,t.activity_no
              ,t.locationcode
              ,t.act_start_date
              ,t.activity
          FROM tabela t) t

Comment: Boa, mas tem um problema estou usando Oracle 9i que nao tem compatibilidade com ignore nulls, alguma outra funcao?
Comment: Editei a resposta, adicionando para o 9i, vê se atende.