Is this type of sound wave possible (Picture)

Question: I apologize in advance if this is off topic for your stack. I saw this picture of a sound wave on a website. I have never seen a design like this for a sound wave. I am under the impression that this is a recording as this site does art from recording voices. I always thought the lines would always start from the middle line and go out. Are sound wave recordings always symmetrical?

Part of what I don't understand is how there are dense areas that are not coming from the center. See circled areas.

I am comparing this to a sound file I recorded with Audacity.

This file is a screenshot from audacity, and then turned B&W and leveled to make 2 colors.
An additional question: Do all audio editing programs display the sound wave the same?
Answer: That waveform looks pretty typical, actually.
If you were to zoom in much closer on the time axis, each "line" as you call it would become one (or more) peaks or troughs of the wave. As you probably know, the amplitude of these lobes represent the positive and negative variation in air pressure that transmits the sound. They are roughly centered around the central axis, but there is no need for them to be perfectly symmetrical. In fact, it's almost impossible to see a perfectly symmetrical waveform. There are a couple factors that contribute to this.
First, while some instruments will just pull the air back and forth by roughly the same amount, some instruments will be accompanied by a positive pressure while being played (think voice, or brass, or woodwinds). So while there will be variations in the pressure, there might ultimately be an overall positive pressure.
Secondly, and more importantly, is a mathematical effect called interference. Whenever you hear a sound, you are usually hearing more than one frequency at a time. For harmonic sounds like musical instruments, this will mostly be limited to harmonic overtones. For unpitched sounds like drums, or complex sounds like speech, there will be a complicated array of a possibly infinite number of frequencies. These waves have varying frequencies and amplitudes, and interact with each other in complex, hard to predict ways. Where two waves happen to have a coincident peak (or trough) -- called being "in phase", they will add together to make that peak stand out more. OTOH, if two waves are "out of phase" (one's peak aligns with the other's trough) they cancel each other out. Depending on which peaks and troughs are aligned, this can make the waveform appear taller on one side or the other.
However, I believe that if you were to zoom in, and add all the area between each peak and the centerline, and subtract all the area between each trough and the centerline, the net result would be about zero (or perhaps a small positive value due to the first reason listed above).
As a side note, there's also a fair amount of graphical aliasing going on, from squeezing more peaks and troughs into a region then there are pixels to represent them. This is why I say that you'd have to zoom in on the original soundwave (just zooming in on the picture won't work, because that level of detail is already gone).
Answer: The areas you circled are caused by drawing the waveform at a lower resolution (pixels per inch) than the sound (samples per second).  If the x-axis had a pixel for every sample then it would not look like it does.  The patterns are not in the waveform, they are just optical illusions.
Every program I have encountered draws the wave form in a similar fashion: linear amplitude on the y-axis and time on the x-axis.  There is a great deal of variation in the details, however.  For example Logic Pro X fills in a silhouette of the waveform when you zoom out to avoid these types of aliasing effects.
Comment: P.S.  Sounds don't have to center on the zero line, look up DC Bias or DC Offset.  We want the sound to center on the zero line though because that is how speakers are designed to work properly, so DC Offset is usually eliminated from a sound if it exists.
Answer: Your waveform picture shows two things.
There's a DC offset, which displaces the whole waveform above the datum line.  This is easy to correct, and probably should be.
It also shows an asymmetrical waveform.   Very common, and nothing to worry about.


Inserir barra de erro padrão no gráfico de barras

Question: Como posso inserir no gráfico abaixo a barra de erro padrão?
Segue os dados e o gráfico como modelo desejado.
resp = c(16,18,17,17,18,15,17,16)
trat = factor(rep(1:2, each = 4), label = c("Roço Abril","Testemunha"))
df <- data.frame(tratamento = c("Testemunha", "Roço Abril"),
             media = c(17,16.5),
             posicao = c(2,2),
             tukey = c("17 a", "16.5 a"),
             ep = c(0.73))
ggplot(df, aes(y = media, x = tratamento)) +
geom_col(alpha = 0.7) +
scale_y_continuous(limits = c(0,25), breaks = seq(0,25,5)) +
geom_text(aes(label = tukey), size = 4, vjust = -0.2)+
ggtitle("Contagem perfilhos 30 DAR")+
theme_bw(base_size = 11) +
xlab("Tratamento") +
ylab("Número de perfilhos / metro")

Comment: Mas onde está a informação sobre o erro padrão no `df`? Ele só possui as colunas `tratamento`, `media`, `posicao` e `tukey`.
Comment: Inseri a informação do erro padrão junto ao df.
Answer: Para ter as barras de erro, use geom_errorbar com ymin e ymax iguais a media ± ep e atribua os valores que não dependem dos dados (cor, espessura da linha e largura das barras) fora de aes.
Também alterei a coordenada y do texto de modo a não estar sobreposto às barras.
library(ggplot2)

df <- data.frame(tratamento = c("Testemunha", "Roço Abril"),
                 media = c(17,16.5),
                 posicao = c(2,2),
                 tukey = c("17 a", "16.5 a"),
                 ep = c(0.73))

ggplot(df, aes(x = tratamento, y = media)) +
  geom_col(alpha = 0.7) +
  geom_errorbar(aes(ymin = media - ep, ymax = media + ep),
                color = "red", size = 1, width = 0.25) +
  geom_text(aes(y = media + ep, label = tukey), size = 4, vjust = -0.5)+
  scale_y_continuous(limits = c(0,25), breaks = seq(0,25,5)) +
  ggtitle("Contagem perfilhos 30 DAR")+
  xlab("Tratamento") +
  ylab("Número de perfilhos / metro") +
  theme_bw(base_size = 11)

Created on 2022-05-19 by the reprex package (v2.0.1)


Como recuperar os valores de um formulário em HTML para uma função em Javascript

Question: Tenho uma página com um formulário feito com Bootstrap e precisaria recuperar os dados submetidos para um arquivo javascript externo ao HTML.
Meu principal objetivo seria recuperar o campo de senha para fazer validações através da função ValidarSenha().
Agradeço toda a atenção desde já.
Segue o código HTML

                <form name="cadastro" class="form-set" action="/pagina-destino" onsubmit="return ValidaSenha()" method="post">

                        Nome
                        <input type="text" class="form-control" id="nome" name="nome" placeholder="ex: João da Silva"/>

                        Email
                        <input type="email" class="form-control" id="email" name="email" placeholder="ex: firstname.lastname@example.com"/>

                        Senha
                        <input type="password" class="form-control" id="senha" name="senha"/>

                        Confirme sua senha
                        <input type="password" class="form-control" id="csenha" name="csenha"/>

                    <button type="submit" class="btn btn-warning">Enviar</button>
                </form>

Comment: Não ficou muito claro o que está exatamente a tentar fazer. Em que local precisa de usar os dados ? De que forma os quer usar ? Qual a localização do arquivo onde quer usar ? Esse arquivo é JS ou PHP ?
Answer: Para pegar os dados de um <input> você pode usar o id dele e pegar no JavaScript usando a função document.getElementById('senha_input').value.
Resposta com outras opções


IT Services: In House or Outsource?

Question: For the purposes of a small business (less than 50 employees) is it generally advisable to hire someone full-time for IT Services or outsource to a separate company?  Here are some details about the company in question:

Health Services - Generally involves gadgets and hardware not easily maintained
25-50 Employees - Most of which interface with a computer regularly
Microsoft - Almost completely windows based

Should this business be outsourcing their IT/Infrastructure issues or hiring someone full time?  If outsourcing is the answer, what are some good companies that do this sort of thing?  What should the requirements be for the third party?
Answer: It All Depends(tm).
I'm a little bit biased because I am an outsourced IT provider. I have Customers who are larger and smaller than the company you describe-- some have in-house IT staff and others don't.
I'll apologize in advance if it sounds like I'm trying to "sell" you in this posting. I'm really not. We only service Customers who we can feasibly visit face-to-face, and your profile says "South Carolina" whereas mine says "Ohio". With that in mind, though, I do think that there is a potential situation that outsourcing may work for you (or, it may not).
If you don't get anything else out of my message, take this away: The specific people who are involved, ultimately, will make any arrangement either succeed or fail. If you get an employee or an outsourced provider who genuinely cares about your business, cares about doing you right, and cares about providing the most efficient and cost-effective experience they can you'll have the best luck. Too often employees see their work as "just a job" and don't give their best effort. Too many outsourcing companies are in the business to make money, potentially at the expense of their Customers.

Outsourcing doesn't necessarily mean "a different person ever time". My company, for example, has been the same three people since we started in 2004. Our Customers see the same faces on every visit. Your selection of an outsourcing firm makes a big difference on this issue.
Going with an outsourcing firm that uses a "fleet" of rotating "technicians" (constantly experiencing turnover) isn't going to give you a good experience. Having a "revolving door" position inside your company will accomplish the same poor results.
The labor expense of an employee depends a lot on their level of skill and your job market. In my area, Dayton, OH, US, I'd expect to pay an admin handling, say, server computer hardware, cabling / network infrastructure maintenance, Active Directory, Exchange, PC issues, a company web site (not necessarily the content-- just the hosting relationship), VPN access for remote users, and backup between $35,000.00 and $50,000.00 / year. Benefits and payroll tax are going to be anywhere from 20% to 35% of the salary (depending on your locality), for a "true cost" in dollars of somewhere beteen $42K to $54K on the low-side.
Just remember that an employee costs more than their salary and benefits. You have an opportunity with many outsourced firms to "cross train" multiple "technicians" with your environment. With an employee you're often stuck with nothing when they decide to seek greener pastures.
With our particular firm, $42K can buy a substantial quantity of on-site presence and VPN-based incident response. I'd shop around whatever you expect the true cost of an employee to be to local IT outsoucing firms and see what you come up with. Based on the size of the company you're talking about, and bearing in mind that I know nothign about your line-of-business software (the quality of which DRAMATICALLY affects service labor outlay), I could easily see that after getting over the initial setup hurdles (wresting "Administrator" rights away from users, getting servers / backups / email / etc setup in an optimal configuration) you could settle into a recurring service routine of 16 - 20 hours per week, and possibly even less.
The best arrangement that we've worked in, historically, has been reporting to a semi-technical manager who handles the day-to-day admin tasks (password resets, new account creation, etc), and defers higher-level problems to us. This keeps the day-to-day expenses lower, but still assures that the infrastructure is properly installed and maintained. Since we're a "services only" Firm (and don't sell hardware, software licenses, etc), it's usually easier for our Customers to grasp that we really are "on their side" and really are looking out for their best interests.
Our business model is to get Customers setup with a solid infrastructure that's setup right from the start, proactively monitored for failures, and ultimately configured with the intention of requiring the least amount of ongoing support labor to "keep running". It's perfectly possible to have a network infrastructure that mostly "takes care of itself" and doesn't need a large amount of daily "care and feeding".
Like I said-- I'm probably biased. This is the kind of work that I've done for years and I think it tends to work very well. Ultimately, though, there is no easy answer.
Comment: I don't know about your company, but I've dealt with some outsourced help that are a pain and some that worked really well. Sometimes it's hard for a small company to weed it out and other times it's painful to recover from another company's "solutions". I think they need to consider this too...
Comment: Like I said-- it comes down to the people and their attitudes. I know what you mean re: "solutions"-- I've had to clean up a number of them. I advise prospective Customers to ask all their potential outsourcing companies "If we decided to stop working with you tomorrow, how easy would it be for us to pick up with an employee or with another outsourcing firm?" We do a lot of work to keep our Customer networks very "plain vanilla". Likewise, we make it very easy and painless to get rid of us. That's probably part of the reason that no one ever has... >smile<
Comment: Small business owners who are having trouble selecting an IT provider (be it an employee or an outsourced firm) would do well to spend some time "networking" with their peers in the small business community. The sad fact of the matter, though, is that with the barrier to entry so low in the IT industry there are a lot of charlatans out there who have no idea what they're doing and are only too happy to take a company's money and leave them with a horrible mess. References, be they for an employee or an outsourcing firm, are *essential*.
Comment: There is good advice in this post. I would generally say that employees are generally more interested in helping the company they work for as their salary is directly tied to the company. How important this is, is probably dependent on how important the IT is to the company. As it is described my instinct would be in house however thats how I work so I will be biased that way.
Comment: It can work either way. When I was a manager at a company w/ a "fleet of technicians" (ick!) I impressed upon the techs that the good of the Customer was our priority. W/o Customers having continued success there wouldn't be money to pay our firm (and, ergo, to pay their salaries). It might seem heavy-handed, but tying a technician's continued employment to the happiness of their Customers was, I believe, The Right Thing(tm). (I took it to heart so much that I quit and started my own company so I could work directly with Customers. You'd better believe that I worry about their happiness now!)
Comment: @Evan - "it comes down to the people and their attitudes" I couldn't agree more. Attitude is prevalent everywhere yet seldom mentioned.
Answer: I think the instance above... In House (full/part time) would probably be the way to go.  Cheaper, more available, and should get better as the new hire becomes familiar with the system.
The interview would be pretty much a standard IT interview.  Try and find the best person for the job basically.
Answer: Even if you outsource, you'll likely need a person to liason between the users and the 3rd party.
I'd think about a hybrid model.  Get a lower end person who can do the light IT work, password resets, printer jams, unplugged network cables, etc, and prefrom triage on IT issues as they come in.  Then look at an outsource for the "heavy lifting":  Server Installations, network infrastructure maintainence, etc.
We are somewhat larger than you are, but we have had good luck with a company called All-Covered.
Answer: Outsource, frankly, and lease your workstations as opposed to buying them. With 50 users, you're rarely going to hit something that's going to be a show-stopper. Just keep a standardized equipment policy -- have all computers be the same (hence the lease option above) and if one breaks, you unplug it and plug a new one in at the workstation. At that point, all you need to do is know how to match the colored plugs. Then your outsourced person will just pick up the broken machines (or you just ship them back to the lease company) and you don't have any downtime or any support cost.
For group file storage and email, outsource those too. That way you will only have issues if your internet connection's down. (And if it's down, and you're on a T1 trunked phone line, usually that's down too.)
Answer: Years ago, I was the outsourced solution to a small health service company in a major city. Financially it worked out well for my clients (and me) as they paid me on a per-service basis, but they were much smaller (10-15 employees) in comparison to your outfit. For my clients, their needs were very simple and I was able to setup things in such a way that would require little intervention.
It's tough to say as just 10 machines can require a lot of maintenance (now replaced with WSUS updates/SMS/remote desktop, etc. etc.) but a lot of little issues tend to crop up in clusters and then months nothing major would occur. Just ask yourself how much technical help do you need during a given day/week/month. That might help steer you in the right direction.
I would investigate the outsource route, but the number of employees who need service might require someone on-site. I would also look into outsourcing a number of IT functions (mail,off-site backup,etc.etc.) that would alleviate costs and still manage to keep things running for all the employees. Now I know others may say hire someone but don't let bias affect a decision like this. There's a lot of pros/cons to go either way. Seeing as how the economy is a huge factor, I'd base your decision based on budget and future projections.
Answer: Like others said, it depends.
If you have 50 employees I would think that you would want to consider having someone in-house, especially if you're a niche or have special legal requirements, so you can have someone who will learn the ins and outs of your particular field and setup.
You might want to consider pricing an outsourcer and see what they average. Then consider:
downtime? How much is it worth to have someone immediately available to work on issues?
For a contract with the outsourced company's cost, is it on par with someone who would be an employee with salary for you, especially if it's a contract with guaranteed response time?
Do you have needs like backups, clustering, network maintenance, etc. that really needs a person there to take responsibility for it but right now you're kind of "coasting" and hoping nothing goes wrong?
Are your IT needs something that really needs someone to take responsibility for a budget over, like maintaining servers and purchasing parts, etc.?
Do you want someone who isn't biased towards selling you on a particular solution or technology (i.e., in the outsource company's interest...I worked with a company where the solution was always accomplished with Netware, no matter what. It had some nice features but it really wasn't what they needed but it worked great for the consultants who were netware certified)?
Do you want to be able to blame an outside company with things go wrong rather than your in-house person?
Are you already shifting responsibility to someone inside the company as your "resident geek" and in the process taking away their job responsibility to maintain something that is outside their job description?
How close are you to a decent outsourcing company...minutes or hours? Can you afford to wait the hours (or days) to have someone come in to work with you on an issue?
If the company requires you to work with them remotely and you're in the medical field, are you qualified to judge your security issues this introduces? What about security of having outside staff get access to your equipment and records? Are you liable if someone...since you don't have control of who will help you one month to the next...decides your records are nice candy to borrow on a USB drive for later browsing?
You might also want to consider that if you're not knowledgeable on the technology in-house, you may want someone there to at least be familiar with your configuration, your hardware and software, your people, someone to look out for your best interest. Even a good sysadmin knows when he's in over his head and needs outside assistance, so it can be beneficial to have someone in-house for the majority of your tech help and still work with outside people when you need a SAN installed or a VOIP solution or something like that.
Just some things to consider. You may have needs you don't even know about until getting someone hired on the inside, like setting up and maintaining central file servers and backing them up properly if you're currently a hodgepodge of added hardware and software over time.
Comment: I find some humor in the phrase you use "Even a good sysadmin knows when he;s in over his head..."  Generally speaking, it's *only* the good sysadmins who know that. The poor sysadmin often ends up digging the hole depper.
Comment: True, I was just on a roll and didn't catch that mis-phrase...I'd edit it to correct it but I agree, it's just more humorous. I'll leave it in. :-)
Answer: People always mention these two options; "inhouse fulltime" or "outsurce".
In my opinion the big problem with outsourcing your Information Technology is that everything becomes a 'reaction' to something broken. There is nobody pro-actively helping with 'minor-issues' or preventing them. There are exceptions, but generally when a company is getting paid by the hour, you only use them when you absolutely need to.
For a small company that isn't running any sort of data center I recommend (and this would be easier if I knew your company better):

Hire a part-time sysadmin (20% - 40%) that comes in once a week. Make him responsible for implementing a backup strategy and any internal support you might need.
Outsource any servers you need, such as email, calendaring (also makes it more flexible for people to work from home without complex VPN connections)
In case of shit, hitting the fan; it will happen. So, it helps to get someone that will be able to rush to the rescue if need be.

I doubt that you have enough work for a full-time admin and it's hard to replace that personal touch you get with your very own sysadmin by hiring a company to do it.
This is based on what I could gather from your information, but without knowing exactly what you expect to be done in terms of IT, this is it.
(p.s. give your sysadmin a hug on Friday. It's System Administrator Appriciation Day!)
Comment: Actually no - it depends on how HE treats YOU, and with 1-2 days per week he will treat you as contractor. Problem on Thursday? Sorry - he is with the other customer that has Thursday allocated.
Comment: Curious...how do you get a full time admin that essentially isn't outsourced? If you can't pay him enough to stick around and be on-call for when the sh* hits the fan, how much do they have invested in the business?

I'm just thinking that what you're describing is more like a consultant with a contract for hours...essentially still outsourcing, no?

50 workstations can still keep a good sysadmin busy, especially if he is tasked with training duties as well and proactively keeping systems (and servers) up to date. That's just in my experiences though.
Comment: I'm going w/ Bart on this one. A "part time sysadmin" is basically a contractor. Nothing wrong with that (in fact, it's how I make my living), but it is what it is.
Comment: It all depends on how you treat it. If you treat him like an outsider and pay a contract, then he's a contractor. If you pay him 20% salary and treat him like a part of the company you get something better. 50 workstations, with training and servers is definitely enough for a full-time admin; we just don't have enough info to speculate on it. IMHO, there's a big difference between 'your 20% sysadmin' and 'that guy who comes in when things break'.
Answer: As an in-house IT person myself I would have to say go for in-house. With that size of a user base it should be enough to keep some one always working. Even if it's putting up keyboard trays...
Outsourcing it means you dont always have the same person in most cases. This can lead to increased costs as it will take time for each person to get to know the envrioment and equipment. And at $75 to $200 an hour for outside help that will add up quickly.
Answer: i think you should have someone in house, outsourcing in many cases end up being very unproductive and for small things it takes longer since you need to coordinate and involve some 3rd party that your issues not even on high priority list
Answer: Well I work for an IT outsourcer, so my perspective might be biased.
The main question you have to ask is "do you think you have enough to keep a full-time person busy?"
If yes, then FT/P is cheaper.
If no, then it becomes a balancing act between costs and responsiveness.  Nothing is more responsive than a help-desk guy sitting there waiting for the next call.  However, if all he's doing is waiting most of the time, he isn't very cost-effective.
If you are going to out-source, you do need someone on-site manager to act as a filter and direct priorities.  This is usually a manager or someone who is already responsible for IT in some way.
You probably want to retain a company rather than a single contractor to help you.  I say this for two reasons -- first, a company can provide alternatives if/when the prime is unavailable (contractors like vacations too), or just isn't working out.  Second, in the case of severe emergencies, a company can frequently scale up the number of bodies working on a problem -- consider having access to a half dozen guys for Exchange migrations or virus storms or whatever, all without having to pay them all the time.  It also makes it easier to have access to after-hours SLA support, companies are more likely to have someone on call and actually available to help you.
When you do get big enough to have a FT/P employee, you probably want to look at a senior person to manage everything, and then grow junior people underneath as required.  Again, your relationship with the contracting company can help, as they can supply junior people as you need them, plus give access to senior people for planning or one-off project requirements.
Answer: I'm an in-house guy so likewise I'm also biased here, but looking at your situation I can see a few factors that may need to be taken into account.

I'm of the opinion that having someone on the ground floor to respond to issues as they arise is more than worth it.  This need not be a full-time dedicated IT person, a lot of smaller companies can get by with just having "the guy who knows stuff about computers" around (particularly if they don't have a Domain).
If you do have a Domain you're looking at needing a dedicated full-time in-house person OR outsourcing.  You won't be able to manage it with just "the guy who knows stuff about computers".
Depending on your line of business outsourcing may not be viable.  If you have any confidential info (govt stuff, trade secrets or whatever) you'll need to be very very careful about who you choose, and ensure that they are absolutely reliable.  If they DO leak anything you can be in a position to throw the book at them, but the damage will have already been done.  This I suppose is one example of where a non-IT factor is crucial to an IT decision.  There are others.

Overall I don't believe there is a single right answer to this question that's universally applicable.  Like I said, I lean towards in-house expertise because of the value of immediate response to things like servers giving trouble at inconvenient times, and it may assist you with confidentiality or regulatory compliance, but at the same time I'll concede that an in-house person can be quite an investment.  The best I can say is to think carefully and to consider factors outside of the pure IT requirement before committing to a decision.
Answer: Depends on how much work out have to do.  I work as an outsourced employee for SMB's.  If you have an employee that is competent enough to handle basic troubleshooting, you don't need someone in house dedicated to IT and can outsource complex and server issues.
Answer: The answer is: whichever one is going to give you the support you need. Right now I work for a large company, and our IT staff (in house) is overloaded. I've had a low-priority request in that has sat for 3 weeks now. I expect I will NEVER get an answer from them (it's about hooking an iPhone to our corporate VPN, and I've worked around them).
The important (and seriously difficult) part of deciding how much and what kind of IT infrastructure is in figuring out how much IT you need. Are your users knowledgeable? Or do they need someone to tell them how to use Outlook every third day? Do you have standard desktops? Or is each system dedicated to it's purpose and needing to be maintained in it's exact configuration? How often do you experience computer and network problems?
My personal opinion is that an on-site IT guy is a real asset, as long as you get a good one.
I'm a firm believer that no matter how good an outsource IT company you hire, you're going to have two issues with them:
1) They may change over time. If they fall on hard times just like everyone else, they may end up cutting corners and reducing service. If you've got a contract with them, you could end up really screwed if they go downhill.
2) You aren't their only priority. Remember that they have other customers and finite resources. Even if they are good, and appropriately staffed, you may well end up getting the short end of the stick if several customers have problems at the same time.
There's one other issue with outsourcing (or indeed with any situation where the IT guy isn't in the same building) - the users are going to try to deal with things themselves in order to avoid having to go through the hassle of calling IT and waiting for IT to arrive. This is generally bad for a variety of reasons: It distracts your users from their work, If they are not computer people then they may make any problems worse, etc.
The worst is that someone in the office will display competence with computers. From then on, when something goes wrong, they are going to ask Bob to help. Since Bob is a decent person, Bob's going to try to help, and you end up losing a lot of Bob's time to IT stuff.
I guess what I'm saying is that even if you outsource most of it, make sure you have a local IT person that the users can turn to. Otherwise, they'll make one up for themselves.
Answer: As all of the other posters says it depends.  I'm biased as an outside IT provider.
At 25 ee's there should never be enough work to keep one tech busy and we have yet to come across a really competent IT person that has another career.  We regularly clean up after part time in-house IT when something bad happens or they move on.  This is a reflection on the pace of change in IT and how specialized it has become, not on part time work or any particulular person. All the caveats apply about finding the right company.
At 50 ee's it could go either way.  If you find the right IT person to hire it could work out great.  It is difficult for non-technical people to evaluate the technical strength of applicants, consider getting help with that part of the evaluation.
Outsource doesn't have to mean hourly and there is a strong trend in outsourced IT to move to a flat fee per device with an SLA.  This means the IT provider has a strong financial incentive to both meet the SLA and keep things running smoothly, in other words be  proactive vs reactive.
Answer: Good advice here, so I'm just going to add a few things.  The choice is a trade off, and there is no one right solution.  Evan Anderson points out (rightly) that 16-20 hours per week is about right for a consultant in an organization your size.  16 hours times $75 per hour is $1,200 per week, $4,800 per month, or somewhere around $60,000 per year.  In that scenario, you're essentially paying for a full time employee, but you're getting two days of work instead of five.  There are companies in my area that charge $150-plus per hour, which makes them largely unsuitable for the kind of work you need.
That being said, a consultant probably has both broad and deep expertise an employee does not.  This can lead to both faster and better project implementation.  Consultants are almost always better at crisis management, as their jobs naturally involve more companies, which mean more crises.  On the other hand, consulting companies often bill their consultants 40-50 hours per week, which naturally results in a bit of flying by the seat of their pants and always needing to get to the next job.
I think you're on the border of needing a full-time person.  You could hire a consulting company and do fine or you could hire an employee and be just as well off.  The deciding factor might be the quality of full time candidates and cost/benefit of an employee versus a consulting firm.
Answer: For every IT-related system you maintain, throw it through this filter question: "Do we use this system in a standard manner like other companies?"
Good examples of this are Email applications, Desktop workstations, and Intranets. Many companies, even specialist companies with specialist IT requirements, still use email, workstations and intranets in the same manner as most other companies out there. These systems, being used in a standard manner, are ideal candidates for outsourcing to a third party.
On the other hand, systems tailored for a very specific "unique to your business" requirement, like a bespoke analog dialinig application which uses highly customized interfaces with the remote equipment. Written in Fortran. On HPUX. Yeah... don't outsource that bit. Maybe outsource the HPUX support element of it, though!
Often you can extend this a bit further and find a good route. Maybe say 'OK... currently we have an email system with a bunch of custom forms and outlook add-ons that we depend on to do business. But with a few weeks of development work, and some buy-in from management, we could transition just that custom element out to a standalone system. Once you do this, you can outsource our email.
I've seen companies with specialized IT requirements attempt to outsource wholesale, and encounter a whole world of pain. Likewise, I've seen companies with specialized IT requirements identify their differentiators, standardize, then outsource, and end up much more efficient as a result.

IT Services: In House or Outsource?


grpc 1.4.3 patch & installation

Question: Could you please help me?
I googled youcto grpc and there was a information about it and it is in master branch:
https://layers.openembedded.org/layerindex/recipe/67896/
So, I tried to git it using:
git clone git://git.yoctoproject.org/poky
however, I couldn't find anything related with grpc which are grpc folder and recipes-support/grpc/grpc_1.4.3.bb file at all.
(There are lots of folder in meta/recipes-support)
Could you please let know what I should do and what I did wrong thing?
Thank you.
//Daum
Comment: Dear, I just do it different way and I could do it. "git clone https://github.com/intel-iot-devkit/meta-iot-cloud.git". Thank you.
Answer: GRPC is not part of POKY it is in meta-iot-cloud/recipes-support/grpc/ layer.
git clone github.com/intel-iot-devkit/meta-iot-cloud.git

clone the above git to your sources/ dir path where the all other layers present like meta-openembedded,poky etc.
Then open the below path and add your layer path
vi build/conf/bblayers.conf

Comment: It works with "git clone github.com/intel-iot-devkit/meta-iot-cloud.git". Thank you so much.

grpc 1.4.3 patch & installation


instead of re-throwing a user-defined exception can we re-throw SQLException and ClassNotFound Exceptions in Dao?

Question: public class EmployeeDaoImpl extends JdbcDaoSupportImpl implements EmployeeDao {

    @Override
    public int save(Employee employee) throws EmployeeException {
        String sql = "INSERT INTO EMPLOYEE VALUES(?,?,?)";
        Connection conToUse = null;
        PreparedStatement ps = null;
        int status = 0;
        try {
            conToUse = getConnection();
            ps = conToUse.prepareStatement(sql);
            ps.setInt(1, employee.getEmpNo());
            ps.setString(2, employee.getEmpName());
            ps.setLong(3, employee.getEmpSal());
            status = ps.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            throw new EmployeeException(
                    "%%% Exception occured in EmployeeDao save() %%% " + e);
        } finally {
            DbUtils.closeQuietly(ps);
        }
        return status;
    }

}

In the example code, the class EmployeeDaoImpl is inserting a record into a database. if any exception raises, it is throwing  EmployeeException, which is an application exception, to the service layer. What is the need of throwing userdefined exceptions? We can throw SQLexceptions also in this case, is it correct or not?
Answer: There is no need to throw a user defined exception in this instance. The SQLException should suffice.
The User Defined Exception would make more sense if the Connection object threw your defined exception.
As long as you catch the exception and do something with it that is all that matters.
Answer: You shouldn't be throwing ClassNotFoundExceptions because the DAO shouldn't be responsible for creating database connections. I would hope getConnection is retrieving an existing connection from somewhere, maybe a threadlocal, where it was put earlier in the request. If it is creating a connection then it isn't closing it, which would be bad. Also you should be using a connection pool (again resulting in moving the code that could throw a ClassNotFoundException to somewhere outside the DAO).
For most SQLExceptions you can't do anything about them but let them bubble up, canceling the current unit of work, and then catch and log it in an exception handler, so having a checked exception is an annoyance. Spring does the right thing here, it translates SQLExceptions into more meaningful but unchecked DataAccessExceptions where different subtypes are used for different types of errors. If you find yourself needing to catch an exception thrown when an RI constraint is violated you would catch a DataIntegrityViolationException without having to worry about what SQLState your database vendor uses for this, because Spring translated it for you already.
With this unchecked DataAccessException there's no reason to have an application specific wrapper exception anymore.
Answer: Yes these kind of exceptions can be thrown as is.
If you have a Ui frontend or some sort of client, then it make sense to wrap it as a user exception and throw.


Combining EC2 with S3 and RDS from AWS Amazon

Question: I would like opinions if the following scenario is feasible or not.  Also, if you think that I see something wrong don't hesitate to mention that.
I have to propose and create a System Architecture schema for a company that runs right now 3 different servers (different server providers) on 3 different locations and they host around 50++ website per server.
So, right now, it is like this:

server1:

website1.com
website2.com
website3.com
website4.com
....

server2:

website21.com
website22.com
website23.com
website24.com
....

server3:

website31.com
website32.com
website33.com
website34.com
....

Server1 has a big MySql database that every other server (server2,server3 and included server1) is using it with a remote mysql connection.
So,
MySQL server from server1 servers:

server1 (locally)
server2 (remotely)
server3 (remotely)

Server1 under the domain website1.com has a folder with images that all the other websites on the servers, included the server1, must to access them.
For example:
website1.com  uses an image file image/image1.jpg, and the same time website2.com and website3.com uses the same image1.jpg  as   http://website1.com/image/image1.jpg
Also, every website on each server checks each time if the file exists. Actually the checking is done by php so, on the server side. They check if the image exist locally using if_file_exist() and remotely with if (getheaders() ==200 )
E.g.
If a visitor try to access the website1.com, the website1.com (actually the server1) checks if website1.com/image/image1.jpg exists.
Also,
If a visitor try to access the website21.com, the website21 (actually the server2) checks if header of http://website1.com/image/image1.jpg == 200 .
So,
The website1.com/image/image1.jpg on server1 accessed and checked if the image exists by all the websites:

website1.com
website2.com
....
website21.com
website22.com
....
website31.com
website32.com
....

In my opinion,
the best scenario probably can be the following:
3 AWS EC2 instances  as running server.
1 AWS S3 bucket that has all the files on the /image/ folder
1 RDS database that servers all the websites that hosted in the 3 EC2 instances.
In that case,
one EC2 instance can get and check if the file exist from the S3 bucket, and the same EC2 instance will get the data on the database from the RDS.
If I am correct, the latency of from EC2 instance to check if file exists and get it from S3 should be really low because it should be "locally" though the AWS infrastructure.
and also, a query on the shared RDS should be faster and more secure due to the same reason.
So,
if a visitor access website1.com
we will have the following:
website1.com ->  EC1 instance

html/php files from EC1
get query data from the RDS
get image data from the S3 bucket

website21.com ->  EC2 instance

html/php files from EC2
get query data from the RDS
get image data from the S3 bucket

Is is a feasible scenario?  Or I see something wrong ?
Did you see any other option on that?
Another option:
By using instead of the S3  the Amazon CloudFront will it solve the problem quicker ?
Edit
The checking should be done because of the following:
image1.jpg   is an image.
and image1-es.jpg is a dedicated image for the specific  country ES (spain).
In other words, server should check there is an image dedicated for visitors from ES (spain), if not, server the general image.
Comment: I'd probably need to learn more about this application, but I'm curious as to why you need to check if the S3 image file is there, vs letting the client make a request to S3 directly?  Latency may be low because it's S3, but S3 isn't super fast in general.  You may consider having a background job go and periodically index the contents of the S3 bucket and shove the results into memcache or similar to speed things up a bit.
Comment: @WedgeMartin  I answered on the question and thanks for your comment.
Also, I think that only on the server-side that checking can be done. Correct me if I am wrong.
Comment: @WedgeMartin Also, may the CloudFront help  to speed up the things ?
Comment: CloudFront typically speeds things up a bit, though keep in mind that updates to it can take quite a bit longer to propagate.
Answer: You plan will likely work, but probably isn't optimal. S3 isn't a file system, so your applications may need to be rewritten to take advantage of it. There are pieces of software available that can make it look somewhat like a file system.
You might be better off using

EC2 virtual machines
EBS volume running just the operating system most likely. You could put some or all of the files to serve (static + PHP) on the EBS volume if you weren't concerned about sharing them with other instances.
EFS (Elasic File System) to store shared files on. If you run Wordpress the whole Wordpress install can be on here - that way if you scale to multiple Ec2 instances running the same website your wp-content folder and such is shared, and you only have to maintain one Wordpress instance. Note this may still be in beta.
CloudFront for CDN file delivery
RDS for database

Serving region specific files is the responsibility of your software, and Amazon infrastructure.
Comment: So, If I can understand correct,

EC2 instance will have the html/php files, the EFS is attached to the EC2 and it contains the sharing folder with the images,  and RDS will have the database-data.
So, if a visitor hits the website1.com, the EC2 will get the files from the EFS ("locally") and the RDS ("locally") again.  And finally the EC2 will server the full web page to the visitor via the CloudFront.

Right?
Comment: Can you please explain me why to have the WordPress installization on the EFS ?
Comment: Indeed, some of the websites are Wordpress, but they are the minority.  They only serve the other "custom frameworked"  websites with their feeds. Nothing more.   Where will it help to have the Wordpress install in the EFS ?
Comment: On my point of view the reason to have the WP installed into the EFS is to have several WP sites with one WP installation. The databases of the WPs will be on the RDS and the installation will be on the EFS.   Right?

There is a link on Reddit about WP + EFS: https://www.reddit.com/r/aws/comments/3trahr/wordpress_web_farm_using_elastic_file_system/
Comment: Answer expanded
Comment: EFS would absolutely be preferred over S3 for an application where the servers are accessing the files heavily like the question seems to suggest.  Of course, it seems like the application would be far better overall if the image link were always pointing to the localized image, with an image server (behind a cache) returning the localized image if available and the default image if not.  If -- as it sounds like -- the HTML is being rendered with image links whose targets are determined based on whether files exist, that sounds dreadfully inefficient and unnecessarily slow.
Comment: @Michael-sqlbot yep. I know that the checking (if image exist) every time is really inefficient. However, the case of doing this, is because images1.jpg can have a dedicate image for Spain, but not for Germany.  In that case, the developers can not point directly the image due to the country of the visitor, because for a German visitor for example it does not exist (so image1-de.jpg return a 404 error code and server has to server the default image1.jpg).  So, it has to be checked every time if there is an image dedicated for the visitors country.
Comment: @Michael-sqlbot 2 points: 1) if you think in that case that I described above, there is an another option that should be great.  The only solution that I can think is to map for every country around the world the images in a DB. So, there would be only a query on that particular solution that checks if the image "lets say exists".

2) I don't get why to have EBS first of all. I think that EBS is for backup purpuses.  Also, I don't really get why to have S3 and EBS together.  In any case, EBS should be faster rather the S3.
Comment: You said: "... on the EBS volume if you weren't concerned about sharing them with **other instances**."  Do you mean my instances on the VPC that the EC2 will belong, or all the EC2 in the region (even if they are not mine).  I think that EBS mounts only to me, and EBS is visible only to my VPC. Correct me if I am wrong.
Comment: You need EBS (Elastic Block Store) because it provides the hard drive(s) for the instances.  EBS is very fast, but the data on an EBS volume is not accessible to any instance except the *one* instance to which it is attached, unless you make it accessible by exposing it with NFS or a web service.  This isn't a good way to share content, since the instance is a single point of failure.  EFS (elastic filesystem) is a managed filesystem that multiple instances can access simultaneously.  It is accessed using the NFS protocol but with layers of redundancy.
Comment: Regarding images, you link to image1-de.jpg.  You have an image web service that handles the request for image1-de.jpg.  If there is no such image, it would return the content of image1-global.jpg instead of a 404 error. This is pretty easily done with Varnish, using S3 or a web server for fetching the image content, and would seem to have a pretty dramatic potential for performance improvement since the application has no need to do lookups at all.  Caching by, or in front of, this service means it doesn't even have to continually look to see whether the files exist.
Comment: @john, I suggest you do an AWS course, either online or in person, to understand these concepts. It's difficult to describe architectural options in a question and answer format, and it's not what FS is for. If you need immediately help you may be best of hiring someone to assist you.


Como relacionar duas estruturas de dados do tipo lista

Question: Estou desenvolvendo um projeto para entender melhor estrutura de dados, no projeto está sendo utilizado estrutura de dados do tipo lista e nele devo cadastrar alunos e após o cadastrado, posso escolher qualquer aluno que esteja cadastrado para incluir uma quantidade n de livros, esses livros também são ordenados por uma estrutura própria que apontam sempre para o próximo ou para seu final.
No meu desenvolvimentos consigo realizar o cadastrado de alunos porém travo na hora de fazer a relação e o apontamento de alunos para livros no momento em que decido cadastrar os livros.
Estou disponibilizando todo código fonte desenvolvido, ele está todo comentado possuindo uma navegação fácil do que está sendo feito, mas especificamente a criação do livro se encontra na linha 355.
Código

Adendos para melhorar o entendimento
Comment: Eu queria comentar a sua publicação, mas eu não tenho reputação suficiente. Então isso aqui não é uma resposta, só quero entender a sua dúvida. Você tem uma lista encadeada de alunos, certo? E cada aluno está relacionado a alguns livros. E cada aluno estará ligado a uma lista encadeada de livros, é isso?
Comment: Exatamente isso Gabriel, acabei de adicionar uma imagem para transmitir melhor essa ideia.
Answer: Vou te ajudar a partir desse canal de respostas, ok?
Você comentou que está com um erro na linha 178 do seu código.
O seu problema é não atualizar o valor de aux, ou seja, o seu while-statement nunca para porque aux nunca troca de valor. A ideia seria a seguinte:
while(aux != NULL) {

    if(cod_aluno == aux->aluno.codigo) {
         if(aux->inicLivro != NULL)
            inicio = removeOrdenado(inicio, cod_aluno);
         else
             printf("O aluno não pode ser removido, pois possui livros em sua conta.");
    }
    else
         aux = aux->proximo;

}

Agora, lendo o bug relatado na linha 222, você percorre a lista, e mesmo se você acha, você atualiza aux, o que não precisa ser feito, você deveria utilizar um if/else. A variável "cot" é dispensável, e o seu IF final não é impresso nunca porque se você não achou aquele código, o valor de aux é NULL.
O código deveria ser:
struct listaAluno *aux;
int cod_aluno;

aux = inicio;

    if(aux == NULL)
{
    printf("Não há alunos cadastrados no sistema.");
    printf("\nImpossivel realizar consulta.");
}
else
{
    printf("\nLocalizar Aluno\n");
    printf("Informe o código do aluno: ");
    scanf("%i", &cod_aluno);

    while(aux != NULL)
    {
        if(cod_aluno == aux->aluno.codigo)
        {
            printf("\nCódigo: %d | Nome: %s | Curso: %s",  aux->aluno.codigo, aux->aluno.nome, aux->aluno.curso);
        }
        else
            aux = aux->proximo;
    }
}

if(aux == NULL)
{
    printf("O código informado não pertece a nenhum aluno cadastrado no sistema.");
}

E bem, quanto ao problema da lista encadeada dentro de outra lista encadeada, eu trabalhei com isso já em alguns laboratórios, e eu não segui a sua ideia de estruturas. Você montou 4 structs, 2 pra listas e 2 pra nós.
O jeito que eu aprendi e me dei muito bem fazendo usa apenas os nós, e para aumentar a eficiência da lista usa a técnica de nós "dummy", são nós que não tem função e são os primeiros da lista, e servem, por exemplo, para facilitar remoções e inserções na primeira vez que elas são ocorridas.
(recomendo a leitura: https://www.ime.usp.br/~pf/algoritmos/aulas/lista.html)
Ademais, como você quer trabalhar com remoções e inserções no início e no fim, eu sugiro usar uma struct de controle, que contem as posições do início e do fim da lista.
Sendo assim, em pseudocódigo, as estruturas seriam:
struct Aluno {
  informações do aluno;
  ponteiro para o próximo aluno;
  ponteiro para sua lista de livros;
}
struct Livro {
 informações do livro;
 ponteiro para o próximo livro;
}
struct Controle {
 informações da lista (quantidade de nós, entre outros); //opcional
 ponteiro para o início da lista;
 ponteiro para o fim da lista;
}

Comment: Obrigado por ver os outros erros que estavam presentes e por me passar esse material, irei ler e modificar o que precisa ser modificado. Não entendi muito bem o uso do Controle, mas acredito que o material irá tirar minhas dúvidas, qualquer coisa entro em contato.


Taylor series remainder question

Question: Let $f(x)=\frac{\sin(x)}{x}$ when $x\neq 0$ and $f(x)=1$ when $x=0$. Starting with the Taylor polynomial of degree $2n+1$ for $\sin(x)$ and the estimate for the remainder term, show that
$f(x)=(1-\frac{x^2}{3!}+\frac{x^4}{5!}+\cdots +(-1)^n \frac{x^{2n}}{(2n+1)!})+R_{2n,0,f}(x)$ where $|R_{2n,0,f}(x)|\leq \frac{|x|^{2n+1}}{(2n+2)!}$ and use this to conclude that $\int_0^1 f \approx \int_0^1 (1-\frac{x^2}{3!}+\frac{x^4}{5!})dx = \frac{1703}{1800}\approx .946$ with an error of less than $10^{-3}$.
The first part of this seems pretty straightforward unless I'm missing something with the piecewise nature of $f$. The second statement is not immediately clear to me, though.
Answer: Basically you estimate $ f (x) $ with the first 3 terms of it's expansion. There will be an error involved, whose value is given in your question. Since we are taking the expansion up to the $ n=2$ term, our remainder is
$ R \leq \frac {x^5}{6!}$
To estimate$ \int_0^1 f (x) dx$ we take the integral of the first three terms of the expansion (which is easily computed). The error involved then is
$\displaystyle\int_0^1  \frac {x^5}{6!} =
\frac {1}{6(6!)} = \frac {1}{4320} \leq 10^{-3}$
So you have your second part

Taylor series remainder question


Allowing authenticated users to create files through Service/Restful

Question: I have setup a restful server running with the services module.  I have also enabled to file resource.  Using this setup I can successfully login from my client application, authenticate the session, upload a file using the file resource and then create a node with node resource.  This all works fine and good as long as I am authenticated with an adminstrator but if I ever try and use a standard authenticated user I get this error back in response from the file resource:
<code>Unauthorized: Access denied for user authuser
</code>
I looked all throughout the user permissions but I did not see any permission to allow authenticated users to create files.  How would I do this?
Answer: Make sure "Save file information" is set for authenticated users


How to show this is commutative and participative?

Question: This is the question:
Suppose that the mathematical structure $(S,*)$ has an inert member. Show that if the following relation holds for any 4 arbitrary members $a, b, c, d$ of $S$, then the combination rule $*$ is commutative and participative.
$$(a*b) * (c*d) = (a*c) * (b*d)$$
But I haven't got any idea.
Here's my solution:
To show that the combination rule $*$ is commutative, we need to show that $a*b = b*a$ for all $a, b \in S$.
To show that $*$ is participative, we need to show that $(a*b)*c = a*(b*c)$ for all $a, b, c \in S$.
First, let's consider the special case where $a$ is the inert element. Since the inert element is an identity element with respect to the combination rule $*$, we have $a*b = b$ and $b*a = a$ for all $b \in S$.
Therefore, if the given relation holds for any 4 arbitrary members $a, b, c, d$ of $S$, then it must hold for $a = e$, where $e$ is the inert element.
If we substitute $a = e$ into the given relation, we get
\begin{align*} (e*b) * (c*d) &= (e*c) * (b*d) \ b * (c*d) &= c * (b*d) \ b*c*d &= c*b*d. \end{align*}
for all $b, c, d \in S$.
This is the last thing I wrote about it. But I don't know if it's true so I can continue or my way is wrong.
Comment: Letting different variables in the equation given for the property is definitely the right way to go, you're on the right track, but I don't think your exact choice will be fruitful. Try to work backwards a little: pick which property you want to prove, and select elements to set equal to the identity according to what will give you those identities.
Answer: Let $a=e$ and $d=e$, then $b*c=(e*b)*(c*e)=(a*b)*(c*d)=(a*c)*(b*d)=c*b$, so we have commutativity. For associativity, we take $(a*b)*d=(a*b)*(e*d)=(a*e)*(b*d)=a*(b*d)$.


Web Scraping no R

Question: Tenho de baixar a tabela desse link: http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp
Estou tentando utilizar o pacote rvest, porém, sem sucesso.
library('rvest')
url <- 'http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-
referenciais-bmf-ptBR.asp'

site <- read_html(url)
info_Ajuste_HTML <- html_nodes(site,'table')

info_Ajuste <- html_text(info_Ajuste_HTML)

lista_tabela <- site
lista_tabela <- html_nodes(site, xpath = "//td")
lista_tabela <- html_table(site, fill = TRUE)

dados <- lista_tabela[[1]]

Answer: Creio que o seguinte responde à pegunta. O problema é que a extração da tabela não está nada automatizada, precisa de saber quantas colunas a tabela tem.
library(tidyverse)
library('rvest')

url <- 'http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-taxas-referenciais-bmf-ptBR.asp'

HTML <- read_html(url)

dados <- HTML %>%
  html_nodes(xpath = "//table//td") %>%
  html_text() %>%
  str_replace(",", ".") %>%
  as.numeric() %>%
  matrix(ncol = 3, byrow = TRUE) %>%
  as.data.frame()

str(dados)
#'data.frame':  294 obs. of  3 variables:
# $ V1: num  1 6 7 11 14 21 22 25 32 33 ...
# $ V2: num  4.9 4.9 4.9 4.9 4.9 4.9 4.9 4.9 4.84 4.83 ...
# $ V3: num  0 4.66 5 3.8 4.49 4.66 4.77 4.47 4.53 4.59 ...

Comment: Foi na documentação do pacote [rvest](https://www.r-project.org/nosvn/pandoc/rvest.html).
Comment: Poderia dizer onde conseguiu o xpath?

Web Scraping no R


Bounds on powers of sums

Question: Given real numbers $x_1, x_2, \ldots, x_n$ such that
$$\sum_{i=1}^n{x_i}^2 \leq \frac{1}{2},$$
find the greatest constant $c$ such that
$$\sum_{i=1}^n{x_i}^m\geq c^m$$
is always true for all odd $m \geq 2$.
I tried using bounds on absolute values, but I don't think the bounds I got are very sharp. Clearly $c\leq -\frac{1}{4}$ by considering $x_1 = x_2 = -\frac{1}{2}$. We also get $c=-1$ works, but it doesn't look sharp. Can anyone help?
Comment: Clearly an important case is where one of the x's is unequal to zero, and all the others are equal to zero. I suggest you examine this special case.
Comment: In this case, I get $c = -\frac{\sqrt{2}}{2}$. How do I prove that this works for all choices of $x_1, \ldots, x_n$?
Answer: As $m$ is odd, in case any $x_i$ is positive, we may replace it with $-x_i$ and get a tighter bound for $c$.  Hence we may assume $x_i = -\sqrt{a_i}$ where $a_i \geqslant 0$, and also we can see the constraint is an equality for optimum, as otherwise we may increase one of the $a_i$.  So it is enough instead to find the maximum of:
$$\sum_{i=0}^n a_i^{m/2} \qquad \text{given}\qquad \sum_{i=0}^n a_i = \tfrac12, \quad a_i \geqslant 0$$
For $m> 2$, the function $\sum a_i^{m/2}$ is convex and hence this can get maximized only on the corners of the convex domain - viz. when one $a_i = \frac12$ and all others are zero.  Accordingly, $c_{max} = -\frac1{\sqrt2}$.

Bounds on powers of sums


Error when instantiating custom field in custom module

Question: I apologize if the answer to this is obvious, but I am newly-embarked on porting a number of complex custom Drupal 7 modules to Drupal 9. I am using Drupal version 9.3.6, PHP version 7.4.28, mysql, apache2.
I have created a custom field as follows, which on install goes without errors and appears in the field list report:
langcode: en
status: true
dependencies:
  module:
    - user
  enforced:
    module:
      - test_module
id: user.field_test
field_name: field_test
entity_type: user
type: string_long
settings:
  case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

But when I try to instantiate it, either with field.field.user.user.field_test.yml or manually through the UI, I get the following error stack:
 [warning] A non-numeric value encountered TypedConfigManager.php:189
 [error]  Error: Unsupported operand types in Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements() (line 189 of /var/www/test_site/web/core/lib/Drupal/Core/Config/TypedConfigManager.php) #0 /var/www/test_site/web/core/lib/Drupal/Core/Config/TypedConfigManager.php(105): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements()

(Sorry, I had to delete the remainder of the stack dump to avoid getting flagged as spam!)
This is the part of TypedConfigManager as follows:
    // Add type and default definition class.
    $definition += [
      'definition_class' => '\Drupal\Core\TypedData\DataDefinition', // Here is line 189
      'type' => $type,
      'unwrap_for_canonical_representation' => TRUE,
    ];
    return $definition;

I am at a loss here. If I create the field storage through the admin interface and instantiate also through the admin interface, everything works fine. I export those definitions through the single export interface, and then I get the failure.
Thank you in advance for any insight!
Update: @Jaypan, here is the code for the field.field:
langcode: en
status: true
dependencies:
  config:
    - field.storage.user.field_test
  module:
    - user
  enforced:
    module:
      - test_module
id: user.user.field_test
field_name: field_test
entity_type: user
bundle: user
label: 'Test field'
description: ''
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings: {  }
field_type: string_long

Comment: I believe fields have two sets of configuration, one for the field on the entity, and one for the storage. You have only listed one set of configuration - maybe you're missing the other. Something to look into.
Comment: Thank you, @Jaypan, but I have both. As mentioned, the error happens even when I instantiate manually. But for completeness I included above the code for the field.field.
Answer: I have figured out where the problem is. The fact that instantiating the fields (both manually and programmatically) triggered the error has nothing to do with it, and I still do not understand exactly why, but here is what I learned by deleting files from the module one-by-one: a view that I had created manually and exported for my module apparently caused some issue in the configuration system. When I deleted the yml file for the view from config/schema, everything enabled fine. Go figure.


Factors of $x^p-a$

Question: Pinter's Book of Abstract Algebra chapter 33, problem C2:
Let $p$ be a prime number.
"Explain why $x^p-a$ factors in $\mathbf{F}[x]$ as $x^p-a = p(x)f(x)$, where both factors have degree$\leq 2$.
Let $p = 5$, $a = 1$.  $\mathbf{F}$ can be $\mathbb{Q}$ or $\mathbb{R}$, among other fields.
$x^5 - 1 = (x - 1)(x^4 + x^3 + x^2 + x + 1)$.
Obviously, the degree of the second factor is greater than 2.  In fact, if $p$ is greater than $4$, one or both of $p(x)$ and $f(x)$ have to be greater than 2.  Not sure what I'm missing here.
Comment: Your quote makes no sense as written. If both factors have degree at most $2$, then the product has degree at most $4$, so you would have $p\leq 3$. There must be context missing.
Comment: This really doesn't make sense.  And writing that "$\mathbf{F}$ can be $\mathbb{Q}$ or $\mathbb{R}$, among other fields." is far too vague.
Comment: My guess (and it is just a guess) is that you are meant to show that "either $x^p-a$ is irreducible or else it has a root."  See, e.g., [this question](https://math.stackexchange.com/questions/460931/prove-f-xp-a-either-irreducible-or-has-a-root-arbitrary-characteristic-wi)  and the question it is linked to as a duplicate.
Comment: http://www2.math.umd.edu/~jcohen/402/Pinter%20Algebra.pdf  FWIW I think question 2 is a continuation of question 1.  In it we are assume $\omega$ is a $p$th root of unity in field $F$ and you are assuming $x^p = a$ is not irreducible (and that a root $d$ exists?  I'm not really sure.)
Comment: @HallaSurvivor: Well, there is actually a *lot* of missing context. First, the entire sequence of problems assumes that $\mathbf{F}$ contains a primitve $p$th root of unity. This **excludes** the stated possibility of $\mathbf{F}$ being $\mathbb{Q}$ or $\mathbb{R}$. It is also proceeding under the assumption that $\mathbf{F}$ does *not* contain a root to $x^p-a$, yet is reducible (end of part 1). However, this is clearly meant to be $\geq 2$ rather than $\leq 2$.
Answer: It's a typo. That said, you are incorrect on many things about this problem. You failed to provide critical context, making your post almost unintelligible and impossible to answer. It was only when that context was provided via a link in the comments to the text itself that I was able to puzzle this out.
This is one of a multi-part sequence of exercises meant to show that if $\mathbf{F}$ contains a primitive $p$-th root of unity, then $x^p-a$ either has a root in $\mathbf{F}$ or else is irreducible over $\mathbf{F}$.
The preamble to the set of exercises explicitly states that $\omega\in\mathbf{F}$ is a primitive $p$th root of unity. That means that it is false that "$\mathbf{F}$ can be $\mathbb{Q}$ or $\mathbb{R}$ or anything". In fact, it can be neither $\mathbb{R}$ nor $\mathbb{Q}$ (which contain no primitive $p$-th root of unity for any prime other than $p=2$), nor can it be many finite fields.
Second, the first part of the problem tells you to assume that the field does not contain any roots of $x^p-a$, but that $x^p-a$ is reducible; the goal is to establish a contradiction at the end, so that you will conclude that $x^p-a$ either has a root in $\mathbf{F}$ or else is irreducible over $\mathbf{F}$.  Note that this means that you cannot take $a=1$, since that violates the assumption that $x^p-a$ has no roots in $\mathbf{F}$.
This is where the typo comes in. You are expected to explain why you can factor $x^p-a$ into a product $p(x)f(x)$ where both factors have degree at least $2$ ("$\geq 2$" instead of "$\leq 2$").
At which point, you are in the territory of the duplicate indicated above.
Comment: thanks - this particular problem hadn't mentioned omega, and I didn't recognize its importance.

Factors of $x^p-a$


webview js interface can not use prototype

Question: I use webview inject a object just like this:
public class mediaplayer {

    @JavascriptInterface
    @SuppressWarnings("unused")
    public void testInterface(int num) {
        Log.d("mediaplayer","testInterface2...." + num);
    }

}
 public mediaplayer _mediaplayer = new mediaplayer();
 WebView.addJavascriptInterface(_mediaplayer, "IPTVPlayer");

and i want use it in web page, just like this:
function MediaPlayer2()
{

    return IPTVPlayer;
}
MediaPlayer2.prototype.setPlayerParams = function (channel) {

    console.log('MediaPlayer2.prototype.setPlayerParams2................');

};
 var mp2 = new MediaPlayer2();
 mp2.setPlayerParams("this is test");

when i run it ,it come out error:
TypeError: Object [object Object] has no method 'setPlayerParams'

I must use webview method just like that, so must return 'IPTVPlayer' .I don't know why i can not use prototype method, please give me some suggestions. I'll appreciate it.
Answer: Prototype-based inheritance without classes can be quite tricky in JavaScript.
There are two main things you have to do:
// 1. Correctly set up the constructors to call the super constructor
function MediaPlayer2() {
  // Call the "super" constructor with the new instance (this).
  IPTVPlayer.call(this)
}
// 2. Correctly set up the lookup chain via the prototype
MediaPlayer2.prototype = Object.create(IPTVPlayer.prototype);
MediaPlayer2.prototype.constructor = MediaPlayer2;

// Now you can start adding methods.
MediaPlayer2.prototype.setPlayerParams = ...

I suggest to keep on reading a bit more background work as well and start using ES6 classes which are more explicit:
class MediaPlayer2 extends IPTVPlayer {
  constructor() { super(); ... }
  setPlayerParams(...) { ... }
}

Comment: Thanks your answer. I try just as you said.But it also come out error: Object prototype may only be an Object or null,,, Object [object Object] has no method 'call'.  I think it's because of IPTVPlayer. It is a Object by webview inject, not a function.
Comment: You're right, you inject an instance into the webview instead of a class/constructor function. Either try injecting the class directly from Java (which I'm not fully sure will work), or try extracting the constructor from the passed instance, i.e. `IPTVPlayer..constructor`.


Intuition for relationship between variance of geometric and exponential distributions

Question: Given that the exponential distribution can be thought of as a continuous version of the geometric, is there an intuitive way to relate their variances?
I have some intuition for how the means of these distributions relate: a larger $\lambda$ corresponds to a larger $p$ (or, put intuitively, a faster rate of arrival in the exponential case corresponds to a higher chance of flipping 'heads' in the geometric case).
However, I have failed to come up with a way to understand how the variances relate.
Comment: When $X$ has an exponential distribution, $Y=\lfloor X \rfloor$ is the corresponding geometric variable.  Let $U=X-Y$ be the remainder.  Use the basic relation $\operatorname{Var}(X)=\operatorname{Var}(Y)+\operatorname{Var}(U)+2\operatorname{Cov}(Y,U)$ as one way to understand how the variances of $X$ and $Y$ relate. To draw generally correct semiquantitative conclusions, argue that to a good approximation the covariance can be neglected, then consider that the support of $U$ is the interval $[0,1].$
Answer: There is a clear relationship between the geometric and exponential distributions.
If $X\sim\text{Exp}(\lambda)$, $F_X(x)=1-e^{-\lambda x}$, and $Y\sim\text{Geom}(p)$, $F_Y(y)=1-(1-p)^{\lfloor y \rfloor}$, where $\lfloor y \rfloor$ is the floor function, then $F_Y$ can be determined by $F_X$ with $\lambda=-\ln(1-p)$, that is $P(Y\le y)=P(X\le \lfloor y \rfloor)$. See B. J. Prochaska, "A Note on the Relationship Between the Geometric and Exponential distributions", The American Statistician, 27(1):7.
As to their variances, you can consider that
\begin{align*}
E[X]&=\frac{1}{\lambda},\qquad V[X]=\frac{1}{\lambda^2} =\frac{E[X]}{\lambda} \\
E[Y]&=\frac{1}{p},\qquad V[Y]=\frac{1-p}{p^2}
\end{align*}
i.e. the variance decreases as $\lambda$ or $p$ increases:

if the rate of arrival is fast, arrivals "concentrate" around a short waiting time;
if the chance of flipping heads is high, then the number of trials "concentrate" around a small number.

An example in R:
<code>> set.seed(1234)
> e1 <- rexp(1000, 0.25)
> e2 <- rexp(1000, 0.75)
> round(range(e1),2)
[1]  0.00 29.07
> round(range(e2),2)
[1] 0.00 9.95
> g1 <- rgeom(1000, 0.25)
> g2 <- rgeom(1000, 0.75)
> range(g1)
[1]  0 22
> range(g2)
[1] 0 3
</code>


Find corresponding digit string lengths between radices?

Question: Each digit of base the base-16 representation of a number corresponds exactly to 4 digits in the base-2 representation, which allows for trivial conversion between these bases.
Other combinations of bases are less straightforward, but still permit short-cutting the generic remainder-and-divide algorithm for converting bases. E.g., 3 digits of base-16 correspond to 4 digits of base 8, and 3 digits of base-256 correspond to 4 digits of base-64 (hence the motivation for the base-64 encoding standard for binary data).
These sorts of relations are all fairly easily discoverable by comparing them to base-2 as an intermediary. But is there a more generic method of discovering whether or not a digit ratio exists between two radices, and if so, what it is?
Answer: Yes!
Digits can be aligned between representations in different bases if there is a solution in integers for $x$ and $y$ in the equation $r_1^x = r_2^y$, where $r_1$ and $r_2$ are the radices of each base. This is equivalent to saying that an $x$-digit number in base $r_1$ can express the same range of values as a $y$-digit number is base $r_2$.
This in turn has a solution when each radix can be written as a power of a common base; i.e., $r_1 = c^w$ and $r_2 = c^z$, so $r_1^x = c^{wx} = c^{zy} = r_2^y$
The values of $x$ and $y$ then tell you how many digits in each base are needed to align with a block of digits in the other base.
The common base for 8, 16, 64, and 32 is base 2, which is why these can be converted between by lining up their bit patterns. However, a similar relationship holds between, e.g., base-27 and base-9 (where 2 base-27 digits correspond to 3 base-9 digits), which can be seen by aligning trit (base-3 digit) patterns.


Add Google search field to website that searches in the address bar

Question: I have created a page to use as a 'homepage' when opening a new tab in Chrome, rather than the default Chrome 'New tab page'. I have used the extension 'New Tab Redirect' to display this page when I open a new tab.
I'd like to add a Google search field to this page that, when the user starts typing, it transfers to the browser address bar (like Google does on Chrome) - to allow either a Google search or to enter a URL.
I have looked around for a solution to this but haven't had any luck. Any ideas how this could be achieved?
Thanks!
Answer: Here it is explained pretty well:
http://www.brenkoweb.com/articles/development/designing-principles/how-to-add-a-search-field-to-your-website.php


The solutions to some Diophantine equations

Question: I have proved these two theorems (are they correct?) but I think most probably they have occurred somewhere else already. Would you please help me find references. Thank you.
Comment: um, this is usually called stereographic projection. You take a fixed solution, $(1,0)$ take coprime integers $(u,v),$   write $(x,y) = (1+tu,tv)$ and solve for the nonzero value of $t$ that causes $(x,y)$ to solve your equation
Answer: Your first theorem is just some subcases of Pell's Equation, so it is possible that this characterization has been done before. You should definitely search the literature further.
Your second theorem deals with a Diophantine equation that can be reduced to an instance of Pell's Equation. Thus I would expect that you might be able to use first theorem to prove the second almost immediately.
As far as verifying your proofs, we can't do that unless you show us your work! But I suspect that what you have done is probably right anyway.
Comment: But my first theorem deals also with $m<0$?
Comment: @sai Ah, I assumed you were only caring about the positive $m$'s. Then a more complete solution is found [here](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=2ahUKEwjHuPGy2tXfAhUBmuAKHcAKD30QFjABegQIBBAC&url=https%3A%2F%2Fwww.springer.com%2Fcda%2Fcontent%2Fdocument%2Fcda_downloaddocument%2F9780817645489-c1.pdf%3FSGWID%3D0-0-45-1314537-p173733615&usg=AOvVaw1pzPkjNnJIObeQI4yCNxwS) on page 92, remark 2.
Comment: @sai So far, none of the references I have looked at since your comment deal with your cases this succinctly, but I think it is fair to say that these are generally known though specification from other theorems or general solution techniques.
Comment: Okay, thank you for your help.


Is there a way to get the row number in Mysql like the rownum in oracle

Question: Is there a way to get the row number in Mysql like the rownum in oracle, If not then is there any indirect way of doing it?
please suggest.
Comment: There is no rank functionality. Refer this [Stackoverflow question][1]

  [1]: http://stackoverflow.com/questions/1895110/row-number-in-mysql
Answer: Until MySQL finally supports modern SQL, the only way to get something similar is this:
SELECT @rownum:=@rownum + 1 as row_number,
       t.*
FROM (
   < your original query goes here >
) t,
(SELECT @rownum := 0) r

Answer: The best practice is to add an auto incrementing ID for each row. This would also help you a lot if, one day, you choose to use relational tables.
In phpMyAdmin, when you create (or edit) a table, you'll see the AUTO_INCREMENT option. You can only have one column with auto IDs enabled.
Edit: This is how you database would look like:
id | name  | email | phone
1    Tekin   ...     ...
2    John    ...     ...
3    Jane    ...     ...

Comment: That is something completely different to a `row_number()` value. What if you want to get the row number after sorting by a specific column?


jquery order of elements

Question:

1

2

    $("#box").sortable({ update: function() {
    var order = $("#box").sortable("serialize");
    alert(order);
    }
   });

How to get the very same result in order variable without using sortable?
Comment: i do not get u what u r saying?. how output should be like? from -> to
Answer: chang
 to
, because ul means unsortable list
Comment: i want to get the order without sortable

jquery order of elements


In every sequence of positive integers, each $17$-sum is even, and each $18$-sum is odd. How many terms can such a sequence have at most?

Question: In every sequence of positive integers, each $17$-sum is even, and each $18$-sum is odd. How many terms can such a sequence have at most? $\\$
I have been able to figure out that in this sequence of positive integers there are more than $16$ odd integers at least. This is because: $\\$
Let's take {$a_1,a_2,\cdots,a_{17}$} to be a sequence of $17$ integers, we know that their sum is even, now if we add another integer let's say $a_{18}$ to this sequence then the new sum should be odd and hence the so-added integer must be odd. $\\$
Hence for every grouping of $17$ integers there should be another odd integer. Now suppose there are less than $16$ odd integers i.e $15$ odd integers. Then if we select a pair in which the $15$ odd and $2$ even
are appearing and then add any other integer i.e even the $18$-sum will come out to be odd which is contradictory !$\\$
Now if there are $16$ odd integers then we can take a $17$-set in which there are $15$ odd and $2$ even, and then to form the $18$-set we can add the $16^\text{th}$ odd number thereby fulfilling the condition. $\\$
Hence the number of odd integers is $\ge16$ . $\\$
Now I am stuck on how to proceed, any help would be appreciated. Thanks !!$\\$
Source : Problem Solving Strategies by Arthur Engel
Comment: But your question says _maximum_ number of possible integers. The sequence has to be finite somehow.
Comment: What is a $17$-sum?
Comment: sum of 17 integers
Comment: You mean you take an infinite sequence of positive integers $(a_n)_{n\in\mathbb{N}}$ under the condition that any subsets $\{a_{j_k}, k =1,...,17\}$ and $\{a_{i_k}, k =1,...,18\}$ sum up like $\sum_{k=1}^{17} a_{j_k}$ is odd and $\sum_{k=1}^{18} a_{i_k}$ is even?
Comment: Do they have to be consecutive?
Comment: we have to find the maximum number of integers needed to form such a sequence @Jfischer
Comment: not necessary @ParclyTaxel
Answer: Since any terms may be chosen, consider $18$ terms. By arbitrarily choosing an element to exclude from the $17$-sum, we show that all the $18$ terms are odd. But this means that all the $17$-sums are odd, which is a contradiction.
Hence the sequence may have at most $17$ elements, and having them all even fulfills the conditions.
(If the sums are all consecutive, a similar argument shows that there may be at most $33$ terms.)


Iterate over json with angular 7 using services

Question: I have a node server that returns the following JSON:
{
        "ResponseStatus": {
          "ResponseCode": 0,
          "ResponseMessage": "Success."
        },
        "Events": [
          {
            "CodEspec": 65957,
            "NomeEspec": "O PIOR ESPETÁCULO DO MUNDO",
            "DiaHoraEspecs": [
              "2019-05-09T21:30:00",
              "2019-05-10T21:30:00",
              "2019-05-25T21:30:00"
            ]
          },
          {
            "CodEspec": 01234,
            "NomeEspec": "O MELHOR ESPETÁCULO DO MUNDO",
            "DiaHoraEspecs": [
              "2019-05-09T21:30:00",
              "2019-05-10T21:30:00",
              "2019-05-25T21:30:00"
            ]
          },

        ]
      }

I created an angular service that executes a GET and returns the JSON.
tickeline.service.ts
getEventos():Observable<Event[]>{
    //get todos os eventos
    return this.http.get<Event[]>(this.url_node, httpOptions);
  }

Also created a model for the event to only get certain parameters:
events.ts
export class Event{

  CodEspec: number;
  NomeEspec: string;
  DiaHoraEspecs: Date[];

}

The in the event component where i want to show the JSON i call the function geteventos from the service.
events.component.ts
export class EventsComponent implements OnInit {

  events: Event[];

  constructor(private ticketlineservice: TicketlineService) { }

  ngOnInit() {
    this.ticketlineservice.getEventos().subscribe(events => {
      this.events = events;
    });
  }
}

events.component.html

Evento:

{{ event.NomeEspec }}

{{ event.CodEspec }}

{{ event.DiaHoraEspecs }}

Problem: Create for every Event object a li element with the corresponding information. At the moment it only creates on li element and doesn't show the JSON information
Comment: You are getting repeated `uls` instead of `lis`, put your `*ngFor` over the `li`
Comment: what is the content of `events` which are returned in `subscribe`?
Comment: `subscribe` returns an array with two arrays inside and in those two is the information of every event
Comment: @LuisMaia but you showed the JSON response, and there is no array with arrays inside. You should be clear which response exactly you are getting.
Comment: @porgo returns the following: `0:
Events: Array(2)
0: {...}
1: {...}`
Comment: @LuisMaia check my answer, I edited this. Now it should work.
Answer: Instead of iterating over ul elements you should iterate over li elements

Evento:

{{ event.NomeEspec }}

{{ event.CodEspec }}

{{ event.DiaHoraEspecs }}

Comment: Still only creates a single li element and doesn't show the JSON information
Answer: In this json which are you presenting Events is a property. So you should get this property from events in subscribe:
this.ticketlineservice.getEventos().subscribe(events => {
  this.events = events.Events;
});

But if you are getting array as response with Events property inside (as you mentioned it in comment), you should do this like this:
this.ticketlineservice.getEventos().subscribe(events => {
  this.events = events[0].Events;
});

And you should also in further steps change a type of return getEventos():Observable<Event[]> because as you showed this is not true (according to this sample JSON response). You are not returning Event array.
And also in HTML file you should make changes like @Dusan Radovanovic post as his answer. So it should like this:

Evento:

{{ event.NomeEspec }}

{{ event.CodEspec }}

{{ event.DiaHoraEspecs }}

Comment: In the model of event i need to change anything? Because I´m getting the following error `Type 'Event' is missing the following properties from type 'Event[]': length, pop, push, concat, and 26 more`
Comment: `this.events = events[0];`, `this.events` returns the error in the comment above: `Type 'Event' is missing the following properties from type 'Event[]': length, pop, push, concat, and 26 more`
Comment: you are getting this because you have a return type `Event[]` from observable in your service, change this for `any[]`: `getEventos():Observable`
Comment: Returns an error in the HTML `Can´t iterate over an object ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'` i changed to `*ng-repeat="event in events"` but also returns an error `Can't bind to 'ng-repeat' since it isn't a known property of 'li'.`
Comment: I also checked once again the response you are getting, and I noticed my error (I think so). It should be: `this.events = events[0].Events;`.
Comment: Yes makes sense, i also changed back the service to `` and still works, thanks for the help
Comment: No problem, sorry for misunderstanding. Im glad that now everything is ok.
Answer: Your JSON is not an array, it is an object.
Inside your subscribe, I think you probably want to do this:
  this.events = events.Events;

As others have mentioned, with your current code you should create two ul lists.  If you want to create a single list with two items you'll need something like this:

Evento:

{{ event.NomeEspec }}

{{ event.CodEspec }}

{{ event.DiaHoraEspecs }}

Moving the *ngFor from the ul to the li
Answer: There are two parts to your problem here.
From the response please pick the Events array and assign it to the events class level variable in event.component.ts
export class EventsComponent implements OnInit {

  events: Event[];

  constructor(private ticketlineservice: TicketlineService) { }

  ngOnInit() {
    this.ticketlineservice.getEventos().subscribe(events => {
      this.events = events.Events;// This is the change for getting only events from the response
    });
  }
}

This way you will have only the events array rather than the entire response.
The second step is to as pointed out by main run a loop on the li rather than the ul as shown below:

Evento:

{{ event.NomeEspec }}

{{ event.CodEspec }}

{{ event.DiaHoraEspecs }}

I would like to add one more good practice which is to add elvis operator or safe operator so that your HTML does not fail.
event.NomeEspec --->  event?.NomeEspec
This way if event is undefined then we are safely accessing the properties of the event object.
Update
getEventos():Observable<Event[]>{
    //get todos os eventos
    return this.http.get<Event[]>(this.url_node, httpOptions);
  }

here you are type casting the response to Event[] whcih you will have to change a bit as shown below.
**getEventos():Observable<Event[]>{
    //get todos os eventos
    return this.http.get<Event[]>(this.url_node, httpOptions).map(response=> response.Events);// map operstor takes your response and sends the Events array as a part of the response for your HTTP call.
  }**

Comment: I already alter the html, but when I change the `event.component.ts` to `this.events = events.Events;` it returns the following error `Property 'Events' does not exist on type 'Event[]'.`
Comment: Hi @LuisMaia I have updated the answer please check if that helps.You need to pick the Events array from response before typecasting the response which you are doing when you say `this.http.get`.So please see the updated asnwer and let me know if it helps.


Converting right-linear grammar to left-linear grammar

Question: I have the following language:
$$L := \{b(ab)^n a^m \mid  n, m \geq 0\}$$
and have created a right-linear grammar:
Grammar     $G(b(ab)^n a^m)$
Terminals       $a, b$
Non-terminals   $S, S_1, S_2$
Start symbol        $S$
Productions
\begin{align*}
S &\rightarrow b \\
S &\rightarrow bS_1 \\
S &\rightarrow bS_2 \\
S_1 &\rightarrow abS_1 \\
S_1 &\rightarrow abS_2 \\
S_1 &\rightarrow ab \\
S_2 &\rightarrow aS_2 \\
S_2 &\rightarrow a
\end{align*}
I'm finding it hard trying to convert the above grammar into a left-linear grammar. Would appreciate if someone is able to help me. I've looked at videos on Youtube but I still cant seem to grasp it.
Am I right in thinking that the strings will be reversed or is there another way to do it?
Comment: [Same question on Computer Science](http://cs.stackexchange.com/questions/54502/convert-a-right-linear-grammar-to-a-left-linear-grammar)
Comment: What exactly are the constraints on $n$ and $m$ in the language?
Comment: Sorry. n, m >= 0
Answer: HINT: I would simply start from scratch and write down a left-linear grammar directly from the regular expression $b(ab)^*a^*$ that defines the language. Clearly you need $S\to Sa$ and $S\to S_1$, where $S_1$ will ultimately generate strings of the form $b(ab)^*$. You'll certainly need $S_1\to S_1ab$; can you work out the rest of the productions from here?
Answer: switch between terminals and non terminals to get (A)r then make the inverse of the automaton to get((A)r)r then you can get the right linear grammar