Can we use a rail gun on the moon to launch stuff directly to mars?

Question: Quite a bit has been written about railguns launching stuff to the earth. But has any work been done on using the moon as a pit stop between the earth and mars.
Answer: It would be a bad idea but on two technicalities.  Railguns produce huge accelerations in a short distance, what's needed for a mobile weapons platform.
For a launcher what you want is a linear motor, not a railgun.  Think of a maglev train, but without a speed limit.
It would be a major engineering project that would certainly have to be built almost entirely from lunar or asteroid resources.  The track would be hundreds of miles long but you have the advantage that the forces on it are much more predictable than here on Earth.
The longer the track and the higher acceleration you will tolerate on the track the farther you can go.  If you take this to its logical conclusion you get a doubled track wrapped around the lunar equator.  You build a second track upside-down and overhead and the cars that ride on it are built to ride either track.  For 5G on that track you can get an ejection velocity sufficient to take you anywhere from practically grazing the sun to an escape orbit.  You still need to bring along some way to stop but your main boost is done.
Clayton brought up transfer windows.  I see this as a non-issue.  Yes, the launcher will only be pointed in the right direction once a month--but there's no deep space target with a launch window that comes that frequently anyway.  It might not be a perfect launch window but such windows aren't a binary state, a sightly mistimed launch just costs you a bit more fuel--but your "fuel" is electricity, dirt cheap compared to rocket fuel you need to haul along.
Clayton also brought up the issue of accuracy.  Yes, a perfect ejection isn't going to happen.  You're not going to be able to fire artillery and hit Mars.  Rocket launches suffer the same limit, the reality is midcourse corrections are needed.
LocalFluff (in a comment to Clayton's post) also addressed the issue of plane changes.  Do them in a flyby, it's still a lot cheaper than the whole burn.
Finally, the second technicality:  It's cheaper to go to Mars than to go to the Moon, even if you figure that your facility on the moon can pluck a craft out of a very low orbit and land it.  (You have a car riding on a track, it shoots cables up as the spacecraft flies overhead.  Get it right, they connect and the spacecraft is hauled down and decelerated.  Miss and you try again next orbit.)  The only reason to use a lunar facility to go to Mars would be if you wanted to do it when you didn't have a decent launch window.
As for the "it's cheaper to go to Mars than the moon" bit:

Start at Earth (bottom left) and work your way up:
9.4 km/sec to reach low orbit
Another 2.44 km/sec to reach geosynchronous orbit
Another .68 km/sec to reach the moon
Now, from here there are two paths:
Going to the moon:
.14 km/sec for capture
.68 km/sec for low orbit
1.73 km/sec for landing.
Note that I was only counting the first two numbers in talking about capturing a vessel in orbit.  In reality the cost would be higher as you're not going to get a capture in a 100 km orbit.  1 km periapsis would be more like it.  I was simply counting .82 km/sec as the cost of the Moon, but if you have to do it with rockets all the way it's 2.55 km/sec.
Going to Mars:
.09 km/sec to leave Earth's SOI
.39 km/sec for a Martian transfer orbit.
Note that the total cost is .48 km/sec, well below the Moon.
What's that I hear from the peanut gallery about the .67 km/sec for capture at Mars?  Note that red arrow on that line.  You get that .67 km/sec from a dip in the Martian atmosphere, not from your engine.  If your objective is landing you can go all the way down without burning, if you want to orbit Mars you will need a small burn to circularize once you have used the atmosphere all you can.  Even with that circularization burn it's still going to be less than the cost of going to the moon.
One point--you would never actually move around like that diagram shows and many of those numbers aren't actually accurate for the shown maneuver.  In practice you always burn as much as you can as close to as massive a body as possible.  Thus if your objective is a low orbit about the moon you don't do the ~10 burns (5 arrows + 5 circularization burns) that chart shows, but rather:
1)  Launch burn
2)  Low orbit circularization burn.  (Note: Some rockets are able to do one continuous burn for these two steps.  This saves the need to use a restartable engine for this purpose.)
3)  Lunar transfer burn.  This will take you to the desired altitude above the moon.
4)  Circularization burn.
In theory burns 1, 2 and 3 can be combined into a single burn but that gives you an extremely narrow launch window and doesn't actually gain you much of anything as you need to get above the atmosphere before piling on too much velocity anyway.
Likewise, you would not find that .39 km/sec would suffice to get you from Earth orbit to Mars, that number is assuming you do the burn in low Earth orbit.
If you really want to learn about orbital mechanics I strongly suggest the game Kerbal Space Program.  While it definitely makes some simplifications the orbital mechanics are pretty accurate (although if you want real numbers you will have to download a mod that gives you our solar system rather than the game one.  The stock game uses a more compact solar system to make things happen faster--transfer time to the most distant planet in the game is under 2 years.
Comment: @Stephan No, I'm comparing leo-to-Moon to leo-to-Mars.  Both Mars and Venus are closer in delta-v than the Moon because you can aerocapture while you have to do it with rockets at the moon.  (A flyby of the Moon is cheaper than a flyby of the other planets.)
Comment: @Stephan To capture you're half right--the Moon is cheaper but not by as much as you say--note the red arrow on the .67 for Martian capture.  You can do almost all of that with aerobraking rather than rockets.  I was talking about low orbit or landing, both of which are cheaper for Mars assuming aerobraking.
Comment: Thanks for pointing out that "railgun" is the wrong term to use here. Indeed it should be a very long linear motor. I don't quite understand the phrase "It's cheaper to go to Mars than to go to the Moon..." can you elaborate?
Comment: Nice graphic but the text size is too small for easy reading. The font size should be doubled and the names of the planets should be larger than the other text
Comment: @Uwe Not my graphic, just what Google came up with.  It's quite readable if you blow it up to full size.
Comment: The math on this is quite a bit off. You're comparing surface-of-earth-to-the-moon cost to leo-to-mars cost. Leo-to-moon is far less than leo-to-mars.
Comment: Leo to moon capture: 3.26 Leo to Mars capture: 4.27. Cost is pretty much double that to land on them.
Answer: Yes, but it would be extremely hard, you would need to accelerate it fast enough to escape the moon's gravity, Earth's gravity, then raise your orbit of the sun to achieve a Mars transfer.
But that's not all!
First, the railgun would need to be aimed perfectly: being one centimeter off on the moon will make you thousands of kilometers off at mars.
Second, you would need to be in a specific place on the moon. This would be a problem, since the moon's orbit takes 27 days, and since the moon is tidally locked, it may take longer than the transfer window to be in the correct position to fire the cannon.
Third, the amount of energy required. From low earth orbit, to a Mars transfer orbit, you need 4.3 kilometers/second of delta v. Back to the energy, the US navy's railgun requires 25 megawatts of energy. For comparison, the ISS's acre of solar panels produce 120 kilowatts at max. And the gun only accelerates a 2.5 kilogram projectile to 2.4 kilometers a second.
In conclusion, it's possible, but not feasible with modern technology. It would require too much energy, have so little times it could be used it would be almost useless, and the tiniest mistake could make it fail.
Comment: Talking about the power draw of a railgun when it's fired is remarkably pointless. There are such things as *batteries* and *capacitors*, you know. What's actually relevant is not the power draw for the milliseconds of firing, but the *total energy*, and you can't measure energy in watts!
Comment: Concerning the *"need to be in a specific place on the moon"*, what about aiming the Lunar rail gun towards a close Earth flyby, to take advantage of an Earth gravity assist towards Mars. Wouldn't that geometrically offer a launch window to Mars every month? (The 2 degrees inclination of Mars' orbit, and the 5 degrees inclination of the Moon's orbit, could maybe be adjusted for by a modest reaction impulse at perigee to take advantage of the Oberth effect).
Comment: The points seem valid, but a little technical note: according to https://en.wikipedia.org/wiki/Delta-v_budget#Delta-vs_between_Earth.2C_Moon_and_Mars moving from LEO to Mars transfer (3.8km/s) is more expensive than Moon surface to Mars transfer (2.9km/s).
Comment: The possible acceleration is limited by the loads structural strength. A lot of extra weigth is necessary for the necessary stability, but all that extra weigth is useless when the load has left the railgun.
Answer: This answer only address the navigation aspects of this.
The arc-size of Mars at opposition from Earth is 22 arc-seconds.
https://in-the-sky.org/news.php?id=20201013_12_100
The very best current technology can do at least 8 milli-arc-seconds.
https://jwst-docs.stsci.edu/display/JTI/JWST+Pointing+Performance
There will be perturbation forces on any projectile from the moon, but assuming those are modeled reasonably well (drag is the most difficult to model which is not an issue for the moon) and accounted for in aiming it should be possible to pull this off with some mid-course corrections.
Comment: I don't think the JWST's no-thrust, high-altitude Lagrangian pseudo-orbit environment makes a good comparison for railgun accuracy. (There are also quite a lot of other factors involved, as some of the other answers have mentioned, and an answer that only addresses one aspect of the question is less than ideal.)
Comment: I meant to put this as a comment under your point about pointing accuracy being a challenge. We absolutely have the technology for pointing accuracy for this sort of system as JWST can achieve an order of magnitude better. Less extreme control systems can also meet the requirements.
Comment: JWST uses low-acceleration, ultra-low-vibration reaction wheels and thrusters integrated over long periods of time in a nano-gravity environment. None of that works on a railgun round being fired. That's fine, since we don't need those extra 3+ orders of magnitude anyway: mid-course corrections *are* good enough.
Comment: Just figured out what you might have meant by "meant to put this as a comment". Are you talking about https://space.stackexchange.com/a/19578? Because if so, I didn't post that answer, and I downvoted it (several years ago).
Comment: Yes, that is what I was referring to.
Answer: yes but you would need to make course corrections on the way. using a maglev directed towards earth you could use the earths gravitational field to magnify any small changes in direction allowing you to shoot in almost any direction you want with only a course correction of 1 to 6 degrees. I could easily see us having little ports we land in and use regenerative breaking on the other side to slow the cargo down. we might also decide to ship things to planets with stronger gravitational pull to generate energy and ship the empty cargo ship back with surplus energy or lighter resources.
Answer: I disagree. Pointing accuracy is not significant. Just get product into Moon orbit. Moon based subgrade rail gun only sends fuel containers, with  huge volume H20 into moon orbit(once base station is created) Containers reused once H20 tranferred, where -in orbit- it is harvested in transfer for E2M vehicle travel. Polar regions apparently have highest yield potential. Gateway 'space tugs' drop construction/printers, hi-temp furnaces, etc. material from moon orbit to surface without landing- with use of high tensile netting span over suitable craters for recovery of material at min. expended energy cost.
Why water? Frozen or liquid, great! . Multiple functions. #1 shielding from micro meteorite impact in E2M trip with external flex bladders.  #2 shielding from solar radiation. external flex bladders #3 shielding from cosmic radiation sources, external flex bladders #4 use of fuel for nuclear propulsion systems with constant accel/decel for 0.5G shortening E2M and return travel time. Energy expended into material 'inertia' in moon orbit is partially positively recovered using Earths' gravity on the way to Mars... everything E2M is about energy efficiency. Multiple staging systems insure max. efficiency. Small technology hurdles, moon base, vacuum the rail gun, subsurface H2O refining.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: Moon orbit /Gateway space tugs transferring, capturing and aligning cargo/orbit synchronicity are  proposed as nuclear propulsed.
Comment: Railguns can have ANY acceleration criteria, and the "accuracy" you mention is not for a return to earth accuracy, but only for a surface to moon orbit. - Much less defined by aiming or accuracy. A sloped raingun track from polar surface to moon orbit is a relatively easy techno develoopment today. Getting construction material to surface, has many options....
Comment: The point I'm trying to make is to break down the different aspects of a Mars mission into their critical energy for any long distance trip to Mars considerations. Earth orbit.Conventional chemical propulsion, reuseable.  Transfer E2MOON to orbit. Build M2Mars craft in Moon orbit, with Gateway resources/fuel from a moon base. Launch M2Mars from Moon orbit, using Earth as gravity assist to Mars.
Comment: Getting 3D printed material and fuel! from a moon base into orbit using a mag/rail gun is the ultimate energy resource efficiency. No atmosphere, low energy density to moon orbit, permanent moon base with first priority the launching to planets. Removing earth based construction methodologies (and massive energy expenditure earth orbit)  has huge energy savings- with operational moon base as priority to planetary exploration.


Network projector adapter for existing projector

Question: Vista introduced a new capability for supporting network projectors, eliminating the need to connecting via a cable to the projector. Does anyone make adapters that can add support for this to existing projectors? I've found a couple of wireless projector adapters (from Plextor and Infocus) but they seem to require custom software on the projecting computer rather than using the standard Windows functionality.
Answer: I haven't found one either. From what I understand, to do this the adapter would need to run Windows CE 6.0, then do an RDP session to the Vista computer.
As an added tease, Microsoft even shows a picture of one in their Windows Network Projector Overview.
Answer: What Microsoft is refferencing is the "potential" to develop a prodoct that can replicate laptop screens on a projector using their RDP software.   Of course, what couldn't you do with a computer with programming skills and unlimited time and patience for an OS that is loaded with a never ending stream of security vulnerabilities.
If you are interested in a product like this, then check out the RVW 200 Remote Viewer - Wireless Network VGA Adapter.   The Remote Viewer is a turnkey hardware and software soluion built on an embedded linux operating system.   All of the software is served up through a browser interface.
Here's how it works, the Remote Viewer is connected to the projector VGA and to the LAN.   You walk into the conference room with your wireless laptop, open your browser and type in the IP address of the Remote viewer (or create a shortcut).   A web page opens up,you click "connect" and your laptop displays on the projector.   This is perfect when you have multiple people in the conference room for a meeting and need to switch from one person to the next without fumbling with wires, plugs and adapters.   The Remote viewer is loaded extra features like the ability to have a hosted session where the "host" controls which laptop is displaying on the projector, again through a browser interface.   The Remote Viewer even functions as a network media player that can play video files and pictures from its HDD through a playlist functionality; entertain and educate the folks before the meeting or just display the corporate logo.
You can buy them and even view a video demonstration at ethernetav.com.
Comment: "unlimited time and patience for an OS that is loaded with a never ending stream of security vulnerabilities" - these sorts of comments are not helpful, at all, in any way, and should be avoided. I see you're also spruking your own product, which means that you're slightly less than un-biased.
Answer: I've used the Iogear DVI NetStation to connect over a LAN to a 42" 1080p monitor.
Connect the NetStation to the projector, and install the included app on your PC to either duplicate your laptop display to the projector; or even use the projector as a secondary display. This is a nice technique because you can hide you primary desktop from the other members of the meeting.
This is NOT very good for live video though.  The technology is called DisplayLink.


Upgrading early 2015 Macbook pro from Mojave to Catalina/Big Sur?

Question: I have an early 2015 Macbook pro with 8GB RAM and i7 dual core processor. It runs Mojave smoothly, and I haven't upgraded to Catalina nor Big Sur. I read that Catalina won't slow things down compared to Catalina, but what about Big Sur?
Answer: If you have enough free disk space, the best thing to do is:

reduce disk space for Mojave.
create a Catalina or Big Sur test environment and so you will see for yourself.

The other option is to install the new system on DDE USB-3 and, despite the loss of performance compared to the internal SSD, you can also test without touching in Mojave.
What is important to know is that Catalina or Big Sur no longer support 32-bit applications.
Answer: If a Mac is within the included range of supported models for an OS, then it should run without problem.
One of the reasons for Apple excluding a Mac from a new OS is that the 'experience' is not good enough, in terms of speed.
I've run all three OSes on a 2014 MBP, and performance was fine. I didn't notice any discernible difference.


Automount cdrom when accessed via NFS

Question: I am currently running CentOS 5 on a server that has a built-in CDROM drive.  I currently have a setup where /media/cdrom is automatically mounted by autofs as needed and I am exporting /media/cdrom via NFS.  I need to be able to unmount this cdrom, eject it, and put in a new one without breaking anything, but this doesn't seem to work.  Is there a better way to do this (noting that I have very little control over the server that is attempting to mount /media/cdrom via NFS)?
Comment: What is "breaking anything"? What are you actually doing? Why do you not use ISO-images instead?
Answer: The problem is that when you want to export a directory via NFS, the Linux NFS server "hangs on" to the exported directory as if it were a process running with an open file descriptor in that directory, preventing the mountpoint from being unmounted (well, technically, the kernel is doing this in the nfs kernel module).  You'd have to shut down the NFS server, unmount the CD (or tell autofs to unmount it), insert the new CD, then restart the NFS server.  Hopefully, you can do this in the time before the NFS client times out.
It would be considerably easier to just mount ISO images, as Nils suggested.
Comment: Unfortunately, ISO images aren't physical CDs -- and the goal here is that the end user can insert a physical CD into the machine and have it appear on a different machine (I didn't write most of the code involved on the other machine, and there's a third machine that expects "ssh machine2 mount /media/cdrom" to do exactly what it needs -- I cannot change anything about that third machine).  The only machine that has a physical CD drive in this system is the first machine.

Automount cdrom when accessed via NFS


How can I make Caps Lock work with Hebrew like it did prior to Sierra and without Ukulele?

Question: In Hebrew the Caps Lock is used to activate the vowel points. How do I restore this feature of Caps Lock in Hebrew, and without creating a new keyboard with a program that I do not know, like Ukulele?
Comment: @Tom Another Hebrew vowels question was closed as a duplicate of the question this is now closed toward. I have voted to reopen this though.
Answer: If you are talking about Apple's built-in Hebrew PC keyboard layout, you cannot make it work like before, but you should still be able to input vowels via Option plus Shift. Or you can download the new keyboard you need to restore the previous behavior.
Answer: It is a regression and loss of functionality caused by Apple, plain and simple. It was not announced, much less given any justification, anywhere that I (or Google or Bing) can find.  It seems like a total goof by Apple.
Contrary to answer 1, you cannot type the same set of nikud using Option plus Shift as before with the Windows Hebrew keyboard, called "Windows - PC" on the Mac: you can type the Apple set of nikud, which is a proper subset of what you could type with Windows - PC.
For example, there is now no way to type Sin Dot and Shin Dot nikudes in the Apple set, whereas you could do so with the Windows - PC set.
Also, the placement of the keys to type with Option+Shift to get a nikud is completely different now. For example, PATAH with Windows PC was Caps Lock+Shift+7, but now it's Option+Shift+6 -- i.e., a change from 7 to 6.
So, you don't just have to change key typing from Caps Lock+Shift to Option+Shift, you basically have to learn the entire set of nikud key locations to combine with anew.
Comment: Your post is not an answer but a combination rant/comment.  You should delete this and repost it as a comment under the question or the earlier answer, after fixing the errors:  There is no "Windows - PC" keyboard on any version of OS X, so it's not clear what you are talking about.  Plus Sin Dot and Shin Dot ARE on Apple Hebrew PC layout at  option-shift s and m.  If you don't like the different nikud locations, you can use the alternative keyboard I have provided (which takes a few seconds to generate with Ukelele).
Comment: @TomGewecke: I am afraid you were mistaken in stating, "there is no 'Windows - PC' keyboard on any version of OS X". All you or anyone needs to do to see that is to go Keyboard Preferences, click + to add a keyboard, choose Hebrew as the language, and then see that there are 3 choices: (1) Hebrew; (2) Hebrew - PC; (3) Hebrew - QWERTY. As regards the reported bug, Apple fixed this bug quite some time ago. It's not present in Mojave, nor in Catalina.


About lying as self defense and saving a life

Question: is telling lies permissible for self defense if youre at the mercy of a robber to save yourself?
Ive been kidnapped and still i spoke the truth.
Answer: Yes, in such a situation it would be permissible to lie. Allah says in the Quran:
"He who disbelieves in Allah after his having believed, not he who is compelled while his heart is at rest on account of faith, but he who opens (his) breast to disbelief-- on these is the wrath of Allah, and they shall have a grievous chastisement."
This verse explains that if a Muslim feels his life is at risk, and pretends not to be a Muslim to save his life - he has been compelled-  then such a person is forgiven and will not be held accountable.
However, it is also permissible to stand your ground and speak the truth regardless. In the story of ashaabul Kahf, the 7 sleepers in the cave could have just falsely pretended to have disbelieved in Allah and claimed to worship idols, but instead, they left their city and refused to worship idols.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: Yes, it's permissible in some conditions.
Asma bint Yazid narrated that the Messenger of Allah said:

"it is not lawful to lie except in three cases: Something the man tells his wife to please her, to lie during war, and to lie in order to bring peace between the people."

Some scholars say that the lie can be in the form of allusion/confusion/hiding in three situations above.
Also, lying is permitted in those conditions:

When your or another muslim's life is under serious threat,
When your goods/values are under serious threat
When you have to keep secret of a muslim
When you have to keep shame of a muslim secret


Effect of Eath's rotation on a ball thrown upwards

Question: Since the Earth is rotating it should have acceleration (in the sense that there is change in direction of velocity). So if we throw a ball upwards won't this acceleration affect its trajectory in some way? (If yes is it due to the smaller size of the ball and length of its path, compared to that of the Earth, we are not feeling it?)
Comment: And this,http://physics.stackexchange.com/q/48287/
Comment: Related: http://physics.stackexchange.com/q/133801/
Comment: Related http://physics.stackexchange.com/q/166853/
Comment: I've created a sort of canonical answer to this at: http://physics.stackexchange.com/questions/227391
Answer: There are several effects. The most obvious one is that, on the equator, your ball will experience about 0.2% less downwards acceleration than at a pole (because of the centrifugal pseudoforce). There are less obvious pseudoforces, too, the Coriolis forces. When you throw the ball straight up at the equator, it will seem to lag behind the earth's rotation: For every meter it goes up, if it wasn't for air friction, it will seemingly speed up in a westerly direction by 0.0003 km/hour (or about 1.5 times the speed of sound, the surface rotation speed of the equator, for every earth radius the ball goes up). At other lattitudes, there is even a seemingly horizontally rotating component. All of these effects are hard to see unless you look at large scale low-friction phenomena (weather systems, ocean currents).
Comment: Thanks @pyramids. Sorry that I cannot up vote the answer due to insufficient reputation. Can you kindly explain your answer? I didn't understand the part concerning "centrifugal force". Also please tell me about the calculation of 0.0003 Km/hr.
Comment: Imagine you're a kid being spun around by an adult holding your hands and spinning so fast you fly off the ground. The force that seems to push you outwards, reuiring a great pulling force via your hands, is a pseudoforce called the centrifugal force. If you do move away from the center of rotation, you will keep your speed---which is slower than a radial beam would spin at that distance. For the earth, it is slower by $\Delta v = (\Delta R / R) * \omega$ where $R$ is earth's radius (about 6000 km), $\Delta R$ your change in height (1m) and $\omega=$ 40000km/24hour, so 0.0003 km/hour.


How do I remove old computers from my iCloud?

Question: Last year I was at a job where I logged into my iCloud at work.  I set my computer up with my iCloud so that everything would be hooked to my phone as well.  Long story short, I am not at that job anymore and my boss is still using that computer and I can see all of the things he's bookmarked since then on Safari.  How do I go about unauthorizing or removing that computer from my iCloud so I don't see his stuff and he doesn't see mine?
Answer: You can log into your account on iCloud.com, select Settings and disconnect from all browsers from there. It might also be advisable to change the password of your iCloud account (and enable two factor authentication at the same time).


In SSMS is there a way to generate a script for table creation based on the table output by a view?

Question: In SSMS is there a way to generate a script for table creation based on the table output by a view?
Comment: I don't really understand the question. What I made of it is that you have a view, you select some data and would like to generate create statement to create a table that could hold that data. Is that what you want to achieve?
Comment: Exactly. Sorry after rereading my description it is a bit obtuse.
Answer: There is no simple way of doing such a thing, because selected data is not sufficient to describe the table. Eg. there might be identity column and you won't know or some column may be nullable but actual data has no nulls and so on.
This is in general a complex task that requires a dedicated program, not an ordinary database management utility.
Answer: I don't know how, but the answer to this question may prove useful to you. It is concerning procedures, but the same principles might apply.


Dissolving only selected features in a layer?

Question: I am curious to know if it is possible to dissolve only the selected features in a layer in QGIS.  In ArcGIS this is the default behaviour (which was actually someone annoying most of the time), but it can be useful to avoid having to export all the features to be dissolved to a new file, dissolving them, and then pasting them back into the original.  Is this possible in QGIS? I do not see it in the Vector > Geoprocessing Tools > Dissolve dialog.
Answer:
Select the features
Launch the Dissolve tool

It should as simple as that. No checkbox, the default behaviour is to use selected items, I think.
Comment: Oh wow, strange, I thought that this wasn't working but I just tried it again and it does indeed behave as you described.  I must have accidentally had the selection on the wrong layer earlier.  Thank you.
Comment: On 3.28, this does not work (any longer?). Even when you manually check 'selected features only', that will result in a layer with only the selected features dissolved. Neither the native nor the gdal dissolve tool can do this from what I can tell.
Answer: Select edit mode. Make sure to display the advanced digitizing toolbar (NOT the panel). Use view->toolbars-> adv.....
Refer to https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#merge-selected-features.
Attribute fields/columns can be updated with values selected from a feature or with a value combined from the features. Works just fine.


geocoder: distance sortable index

Question: I'm developing a rails app where Users are having many Items. The users are geocoded thanks to another model I called Place that is relying on the ruby geocoder gem.
class Place < ActiveRecord::Base
    attr_accessible :street_number, :street, :city, :postal_code, :country, :latitude, :longitude

    belongs_to :placable, :polymorphic => true
    geocoded_by :address
    after_validation :geocode

    def address
       [street_number, street, postal_code, city, country].compact.join(', ')
   end
 end

In the user model, I delegated methods from the Place model to be able to access them directly at the user level.
class User < ActiveRecord::Base
  has_many :items, :dependent => :destroy
  has_one  :place, :as => :placable, :dependent => :destroy
  accepts_nested_attributes_for :place
  attr_accessible :place_attributes

  geocoded_by :address
  delegate :address, :to => :place, :allow_nil => true
  delegate :latitude, :to => :place, :allow_nil => true
  delegate :longitude, :to => :place, :allow_nil => true
  #...
end

The same trick is used at the items level:
class Item < ActiveRecord::Base
  belongs_to :user

  # place
  geocoded_by :address
  delegate :place, :to => :user, :allow_nil => true
  delegate :address, :to => :user, :allow_nil => true
  delegate :latitude, :to => :user, :allow_nil => true
  delegate :longitude, :to => :user, :allow_nil => true
  # ...
end

Now I'd like to set up an index on items such that they are sorted by distance to the current user. I don't find a design to perform the task in this setup.
I tried to do the following with the delegation of the near method from geocoder on the User model and the Itemmodel but the sql query fails complaining that latitude and longitude are not columns of the items table. This is actually correct but I wish to access the ones in the placestable instead.
  # this added to the user model:
  delegate :near :to => :place
  # this added to the item model:
  delegate :near :to => :user

  class ItemsController < ApplicationController

    def index
       @items=Item.near(current_user.place, params[:distance]).paginate(:per_page => 20, :page => params[:page_name])
    end
  end

I would like to avoid the solution where both users and items are having attributes for geocoding (latitude, longitude, address, etc.).
Comment: What database are you using? Postgres has a module for geographical information that might help solve your problem.
Comment: @dpassage - Im' indeed on Postgres. Could you give me more info on the module you mention? thks
Comment: Couple of things. There's PostGIS (http://postgis.refractions.net) for the hardcore, or the standard Postgres extension earthdistance (http://www.postgresql.org/docs/9.1/static/earthdistance.html) for the less hardcore.
Answer: I dont know if it's too obvious to me or I'm wrong, but allow me try:
I'd just create a column(e.g, location - at Item model) to save the current location of the item and then compare it with the current user location.
Wasn't what you looked for? hope I helped!

geocoder: distance sortable index


Do individuals saving adversely affect the economy?

Question: Does decision of Individuals to save money affect the economy of a country negatively? I think so yes, because if a high earning individual refuses to spend money then it stop the 'gears' of the economy from turning.
Comment: If you look beyond money supply, there are a lot of positive effects of increased household savings, eg: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5569149/#:~:text=Voluntary%20household%20saving%20rate%20reflects,higher%20household%20propensity%20to%20save.
Answer: The answer is that it depends how the money is saved and whether we talk about short-run or long-run.
in the short-run
Saving in form of investing in stocks and bonds or in other form that increases investment spending on productive activities does not hurt economy.
However, saving by hoarding cash under the mattress, or saving by firms in form of increasing their inventory of goods, or investing into companies that will just 'sit on the cash' is bad for the economy.
This is because investment spending has the same multiplier as consumer spending:
$$Y= \frac{1}{1-c_1}\left(c_0 + I + G \right) \tag{*}$$
Where Y is output, $c_1$ marginal propensity to consume, $c_0$ autonomous consumption, $I$ investment and $G$ government spending.
Regular saving has no effect on $Y$ because decreasing $c_0$ will be offset by increase in $I$. However, in case of saving in form of inventory or cash under mattress $Y$ contracts and so the increase in savings is offset by fall in $Y$.
What matters more than the total saving is the fraction of income saved as it affects the size of the multiplier.
in the long-run
In the long-run the equation * which describes aggregate demand does not matter. No matter what aggregate demand is the aggregate supply is perfectly vertical so the output is fully determined just by productive capacity of the economy. That is in long run $Y=f(K,L)$ where $f()$ is production function that depends on inputs of capital and labor.
In the long run saving has either no negative effect but no positive effect either or positive effect. This depends on whether you believe growth is exogenous or endogenous (i.e. whether saving has som effects on the production technology or not). This is not settled question yet (see Romer Advanced Macroeconomics ch 3).
————————————————————
PS: If we just talk about single individual and not extremely large sums of money not group of individuals doing the same thing the effect, positive or negative, will be negligible.


What does the line behind zoning symbolize?

Question: When I go to zone some land I have a box that hugs the road symbolizing the buildings. However, there is also a depth line drawn at what I would assume is the possible largest building size. The thing is I can still zone regardless of if that line is red or green. Will this zone still flourish if I place it when the line is red?
Comment: I suspect it is a line detailing the maximum growth but won't be sure until I see what you're talking about. In these instances, the zone does require a minimum amount of space to create a building at all, so leaving too little space will waste the zone, but it is possible to create plots that only have enough space for a particular density of construction and in those cases you will end up with a zone with a small house in it, that will never grow larger.
Comment: any chance of a screenshot?
Comment: Sadly I am at work at the moment and finding a screenshot that specific may be tough haha. I'll see what I can do.
Answer: There is a line that appears a short distance away from the road while zoning.  That line shows you the distance a building will require in order to develop a lot at that point.  If there is insufficient room, the lot will not develop.
Think of it in terms of street widths.  Streets are 1 street wide.  Avenues are 2 streets wide.  Low density lots are 2 streets long.  Medium and high density lots are 4 streets long.
If you zone where two streets meet forming an acute angle, development will not occur until the point where the streets are 2 street widths apart.

When zoning against a medium density street (or higher), the helper line will be bright, dim, or red.  Bright indicates medium and high density buildings have enough room.  Dim indicates low density buildings have enough room (medium and high will not develop).  Red means that no buildings will develop.
Comment: So why am I even allowed to zone it if the game knows it won't develop?
Comment: This pretty much - there is no cost in zoning or dezoning, the game doesn't tell you where to put your roads, you have to make that choice for yourself. If you get it wrong - nothing will develop, but at least you were allowed to get it wrong!
Comment: Zoning is free!  Extra zoning doesn't hurt the city in any way.  Also - if the obstacle is later removed, a lot will develop.
Comment: Also, I wonder if beautification is dependent on zoning. I had a lot with acute angle zoned commercial, and once the building upgraded in density and wealth, I had a small row of trees with benches or somesuch show up there. Would they shop up if it would not have been zoned?


What's a good solution to have a configuration settings specific to a machine?

Question: HI,
I want to have set configuration settings for a unit test project that is only relative for one machine ( i.e build machine). So for e.g. is the unit test project is being compiled on a developer machine then use settings A from App.config, if it's compiled on a build machine then use settings B from App.config. Is there a best practice for this sort of things?
Answer: In the appSettings tag, you can add an attribute like:
<code><appSettings file="moreSettings.config">
</code>
Inside the 'moreSettings.config' file, you create an  tag that contains key-value pairs for any of the key-value pairs that you want to override from the main App.config file.
Comment: +1 - I use this frequently; especially for the `connectionStrings` element.
Answer: you can use conditional compilation symbols (just same as macro in C/C++) also...
Answer: Well, i guess you could check the hostname (this should be possible in almost any language or build environment) and depending on that decide what settings to use.
However i would not advise you to "automagicly" decide to do a developer/debug build. But rather i would suggest you provide a "switch" either on comandline or in a config file. Which you than explicitly enable in your setup on the development/test machine.


Why does the acceleration $g$ due to gravity not affect the period of a vertically mounted spring?

Question: For a vertically mounted spring, I was looking at the formula $ T= 2\pi \sqrt{m/k}$ for a period. Why doesn't the gravitational acceleration $g$ factor in?
Comment: Have you done the math? Seen the derivation?
Answer: The effect of gravity is only to shift the equilibrium point, so at equilibrium (at rest), a vertical spring will be extended as compared with the same spring in a horizontal position. But this does not affect the period.
The equation for the dynamics of the spring is $m\frac{d^2x}{dt^2}=-kx+mg$. You can change the variable $x$ to $x'=x+mg/k$ and get $m\frac{d^2x'}{dt^2}=-kx'$. So the dynamics is equivalent to that of spring with the same constant but with the equilibrium point shifted by a distance $mg/k$
Update:
when you replace $x$ in you equation you have $x=x'-mg/k$ so you get $m\frac{d^2(x'-mg/k)}{dt^2}=-k(x'-mg/k)+mg$
On the left side you have $m\frac{d^2(x'-mg/k)}{dt^2}=m\frac{d^2x'}{dt^2}$ because the derivative of a constant ($mg/k$) is zero, and on the right side you get $-kx'$ after distributing.
Comment: But why does that happen? Even in a vertical system, why doesn't "g" factor in?
Comment: Thank you so much! Just a quick question; why does x'=x+mg/k? I tried writing it out myself, but somehow I can't manage it.
Comment: I edited my answer. Hope it helps
Comment: You want $x'=x-mg/k$, as can be seen by solving $mg-kx=-kx'$.
Comment: -k(x' -mg/k) +mg seems like it should be -kx' + 2mg?   how does it just reduce to kx'?
Answer: Just look at the equation of motion.
Suppose you hang a spring from the ceiling, and that it hangs a distance $y_0$ from the ceiling in equilibrium (we orient our axis so that positive $y$ points downward).  Then, the equation of motion is
$$
m\ddot{y}=-k(y-y_0)+mg,
$$
and so
$$
\tfrac{\mathrm{d}^2}{\mathrm{d}t^2}(y-y_0)+\tfrac{k}{m}(y-y_0)=g.
$$
The square of the frequency is given by the coefficient of $y-y_0$, in this case $\frac{k}{m}$, which you'll note does not involve $g$.
Answer: The period of oscillation depends on the restoring force and the inertia (mass) which is oscillating.
Gravity is a constant force. When the mass is in its equilibrium position this force is balanced by the spring force. When the mass moves away from equilibrium the force of gravity does not change, only the spring force changes. The restoring force is caused only by the spring force.
Although gravity affects what the equilibrium extension will be, it is not the restoring force, so it does not affect the period of oscillation of a mass on a spring.
However, gravity does affect the period of a pendulum. The gravitational force on the pendulum mass is constant and independent of displacement, but the moment of this force - which causes the pendulum string to rotate back towards the equilibrium position - is not constant. It increases with the angular displacement. The restoring moment (torque) depends on gravity, so gravity affects the period of a pendulum.
Answer: When we hang  spring pendulum then the net force on that pendulum is zero that is one force is gravity and another forces Is against Gravity So we can set that the pendulum is in equilibrium because the net force is zero now if we applied an external force to pendulum then it's shift By some displacement and SHM will start.
Answer: I didn't see this answer so I would include it for completeness.
So the three base parameters at work here are mass with unit $\text{kg}$, gravitational acceleration with unit $\text{m}/\text{s}^2$, and a spring constant with unit $\text{kg}/\text{s}^2$.
Dimensional analysis states that you can only feed to an arbitrary mathematical function an expression which has no units; you find all ways to combine your base parameters into unitless parameters $\beta_{1,2,\dots}$ and then any other quantity you want to calculate must take the form $\alpha~f(\beta_1,\beta_2,\dots)$ in general, where $\alpha$ is some combination of the original parameters which has the right units.
There are no ways to assemble any interesting unitless parameters above, so $f$ must be a constant, and the only times must all be expressible as $f~\sqrt{m/k}$ for some constant unitless number $f$. Anything else would simply not have units of time, or would take an arbitrary function of a unit-carrying parameter.
Answer: To go a little fundamental on the problem, we don't know whether gravity has an effect on the period or not. Clearly, for every situation that has been tested, it makes no difference, but the "equivalence principle" hasn't been tested in every regime, there's still a little wriggle-room. Essentially, we don't have a proof that the "m" in F=ma is the same "m" as the one in G=m1m2/r^2, so it's possible that different mass objects could fall at (very slightly) different accelerations in a given gravitational field.
This is "real" physics, but at the fringe, so don't go quoting this in an exam ;)


If someone have experienced supernatural abilities through meditation, than why don't he shows it to world?

Question: If somebody goes beyond fourth jhanas and has received super knowledge and also powers, than why don't he shows it to world and shares his knowledge and experience to world or say scientist and science community so that the general humans will believe in dharma and religion?
Answer: The objective of Dhamma is the work yourself out of stress and misery which is to follow the Noble 8 Fold Path. These kinds of practices diverts from this focus. If someone start practicing being attached by such display then most likely their goal will not be tied with the Buddhist goal.
Perhaps for this reason monks are not supposed to display such abilities. Even for lay, through there is not rule, it is not advisable as you are diverting the attention and focus from the true purpose of the practice. Also then meditation practitioners will be no different from magicians and illusionist, like David Copperfield. People will go to them to learn magic tricks and not to learn the dhamma with a view to Nirvana. People go to see David Copperfield for entertainment and not spiritual guidance! Also when displaying these abilities one might develop pride which would lead to one's downfall.
Displaying these abilities may attract a following and belief, but for the wrong reason.
Answer: If the story of Jesus is believed to be true, Jesus did what is suggested in the question and look how Christianity turned out; thousands of years of killing over a (narcissistic) personal saviour.
Acts of magic or witchcraft will not change the majority of people for the better. This is why DN 11 teaches with proper wisdom the 'miracle of instruction' is superior to the 'miracle of psychic power'.
Answer: http://www.accesstoinsight.org/tipitaka/dn/dn.11.0.than.html
Kevatta (Kevaddha) Sutta: To Kevatta
This Sutta talks about the drawbacks of displaying magical powers.
tl;dr it mostly just does not prove anything other that you do have the powers, people will still try to argue that it is not what you say it is.
Answer: Of Leonardo da Vinci it is known that he invented the principle of submarine boats - but also it is transmitted that he explains "why I do not give this to the open: because they would use it for even more warfare on the sea" (paraphrased from memory). Similar caveats have been sometimes explicated in science (for instance with atombomb by Einstein and others - documented in a biography I've read).
Anyway... the best answer on this has surely been given by @Suminda and the idea with it should be a frequent topic in self-observation and meditation.


UK citizen entering UK on US passport

Question: I am travelling to the UK but my UK passport is about to expire and so would like ot enter the UK with my US passport.  How is allowed and legal?
Comment: In principle, a country should allow any citizen to enter, and some countries consider expired passport to be sufficient proof of citizenship. So you may not have a problem at all (but you should obviously check)
Answer: As explained in Do I have to enter the UK on my UK passport? using your UK passport is not mandatory. So you can certainly use your US passport if that's more convenient.
Furthermore, an expired British citizen passport is also enough to enter the UK and should be enough for the airline.

UK citizen entering UK on US passport


User space buffer and Kernel buffer

Question: I am recently studying file system in linux. I learned that when we call fopen(), the library call will call malloc() to allocate space for the FILE structure, and inside this FILE structure there will be a buffer for I/0. But later on I found that the write system call actually writes the data to the kernel buffer, So what's the difference between these two buffers?
Comment: I do have a book, it's advanced UNIX programming. Just want to get things straight
Comment: Don't mind, you need to have a book to read first.
Answer: You have to understand two things: fwrite() is a standard library's routine operating on FILE structure, but write() is a system call. I bet fwrite() uses write() internally. Nothing keeps fwrite() from providing user space IO-buffering until it is ready to pass your data on to the write() syscall.
write() syscall in it's turn goes straight to the kernel and says: "Hey kernel, I've got this user space buffer here. Will you write this one to the storage for me?".  And here it's up to the kernel what to do next: it will either go directly to storage to write the data, or, most likely, copy the data to kernel buffer, until it decides it's time to modify storage data.
Turning back to your question. Any kind of buffering is done to accumulate data in order to postpone turning to more expensive operations: standard library may consider invoking syscall on every len-byte expensive, kernel considers going to hard disk on every syscall expensive and so on.
You might want to read this to see how far buffering goes https://fgiesen.wordpress.com/2015/10/25/reading-and-writing-are-less-symmetric-than-you-probably-think/
Comment: It's in the `FILE` structure, I guess. Look, library buffers IO  on a per-file basis. In order to do its per-file work it gives application some opaque `FILE *` file handle, so that when you turn to library's routine you pass that handle in. This handle tell everything to the routine the latter has to know to do it's job (buffering included).
Comment: So library function has its own buffer or the buffer is in the FILE structure?
Answer: The FILE structure holds the meta data about the opened file (mode, stream position, etc). It is part of the C Standard I/O interface.
The buffer allocated as part of FILE takes only a limited amount of data (e.g. when the stream is buffered). It is deallocated upon fclose(). You may even provide your own user space stdio buffer with setvbuf().
The kernel buffer receives the file contents written by write(), whenever the stream is flushed or the associated file descriptor is closed.
Comment: Does that mean that if the stream is buffered, data is first written to user space buffer then to kernel space buffer? But what if the stream is not buffered, for example, the stderr, does it mean that the output go straightly to the error message and does not even get stored in kernel cache?
Comment: @lplouis Yes, if the stream is buffered, it goes to the `FILE` buffer first. That's the whole point: avoiding **expensive** system calls for only a handful of bytes. If it is unbuffered, any operation goes directly to a read() or write(). The latter one you usually want for diagnostic messages: you want to be informed as soon as something goes wrong.
Answer: The FILE structure holds the information about the opened file.this defines the FILE struct members. But in kernel level a file has been accessed by inode, buffer cache.
Data is getting read/write to disk from user space through buffer cache using method copy_to_user and copy_from_user.
Answer: There is a very big difference between the two buffers, one is kernel buffer and the other is the user buffer. So, what basically happens when you do a I/O is that the buffer from the user space is copied into a buffer in the kernel space. The function copy_from_user() does this task.
Now the question which arises is why do we need two buffers, when the kernel has access into the user space? The reason is that the kernel does not want to read the user buffer directly because both the kernel and the user space has different address spaces and so a valid address in user space might not be a valid address in kernel.
In kernel if a non-valid address is accessed then the system will panic immediately, so the function copy_from_user does the task of mapping the user space address and the kernel space address and checks if the address is accessible or not. If not then it simply returns EFAULT (bad address).

User space buffer and Kernel buffer


Feature selection for the text mining?

Question: Before performing the task of text mining, we need to select the features for characterizing each given document. Are there any systematic guidance on choosing the document features? How does the length of the document affect the feature selection process for the documents?
Comment: what for ? Clustering ? Classification ? Related: http://stats.stackexchange.com/questions/26049/feature-selection-methods-for-document-classtification
Answer: There are a lot of ways for doing feature selection.  I'll give you my "system" that works in my domain (insurance).
The first thing I usually try is calculating TF-IDF and taking the top 5-20% depending on how many features there are.  To be honest, I don't worry too much about document length at this stage (or more specifically - the difference in lengths between documents) - I feel the TF portion of TF-IDF accounts for that, and IDF essentially creates a "corpus specific" stopword list.  But I'm also not comparing Tweets to say War and Peace either.
I then take these features and use Naive Bayes to classify - I consider this to be my "baseline", but it's often good enough - especially since I frequently only need to quantify text for combination with more traditional structured data.
Hope this enough to get you started.
Answer: It really depends on the data and the problem you are trying to solve. Tf-Idf is very common but one might also consider if a binary weighting scheme is better.
What algorithm to choose  for your particular task can be difficult to say ad-hoc but SVM's are very popular. The text mining project i did so far was with tf-idf score and linear support vector machine, with no feature selection.
Answer: There's a python library for feature selection
TextFeatureSelection.  This library provides discriminatory power in the form of score for each word token, bigram, trigram etc.
Those who are aware of feature selection methods in machine learning, it is based on filter method and provides ML engineers required tools to improve the classification accuracy in their NLP and deep learning models. It has 4 methods namely Chi-square, Mutual information, Proportional difference and Information gain to help select words as features before being fed into machine learning classifiers.
from TextFeatureSelection import TextFeatureSelection

#Multiclass classification problem
input_doc_list=['i am very happy','i just had an awesome weekend','this is a very difficult terrain to trek. i wish i stayed back at home.','i just had lunch','Do you want chips?']
target=['Positive','Positive','Negative','Neutral','Neutral']
fsOBJ=TextFeatureSelection(target=target,input_doc_list=input_doc_list)
result_df=fsOBJ.getScore()
print(result_df)

#Binary classification
input_doc_list=['i am content with this location','i am having the time of my life','you cannot learn machine learning without linear algebra','i want to go to mars']
target=[1,1,0,1]
fsOBJ=TextFeatureSelection(target=target,input_doc_list=input_doc_list)
result_df=fsOBJ.getScore()
print(result_df)

Answer: Approaches to feature selection have been developed since the 1960-es. It's a tricky problem to approach when looking for the optimal feature subset to select.
In the 1968-paper, Huges demonstrated that the performance of a classifier can peak and thereafter decline - on an independent test set - when adding still more features [G.F.Hughes. On the mean accuracy of statistical pattern recognizers, IEEE Trans. Inf. Theory, 14 (55-63) 1968]. This test-performance peaking is counter intuitive as one would expect that adding even more features to a classifier should not decline its performance. Acknowledge that all 'good' features are retained when adding still more (possibly noisy) features. The larger the training set size is, in terms of observations or 'cases', the later will a possible 'peak' occur.
Peaking is synonymous with overfitting of your text classifier.
Your question: "How does the length of the document affect the feature selection process for the documents?"
Text length, and therefore training set size certainly influences the location of a possible peak, when pruning redundant features. The larger the training set size the less risk of overgeneralization (and hence peaking).
Your question: "Are there any systematic guidance on choosing the document features?" I recommend that you dig into the subject 'feature selection' in the scientific literature, for example [M. Kudo, J. Sklansky, Comparison of algorithms that select features for pattern classifiers, Pattern Recognition, 33(1), 25-41, 2000]. One strategy that stands out for feature selection is floating search by Pudil. It's more work to implement than a simple wrapper, but 'floating search' does often yield superior results.

Feature selection for the text mining?


Setting up parameters for linear referencing tools in ArcPy

Question: I am attempting to write a python script to utilize the Create routes, Locate features along route, and Make route event layer tools from the Linear Referencing tool box. The ultimate goal is to write this into a python toolbox as a custom tool.
I am having an issue with defining the "out_event_properties" parameter on both the locate features and make event tools. As per the Esri documentation for these tools, the data type of this parameter is a "Route Measure Event Property" and I am not sure how to define this parameter.
It is a single parameter that defines up to four subparameters . When you pull the linear referencing toolbox into python, there is only one space for this parameter, although I need to define several . Also note that it is called out_event_properties in the locate features tool and in_event_properties in the event creation tool.
Here is a snip of some of my code:
<code>route = arcpy.lr.CreateRoutes(input_line,route_ID_field,"route","LENGTH")

table = arcpy.lr.LocateFeaturesAlongRoutes(input_points,route,route_ID_field,radius,"out_table","RID")

SP_Out = arcpy.MakeRouteEventLayer_lr(route,route_ID_field,table,route_ID_field,"station_points")
</code>
Answer: A simple solution is to run the tool from toolbox in ArcGIS Pro on some sample data then go to history and right click on the run tool and choose copy python command and paste that into your IDE, you will see exactly what it has placed there, my guess a list.


How do I calculate where a wing is most likely to break?

Question: I want to make a delta wing out of carbon fiber, but I do not know how many carbon fiber layers would be needed to prevent the wing from breaking due to shear stress. What would be the calculations and equations needed to find this out; which point is most likely to break? Sorry this question is devoid of details, I am quite lost when it comes to this.
Comment: I think this is way too broad. A good answer to this question would basically teach you a course in structural mechanics and maybe a course on composite materials. That's a few hundred hours of study load. You could try some textbooks, e.g., Mallick: Fiber Reinforced Composites (no affiliation, just a book I happen to own).
Comment: Is this wing unique in shape and size? If so you might be able to duplicate the work others have already done. If not, build the wing with one layer of CF, then test to failure. Keep adding layers of CF until you achieve the strength you need.
Comment: Where do you imagine the shear stress will be?
Answer:
Image source: modified from chegg.com. Picture earlier used in this answer
What is required is dimensioning the load, then the material placement and thickness.

The load.
In a cantilever wing, the load in flight is at the wing root, caused by the lift. So the being moment upwards is the integrated lift distribution from wing tip to root, dimensioned for the highest load factor, in both an upwards and a downward direction (inverted flight). This wiki contains some regulation limits:

For transport category airplanes, from −1 to +2.5 (or up to +3.8 depending on design takeoff weight)[5]
For normal category and commuter category airplanes, from −1.52 to +3.8[6]
For utility category airplanes, from −1.76 to +4.4[6]
For acrobatic category airplanes, from −3.0 to +6.0[6]

The complete integrated lift load must be compensated for by a shear load downwards at the wing root.
There is a twisting load as well, probably not an ultimate load in a low aspect ratio delta wing.

Material placement.
As can be seen in the pic, the wing bending moment is counteracted by a compression load in the upper skin and a tension load in the lower skin. The wing skins would need to be placed a fair bit apart, without causing strife with the aerodynamicists. A support structure that keeps the skins apart is a must, depending on the size of your craft could even be a honeycomb. Reduced wing thickness towards the tip is a good idea to save weight.

Carbon fibre layers.
As many as required to absorb the loads found from points 1. and 2., dimensioned for skin buckling.
Answer: I want to make an airplane out of paper.  The delta is the best choice, one of the strongest and easiest airfoil shapes to make.  Very good for low wing loading, does not lift as well as a straight wing.  Good stall characteristics.
I want to make a suspension bridge out of carbon fibre.  Good for cables, but too flexible to keep the bridge from swaying.
You need to combine the carbon fiber with a stiff, but light material, such as balsa!.  Carbon fibre "sandwiches" can be had at your local hobby shop and are amazingly strong.
If in doubt, build some models and analyze the effect of extreme loading (with weights), then do your delta wing scale- up.  Other platforms may be tried as well.


AES encryption on mobile vs pc

Question: I am running a simple AES encryption operation both on desktop(using core i7 processor, 16GB Ram, eclipse and JDK8) and mobile(Android emulator using Intel atom X84 processor 2 GB ram, Android 6.0). I am surprised with the result when mobile emulator took significantly less time than desktop for encryption operation with same amount of data and same key. Could anybody explain why it is happening?
Comment: I've downvoted as you've provided nothing that defines the tests that you are running. Happy to change my vote if you clearly specify the tests, running environment and of course results.
Answer: Be adviced benchmarking (and micro-bechmarking) is a very tricky domain.
You need to consider startup, warmup, I/O time.. So there are a lot of factors involved you haven't stated. AES encryption itself is serial operation so it all comes down to CPU speed or HW support of AES operations. My guess would be the emulator app and data are loaded in RAM, while on the desktop you have to read it from the disk.
AES has even very nice property (if someone recalls the name, please comment) the implementation could use relatively small amount of memory for limited devices or for more powerful platforms the shift and mix operations can be translated to lookup tables so the operation is faster but it requires more RAM and the preparation time (warmup) may be longer.  (I am not sure what is used in the Android libraries)
So - summing up - to get better answer you'd have to provide more information and prepare the benchmarking well.
Comment: The warmup time of the AES algorithm itself should be insignificant unless the AES algorithm is re-initialized for each and every small encryption routine.
Answer: The disparity is just between the implementations.  If you have a Java method, and an emulator that used the hardware AES blocks, you should see only a difference based on CPU speed because in both cases, completion takes 14 cycles.  The overview of AES-NI will get you more information.
It's just probably a function of how the JVM is implemented combined with the classes, but from a hardware perspective, it should basically be the same.

AES encryption on mobile vs pc


How do I recover JPEGs with no file size?

Question: I downloaded some wedding photos into my external drive about a month ago.  A total of 3 cards were downloaded into 3 different files.  The first file lists all of the photos, about 600 images, but they have zero bytes.  The other 2 files are fine.  I can't recover the compact flash card because I have used it too many times since then.  Is there any way to recover the images on my drive?
Comment: I assume that when you write `3 different files` you mean `3 different folders`
Comment: yes, 3 different folders
Answer: Sorry, can't be done.
Zero byte file size means that everything but the file name is gone. And since you have used the flash card several times there is nothing you can do.
You have my sympathies.
Comment: I figured it was a lost cause but just wanted to get some input in case someone had a miraculous solution.
Answer: In case it happens again make sure you tried Photorec before writing to this disk, even if your filesystem is damaged and don't report a size for files, data can still be here though.
The way Photorec works is by scanning the drive for file headers then following pointers to next blocks then write eache file found in a new file.


98 Camry Steering is creaky + rough

Question: What simple diagnostics or simple remedies can be performed to either identify or correct the root cause of the problem.   The idea is to try simple / easy diagnostics or remedies first in the hope that the issue will be resolved.
Answer: A shop would start with these basic tests:

When parked, engine on, turn steering wheel slowly from full left to full right, then return to center. Then, at center with engine off, wiggle the steering wheel quickly back and forth about 15 degrees while someone watches each front wheel. Do they both move a bit? You are looking for looseness.

Next raise the car a bit so you can wiggle each wheel while the steering wheel is held tight. Put your knees against the tire and try to "steer" each wheel.

Put a bar under the tire and try to pull each tire up and done. Again you are looking for looseness.

98 Camry Steering is creaky + rough


Risks of AJAX calls to asmx

Question: Currently working on an ajax call to an ASP web service (.asmx).
In a situation where I POST to the url/.asmx/WebMethod, am I exposing information of any kind?
In the 'WebMethod' I am running a PostJsonAsync that calls an API and passes along a json string.
As I am still learning, I've been told that calling any public [WebMethod] exposes the code, but I am not sure how that is possible.
Is it possible at all for a user to access the WebMethod server-side code that I have and peek into the API calls that are available?
I've attempted some minor security methods.. We are working with Sitefinity CMS. What I did was call a WebMethod that receives the CurrentUserIdentity and returns a GUID. If the current user is logged in, it returns a valid Guid, if not it returns a Guid full of zeros.
Then, I call the WebMethod containing my API call and post a json object along with the valid or invalid GUID. The server-side WebMethod code will then verify if the GUID is valid and continues based on if a UserProfile can be generated.
To me, this seems to be secure, but I've been told that this still leaves the WebMethod exposed as well as the API. I am however just not understanding what is exposed and what can be used.
If anybody can direct me to any resources that has more information on this, or if anybody can advise me on WebService security, I would appreciate it.
Thanks in advance.
Answer: If you're calling the methods via AJAX, then they are exposed to the public...and can be called by anything that can make a call to your server. That being said, there's nothing wrong with it unless you're doing something that's easily abused.
In your particular case, it sounds like the code is accepting a GUID that is assumed to have come from the first API call. If that's really the case, you may want to rethink how the mechanism works. Adding authentication checks for each method that needs to be restricted may be a better solution.
Comment: yeah i've been trying to work out some solutions involving legitimate authentication checks. thank you for the response

Risks of AJAX calls to asmx


Spider-man and the wrestling ring

Question: In both 2002's Spider-man and 2012's The Amazing Spider-man Peter Parker somehow ends up in a wrestling ring.  Is this based on a storyline in any of the Spider-man comics?
Comment: I thought it was an artifact. Spider-man and the Ring of Wrestling. Adds + 2 to melee and +1 to dodge.
Comment: @Zikato Spiderman's ring of wrestling (DnD ver.): gives +8 to grapple checks, allows you to ignore the reach of the opponent
Answer: Indeed, this goes all the way back to 1962 and the the first-ever Spider-man story, Amazing Fantasy 15. From comicbookresources.com:

Peter decides to test out his newfound powers by taking part in an amateur wrestling competition, donning a mask just in case he loses. Peter quickly beats pro wrestler Crusher Hogan and wins the competition prize money. A TV producer (later said to be a TV agent named Max Schiffman) witnesses the event and convinces Peter to perform on late night TV. He suggests Peter keep the "mask angle" since a secret identity is "great showmanship."
[...]
Minutes after his television debut as the "Amazing" Spider-Man, the web-spinner sees and ignores a thief that runs past him and escapes the building. When a security guard asks why Spidey didn't trip or grab the guy, the teenager displays newfound arrogance by proclaiming that he is no longer concerned with anyone but himself. Catching criminals isn't what he's paid to do.
[...]
For days (or weeks), Spider-Man continues to impress studio audiences and play to packed rooms. But one night, Peter finds police at the Parker home. They explain his Uncle Ben surprised a burglar who then shot and killed him. The burglar got away but police have cornered him at the old Acme warehouse at the waterfront. Enraged, Peter dons his Spider-Man outfit and confronts the burglar directly. After knocking the killer out, Peter sees his face and realizes in horror that it's the same thief from the studio. Guilt-ridden that he could have prevented his uncle's death if he hadn't been selfish, Peter realizes that "with great power there must also come -- great responsibility."

The movie adaptations tend to leave out the middle section, where he becomes a TV personality, likely in the interests of time. I've included scans of a handful of pages below (note that I did omit some of the in-between pages).
Comment: You're officially the Fastest Gun In The West. :)
Comment: @Ixrec the panel that shows the webbing under his arms just might inspire another question.
Comment: I miss the webbing under the arms
Comment: The webbing under his arms reminds me of a flying squirrel. I'm glad they cut that part of the costume.
Comment: Holy macaroni. That's so completely different from the movie version I almost feel tempted to read the original comic.
Comment: @Mindwin Some of them are classics only because they were first, not necessarily good but I see your point :).
Comment: @Mindwin I am absolutely not saying that this particular comic is bad or anything, I'd certainly love to read the old issues myself (even though they do feel like they aged a lot, at least from those strips). Rather I was musing on how I've encountered various things in my life that were considered classics but they didn't live to the expectations, at least to my expectations. I had this with the movie "Nosferatu" which is a classic one but, beyond the titular, terrific role, was pretty mediocre even when compared to some other movies of the same decade.
Comment: @Maurycy Please keep extended discussion out of comments; take it to chat instead
Comment: @Mindwin See above; please take extended discussion to chat
Answer: Jason Baker just beat me to the punch, but since I already got all the pictures ready, I'll add them here to supplement Jason's answer.
In the comics, as in the movies, one of the first things Peter Parker does after acquiring his superpowers is to wrestle "Crusher Hogan" for a cash prize.  This takes place in Amazing Fantasy #15.
Comment: I guess this would be a pity upvote, but surely the slower gun deserves at least 20 fake internet points.
Comment: Aaaaaaaand he beat me to the punch again with the pictures.  Dammit.
Comment: @WadCheber I'll definitely give you a +1 on this but since Jason beat you to it he will get the accept.
Comment: This is why it's generally a good idea to go ahead and submit your answer, and then go back and edit in the visual aids or further elaboration.
Comment: @Whovian4Life - That's fine.  He beat me fair and square.

Spider-man and the wrestling ring


How do I get photo albums to sync via iCloud?

Question: I seem to remember photo albums that I created/edited on my iphone syncing via icloud with iphoto and my ipad. After a full restore and update, I can no longere make this work. Please help.
Answer: iCloud only synchronizes photos in your 'Camera Roll' through Photo Stream.
iCloud doesn't synchronize photo albums.
It is possible to synchronize photo albums in iPhoto with your iOS device, but for that you need to sync your iOS device with iTunes on your Mac.
Connect your iOS device with your Mac > click on your device in the left column in iTunes > click the 'Photo' tab > there you can select which photo albums you want to sync with your iOS device.
Comment: This is ridiculous. I could not believe this could be true - it's like not being able to see playlists of your music on different devices.
Comment: Ah, yes. Thanks for the clarification. I wonder where I got my wires crossed. However, what I really want is for albums that I create and organize on my iphone to show up in iPhoto, which doesn't seem to happen no matter what I do.
Comment: I've already looked into that because it's something I want too, but unfortunately that's not (yet?) possible.
Answer: All you have to do is make a Photo Stream like you would an album. They don't need to be shared with anyone so that's what I do... and if you decide later that you want to share the Photo Stream with anyone, you can easily do that by editing it. I hope that helps! :-)


Romance without cliche?

Question: My school is doing a romance writing competition in which there are no cliches allowed - but that is the only way I know to write romance. I mean, I haven't read a single book that hasn't had a bit of cliche. How are you supposed to make a romance novel without it having cliche parts?
Comment: Can you explain what you mean by "no cliches allowed"? Is that a literal rule? Does the text of the contest rules give any explanation whatsoever?
Comment: Ask for a definition of romance and a list of clichés. A "romance" can be anything from an ancient Greek "Hellenistic romance", a medieval "chivalric romance", a story about love relationships in general, or a contemporary genre (which is fundamentally based on clichés). So ask to clarify what the competition is actually about.
Comment: @aparente001 to be fair, though, Austen *coined* a lot of the clichés, so that wouldn't necessarily help.
Comment: I was coming to this question specifically to say "Wait, why are you avoiding cliché?" in the comments. That your school is organizing a writing challenge involving that is either because they lack the awareness that clichés exist for a reason, have a tighter definition of cliché than I do, or, hopefully, because the point of the exercise is to teach why clichés are clichés for a reason.
Comment: Bluntly this contest is "Can you guess what I think is cliched?"  It is impossible to write any kind of story without using something that someone would think cliched.
Comment: Perhaps you are reading pulp fiction romances.  Try reading great literature romances instead.  Maybe some Jane Austen?
Comment: Does the romance have to be successful? A tale of unrequited love is a lot closer to reality than the typical whirlwind romances you typically read about.
Comment: @Standback - That's a good point.  I think we need more information about the assignment.  What does the competition announcement say?  I don't have enough rep to vote to close.
Answer: A good way to avoid cliche in romance is to choose unusual characters as participants in the romance.

The love poetry shared between a pair of nuclear physicists could be very romantic without being at all cliche.
Escaped prisoners on the run from the Law might fall in love during a high tension cat-and-mouse pursuit, leading to frenzied encounters peppered with the risk of capture and betrayal.
There is no rule that says that romance needs to involve humans.  Try writing a canine or feline (or god-forbid, a mixed canine feline) relationship.

Breaking from traditional two person pairings and three person love-triangles can also be useful for avoiding cliche.  A happy quintet would be ripe with odd geometries and opportunities for entertaining miscommunication.
Simply stated, if you don't want it to be cliche, make it strange.
Comment: You answer is really good. A few of the best romances I ever read were the ones that subverted my expectations in ways somewhat similar to the ones you described, with unusual pairings. You got my upvote!
Answer: Given that you haven't given us a lot of the givens...
Not every romance is cliché. There are formulas, to be sure (c.f. Harlequin, Nicholas Sparks, Lifetime), but just because the tropes are heavily used doesn't mean you have to use them, or that they have to feel worn.
So: Pick up the nearest romance book and start making a list of the clichés. I don't have one to hand, so I'm just going to start riffing off the top of my head. These won't all necessarily be in the same story:

Man and woman
Meet cute
Love at first sight
Hate at first sight
Mistaken identity
Pretend relationship for the benefit of a third party
Boy gets girl, boy loses girl, boy wins girl back
Physical Mary Sue characteristics (heart-shaped face, vividly colored
eyes, perfect physique [particularly without any effort like constant
dieting or exercise], flowing/tousled hair)
Person A is normally eloquent and intelligent but gets stupidly
tongue-tied in the presence of Love Interest Person B
Sassy Black/Gay Best Friend

You get the idea. So write down everything you can see in this romance in your hand.
Then make an effort to write something which avoids as many of those as possible. Make it a same-sex slow burn. Have no jealous exes or disapproving parents. Create normal, rounded friends. Describe ordinary-looking people. And so on. Brokeback Mountain is a heartbreakingly beautiful romance which I wouldn't describe as clichéd, even if it has "love at first sight" and "disapproving society" because it's fresh and uniquely done.
If you're worried about clichés, don't write them.
Answer: That's a bit of a tough assignment, because there is no precise definition of a cliche. But you may find the advice of George Orwell in his essay "Politics and the English Language" useful. It's not about writing romance, obviously, but it is about avoiding cliche. Lazy writers, Orwell contends, write by stringing together familiar phrases that are rattling around in their heads. Often the result is opaque and frequently it is illogical as well. A good writer thinks through what they say, gets a clear picture in their mind, and then writes down what they see in their head in plain language. Thus they are describing things fully seen, not regurgitating word soup.
http://www.orwell.ru/library/essays/politics/english/e_polit/
Answer: In my experience, the key to writing romance that won't be full of cliché is to make the protagonists complex, rounded characters who have a life. Give them backgrounds, duties, families, fears, hobbies, habits, friends (some mutual, some not), living conditions, dreams, goals, skills, past traumas and personality quirks. Those things don't have to all be in the focus of the story but will provide a terrain that, importantly, won't conveniently reshape itself to make way for the plot, but in which a path needs to be found. Such heroes just won't fit into the simplicity of a cliché. Not if you can keep them in character.
That's it. That's the trick. Easy to describe, less easy to actually pull off.
Answer: An example of one cliche bust romance I always like is Disney's Hunchback of Notre Dame, which sets up three different characters who are a romantically interested in Esmerelda:  Frollo, Phoebus, and Quasimodo.  In breaking with tradition of Disney in romance, the film ends with Frollo, the villain, bested by Quasimodo but Quasimodo realizing that Phoebus and Esmerelda are in love and giving both his blessing (implying he isn't going to try fight for Esmerelda's affection any more.).  This is a subversion of numerous cliches present in romance.
For starters, the hero gets the girl:  Not only does the male protagonist not win the affection of the female protagonist, Quasimodo realizes that while Esmerelda treats him with respect and decency, that doesn't imply romantic love... but he's the one to break the love triangle between him and Pheobus peacefully, which is rare for love triangles to resolve this way at all... but the protagonist being the graceful loser is all but unheard of.
Additionally, while it's clear that Frollo's desire from Esmerelda is lust and she strongly objects to his advances, Quasimodo's desire for her is, while wholly innocent given his sheltered nature, is shown to be very close to Frollo's motivations for their affection.  Both ascribe there attraction to her as a result of supernatural qualities she does not poses (The often praised villain song "Hellfire" which shows audiences the full depravity of Frollo immedieately preceeds "Heaven's Life" where Quasimodo likens Esmerelda's concern for his well being to romantic interest and likens his feelings to what it must be like to feel "Heaven's Light", because his abusive upbringing has lead him to believe that Frollo is the high water mark of basic human decency.  While the film predates the widespread use of the term, Quasimodo displays all the classic signs of the "Nice Guy" cliche... best described as some guys thinking that being "Nice" to women deserving a woman to show romantic interest.
Even if it was intended to be similar to it, unlike many explorations of this character cliche, Quasimodo is never once demonized for having this attitude and when presented the opportunity to eliminate the competition from Pheobus, refuses to take such actions.  A more modern use of the Nice Guy always presents the behavior as wrong and something the "Nice Guy" should know is wrong, but here, it's clear through his background that he has a warped sense about the basics of human kindness, but it's symbolically done by the nature of the two songs (In the original release of the sound track, the two songs were listed as one under the title "Heavens Light/Hellfire" meaning that they were written to stand side by side.  Notably they were separated by the Latin singing of Confiteor which begins on the conclusion of Quasimodo's song, and continues in Counterpoint to Frollo. The Confiteor is traditionally said publicly to the church at large prior to a priest hearing one's specific sins and is meant to be a general admission to sin to the public as a whole (The priest hears the specifics). In the Catholic Faith, an action can only be sinful if one is aware it is sinful.  It's absense during Quasimodo's half of the song symbolizes that... while wrong, he's still innocent because there is no way for him to know it's wrong... but Frollo is clearly choosing to sin.).
The one cliche that the movie holds is to the idea that "The First Man Wins" that holds that the male character that meets the female character first will win her love in the end of the story.  This isn't avoided, as Phoebus is the first of the three men to encounter Esmerelda, seeing her give a street dance while trying to find his way to the Palace of Justice.  Upon witinessing guards harass her, he intervenes to stop her, at first appealing to their own decency (seems like a typical guy thing done to impress the girl) before revealing he's the new Captain of the Guard.  After the fight scene is over, he recovers some money spilt in the confusion, spies an old beggar, and drops the money into the beggar's cup, and leaves without word... only for the audience to learn that the beggar is Esmerelda in disguise.  It's clear from her reaction that she's unsure about Phoebus's interaction and what motivates them.  If he gave the beggar the coins, not knowing it was Esmerelda, than it shows that he isn't doing this for his own benefit.  If he knew it was her... then not only was he returning to her what was hers to begin with, but symbolically, he recognizes her for what she really is.  Whether she trusts him or believes it's an act, he's still doing what is right.  It's later demonstrated that his concern for Esmerelda is only motivated because he rejects the policies that persecuted her people and while they may be people beneath his station, they are still people and deserve the treatment of such.
The ultimate cliche of a romance is that the hero gets the girl (or that the girl gets the guy) because real life doesn't work like that.  Some examples are that a guy and girl are attracted to each other but can't explore the relationship because one of them is currently dating someone else.  When the person finally leaves the relationship and attempts to strike one up with the other... they learn that that person has moved on and is dating someone else.  And the back and forth continues.  Eventually, the meet later in life and both acknowledge their feelings for the other... but ultimately they decide that those feelings are strong enough that they would never ask them to become the kind of people to leave a relationship they developed on a whim and that the question "Were we meant to be" is to be left at the resolve.
Another popular story is that of the "The Lady or the Tiger".  The story is of a man who falls in love with a princess who returns his love.  However, he is not of noble blood and her father, the king, finds out.  For his crime, the king sentences the man to die by being mauled in an area by the Tiger.  The night before the execution the princess pleads with her father for hours to let the man live and tells the king of her love for the man.  The next morning, the man is walked to area and told to go through the door when the trumpet sounds.  He waits alone as the din of the crowd grows and the cheering as a speech is made bellows.  Finally the trumpet sounds.  The story always ends at this moment, with the narrator asking the audience which of the titular duo did the man meet when he opened the door.
Here the twist is that the conclusion of the story is that the conclusion is based wholly on the nature of the reader.  That the crux of the story hinges on the fact that the build up is more important than the outcome... the answer will change the story and the emotional weight, but is never given and left to the reader to surmise the true meaning of the story and ascribe that meaning they choose to assign. Is it a happy story?  Or is it a sad one?  It says more about you than it does about the storyteller.
Answer: My suggestion would be, write the romance first, pick out as many phrases from it as you can, and search them up. If you receive many results, especially from excerpts or in a list of clichés, then it probably is a cliché.
The definition of cliché can be loose. One person may think it a cliché, while another doesn't. Most metaphors and similes are considered clichés, so you may want to avoid them, unless you came up with them yourself and cannot find a search result for them.
A plot form can also be a cliché. If you can't find an original plot idea, you are perfectly allowed to take a clichéd one, then twist it. Reinventing can be just as fun as inventing.

Romance without cliche?


Help my Cat Palm

Question: Need help with my cat palm. I got the plant two weeks ago and since two days ago all leaves are dropping off. Is this under watering or over watering? What do i do to save it?
Comment: (I know nothing about Cat Palm's specifically).   How much light is the plant getting, and how much was it getting in its old location?  How cold is it getting?   Is their drainage at the bottom of the pot?
Answer: It's hard to tell from the picture but the usual issues are:

not enough light
too much water
maybe the grower did not acclimate the plant to lower light conditions before shipping it.

This is what you can do:

move the plant as close as possible to a south, east or west window with an unobstructed view so it gets more light
water when the top inch of soil is dry.  Then, water thoroughly till water runs out the bottom of the pot.  It can take a week or two to dry out enough for more water
new plants will shed leaves or fronds in response to lower light.  Trim the dying growth off cleanly at the base of the stem
watch carefully for spider mites which are usually seen living on the underside of the fronds.  They look like tiny grains of salt and will make webs when there are a lot. The cat palm in this question has spider mites. Check weekly for mites and read this question if you see them to learn how to control them.
Answer: A cat palm begins to shed its leaves when it's either being over or under watered.
Over-watering often leads to yellow leaves and a soggy, dense soil feel. While, under-watering results in dry, crispy leaves.
Here's how you can rescue your plant:
Adjust your water schedule, start by checking the soil moisture. To accurately check soil moisture, stick your finger about an inch into the soil.
Check Light Condition because Cat palms prefer bright, indirect light. If it's not getting enough light, it might drop leaves.
Check the temperature because sudden changes in temperature can lead to leaf drop.
Regular checkup of any sign of pest infestation.
Feeding your cat palm correctly.
Prune dead leaves.
Be patient, give your cat palm some time to adapt, and hopefully, it will recover.

Help my Cat Palm


Dynamic urls with jQuery pushState and shared headers/footers

Question: I'm working on a little website endeavor and am trying to use jQuery + ajax to dynamically load in information.  As of right now I have a home page ~/home and a profile page ~/profile.  These two pages share the same header and footer and I load first the header, then the page, then the footer.  When I switch pages I just replace the page div with another's html.  However the problem here is if you navigate to ~/profile and load it just loads an html page with the page div content.
Basically I'm wondering if anyone has good suggestions on a system to be able to navigate to any link and have the browser know to load the separate header and footer files without hardcoding all of it into each file.  I assume it would involve some sort of PHP / framework, but the only one I've worked with CodeIgniter which I am very unexperienced with.
This snippet from here looked promising: CodeIgniter + jQuery(ajax) + HTML5 pushstate: How can I make a clean navigation with real URLs?
if (!$this->input->is_ajax_request())
    $this->load->view('header');

$this->load->view('your_view', $data);

if (!$this->input->is_ajax_request())
    $this->load->view('footer');

My only question would be how to have a controller set up that intercepts any link on my domain and loads in the header and footer, with the header file having the linked js file that knows which page to load into the middle via ajax.
Answer: This question is not so simple than you think. It's not just about header and footer, you have mime type changes too. You have to send the html message with text/html, and the ajax message with text/plain content type header. You will need 2 skins/skeletons: one for html, one for ajax call. You'll need a skin provider is able to decide which skin to use in the current situation. You have to render the content independently from the skins, or the skins must call the render method on the content.
It looks very-very roughly like this:
class Controller
{
    public function __construct()
    {
        $provider = new SkinProvider();
        $this->skin = $provider->getSkin();
    }

    public function action()
    {
        $this->skin->render(new Content());
    }
}

class SkinProvider
{
    public function getSkin()
    {
        if ($this->input->is_ajax_request())
            return new AjaxSkin();
        else
            return new HtmlSkin();
    }
}

class AjaxSkin extends AbstractSkin
{
    public function render($content)
    {
        $this->contentType('text/plain');
        $content->render();
    }
}

class HtmlSkin extends AbstractSkin
{
    public function render($content)
    {
        $this->contentType('text/html');
        $this->load->view('header');
        $content->render();
        $this->load->view('footer');
    }
}

class Content extends AbstractView
{
    public function render()
    {
        $data = $this->model->ask();
        $this->load->view('your_view', $data);
    }
}

You can put the constructor of the Controller into and abstract controller, and you will have the actual skin in every controllers you extend from that.


Multiple recepticles in a circuit which covers multiple rooms, all controlled by a single GFCI receptacle

Question: I have a 120VAC 15 AMP Circuit that powers 2 receptacles on a back porch and 5 receptacles in a garage on the opposite end of the house. The first receptacle in the circuit is a GFCI on the back porch. This is very inconvenient it one is working in the garage and trips the GFCI on the back porch. Is there any way I can install another GFCI on the same circuit in the garage that will just protect the receptacles in the garage. I could put the garage receptacles on a separate breaker from the back porch but would be more costly.
Answer: You should never have more than one GFCI device on a single circuit, as they tend to interfere with each other and cause each other to trip.
I may be wrong, but I also don't think it's technically permitted to have outside circuits on the same line as inside (garage) circuits.
Regardless, your best option - especially since you're probably operating heavy duty equipment in the garage - is to put the garage on its own circuit.
Comment: Do you mean you shouldn't have multiple GFCI devices on a circuit at all, or that you shouldn't connect a GFCI device to the "LOAD" terminal of another GFCI? I frequently see kitchens with several GFCI receptacles.
Comment: @HenryJackson The multiple GFCIs in kitchens are likely not on the same circuit, as NEC requires a minimum of 2 small appliance circuits in kitchens.  In any case, you should not connect a GFCI device on the load side of another GFCI device.


Is Lubuntu 18.04 larger than 17.10?

Question: I recently upgraded to Lubuntu 18.04 from 17.10 on a machine that does not have a lot of hard drive space. The upgrade was very smooth -- not a glitch. But post-installation I lost close to 1GB of space, maybe a bit more. Just wondering if that is to be expected, if the new version is simply bigger. And if that is not it, what is causing it? I'm relatively new to linux. Thank you.
Answer: It's not anywhere near 1 GB larger. In fact, since the Lubuntu 18.04 installer ISO is about 1 GB, it might be hanging on to the package installer files it downloaded while you were upgrading your system.
You can try cleaning up APT packages and package installer files which might not be needed anymore by opening a terminal (press Ctrl+Alt+T) and running:
<code>sudo apt autoremove --purge
sudo apt clean
</code>
Answer: It is obvious that the 18.04 is larger than the 17.10 and this is because the newest release (18.04) comes with more features.
Also the 18.04 requirements (CPU, RAM and Memory) are higher than Lubuntu 17.10.
Also, the OS size or memory grows up with the tools you install.
So to sum up, 18.04 is larger than 17.10 but it is not remarkable difference. And in general, the more packages and tools you install, the larger gets your OS.
You can free some space by running, on the terminal :

sudo apt-get clean
  sudo apt-get autoremove

Is Lubuntu 18.04 larger than 17.10?