Yarn Installation error, View Storefront installation

Question: While I am trying Install Vue Storefront in my windows 10 machine, it generate yarn installation issue.
Please refer the screenshot.
Comment: Are you running `cmd` in Administrator mode?
Comment: Ya sure, I am running administrator mode.
Answer: Vue storefront does not support direct Windows workflows.
please follow:
https://docs.vuestorefront.io/guide/installation/windows.html#requirements
to install vue-storefront on Windows. Docker is the only supported method for this.
Answer: To install Vue storefront on windows platform.
Please visit the once:
https://www.youtube.com/watch?v=zL_T3WzVLG0
Which already explains well, how to install and what needs to be installed in your window system.


Possible list of motivations for playing an instrument (by hand)

Question: Given that nowadays people can compose and play via a mobile phone or computer, what could or would some possible reasons for wanting to be able to play an instrument by hand be?
Can't you just try out your tunes via a computer interface and play them when you want?
Then what is the difference?
What is the advantage (of playing by hand)?
Thanks.
Comment: I don't see how this is getting so many answers or upvotes, really. It's just an argument from incredulity.
Comment: Well there is also the option of taking up the organ and playing with your feet. Let us not succumb to a false dilemma where only two horns are proposed when there exists a third option.
Comment: I think the answer will also depend on your motivation. Are you a music producer who just wants to get the *sounds* of various instruments? Or do you want to actually be able to play the physical instrument? I'm also having a hard time understanding what you're asking in a way. Fwiw, the "famous" Seinfeld bass lines are all done on a keyboard. Does that make it any more/less appreciated?
Comment: I'm voting to close this question because "list-type" questions should not be asked, as attested in the [Help center](https://music.stackexchange.com/help/dont-ask)
Comment: Do you prefer to type on a real keyboard? Or an image of a keyboard on a touchscreen? Why? Is your goal to play? Or to listen?
Comment: Every answer has at least one dv, with no reasons given (as usual). Wonder if it's the same dv-er, and why.
Comment: @Tetsujin the difference is that you can easily gather information about Arctic in an encyclopedia, while the reasons to play an instrument might not be as obvious. Or perhaps they are obvious to you, but not to the OP. It's not a role of the OP to present an argument (that's the role of people writing the answer), it's they role to ask a question, and explain what lead them to that question, and I think this is fulfilled here.
Comment: @Tetsujin - Well, if you don't need to be able to play flute/clarinet/trumpet/timpani/piano/electric guitar/etc. in order to compose for them *while knowing their limitations and what they can do that most other instruments cannot*....
Comment: Is there a catchy name for argument that goes like "this thing is obvious to me, so I don't see why anyone else would ask about it"?
Comment: What kind of "computer interface" are you suggesting people would "try out their tunes" with?
Comment: @NeilMeyer  Yeah, since any good jazz orchestra will have more like 12 horns!  :-)
Comment: In a few years time, this will be so commonplace, that we won't even question!
Comment: @ojs - yes, it's mentioned in the very first comment. It's called 'argument from incredulity'. That's its proper name. "I can't believe this is/isn't true, based on my own personal experience, as opposed to actual facts." e.g. "I've never been to the Arctic, therefore it cannot be as cold as people say it is." It's an argument that rests on belief, or lack thereof.
Comment: @Tetsujin I was referring to your comment, not the original question :)
Answer:
What is the advantage (of playing by hand)?

Expression.  How much space is between the first and second notes?  How much space between the second and third?  Which of those three notes is the loudest?  Which is the softest?  Is each note held at the same volume or do some of them crescendo or decrescendo or perhaps one and then the other?  Is one note held a few milliseconds longer than the other two?  Are they tuned slightly differently?  All of these microscopic details and more are part of an expressive performance, and so far I'm only considering three notes.
This level of detail is not notated in sheet music, and applying it to a computerized performance is a painstaking process that goes far beyond "try out your tunes via a computer interface."  It's a useful tool, but it's not going to yield a comparable result to a human musician without a lot of work.
Answer:
Can't you just try out your tunes via a computer interface and play them when you want?
Then what is the difference?

The difference is the same as that between playing NBA on the Playstation or XBox and playing real basketball on a basketball court with your friends and teammates.
The second requires the development of physical skills and deepens social connections, both of which give a great deal of pleasure and sense of achievement. The first can also give a sense of pleasure, albeit more onanistic in nature.
Comment: Whenever I play piano, it's pretty much always at home and alone. No deepening any social connections there.
Comment: I'm not sure about the comparison. Playing a computer game requires developing physical skills, perhaps comparable to those needed to play an instrument.
Comment: @Dekkadeci that's like doing sports such as cycling alone through the wild then. It's still much more than playing a video game of the same thing.
Comment: @user1079505 I do both and music is more strenuous and difficult, if less addicting
Comment: The analogy with sports games is interesting, because sports games aren't necessarily *worse* versions of the sports they're inspired by - they're *different* skills that have the potential to be just as deep and satisfying for different reasons. (Whether certain games reach that potential is arguable, but beside the point.) Similarly, writing music using a computer isn't a worse version of playing an instrument - it's a different activity that tests a different set of skills.
Answer: There is a great difference between playing piano by hand and writing for piano on a computer (I do both). It's much easier to write down things on the computer but the recorded sound is different. Also there is tactile feedback when playing an instrument (at least on piano or clarinet or bass or accordion or organ) that does not occur when using a computer.
I tend to go back and forth between the computer and the piano. Feedback from piano to computer and vice versa is useful.
Mostly, it's sound and feel.
Comment: My handwriting isn't that good. I tend to play things on the piano and sketch out the melody on manuscript or blank paper (and maybe a bass line) with a few chord symbols. However, then it's much easier to fill the actual chord patterns and expand the instrumentation with Finale or something similar (nothing for Android yet.)
Comment: "It's much easier to write down things on the computer": in what sense?  Are you comparing the time required to put the piece into the computer against the time required to teach yourself to play it?  In that case, this statement is probably not true for the most accomplished of pianists nor for less difficult piano pieces.  Or do you mean something else?
Comment: Thanks, that makes sense.  My handwriting stinks, but I don't do a lot of composition :-)
Answer: There are three components:

Ability for a computer to reproduce a sound of an instruments. This is done using virtual instrument, which developed a lot last years. It is certainly possible for a virtual instrument to sound like a real instrument – after all,  most of them base on recordings of real instruments. What's still challenging is reproducing all nuances of articulation.

The virtual instrument interface. Presently the most prevalent standard is MIDI. The most basic information is a note start, note end, and its velocity. This may or may not be sufficient. Consider e.g. a violin note, with changing bowing, dynamics, vibrato... in order to transmit information about articulation one can use additional MIDI information, like pitch bend or modulation wheel, aftertouch, or additional fake notes which instruct the virtual instrument to use different articulations. This varies from instrument to instrument and is often non-intuitive.

The human interface. I think this is the most important part. You can input MIDI notes using a MIDI controller (e.g. a keyboard), or by typing them in a DAW or similar program. This is a quite different experience from playing a real instrument. A MIDI controller can certainly be learned, but it may have different capabilities from the instrument which sound you want to reproduce, resulting in different music. In turn, when programming the notes, you loose the immediacy of making music. You no longer actively respond to what you hear. Such process differs significantly from playing a music instrument.

Virtual instruments are widely used today. This depends a lot on the instrument and on the music style. For example in rock and metal recordings programmed drums are sometimes even preferred to a real drummer, due to consistent articulation and timing and easiness (read: low price) to make the recording. In turn jazz drums typically are recorded by the musicians, as the style requires use of subtle articulations and interaction between the musicians.
Virtual instruments are used successfully in music applications and music styles where the listener either doesn't pay to much attention to the details of the sound, or doesn't care if the sound of the original instrument is reproduced accurately. These areas are still changing as the technology evolves.
Since decades already there are many electronic instruments used which don't even attempt to reproduce accurately sound of any acoustic instruments. Synthesizers, electronic drums and more. There are whole music genres based on electronic sounds. You make this music either by programming, or by using a controller of your choice.
There are many ways to make music, and it's up to you to decide what you like. If I were to advise a new musician, I would tell them to try out many things, and decide based on their own experience.
Answer: With modern technology, it's pretty easy to just type some words on your phone and have a computer voice read them. Given that, why do people still speak words using their mouths? What's the advantage?
The answer, of course, is that for most people, speaking is much faster and easier than typing words and having a computer voice read them. If I have something I want to say, I can just say it without having to type it.
Of course, a lot of people have disabilities that make it difficult or impossible to speak, so for those people, assistive devices and software can be very useful.
The same goes for musical instruments. If I'm a skilled pianist, then playing the piano is much faster and easier than entering notes into a computer program and having the program play them. If I have something I want to play, I can just play it without having to enter it into a program.
Granted, most people are not skilled pianists. But playing the piano fluently is a skill that can be learned.
Comment: Good analogy, but I'd say that's not the reason people speak. I can type faster than I can speak (on a good keyboard), but I still dislike texting people. Because speech carries more than text, and in particular the being-together-and-talking bit is a whole extra dimension that text can't capture at all. Similar with music.
Answer: Playing with others won't be the same - although Zoom et al may negate that. And I wouldn't want to be taking my computer to a party/gathering or suchlike. Just like I wouldn't drag a keyboard along..!
I guess the future may well incorporate that sort of playing, but thankfully it's a fair way off (for me at least) right now!
Interesting concept (+1), and certainly futuristic, but how would one actually go about playing live n such a way?
Comment: People are already running virtual instruments on tablets and cell phones, and portable MIDI controllers are a thing too
Comment: @ojs - I tend to let things run for a while before I jump onto any bandwagon. Still using Minidiscs! Basically so that wrinkles can be ironed out, and it's 'safe' to get on board. Not quite Luddite, but getting there!
Comment: I know. But just because you don't like something doesn't mean that others can't enjoy it.
Comment: @ojs - I haven't said they mustn't  enjoy it, or shouldn't enjoy it. Each to their own.
Answer: The answer could be your listening preferences. If you prefer listening to midi instruments than live recordings in great studios, such as Air Studios in the UK then there wouldn't be any reason for you to practise instruments 'by hand'. From a technical perspective, the virtual instruments are not good enough creating overtones. When you hit a note, let's say on the piano, the piano creates side tones which are called overtones. Dynamics are another reason, computers are not good enough on dynamics. Again, it's all about your listening preferences. Nowadays, composers write both for computers and human players. I myself love and fond of virtual instruments including virtual pianos and virtual guitars and stuff but I don't think they can be a substitution. On the other hand, there are virtual instruments which are originally virtual. I mean, if you navigate to the native instruments or spitfire web page you can see many 'totally' virtual instruments.
I think you will enjoy reading this
Comment: Thank you for your answer. I do not understand overtones. The ones you mention, how do they work, or, how are they generated?
Comment: @ojs "virtual instruments are not good enough creating overtones" is a fair statement, although some might debate it (the most advanced virtual instruments are pretty close to the real thing; for example, state of the art digital pianos now model sympathetic vibration).
Comment: @phoog Yes, there's a great improvement. But I prefer the old style, these new digital pianos doesn't satisfy me as the real, even cheaper ones. Btw, which piano sound library do you suggest ?
Comment: @orhantorun I use digital instruments very infrequently and too casually to be a connoisseur of sound libraries.  I agree that real instruments are better :-)  I've just noticed that the degree of deficiency in synthesized music that seeks to emulate acoustic music has decreased in the last several decades.
Comment: @orhantorun I know perfectly well what an overtone series is. The thing is that reproducing the overtones isn't difficult but also just reproducing them doesn't sound anything like the real instrument. This is why I suspected that you used the word to mean something different (like the sympathetic vibration mentioned in comment above).
Comment: Do you have access to Oxford Grove Music? It ll help you understand overtones; if you don't have access let me know as I can send you some other resources. I dont understand the rest part, are you asking about the 'completely' virtual instruments? For instance, some synth sounds?
Comment: This is not the usual meaning of "overtones"
Comment: @ojs Yes it is. To be rational, I'm making a copy paste from the Oxford Dict. of Music: 'overtone: Any note of the harmonic series except the fundamental.' Also, I suggest you reading this:
 britannica.com/science/sound-physics/Overtones
Comment: @orhantorun ok, in that case I think you're wrong. There are some who use the word overtones to mean nuances, but generally sample-based virtual instruments do get the overtone series right. It's the expressiveness of real instruments, physical feedback and details like the sympathetic vibration that are missing.
Comment: I've never seen a person using the term overtones to express nuances; there isn't such a definition in music dictionaries. It's not about my or your opinion. Nuances and overtones are totally different things.
Comment: Ok, would you add some information about these supposed missing overtones? And for non-dictionary use, have a look at these cocoa powder overtones: https://drwakefield.com/news-and-views/around-aromas-the-many-flavours-of-coffee/
Comment: you are going definitely out of topic, I already provided a link to Britannica and suggested Oxford Grove to the OP as they are concise and great sources. Saying 'I didn't know that thanks for letting me know' shouldn't be that hard. My last comment (not to turn this into a discussion as I think it would be out of the rules of musicstackexhange.)
Comment: @ojs No problem then. By the way I'm not a coffee connesseur but I drink it a lot -just to be awake- I don't think my cheap 'french press nescafe' is good at producing 'overtones' than my guitar is
Answer: Let me ask you the inverted question: while I'm playing the piano, or playing soccer or ..., somebody tells me "I can do better than you" and he pushes some buttons.
... and indeed: what comes out of the button-machine indeed sounds better than what I produce, using my bare hands, so what?

You are 100% dependent of a machine you have absolutely no control of.
In top of that, there is no pride in pushing some buttons.

I'll will feel proud for what I can do, and you will feel even more proud for doing less and producing more (or better), and both of us will go separate ways.
Several years later we meet again, and what has happened? The machine producers have heavily increased their prices (the prices of the machines themselves, the prices of the usage, ...) and you will be poor!
I, however, still am enjoying my musical instrument, I'm still enjoying my soccer ball and I have even improved my skills, playing the piano and playing at soccer, and I will be rich!
Comment: One is also less fun if your goal is to play, not just listen.
Comment: Why do you think computers are not a race to the bottom market like ... computers?
Comment: Very few folk become rich playing either piano or football.
Comment: @Tim: although I used the word "poor" in a financial context, the word "rich" might have a financial one, but in my case it's more like a personal one: you have no idea how rich I feel when I create beauty at my piano! :-)
Answer: All good points above, but I feel the most important was left out.  The difference is that playing music FEELS GOOD.  Your body, mind, and instrument become one thing happening in real time.  And this is what people perceive during a live performance that no amount of synthesis can achieve.  Live music evokes JOY in the performer and audience.  It's ephemeral, here in the moment and then gone forever.  Digital composure and playback is certainly fun too, but not the same.  Not to be overly graphic, but it's a bit like the difference between making love to your spouse or creating a sex scene using Blender or Unity.
Answer: Most of the answers here focus on the result, but there is also the process aspect.
Playing an instrument can be deeply meditative, even if you do not play well enough to perform. It is a reason enough by itself, being therapeutic for body and mind.
A bonus side effect is when you get into the flow of playing, you get a lot of interesting ideas right at your fingertips. While not a complete substitute for methodical composing, this is definitely a great way to compose.
Answer: This question is pointless, but I'll provide a wonderful (IMNSHO) counterexample:
Ludwig vanB  composed orchestral work just fine without any sonic input of any kind.
Res Ipsa Loquitur
(Yes, I like HST's books)


"Catch All" Server-Side Load Profiling

Question: If I have an infrastructure with some Web Servers (Windows 2003 and IIS) and a Database (SQL Server 2005) and ASP.net, I wonder if there is a catch-all tool that simply allows me to say "Ok, I now open this page and you tell me exactly what happens on ASP.net, IIS and SQL, CPU, RAM and Hard Disk".
Of couse I can add tracing to my ASP.net and then to my SQL Server and then I have to see how to deal with IIS (as images for example do not go through ASP.net), but I wonder if anyone has a way to get an overview of pretty much everything in a simple way? Preferably free, but as long as it's good it can also cost money.
Answer: Look at using SQL Server Profiler and Windows Server performance monitor traces together. SQL Server 2005 allows you to co-relate these two files together.  This article describes how to do this well.
In addition to this, If you use the application name= parameter in your SQL Server connection string you can capture this in the Profiler trace & use this as a way of passing information from your asp.net/asp application like what filename is being executed.
Answer: You could try commercial tools like BMC AppSight, or if it's .Net based only, AVICode.
If you're looking to do this on the cheap, a combination of IIS logs and Perfmon counters would cover your needs.
Answer: Windows Performance Monitor is a pretty good bet. It will embed itself as an ActiveX control into a web page, so you can just open it up, and its counters can monitor pretty much every aspect of the server (just as long as it can be represented numerically).
You can monitor remote servers, as as long as the account it's running on has admin privileges over them.
The counters we generally run for visual reference are:

ASP.net \ Applications Running
ASP.net \ Requests Wait Time
Processor \ % Processor Time
PhysicalDisk \ Avg. Disk Queue Length
Memory \ Avaliable MBytes

There are a bunch of SQL based metrics (wait time, queries per second, avg query run time, etc) that I don't have handy on me right now but it's pretty flexible in its reporting. Same with ASP.net - you can have it report on individual applications, or use the _total counter for all of them.
Answer: Hmm. I'm not familiar with one tool that will give you everything but you can accomplish this with a combination of tools.
You mentioned SQL Server, so SQL Profiler is something you should look at to monitor everything going on in your db.
For everything going over Http you should look into Fiddler.
CPU, RAM, and Hard Disk can be monitored via perfmon.exe (built into Windows) or Process Explorer.

"Catch All" Server-Side Load Profiling


ES6 - Parse HTML string to Array

Question: I have an HTML formatted string:
let dataString = '
Lorem ipsum

Lorem ipsum 2

';

How can I parse this string to get an array of tags as below?
let dataArray = [
  '
Lorem ipsum
',
  '

',
  '
Lorem ipsum 2
',
  '

',
];

Comment: Please visit [help], take [tour] to see what and [ask]. Do some research, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output.
Comment: What have you tried yet? It's better to showcase what you have tried so people can have a better understanding of what you are trying to do.
Comment: You could create a DOM element, set the innerHTML to this string and get the element's child nodes.
Comment: I tried .split(//g) but it only split  tags. I want to have
Answer: Turn it into a document with DOMParser, then take the children of the body and .map their .outerHTML:

const str = '
Lorem ipsum

Lorem ipsum 2

';

const doc = new DOMParser().parseFromString(str, 'text/html');
const arr = [...doc.body.children].map(child => child.outerHTML);
console.log(arr);

(you can also achieve this by creating an element and setting the innerHTML of the element to the string, and then iterating over its children, but that could allow for arbitrary code execution, if the input string isn't trustworthy)
Answer: Dom parsing is recommended.
Here using vanilla JS without the DOMParser used in the other answer

let dataString = `<p>Lorem ipsum</p> <figure><img src="" alt=""></figure> <p>Lorem ipsum 2</p> <figure><img src="" alt=""></figure>`;
let domFragment = document.createElement("div");
domFragment.innerHTML = dataString;
const arr = [...domFragment.querySelectorAll("div>p,div>figure")].map(el => el.outerHTML)
console.log(arr)

If you cannot use that, then your SPECIFIC string can be split like this after fixing your nested quotes.
Note any change for example adding a space after the  will break such a script

let dataString = `<p>Lorem ipsum</p> <figure><img src="" alt=""></figure> <p>Lorem ipsum 2</p> <figure><img src="" alt=""></figure>`;
dataString = dataString.replace(/> /g,">|").split("|")
console.log(dataString)
Comment: This is very specific to this example. If there is a space after ``, it will add another element in the output
Comment: Hence my statement: _then your SPECIFIC string_
Answer: I am not clear with your question. Is that a random string or a html string? The split rule is slice the origin string into html element parts?
If true, I think we can handle it with a dummy element.
For convenient, I use jQuery selector:

let stringToSplit = `<p>Lorem ipsum</p> <figure><img src="" alt=""></figure> <p>Lorem ipsum 2</p> <figure><img src="" alt=""></figure>`
$dummy = $("
"); // create a dummy
$dummy.html(stringToSplit);
var dataArray = [];
var dummyChildren = $dummy.children();
for (var i = 0; i < dummyChildren.length; i++) {
  dataArray[i] = dummyChildren[i].outerHTML
}
$dummy = null; // remove from memory
console.log(dataArray)

Comment: I made you a snippet.  You do not actually answer OP's question since you have an array of innerHTML and not outerHTML. Also why loop using a for loop when you have jQuery to your disposal? OP did not actually ask for jQuery either. - also no need to actually append the div to the body. It can be done in memory. See [my version](https://stackoverflow.com/a/59353945/295783) which does return the HTML strings requested. Also you do not use `slice` which is a JS function in its own right
Comment: Thank for your tips. I corrected my answer. I'm just a beginner here so my approach may not be the shortest and smartest :D

ES6 - Parse HTML string to Array


Show distinct vectors of a vector space is basis

Question: Let $u$ and $v$ be distinct vectors of a vector space $V$. Show that if $\{u, v\}$ is a basis for $V$ and $a$ and $b$ are nonzero scalars, then both $\{u+v, au\}$ and $\{au, bv\}$ are also basis for $V$.
Comment: Do you know what a basis is ? Then, what do you need to prove about $\{u+v,au\}$ and $\{au,bv\}$ ?
Comment: Hi! Please share your thoughts and/ or your work
Comment: Show some of your own work/thoughts please
Answer: Since $\{u,v\}$ is a basis, we know that we can write every $x\in V$ as
$$
x = x_1 u + x_2 v
$$
for unique scalars $x_1,x_2$.
I will show the first example $\{u+v,au\}$ the second example is not very different. Again take an arbitrary $x\in V$ then
$$
x = x_1 u + x_2 v = x_2u + x_2v + (x_1-x_2)u = x_2 (u+v) + \frac{(x_1-x_2)}{a}au.
$$
so every $x$ is in the linear span of $\{u+v,au\}$. Since $\{u+v,au\}$ has two elements and $V$ is two dimensional this set is also a basis.
Answer: A basis for an n-dimensional space has three properties- and any two of them imply the third:
1) The set of vectors spans the space
2) The vectors in the set are independent.
3) The number of vectors in the set is n.
Here, we are told that {u, v} is a basis so we know all 3 of those.  In particular, we know (2)- that u and v are independent so if au+ bv= 0, we must have a=0 and b= 0 and (3) this vector space has dimension 2.
Then suppose, for some scalars, p and q, p(u+ v)+ q(av)= pu+ (p+ qa)v= 0.  Since u and v are independent, p= 0 and (p+ qa)= qa= 0.  Since a is non-zero, q= 0.  So u+ v and av are independent and there are 2 of them- they form a basis.
Suppose, for some scalarts, p and q, p(au)+ q(bv)= (pa)u+ (qb)v= 0.  Since u and v are independent, pa= 0 and qb= 0.  Since a and b are non-zero, p= 0 and q= 0.  So au and bv are independent and there are two of them- they form a basis.


How to highlight multiple bar using matplotlib

Question: I want to highlight the max value and 2 other bars. Can anyone help me with this, thank you!!
<code>#Figure size
plt.figure(figsize = (20, 8))

#Group by position and find the mean salary
df.groupby("Position")["Salary"].mean()

#Plot bar graph
ax = df.groupby("Position")["Salary"].mean()

#Highlight max value bar
ax.plot.bar(color=np.where(ax==ax.max(), '#ff9999','cadetblue'))

#Axis label
plt.xlabel("Position",fontsize=12)
plt.ylabel("Salary",fontsize=12)
plt.title("Wages for different job functions", fontweight='bold', fontsize=14)

plt.show()
</code>
Answer: Get an array of bar graphs and set the color of the desired location. In the following example, besides setting a special color for the largest value in your code, you have also set the fourth to red.
<code>import matplotlib.pyplot as plt
import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)

plt.rcdefaults()
fig, ax = plt.subplots()

# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

bars = ax.bar(y_pos, performance, align='center', color=np.where(performance == performance.max(),'#ff9999','cadetblue'))
ax.set_xticks(y_pos)
ax.set_xticklabels(people)
ax.set_ylabel('Salary')
ax.set_title("Wages for different job functions", fontweight='bold', fontsize=14)

bars[3].set_color("red")

plt.show()
</code>
Comment: The basis of my answer is a modification of the sample in the official [reference](https://matplotlib.org/stable/gallery/lines_bars_and_markers/barh.html#sphx-glr-gallery-lines-bars-and-markers-barh-py). The sample graph is a horizontal bar graph, so please note that the names of the x and y axes are wrong in the code.
Comment: I got this error: TypeError: 'AxesSubplot' object is not subscriptable. Do you know whats the reason?
Comment: Did you run it with my code? In your code, ax is the name of the data frame, and you are drawing a graph in a pandas plot. In my code's matplotlib, ax is a graph object, so I think that's the cause.


Set "publish to web" in Google spreadsheet using Drive API (PHP)

Question: I am trying to use the Google Drive API to set a Google Sheet into "Publish to Web" mode so that I can embed it on my website.
Using the Drive API in my PHP:-
<code>// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Sheets($client);

$driveservice = new Google_Service_Drive($client);
/*
$copiedFile = new Google_Service_Drive_DriveFile(array('name' => 'Project plan'));
$responseBody=$driveservice->files->copy("1hAjKEox4hhlK4aoCVLuUVfTJbKPhFklG1gG9-HsGH7U", $copiedFile);
$sheet_id=$responseBody->id;
*/
$sheet_id="1tYktONmPaaxGaS5ylNn8nTzPjtdEsuYIDHakhap8Amk";
$revisions=$driveservice->revisions;
$sheetinformation =$revisions->listRevisions("1tYktONmPaaxGaS5ylNn8nTzPjtdEsuYIDHakhap8Amk");
$revisions=$sheetinformation->getRevisions();
$count=count($revisions);
$revision_id=$revisions[$count-1]->id;
$finalrevision=$driveservice->revisions->get($sheet_id,$revision_id);
$finalrevision->publishAuto=true;
$driveservice->revisions->update($sheet_id,$revision_id, $finalrevision);

die();
</code>
As far as I can tell this conforms to the Drive API specification (I really wish they hadn't removed the code examples for PHP!). However, I am getting the following error returned in the Response body:-
<code>"error": {
  "errors": [
   {
    "domain": "global",
    "reason": "fieldNotWritable",
    "message": "The resource body includes fields which are not directly writable."
   }
  ],
  "code": 403,
  "message": "The resource body includes fields which are not directly writable."
 }
}
</code>
Any help would be appreciated!
Comment: Referring to this [SO post](https://stackoverflow.com/questions/38533957/google-sheets-api-how-to-publish-to-web-for-embeddable-sheet), can you try removing the finalrevision parameter? Seems the sample used fileId and revisionId only.
Answer: Add parameters when getting finalrevision:
<code>$finalrevision=$driveservice->revisions->get($sheet_id,$revision_id, array('fields' => 'publishAuto'));
</code>
Without last parameter, get method will return you whole revision (with all fields, including read only ones).

Set “publish to web” in Google spreadsheet using Drive API (PHP)


como eu arrumo o "Menu ficando por baixo do slide"

Question: pessoal na onde eu estou errando :/ ... ?

@import url('https://fonts.googleapis.com/css?family=Montserrat+Alternates');

h2{
font-family: 'Montserrat Alternates', sans-serif;

}
@import url('https://fonts.googleapis.com/css?family=Gentium+Book+Basic');
.numero{font-family: 'Gentium Book Basic', serif;
    opacity: 0.6;
     font-size:medium;

}
.iframe-container{
    position: relative;
    width: 100%;
    padding-bottom: 59.25%; /* Ratio 16:9 ( 100%/16*9 = 56.25% ) */
}
.iframe-container > *{
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}
body{
    background-color:;
}

    <title>Brown Odontologia</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="css/styles.css">
    <link rel="stylesheet" type="text/js" href="js/alerta.js">

BROWN ODONTOLOGIA

SEU SORRISO É NOSSA MISSÃO

            Quem Somos ?
            Por que nos escolher ?
            Especialidades
            Como chegar ?

                <button type="button" class="btn btn-primary-center dropdown-toggle" data-toggle="dropdown">Contatos</button>

  WhatsApp

  WhatsApp

Fácil Acesso

Como chegar ?

Second slide label

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

O que vale é a qualidade

Venha Conhecer Nossos Planos

                Anterior

                Próximo

Answer: É só colocar um z-index no header

<!DOCTYPE html>

  <title>Brown Odontologia</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link rel="stylesheet" type="text/css" href="css/styles.css">
  <link rel="stylesheet" type="text/js" href="js/alerta.js">

BROWN ODONTOLOGIA

SEU SORRISO É NOSSA MISSÃO

      Quem Somos ?
      Por que nos escolher ?
      Especialidades
      Como chegar ?

        <button type="button" class="btn btn-primary-center dropdown-toggle" data-toggle="dropdown">Contatos</button>

  WhatsApp

  WhatsApp

Fácil Acesso

Como chegar ?

Second slide label

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

O que vale é a qualidade

Venha Conhecer Nossos Planos

          Anterior

          Próximo

Comment: mais como deixa o fundo branco (não acho q ficaria legal o fundo meio transparente)
Comment: @caiquesey cara até tentei ver aqui pq fica transparente, mas não consegui resolver... acho que vc poderia abrir outra pergunta para ver se aparece alguém com uma resposta para isso
Answer: É, você pode usar o z-indez nas div's que você quer sobrepor, exemplo na
header{
 z-index:2; /* Se der conflito você aumenta o número*/
}


Vector spaces, subspace.

Question: Examine that $W$ is a subspace of the vector space $M_{3x3}$
$W=({A:det(A) \ge} 0)$
I have two conditions:
1) $ \vec u + \vec v \in W $
2) $ \alpha \cdot \vec u \in W $
$ B,C \in W $
$det(B) + det(C) \ge 0 $
I don't know any properties of determine of matrix which could help with these.
Comment: I don't understand your attempt: you've just written down four inequalities, with no clue as to what you're doing with them. Please explain further.
Comment: @ChrisEagle - do you think that the claim is true ? how about $diag(-2,-8,1)+diag(3,3,3)$ as a counterexample ?
Comment: @ChrisEagle - or take something in $W$ and the scalar as $-1$ then $det$ changes signs
Comment: Yeah, let $A\in W$. Then $(-A)\in W$. But $A+(-A)=0\notin W$, contradiction, therefore etc. etc. etc.
Comment: @Belgi: Why are you telling me this? Of course I can solve this problem. Post an answer if you want to.
Comment: It was wrong what i've wrote. I have no idea how start with it.
Comment: @ChrisEagle I trust that you know the answer, but because you asked the OP about his effort that threw me off to think that he is trying to prove something that correct...
Answer: $W=\{A\colon \det A\geq 0\}$ is not a subspace of the vector space $M_{3\times3}$ (I assume it is over the reals). Take for example
$$
I=\begin{bmatrix}
1 & 0& 0\\
0&1&0\\
0&0&1
\end{bmatrix}.
$$
Obviously $\det I=1$ and $I\in W$. Now take $(-1)I$ and observe that $\det (-1)I=(-1)^3\det I$.
Answer: This claim is not true:
First, note that $A=diag(-2,-8,1),B=diag(3,3,3)\in W$ but $A+B\not\in W$.
Moreover, if $A\in W$ then $|-A|=(-1)^{3}|A|\leq0$ and so $-A\in W$
iff $|A|=0$ but there are matrices in $W$ with non-zero determinant

Vector spaces, subspace.


Neologism based songs

Question: Lacking in music vocabulary I'm finding it hard to articulate, but I am looking for songs (or the genre) that use sounds and made up words purely for its aesthetic quality. The closest thing I can conceive of is something like Adiemus which uses vocals as an instrument where the words have no inherent meaning of themselves. Beatboxing I think comes close too but the 'vocabulary' in beatboxing seems somewhat more limited.
Comment: Check out "scat-singing". https://en.wikipedia.org/wiki/Scat_singing
Comment: @Olli scat-singing is one class of this.  Since scat involves (usually) sneaking a lot of words into the stream, it's not the same as purely singing a sequence of "voice shapes" such as la-la-fa-tu-tu, e.g.
Answer: Elizabeth Fraser of the Cocteau Twins used to make up/pick up random words just for their sound.
Search terms that may interest you:

an invented language is called idioglossia;
the broader study of euphony (what sounds good) is phonaesthetics.
Comment: wow thanks! you read my mind with those search term suggestions! Gotta get reading.
Answer: Nat King Cole's "Frim Fram Sauce" comes to mind as does the "Hapsut Song."

Neologism based songs


Theremin recommendations

Question: I was wondering if anyone around here had any experience playing the Theremin and might be able to recommend some specific models on the market that are worth looking into. Any advise/ideas are highly appreciated.
Comment: I had suggestion from my uncle who is a long-time electronics wizard and antiques collector which very much surprised me: the type of Theremin that's really desirable is a vintage 1930s model as designed by Leon Theremine himself. My uncle does not like the Moog designs.
Answer: Almost all Theremins sold these days are Moog theremins, or kits.
While I get the point @luserdroog makes, the Moog ones are really good (I have never played an original Theremin though, so maybe I'm not aware of how good those are)
The two I have tried have been a Moog Etherwave Plus, and a kit version (that I think is based on the standard etherwave) - the difference is that the Plus gives you additional outputs to control analogue synthesizers. If you don't need that I think the Standard will be sufficient.

Pic from Gak.co.uk
Comment: I tried prodding my uncle for more details. But I think I need to do my homework so I can ask him the right question.
Comment: would be good to have quantitative differences - I have just never seen an original one :-)
Comment: Thanks for your replies, @luserdroog I'll research differences between original & moog theremins.
Answer: If it's your first theramin and you're not really sure if you want to make the investment, there are tons of inexpensive kits that you can get, and they're really fun to make! My first one was the little red mini theramin kit from gakken: https://www.adafruit.com/product/1822 discontinued but appears to be available from a few vendors for $35-$70, which is nothing compared to the $300-400 you'd spend on the moog. Definitely worth trying it out first before throwing that much money into it.

Theremin recommendations


How to count the number of anonymous users that are currently using the site?

Question: I want to either use a module or write a module which allows me to count the number of Anonymous Users that are currently using the site.
What is the best method for this to be achieved? I looked at the statistics module but this does not enable me to count the data. I discovered views is capable of  this with this setting, "Content statistics: Most recent views". But, there was no option for anonymous data.
Comment: It may not be possible to do this. By default anonymous users don't get a session in D7 until they do something such as a form submission that requires one, so there is no way to identify them individually and hence count them.
Answer: The admin_menu module does this, and provides this function:
<code>/**
 * Counts how many users are active on the site.
 *
 * Counts how many users have sessions which have been active since the
 * specified time. Can count either anonymous sessions or authenticated
 * sessions.
 *
 * @param $timestamp
 *   A Unix timestamp. Users who have been active since this time will be
 *   counted. The default is 0, which counts all existing sessions.
 * @param $anonymous
 *   TRUE counts only anonymous users. FALSE counts only authenticated users.
 *
 * @return
 *   The number of users with sessions.
 *
 * @todo There are mostly no anonymous sessions anymore. Split this into a
 *   separate module providing proper user statistics.
 */
function admin_menu_session_count($timestamp = 0, $anonymous = TRUE) {
  $query = db_select('sessions');
  $query->addExpression('COUNT(sid)', 'count');
  $query->condition('timestamp', $timestamp, '>=');
  $query->condition('uid', 0, $anonymous ? '=' : '>');
  return $query->execute()->fetchField();
}
</code>
It returns the count of users who have been active in the past (default) 15 minutes like this:
<code>    function admin_menu_get_user_count() {
      $interval   = REQUEST_TIME - variable_get('user_block_seconds_online', 900);
      $count_anon = admin_menu_session_count($interval, TRUE);
      $count_auth = admin_menu_session_count($interval, FALSE);

      return t('@count-anon / @count-auth', array('@count-anon' => $count_anon, '@count-auth' => $count_auth));
}
</code>
Answer: Depending on what you want to know the google analytics module could help you. It counts the number of unique users. This is only helpfull if you don't have to many registered users.
Comment: For most things the Google Analytics module works well for anonymous users and can even work pretty well for logged in users if the role settings are used in the contrib module.
Comment: I would use Google Analytics and set a custom (GA) variable indicating whether the user is logged in. You can easily get this out of a body class using jQuery.
Answer: For info related to visitors of a website, consider the visitors module as an  alternative.One of the things you get from it is a Visitors Block, which includes, among others, data about:

Total Visitors.
Unique Visitor.
Registered Users.
...

Combining these 3 numbers is a possible estimate to "calculate" the number of unique not-registered (anonymous) users.
This module also comes with some reports & charts (a typical related requirement ...).
Its community docu and/or project page contains some more details. However its documentation pages still need quite some work to get completed. Refer to issue #2432369, for various topics that still need to be included somehow. The child issues of this issue already contain some pointers to documentation contained in existing issues. Testing the module in your own environment is a possible approach to find out what the module's capabilities really are.
Disclosure: I'm the new maintainer of this module,
I hope this does not violate the site's policy on self-promotion.
Comment: The OP is asking about anonymous users.
Comment: The project page doesn't explain how the module helps counting the number of anonymous users who are using the site. May you expand on that part?


Limit using l'Hopital's rule with logaritmus

Question:
What is $\lim_{x\rightarrow0}(1+2\sin x)^\frac{1}{\tan x}$?

Computing $\lim_{x\rightarrow0}\log(1+2\sin x)^\frac{1}{\tan x}=\lim_{x\rightarrow0}\frac{\log(1+2\sin x)}{\tan x}$
Here, where I can use l'Hopital's rule I get:
$\lim_{x\rightarrow0}\frac{\log(1+2\sin x)}{\tan x}=2$
But now my question is:
$\lim_{x\rightarrow0}(1+2\sin x)^\frac{1}{\tan x}$ = $\lim_{x\rightarrow0}\frac{\log(1+2\sin x)}{\tan x}=2$?
I don't think they are the same, but can I remove the log? Maybe it's easier than I think, but now I don't know how to go on.
Answer: You mean $$\lim_{x\to 0}(1+2\sin x)^{\tfrac{1}{\tan x}}=\exp\lim_{x\to 0}\frac{\ln (1+2\sin x)}{\tan x}=e^2.$$
Answer: The first equality you write is incorrect. You can evaluate
$$
\lim_{x\to0}\frac{\log(1+2\sin x)}{\tan x}
$$
in order to compute the given limit, but they are not equal; if $l$ is the latter limit, then the one you're looking for is $e^l$.
Now, with l'Hôpital,
$$
\lim_{x\to0}\frac{\log(1+2\sin x)}{\tan x}=
\lim_{x\to0}\frac{\dfrac{2\cos x}{1+2\sin x}}{1+\tan^2x}=2
$$
and therefore
$$
\lim_{x\to0}(1+2\sin x)^{1/\tan x}=e^2
$$
Answer: As an alternative
$$\large (1+2 \sin x)^\frac{1}{\tan x}=\left[(1+2 \sin x)^{\frac1{2\sin x}}\right]^\frac{2\sin x}{\tan x} \to e^2$$


How to use multilevel and hashed categorical variables to build an anomaly detection classifier

Question: I am building a binary classifier to detect hacker intrusions from a network. My dataset has over 20K events, of which 4% are positive (intrusions) and the rest are safe events. I am attempting to use random forests to build the classifier, but most of my variables are categorical variables (i.e., IP addresses) with over 19K levels. Moreover, the data is hashed, so I don't have the actual IP addresses, but its hashed numbers. I considered one hot encoding these variables, but this would result in 19k different variables, or reducing the dimensionality of these variables, but given that they are hashed, I don't think I can do this.
Further, I understand that hashing an input could result in two ore more IP addresses associated with a single hash numbers, therefore preventing me using the hash number to discern between safe and unsafe IP addresses (the same hash could in theory be given to both). Is there any way around this?
I have other data to work with, but they don't seem to be working that well when attempting, for example, logistic regression. I am considering other methods like weighted logistic regression or maybe an outlier detector, but I haven't used one before.
Comment: What hashing algorithm was used (or what do the final hashes look like?)
Comment: Just like long alphanumerical strings of around 200 characters.
Answer: The core of your question seems to be whether a hash of an IP address can be used as a replacement for the IP address itself or if this will not perfectly differentiate the IP addresses (due to hash collisions).
Let's assume you are using SHA-1 hashes, which have 160 bits in the hashed value (and therefore $2^{160}$ different hash values). The probability that $k = 19,000$ hashes randomly selected from the set of $N=2^{160}$ possible hashes are all unique is:
$$\frac{N-1}{N}\frac{N-2}{N}\ldots\frac{N-(k-1)}{N}$$
This means the collision probability is roughly $10^{-39.9}$, meaning it is vanishingly unlikely that you would have a hash collision, and you can almost certainly safely use the hashes in place of the real IP addresses.
Comment: great answer, thanks! would this significantly change if a different (but also commonly used) function was used?
Comment: @user3824382 Hash functions are designed to make collisions very unlikely, so unless a very weak hash function were used (e.g. CRC32), you should be fine. Given that you stated that your hashes were "long alphanumerical strings of around 200 characters" in your comment on the question, my guess is that hash collisions should be vanishingly unlikely in your case.


styling submit form button for mobile

Question: I have styling done for the submit form buttons on web, and when i maually resize my browser, the stying stays the same in smaller widths. But, when i videw on my Iphone 6, the stying looks like default drupal button.
Is there something is the base theme Bartik that is causing an override on true mobile?
I'm using Drupal 7 and only have 2 themes installed, My custome theme, and Seven for admin use.
<code>.button,
input[type="button"],
input[type="submit"] {
  padding: 7px 14px;
  display: inline-block;
  border: 0;
  font-weight: 500;
  outline: none;
  font-size: 14px;
  cursor: pointer;
  width: auto;
  -webkit-transition: all 0.2s ease-in-out;
  -moz-transition: all 0.2s ease-in-out;
  -o-transition: all 0.2s ease-in-out;
  -ms-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
  border-radius: 3px;
  box-shadow: inset 0px -1px 0px 0px rgba(0,0,0, 0.1);
}

.button i {
  margin: 0 2px 0 0;
}

.button.gray {
  color: #fff;
  background: #aaa;
}

.button.gray:hover {
  background: #a0a0a0;
}

.button.light {
  color:#999;
  background:#f2f2f2;
  box-shadow: inset 0px -1px 0px 0px rgba(0,0,0, 0.05);
}

.button.light:hover {
  color: #fff;
  background: #a0a0a0;
  box-shadow: inset 0px -1px 0px 0px rgba(0,0,0, 0.1);
}

.button.color {
  color:#fff; background: #a0a0a0;
}

.button.color:hover {
  background: #a0a0a0;
}

/* Input Button */
input[type="button"],
input[type="submit"],
input[type="button"]:focus,
input[type="submit"]:focus {
  color:#fff;
  background: #a0a0a0;
  padding: 8px 14px;
  border: none !important;
}

input[type="button"],
input[type="submit"] {
  /*float: left;*/
}

input[type="button"]:hover,
input[type="submit"]:hover {
  background: #a0a0a0;
}
</code>
My Responsive Media Queries are in two sections
<code>/* Standard 1180 (devices and browsers) */
@media only screen and (min-width: 1200px){
  .caption.text { margin-left: 0 !important; }
  .caption h2,
  .caption h3,
  .caption p {margin:0;}
}

/* Smaller than standard 1180 (devices and browsers) */
@media only screen and (min-width: 959px) and (max-width: 1199px) {
  .caption.text { margin-left: 50px !important; }
  .caption h2,
  .caption h3,
  .caption p { margin:0; }

  #navigation ul > li > a { padding-left: 15px; padding-right: 15px; }

  ol li ol.childlist .comment-des {
    float:right;
    width:78%;
  }

  .comment-des {
    float:right;
    width: 81%;
  }

  .add-comment textarea,
  #contact textarea { min-width: 97%; }

  .flickr-widget-blog a {
    width: 57px;
    height: 57px;
  }

  #not-found { margin: 50px 0 75px 0; }

  #not-found h2 {
    font-size: 210px;
    line-height: 210px;
  }

  #not-found p {
    font-size: 28px;
    line-height: 36px;
  }

  #not-found i {
    font-size: 200px;
    top: -5px;
  }

}

/* Tablet Portrait size to standard 960 (devices and browsers) */
@media only screen and (min-width: 768px) and (max-width: 959px) {
  .caption.text { margin-left: 30px !important; }
  .caption h2 { margin-top: -8px;}
  .caption p { margin-top: 8px;}
  .img-1 {margin-left: 0 !important;}

  #navigation ul > li > a { padding-left: 14px; padding-right: 14px; }

  #search-form {
    position: absolute;
    right:0;
  }

  .search-container { margin-left: 50px !important; }
  .the-icons { font-size: 13px; }

  ol li ol.childlist .comment-des {
    float:right;
    width:71%;
  }
  .comment-des {
    float:right;
    width: 75%;
  }

  .add-comment textarea,
  #contact textarea { min-width: 96%; }

  .flickr-widget-blog a {
    width: 69px;
    height: 69px;
  }

  #not-found {margin: 35px 0 60px 0;}

  #not-found h2 {
    font-size: 160px;
    line-height: 160px;
  }

  #not-found i {
    font-size: 155px;
    top: -4px;
  }

  #not-found p {
    font-size: 22px;
    line-height: 32px;
  }
    #footer, #footer-bottom {text-align: center;}
  .get-in-touch li i, .get-in-touch li p strong {float: none}
  .get-in-touch p {margin: 0;}

}

/* All Mobile Sizes (devices and browser) */
@media only screen and (max-width: 767px) {

  .caption.text {margin-left: 30px !important;}
  .caption h2 {font-size: 32px; margin-top: 10px;}
  .caption h3 {font-size: 20px; margin-top: 15px;}
  .caption p {display: none;}
  .img-1 {margin-left: 0 !important;}

  .fullwidthbanner-container { top: 0; }

  .showbiz.our-clients ul li img { margin: 0 auto; }

  #breadcrumbs ul {
    float: left;
    margin-top: 0;
    padding: 0 0 24px 0;
  }

  #titlebar {
    top: 0;
    margin-bottom: 40px;
  }

  #titlebar h2 {
    margin-top: 3px;
  }

  #googlemaps { padding-bottom: 40%; }
  .plan-features { margin-bottom: 25px; }
  .medium .post-img { margin-bottom: 20px; }

  #filters { margin: 10px 0 30px 0; }
  #filters a { margin: 0 5px 5px 0; }
  .line.filters { display: none; }

  .line.showing {
    display: inline-block;
    margin: -11px 0 0 0;
    z-index: 5;
  }

  .social-icons-footer {
    margin-top: 5px;
    float: left;
  }

  #footer { padding-top: 10px; }
  #footer h3, #footer h2 { margin-top: 30px; }

  .featured-boxes { margin: 40px 0 5px 0; }
  .featured-box { margin: 0 0 25px 0; }

  a.button.launch { margin: 0 0 30px 0; }
  #related-work figure {margin-bottom: 20px;}

  .search-form {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid #f0f0f0;
  }

  #contact input[type="submit"] {
    margin: 0 0 30px 0;
  }

  #not-found {margin: 15px 0 25px 0;}

  #not-found h2 {
    font-size: 110px;
    line-height: 120px;
  }

  #not-found i {
    font-size: 105px;
    top: -2px;
  }

  #not-found p {
    font-size: 22px;
    line-height: 32px;
  }

  #footer, #footer-bottom {text-align: center;}
  .get-in-touch li i, .get-in-touch li p strong {float: none}
  .get-in-touch p {margin: 0;}

}

/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
@media only screen and (min-width: 480px) and (max-width: 767px) {

  ol li ol.childlist .comment-des {
    float:right;
    width:63%;
  }

  .comment-des {
    float:right;
    width: 68%;
  }

  .add-comment textarea,
  #contact textarea { min-width: 95%; }

  .flickr-widget-blog a {
    width: 87px;
    height: 87px;
  }

  #footer, #footer-bottom {text-align: center;}
  .get-in-touch li i, .get-in-touch li p strong {float: none}
  .get-in-touch p {margin: 0;}

}

/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
@media only screen and (max-width: 479px) {

  .caption h2 {font-size: 32px; margin-top: 0;}
  .caption h3 {font-size: 18px; margin-top: 10px;}
  .caption p {display: none}

  ol li ol.childlist .comment-des {
    float:right;
    width:49%;
  }

  .comment-des {
    float:right;
    width: 56%;
  }

  .add-comment textarea,
  #contact textarea { width: 90%; }

  .flickr-widget-blog a {
    width: 82px;
    height: 82px;
  }

  .dropcap {font-size: 52px;}

  #footer, #footer-bottom {text-align: center;}
  .get-in-touch li i, .get-in-touch li p strong {float: none}
  .get-in-touch p {margin: 0;}
}
</code>
The Second Media Queries CSS is only for layout purposes and shouldn't effect anything but column widths.
Picture 1 is from Firefox on my desktop

Picture 2 is from my iphone 6 Safari

My Page code shows this for the viewport code:
meta name="viewport" content="width=device-width, initial-scale=1"
My PHP is not rendering the final maximum-scale=1
Here is my PHP that is in my template.php file"
<code>  function your_theme_name_preprocess_html(&$vars) {
$viewport = array(
  '#tag' => 'meta',
  '#attributes' => array(
    'name' => 'viewport',
    'content' => 'width=device-width, initial-scale=1, maximum-scale=1',
  ),
);

drupal_add_html_head($viewport, 'viewport');
}
</code>
Comment: Hi, Tim. It might be helpful to provide: 1) your custom CSS for the buttons (including media queries); 2) screenshots of the way your button looks in the browser as well as on your phone.
Comment: That helps! Although I don't think you need to include the second block of CSS since there are no styles there for button input element as far as I can tell. Two things to try: 1) make sure your viewport tag is in place; 2) clear the cache on your mobile browser.
Comment: I didn't have my viewport yet, now i do, but still no change.
Comment: If you have your viewport tag `` and you've cleared the cache on your mobile browser, that just makes no sense to me. Sorry. :(
Comment: Found a similar post: http://stackoverflow.com/questions/16814207/responsive-design-site-showing-differently-on-iphone-versus-smaller-browser
Comment: i added my viewport code above. maybe something is wrong with it.
Answer: After a lot of searching with different terms i found the answer. Simple but effective.
-webkit-appearance: none;
Simple CSS value that stops any strange webkit CSS from rendering, and will then use the sites CSS as normal.

styling submit form button for mobile


PyQt5 Python: How to go through Individual Row of Data from MySQL Query Result

Question: I am trying to add item in a QComboBox in PyQt5 using Python. I am having problems in adding data from the SQL Query per row.
cursor = cnx.cursor()
            query = "SELECT buyerID, lastName, firstName, middleName FROM buyer ORDER BY id DESC LIMIT 5"
            cursor.execute(query)
            data = cursor.fetchall()
            item = list()
            for a, b, c, d in data:
                row = "{} | {}, {} {}".format(a, b, c, d)
                item.append(row)
            self.customerID.addItem(str(item))

This results to only a single item added into the Combo Box:
100000 | lastName, firstName middleName, 100000 | lastName, firstName middleName, 100000 | lastName, firstName middleName...etc.

What I want to happen in the ComboBox is like this (Add a total of 5 items in the Combo Box)
100001 | lastName, firstName middleName
100002 | lastName, firstName middleName
100003 | lastName, firstName middleName
100004 | lastName, firstName middleName
100005 | lastName, firstName middleName

Edit:
cursor = cnx.cursor()
query = "SELECT buyerID, lastName, firstName, middleName FROM buyer ORDER BY id DESC LIMIT 5"
cursor.execute(query)
data = cursor.fetchall()
item = list()
for a, b, c, d in data:
    row = "{} | {}, {} {}".format(a, b, c, d)
    item.append(row)
    self.customerID.addItem(str(item))  <------- I just moved this line of code into the FOR loop statement to add the item per loop.

Same Problem:
The appended Item added is still all the rows of data grouped into one.
Comment: Just use [`addItems(item)`](https://doc.qt.io/qt-5/qcombobox.html#addItems) (note the final "s").
Answer: After posting my question and tinkering on myself, I stumbled upon the answer to my question as I realized that I had to change the FOR LOOP statement to enumerate over the length of the data from MySQL Query Result and  .addItem to the ComboBox before it goes on to the next tuple from the results from data (SQL Query Result).
for a in enumerate(data):                 <--- changed the for loop statement to "enumerate" how many data inside the MySQL Query Result
     j, k = a                             <--- split (index, tuple) in a
     l, m, n, o = k                       <--- separate tuple into strings
     string = "{} | {}, {} {}".format(l, m, n, o)
     self.customerID.addItem(str(string)) <------- I just moved this line of code into the FOR loop statement to add the item before moving on to the next row in SQL results.


Finding $V(X)$ when you don't have a density/distribution function.

Question: I just did the first part of this problem:
You have a lot of $50$ items and are taking a sample size of $15$. In the lot $3$ items are defective. The lot is accepted if the number of defective items, $X$, is less than or equal to $1$. Find the probability that the lot is accepted.
$$\frac{\large{47 \choose 14}{3 \choose 1}}{\large{50 \choose 15}}+\frac{\large{47 \choose 15}{3 \choose 0}}{\large{50 \choose 15}}=.7892...$$
I was then asked to find the variance. Up until this point, I've always had some pdf or CDF from which to work with. Am I suppose to recognize this as a type of binomial distribution and thus, $V(X)=npq$. Where $n=50, p=\frac{47}{50},$ and $q=\frac{3}{50}$? Or, is the probability the lot is accepted suppose to be seen as some type of mean? If so, what would $E(x^2)$ be then?
Comment: You can find $Ef(X)$ by: $Ef(X)=f(0)P(X=0)+...+f(3)P(X=3)$. This for functions $f$ prescribed by $x\mapsto x$ and $x\mapsto x^2$ respectively. Then $EX$ and $EX^2$ are found and $Var(X)=E(X^2)-(E(X))^2$.
Comment: I would say that it is a hypergeometric probability distribution. Link to the variance formula: http://en.wikipedia.org/wiki/Hypergeometric_distribution
Answer: I'm not certain if this is appropriate or not, but for the sake of completeness, I thought I'd add my solution based off of georg's comment above. This does appear to be the correct answer.
We have a hypergeometric probability distribution. Thus,
$$V(X)=n\left(\frac{M}{N}\right)\left(1-\frac{M}{N} \right)\left(\frac{N-n}{N-1}\right)$$
$N=50$
$M=47$
$n=15$
$$V(X)=15\left(\frac{47}{50}\right)\left(1-\frac{47}{50}\right)\left(\frac{50-15}{49}\right)$$
$$=.6042...$$


Can't figure why my if statement is not working

Question: I can't figure out why my if statement is not working. For some reason it always evaluates first if statement as true, and in result outputs the wrong value.
With numberOfDays = 19 it should output 4.95, but instead it outputs 1.65, because it evaluates first if statement as true and doesn't change the value of numberOf7DayPasses:
class TransitCalculator {

    int numberOfRides;
    int numberOfDays;
    double[] prices = { 2.75, 33.00, 127.00 };

    public TransitCalculator(int myRides, int myDays) {
        numberOfRides = myRides;
        numberOfDays = myDays;
    }

    public double unlimited7Price() {
        int numberOf7DayPasses = 1;

        if (numberOfDays % 7 != 0 && numberOfDays / 7 != 1 && numberOfDays / 7 > 1 && numberOfDays / 7 < 2) {
            numberOf7DayPasses = 2;
        } else if (numberOfDays % 7 != 0 && numberOfDays / 7 != 2 && numberOfDays / 7 > 2 && numberOfDays / 7 < 3) {
            numberOf7DayPasses = 3;
        } else if (numberOfDays % 7 != 0 && numberOfDays / 7 != 3 && numberOfDays / 7 > 3 && numberOfDays / 7 < 4) {
            numberOf7DayPasses = 4;
        } else if (numberOfDays % 7 != 0 && numberOfDays / 7 != 4 && numberOfDays / 7 > 4 && numberOfDays / 7 < 5) {
            numberOf7DayPasses = 5;
        } else if (numberOfDays % 7 == 0 && numberOfDays / 7 == 1) {
            numberOf7DayPasses = 1;
        } else if (numberOfDays % 7 == 0 && numberOfDays / 7 == 2) {
            numberOf7DayPasses = 2;
        } else if (numberOfDays % 7 == 0 && numberOfDays / 7 == 3) {
            numberOf7DayPasses = 3;
        } else if (numberOfDays % 7 == 0 && numberOfDays / 7 == 4) {
            numberOf7DayPasses = 4;
        } else if (numberOfDays % 7 == 0 && numberOfDays / 7 == 5) {
            numberOf7DayPasses = 5;
        }
        double priceOfOneRide = numberOf7DayPasses * prices[1] / numberOfRides;

        return priceOfOneRide;
    }

    public static void main(String[] args){
        TransitCalculator testPerson = new TransitCalculator(20, 19);
        System.out.println(testPerson.unlimited7Price());
    }
}

Comment: have you debugged your code? what do you mean "is not working"?
Comment: how do you expect an int to be both >1 and <2 ?
Comment: Off topic but our code would be much easier to read if you assigned `numberOfDays % 7` and `numberOfDays / 7` to 2 local variables and then used them in your conditions.
Comment: For the life of me, I can't figure out what kind of logic you're trying ti implement, but I'm pretty sure that it can be done with a lot less code.
Answer: You say that you think it returns 1.65 because the first condition is evaluated true? So I guess you didn't use a debugger to step trough the code to see what really happens!
If the first condition would be evaluated to true, the output would be 3.3 (= 2*33/20)
The output is 1.65 which means none of the conditions evaluates to true.
The first condition (and the 2nd and the 3th and the 4th) can't evaluate to true because they will always be false. The 1st condition contains:
numberOfDays / 7 > 1 && numberOfDays / 7 < 2

NumberOfDays is an int and because of that the result of numberOfDays / 7 is also an int.
An int can't be greater than 1 and smaller than 2. So the condition will always be false. And in the 2nd, 3th and 4th condition, the numbers are different but they have the same problem.


Is there a way to force a tooltip to show in a specific place for an imput element?

Question: I'm working on a list of filters and due to size restraints, I want to have text input elements for each column. Each input's value will be the name of the column initially, but will be wiped out when the user clicks it. I want a way to display a tooltip above the input with the name of the column, whenever the input is being focused (so the user can see what he's doing without having to cancel his action and start again).
Comment: http://docs.jquery.com/Plugins/Tooltip i havent used it but it might give you some ideas.
Comment: if you don't like the default behaviour then use a custom one, [like these](http://slodive.com/web-development/best-jquery-tooltip-plugins/)
Answer: you can do this via applying CSS on Tool tip
<code>.tooltip {
  border-bottom: 1px dotted #000000;
  color: #000000; outline: none;
  cursor: help; text-decoration: none;
  position: relative;
}
.tooltip div {
margin-left:50px;
margin-top:50px;
margin-right:80px;
margin-bottom:300px;
  position: absolute;
}
</code>


jQuery Background Canvas transparency

Question: I'm using the jQuery Background Canvas plugin and have created a DIV with rounded corners and a gradient effect. However, I'm unable to get the transparency to work. What am I doing wrong? Here's the JavaScript:
$(document).ready(function()
{
$(".Test").backgroundCanvas();
$(".Test").makeElementTransparent("#CECFCE");
$(".Test").backgroundCanvas(true, "#CECFCE");
});

function DrawBackground() {
$(".Test").backgroundCanvasPaint(TestBackgroundPaintFkt);
}
// Draw the background on load and resize
$(window).load(function () { DrawBackground(); });
$(window).resize(function() { DrawBackground(); });

function TestBackgroundPaintFkt(context, width, height, elementInfo)
{
var options = {x:0, height: height, width: width,
radius:7, border: 0 };
// Draw the red border rectangle
context.fillStyle = "#CECFC6";
$.canvasPaint.roundedRect(context,options);
// Draw the gradient filled inner rectangle
var backgroundGradient = context.createLinearGradient(0, 0,
0, height - 10);
backgroundGradient.addColorStop(0 ,'#F7F7EF');
backgroundGradient.addColorStop(1, '#CECFCE');
options.border = 1;
context.fillStyle = backgroundGradient;
$.canvasPaint.roundedRect(context,options);
}

The element itself looks like this:

   something here

And here's the CSS for it:
.Test {
    width: 300px;
    height: 300px;
}

Comment: I think I might have mistaken the transparent functionality of this library with the alpha transparency you can apply to elements in HTML. In fact, it's the alpha transparency that I'm trying to achieve.
Answer: I ran into the same problem.
In my case, the following line did the trick:
$('#*[canvasId]*').css('background-color','transparent');

Answer: The solution has nothing to do with this jQuery library; it's the opacity/transparency CSS attributes. For Firefox and Safari, this does the trick:
.Test {
   -moz-opacity:0.5; /* For older FF versions */
   -khtml-opacity:0.5;
   opacity:0.5;
}

For IE, this was necessary:
canvas.jbgCanvas {
   filter:alpha(opacity=50);
}

In most cases, you should be able to apply the filter attribute to your element; but in this case, the only way it worked was to apply it to the CANVAS object.

jQuery Background Canvas transparency


Android fresco how to get save cache callback?

Question: I got a question about android fresco library. Do you guys know how to get callback when file is saved in cache? Generally, we could get file from cache:
ImageRequest imageRequest= ImageRequest.fromUri(url);
CacheKey cacheKey= DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(imageRequest);
BinaryResource resource = ImagePipelineFactory.getInstance().getMainDiskStorageCache().getResource(cacheKey);
File file=((FileBinaryResource)resource).getFile();

However, if I put this in onCreate() function, it will crash since the file was not in the cache yet. Do you guys know how I got get a callback when the fresco finish saving it? Is it DataSubscriber? Could you guys provide an example? I read the documentation but I couldn't figure out.
Thanks.
Answer: I am part of the Fresco team and may be able to help. Please see our documentation on how to properly get the encoded image bytes. There is a code example of how to get an InputStream of the encoded image (which is what is being stored in cache). You can then use those bytes directly, or if you need a File in order to pass it somewhere else, you should create your own file and store the returned bytes in it. There is no other safe way to deal with cached images because you have no guarantees that Fresco will not evict (delete) the cached file at any time.
Comment: As we know, fresco can't resize gif or png and such stuff.If i wanna resize it, i have to compress it my self.After getting a compressed bitmap, i don't know how to load it by fresco.Could you give me some advise?


Style is not applied while converting Html string to pdf itextSharp

Question: Below is the Code from which I am trying to generate pdf.
  Appending Html string and Converting into  Pdf,
The Pdf is generating but style is not applying .
protected void Demo()
{

    StringBuilder sb = new StringBuilder();
    sb.Append("");
    sb.Append("
");
    sb.Append("
");
    sb.Append("
");
    sb.Append("");
    sb.Append("
");
    sb.Append("


Composite control from LinearLayout get messed up when replaced with merge

Question: I want to create a composite view from a bunch of controls, by extending a LinearLayout.
I'm using an XML file to specify the inner layout of my custom control. I'm inflating the custom control from the code via LayoutInflater.
The Problem is:
If i replace the root LinearLayout element to a merge element in the XML, my whole layout fall apart. If I don't, then I only encapsulated a LinearLayout with my custom one.
The question is:
What do i have to change in the merge layout, so my view looks like how a linear layout should?
How it looks like:
With LinearLayout (this is how i want it to look like):
http://oi45.tinypic.com/2pqwby1.jpg
With merge (this is the tag i want to use):
http://i45.tinypic.com/155j4o0.png
The code:
TowerLayout.java (no problems here, just in case):
public class TowerLayout extends LinearLayout implements OnClickListener {

    public TowerLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.tower_layout, this, true); //this is what i want to use.
        //((LinearLayout)findViewById(R.id.root)).setOnClickListener(this); //this is the current ugly workaround.
        this.setClickable(true);
        setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Toast.makeText(getContext(), "Foo", Toast.LENGTH_SHORT).show();
    }
}

What i have in Tower_Layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:duplicateParentState="true">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="TowerA"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:duplicateParentState="true"
        android:textSize="32sp" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.28"
        android:duplicateParentState="true"
        android:src="@drawable/icon" />

</LinearLayout>

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Basic information"
    android:duplicateParentState="true"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_marginLeft="15dip"
    android:layout_height="wrap_content"
    android:duplicateParentState="true"
    android:text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:duplicateParentState="true"
    android:text="16m"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="100sp" />

What i want in Tower_Layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:duplicateParentState="true">

    ...

</LinearLayout>

...

</merge>

One more thing:
I know, the screenshots are from the eclipse designer, but believe me: they look like this on android phone as well.
Comment: Are you sure `TowerLayout` extends `LinearLayout`? From the images it seems to extend a `RelativeLayout` or a `FrameLayout`.
Comment: Where are you setting the `android:orientation` for your `LinearLayout`s? Both the parent `TowerLayout`, and the child inside the `merge` tag. It shouldn't matter much, but I've seen some strange layouts when it wasn't set.
Comment: @Luksprog Yes, I'm 100% sure it extends from the LinearLayout. The code/xml are 100% Copy + Paste
Comment: @Geobits From now on, you are my personal hero. That was the problem. I was searching for hours now. :) After i set the orientation explicitly magic just happened :) Thank you very much.
Comment: No prob, I'm glad it helped. I added it as an answer so you can close out the question and possibly help future users.
Answer: You should explicitly set the android:orientation tag for your layouts(and any LinearLayout, ever). Android supposedly uses horizontal by default, but in my experience it just messes it up if it's not set, and leads to some very strange-looking layouts.


Dropdown Button Didn't Showing

Question: I work with Jade (pug) and Nodejs.
I created a dropdown button, so that user can choose an item, but it didn't show in the application. There is no dropdown there. I've already use display:block and clean the browser cache. But still stuck here.
Here is my .pug file:
<code>.filters-nav
  .btn-group.m-r-15
    button.btn.btn-inverse.dropdown-toggle.waves-effect.waves-light.btn-custom(type='button', data-toggle='dropdown', aria-expanded='false')
      span.btn-label
        i.fa.fa-filter
      | Add filters
      span.caret
    ul.dropdown-menu.filters-dropdown(role='menu')
      li
        a(href='#', data-filter='table_1_filter_0') Instrument ID
      li
        a(href='#', data-filter='table_1_filter_1') Instrument Code
</code>
I wonder if it is CSS, but all I know is CSS doesn't related to element visibility at all.
Comment: you can use your browser's `developer tools` and `inspect element` feature to check whether this element is even being rendered in the html and if yes, then which css rule is causing it to be hidden.
Comment: You can show and hide elements with CSS using the `display`, `visibility` or `opacity` property. Post your relevant CSS.
Comment: @Charlie Martin I've got so many CSS related to this .pug. Do you mean the CSS with same filename with this .pug?
Comment: Besides, which element I have to check in CSS, is it `filters-nav` or else?
Answer: Maybe this will help, its pug plus the css
<code> li.dropdown.btn.btn-default
  span.glyphicon.glyphicon-th-list
   ............
</code>
https://codepen.io/thehumanscience/pen/qbLepW

Dropdown Button Didn't Showing


How to override prepareTranslation method in Drupal\content_translation\Controller in drupal 8?

Question: I want to override prepareTranslation method using my custom module in drupal 8. You can find this function here(Drupal\core\modules\content_translation\src\Controller\ContentTranslationController.php).
Answer: You can use hook_entity_prepare_form() to override the values from prepareTranslation() on $form_state.
Comment: Thanks for your reply. I want to change the $source_translation variable's value of prepareTranslation() function and rest of the things should work as it is in core function.i tried using below code but not geeting output.
Comment: function testmodule_entity_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Form\FormStateInterface $form_state) {
    $source_translation = $entity->toArray();
    $source_translation['title'][0]['value'] = "Hello";
    $source_translation['body'][0]['value'] = "Fine";
}
Comment: $soruce_translation is available in form_state. you could change it there. that's what prepareTranslation() is doing.
Comment: i tried using form_state but not able get values.e.g. ($form_state->getValues('body')) this prints blank array. I am new to drupal 8 can you please help me with small snipate of code?


How to overcome "Add new date link" issues in the 7.x-3.4 Calendar?

Question: Solved See my solution in the answer below.
I am having an issue with the 7.x-3.4 Calendar, and would like to know if anyone has a solution, or suggested solution, to this issue.
Background: I have created a new content type of "Booking", and have created a new Calendar View that displays only dates of this content type. The Calendar works fine, and if I add new content through my Administrator option of "Add content", I can define my date, taxonomy terms and specific information (such as the Point of Contact (POC) name and email address) without an issue. These display perfectly on my newly created calendar, with a coloured stripe dependant on the taxonomy term selected (just for interest, the taxonomy term defines which room they would like to book). From here however, I have this issue:
In the page to edit the view for the calendar, I select Format > Show > Settings, and get the "Month: Row style options" page. When I select a content type in the "Add new date link"   dropdown box, I do not get an "Add" link on my Calendar. (I have tried all the different types of content, including a content type that all authenticated users are able to, and actively do, create new content within. I have edited the permissions to allow all authenticated users to create content of content type "Booking". As a point of interest, I also use OG, however have not defined an OG "Group" to this content type, and do not plan to align this content type or calendar with any form of OG functionality in the future. I thought it pertinent to mention this in case here is where my problem lies)
I would greatly appreciate any feedback or thoughts anyone has, please do not hesitate to ask for any more information that you feel you may need!
Answer: OK, so I have fixed this with a custom work around. There are many modules that I am using that may be interfering with the permissions to add a new date, and be limiting what can be displayed in the view. No matter, here is how I solved it:
First of all, set up the modules and permissions as following:
Go to admin > modules, and find the PHP Filter module, ensure it is enabled:

Next, go into the permissions and find the following:

Ensure that the last option, "Administrator", is selected.
Next, go to the view where you would like to add the "Create Booking" (or whatever content type it is you are after.) From here, create a new header of type "Global: Text area"

What I chose to do next was create a link to a new view, and on this view I expose the form to add the new date/event. If you want to embed the create form here, then skip the next step, however I find doing it this way leaves the current calendar in it's original state, and by clicking the about to be created "+ Add Event" link, you will be taken to a new view that contains the calendar and the exposed form.
Now, select "Full HTML" as the Text format, and place the following code in the text box. This will create a link to a new view, which we will make next. The two lines below are simply coloured text that I will use as a legend for the calendar.

+ Create Booking

When we next create the view containing the form to add the new date/event, if you chose to use a different path, come back here and change "/calendar/create_booking" to your preferred path.
Now, apply changes and save the view. Go back to your Admin > Structure > Views page, and locate the view of your current calendar. Now, on the "Operations" dropdown, select "Clone View"

Rename the newly created view (I called mine "Create {Your Old View Name Here}"). Now, open up the "Edit" option for this view and create a new Header of type "Global Text Area" as before. This time, we want the Text Format to be "PHP Code" and to place the following code in your text area:

<?php
  module_load_include('inc', 'node', 'node.pages');
  $node_form = node_add('node_type');
  print drupal_render($node_form);
?>

Remember to change 'node_type' to your desired content type. Save the Header, and return to the last screen. Now simply change your path to what you wish:

And now finally, go back to your original Calendar view, edit the header to contain the correct path in the link we made, and you're finished! The form is now exposed for users to create a new event/date. Ensure that you set the appropriate permissions for users to be able to create this content type, and remember that their view of the create form will be much simpler than yours.
Hope this helped you if you had the same issue as me!


sequence of bounded domain in $R^n$

Question: Consider
$$\Omega_1 \supset \Omega_2 \supset \cdots$$
a sequence of bounded, open and convex domains in $\mathbb R^n$, with all the inclusions strict. I want to prove that $\bigcap \Omega_k \subset \overline{\bigcap \Omega_k}  \subset \Omega_k$ for all $k$.
I believe this is true. In some cases is easy to see this. but i dont know how to prove . Someone can give me a hint to how to prove or disprove ?
the problem is the second inclusion
Thanks in advance
Comment: By "$\cap\Omega_k$ do you mean $\bigcap_k\Omega_k$?
Comment: @MichaelHardy , yes  =)
Answer: The second inclusion is sometimes false.  E.g. in $\mathbb R$, $\Omega_k=(0,1+1/k)$.
Answer: As for the first inclusion, it is obviously weakly true, since every set is included in its closure by definition. But the inclusion need not be strict. Let, for each $k\in\mathbb{Z}_+$, $\Omega_k\equiv(-1/k,1/k)$. Then, the intersection $\bigcap_{k\in\mathbb{Z}_+}\Omega_k$ is $\{0\}$, which is a closed set, so that it is equal to its closure.

sequence of bounded domain in $R^n$


Power loss at company

Question: Property management at my organization has informed me that our building will be losing power for 4 hours tomorrow.  I need to be prepared for this event (we're a small organization, i'm young, therefore I am I.T).  What sorts of things do I need to be aware of.
I am planning on going in and shutting down all machines and printers.  Will this cover me?  We have a managed switch.  Does it need to be shut down?  Do I need to disconnect plugs in case of a surge?
Seems like I'll be covered all around if I just unplug everything.  Thanks for any insight though.
Answer: Before the outage:

Power everything off - workstations, servers, printers, switches, the works.
Turn off your UPS' so they don't panic when power is lost.

After outage in this order:

Turn on UPS
Turn on networking (router, switches etc)
Turn on servers
Turn on workstations
Turn on everything else

Have a test plan ready so you can test important functionality is working

Internet connectivity
Email, printing etc

If possible, have a laptop with a separate network connection handy (ie: you can get to the internet without your work router working). That way you have a way to ask for help here if something goes wrong with the networking when it comes back up. :)
You should be fine though - the fact that you took the time to ask here shows you already have the requisite "clue" required for IT support!
Comment: +1. A couple of things: if you have the login for the managed switch, make sure you log in and save the configuration. Also, see if you have the cables required to connect to the console port of both your router and switch. Many of them require serial (DB-9) connections, so if you have a recent laptop, you may need a USB->serial adapter. Good luck.
Comment: +1 for the laptop with its own internet access. In addition to calling for help, you can use this to test that outside items are available beyond your network and inside resources aren't. That _was_ a part of your test plan right? Riiight?
Comment: +1 and also figured I'd repeat what some of the posters have already said below about unplugging some of your valuable hardware from the WALL if you don't know exactly what the facilities people are going to be doing to the power lines.  Better safe than sorry!
Comment: Thansk for the detail.
Comment: Yeah, definitely isolate as much from the supply as you can. However, don't have anything running on the UPS when it's isolated, as you NEED the ground connection if anything is online.
Answer: Having just done through a datacenter shutdown in the last week, this is fresh on my mind ;). Yes, shutting everything down needs to be done. Some things can tolerate having the power yanked out from underneath them, and they typically can be identified by not having a power switch on them. Depending on what the heck the facilities people are doing, you may want to physically unplug higher value assets from the wall.
Sometimes you can get sizeable power-surges when power returns, and that can kill gear. Also, be aware of your start-up load. EVERYTHING powering on at once may be enough to pop breakers and bring everything down again. That sucks. Try for a staged power-on to get around this.
EDIT: We had a case where the transfer switch for the generator didn't fire, and the UPS ran out of batteries. When utility came back, everything powered on at once. 20 seconds later the UPS hit Overload and dropped load from the room again. By then enough techs had arrived on site (it HAD to happen during a weekend) that they managed to get enough stuff turned off at the rack-switches that when utility came back again the room didn't drop again. That yo-yo cost us a lot of hardware, and it was week recovering from some of the damage.
Comment: Big up to that staged power-on
Comment: Definitely agree- make sure that you turn on the servers one at a time, and let them get the disks fully spinning before you bring up the next one. Otherwise, you can easily pop the breaker- I've done it myself.
Answer: The only thing I'd add is to make sure you have all your support contracts and replacement parts easily findable.  I'm sure you do, but double and triple check that.  If you've had servers that haven't powered down in a long time you'll occasionally find issues with all the moving parts (hard drive bearings/motors, fan motors and bearings and some really silly stuff that we normally don't think about).
If you can be there for the duration, make up a list for your important servers including their service tag, configurations, where the backups are and any people that might be responsible for apps on each machine.  Tape that up on the side of the server in question, or have it in a binder in the datacenter for when you start trying to bring things back up.  You don't want to have to keep running all over your office if something is broken.
Answer: First of all, you've got good backups, right? :) Always a good idea to make sure that you're all backed up, just in case a disk decides to not spin up, etc. when you bring everything back online. Nothing like breathing easy after a power outage then realizing that one critical SQL server never came back. :)
Second, you're right, gracefully shut down and turn off all servers, etc.
If it's not a modern building and/or you don't have a UPS in-line with surge protection, (which it sounds like) or anything like that, it's always better being safe rather than sorry, and I would suggest unplugging equipment. Bringing power back online could result in a power spike.
Also, a little FYI; bring your core servers down last, (such as DNS, etc.) You don't want to bring down your DNS servers and find yourself unable to resolve the rest of the servers if you're shutting them off remotely :)
When bringing everything back online, bring the network equipment up first, then your core critical servers, then finally your app/file servers.
Good luck!
Answer: Shut everything down, including switches and routers, and either unplug or turn off at the wall socket.
If you're worried about surges, is there a budget to get a few small UPS to cover the most critical equipment?
EDIT:
I like neobyte's suggestion to have a "test plan" for when you bring stuff back up. Even if you just have one in your head, and a firm order to follow to restore services quickly you'll be fine. Make sure people know that you're working to a plan and hopefully they'll understand why switching on their workstation before you've looked at the servers and switch isn't going to help!
Comment: We have a small UPS covering the vital stuff.  I think I will do as suggested and disconnect everything from the walls as well.
Answer: Inter-server dependencies / server boot order will be best laid out ahead of time, too.  For example, if it's a windows network, power up DC's first, then database servers, then exchange, etc.  This is a great list for your documentation, in any case.
Minimizes restarts and logfile spam.
Answer: Too late for a rehearsed shut-down scenario .. I suggest you do all you described, then be around when power comes back ..
don't forgett to post a note explaining to your collegues what happened .. most of them will have "forgotten" to turn of their computer and might want to know why the system needs to be booted...
Comment: Great suggestion to leave an explanation for colleagues.  Thanks.

Power loss at company


How to display only the last field?

Question: I used
cut -d " " -f 8

and
awk '{print $8}'

But this assumes that the 8th field is the last one, which is not always true.
How can I display the last field in a shell script?
Comment: you wrote **byte** through your question, do you really mean byte? or field/column??
Comment: Sorry; I meant field/column. Question clarified.
Answer: Try doing this :
$ awk '{print $NF}'

or the funny
$ echo "foo bar base" | rev | cut -d ' ' -f1 | rev
base

Comment: +1 `for (quick) answer -> got \1 upvoted -> \1 deleted -> \1 undeleted!`  good job!
Answer: Edit: this answer is wrong now because the question changed. Move along, nothing to see here.
You can use tail to print a specified number of bytes from the end of the input
tail -c 1

Comment: Oh, I foolishly answered the question that was asked, not the one that was intended ;)

How to display only the last field?


According to this table, can I say my variables are integrated of order 1?

Question: I tested my variables in ADF unit root test , can I say they all integrated in order of 1?
Answer: You cannot reject the null hypothesis of a unit root in levels for either of the three specifications, using conventional significance levels of 1%, 5% or 10%.
You can reject the null hypothesis of a unit root in first differences for all three specifications, using conventional significance levels of 5% or 10%.*
If you believe that at least one of the specifications is adequate for your time series, then yes, you can conclude your time series is integrated of order 1.
* 1% might not work out since you have multiple hypothesis being tested in this table, so you have to adjust the significance level for that. However, if you chose to ignore two out of three specifications altogether before seeing the test results and hence look only at the one in red, then 1% is also fine.


Docker COPY and effect on permissions?

Question: I'm modifying an existing docker image which was originally as follows:
FROM puppet/puppetserver-standalone:2.7.2

ENV PUPPETDB_TERMINUS_VERSION="4.3.0"

RUN apt-get update && \
    apt-get install --no-install-recommends -y puppetdb-termini="$PUPPETDB_TERMINUS_VERSION"-1puppetlabs1 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN puppet config set storeconfigs_backend puppetdb --section main && \
    puppet config set storeconfigs true --section main && \
    puppet config set reports puppetdb --section main

COPY puppetdb.conf /etc/puppetlabs/puppet/

COPY Dockerfile /

There is already a command copying to /etc/puppetlabs/puppet/ I'm now an additional script to the same folder by adding a second COPY as follows:
COPY node.sh /etc/puppetlabs/puppet/

This change compiles but when I use the image in a docker-compose project everything breaks. It seems to be related to a permission issue:

puppet              | Caused by: org.jruby.exceptions.RaiseException:
  (RuntimeError) Got 8 failure(s) while initializing:
  File[/opt/puppetlabs/server/data/puppetserver/state]: change from
  absent to directory failed: Could not set 'directory' on ensure:
  Permission denied - /opt/puppetlabs/server/data/puppetserver/state;
  File[/opt/puppetlabs/server/data/puppetserver/lib]: change from absent
  to directory failed: Could not set 'directory' on ensure: Permission
  denied - /opt/puppetlabs/server/data/puppetserver/lib;
  File[/opt/puppetlabs/server/data/puppetserver/preview]: change from
  absent to directory failed: Could not set 'directory' on ensure:
  Permission denied - /opt/puppetlabs/server/data/puppetserver/preview;
  File[/opt/puppetlabs/server/data/puppetserver/bucket]: change from
  absent to directory failed: Could not set 'directory' on ensure:
  Permission denied - /opt/puppetlabs/server/data/puppetserver/bucket;
  File[/opt/puppetlabs/server/data/puppetserver/yaml]: change from
  absent to directory failed: Could not set 'directory' on ensure:
  Permission denied - /opt/puppetlabs/server/data/puppetserver/yaml;
  File[/opt/puppetlabs/server/data/puppetserver/server_data]: change
  from absent to directory failed: Could not set 'directory' on ensure:
  Permission denied -
  /opt/puppetlabs/server/data/puppetserver/server_data;
  File[/opt/puppetlabs/server/data/puppetserver/reports]: change from
  absent to directory failed: Could not set 'directory' on ensure:
  Permission denied - /opt/puppetlabs/server/data/puppetserver/reports;
  File[/opt/puppetlabs/server/data/puppetserver/facts.d]: change from
  absent to directory failed: Could not set 'directory' on ensure:
  Permission denied - /opt/puppetlabs/server/data/puppetserver/facts.d

I'm really puzzled because there was already a .conf file being copied to the same folder before I added my modification. Does anyone have an idea on how this change may have affected permissions?
Answer: According to the page on DockerHub the image code should be identical to the github code.
I found that importing the image directly in a second docker image instead of modifying the original seemed to work:
Dockerfile:
FROM puppet/puppetserver

COPY node.sh /etc/puppetlabs/puppet/

Docker COPY and effect on permissions?