A few of my coworkers and I were discussing this and spitballing ideas off one another about possible solutions.
One we came up with, the only one I liked, was to have National Guard personnel be required to serve at least 1-2 years on "school" guard. This means that on public school grounds there would be at least one armed Military person standing guard. Would this prevent all or save all, no, but it may deter some students from following through with their plans.
The problems or things we don't know are: what about private schools, and are there enough National Guard members to actively guard every public middle and high school in the country?
As far as preventing shootings at places of business such as YouTube... shrugs