Space Elevator on Mars with Today's Technology Possible?

Question: I know it's not possible with Earth today, but With today's level of material science technology, would it be possible to make cable strong and light enough to make a space elevator system connecting a Mars-synchronous satellite to an anchor on Mars' surface, ignoring any load at all by an elevator car? Or can someone say with a high degree of certainty that the level of strength to weight possible in cables today is still far from possible even with Mars' lower mass compared to Earth?
Comment: More on space elevators: http://physics.stackexchange.com/q/15052/2451
Answer: the simple answer is no. Materials for an Earth elevator are at least one order of strength too weak at this time. Mars gravity is around 0.378 of earth, so materials are still too weak.
The long answer is much more complicated:
1. Taper of the tether plays a role as much as the safety factor you want to engineer into your elevator, how much a tether can hold, and how much material you can put into space to construct it. Strength, taper, and tether mass are related. You can check for the Space Elevator feasibility condition via isec.org or Google. It is basically some form of decay equation: how much do you need to keep lifting to maintain or grow your elevator, basically taking away from transport payload for maintenance/repairs.
2. Mars has some interesting options with Deimos being made of mostly Carbon. Material for a tether could be refined on site, e.g., when Planetary Resources engineers related technology for asteroids. Deimos' orbital period is with 30.30h is close to the sidereal rotation period of Mars with 24.6229 h. You could work a tether that drops from Deimos part way into the Mars atmosphere and get something that you could attach to with much smaller Delta V than getting to orbit, thus limiting tether strength and mass requirements substantially further. I strongly believe that that the Deimos model is probably close to being within reach of today's advanced materials. Of course you need to work out some control to avoid Phobos dropping by every so often below Deimos.
3. The best anchor point for a Mars Elevator, once material becomes sufficently strong for surface attachment would be on Olympus mons. That puts it above sand storms and other Mars weather.
Finally: I believe that Mars is destined to become the shipyard for the solar system. It is sufficiently friendly for construction sites and the lower gravity makes it much more amenable to lift things to space than Earth.
Hope this helps. Let me know if you have any more questions about the material strength.
Martin
Comment: You can convert the exponential falloff into a linear material strength required, as was done in the NIAC study by Brad Edwards. You can then also ask the question if today's materials are the ~3 GPa strength of Kevlar or maybe the ~5-10GPa of M5, should you be able to acquire it. Or how much taper you are willing to deploy with. That is why this answer is not as simple, not even with your assumption that I just used a linear factor, which is not stated. With clearer boundary conditions we can give a clearer answer, i.e., calculate it. :)
Comment: Sorry for deleting my comment just before you posted your...I had concluded that I was wrong on roughly the basis you give.
Answer: The calculations for the tapered space elevator are a little nasty, but apparently fairly workable as a closed form.  I feel like it's rather unsatisfactory to leave this question without a quantitative sense, considering that it's possible.
To start off with, we need to formalize the fact that we're interested in the change in area, tension, or linear mass-thickness over the length of it.  All 3 of these are directly proportional to each other.  What's more, the differential equation for tapering doesn't care which.  That is:
$$ \frac{ \lambda'(r) }{ \lambda(r) } = \frac{ \frac{ G M }{ r^2 } - \omega^2 r }{ \left( \frac{ \sigma}{ \rho} \right) } $$
The (sigma/rho) quantity is the material specific strength.  I'm using lambda to indicate kg/m linear mass thickness, but you can easily replace it with any of the other proxies.  This equation has a solution.  Here it is in terms of simple values, and then in terms of the pseudo-potential.
$$ \lambda(r) \propto \exp{ \left(  \frac{ - \frac{ GM}{r } - \frac{1}{2} \omega^2 r^2 } { \left( \frac{ \sigma}{ \rho} \right) }  \right) } \rightarrow \exp{ \left( \frac{ U(r) }{\left( \frac{ \sigma}{ \rho} \right) }  \right) } $$
To get the "taper ratio", we're interested in the area at geosynchronous orbit divided by the areas at the surface.  This just consists of plugging in values.
$$ \frac{ \lambda(r_{GEO}) }{ \lambda(r) }  = \exp{ \left(  \frac{ U(r_{GEO}) - U(r) } { \left( \frac{ \sigma}{ \rho} \right) }  \right) } $$
Most people reading this probably have the requisite knowledge to do this calculation.  Here are some, just to look at.  I divided the specific strength by a factor of 3 to give a sense of the "engineering margin"
<code>   mat        m^2/s^2     ratio       3x ratio
Nanotubes   46268000      1.228         1.851
Zylon        3766000     12.449      1929.560
Kevlar       2514000     43.707     83493.590
Stainless     254000      1.728E+16     5.16E+48
seatbelt      108693.     8.806E+37
</code>
You can see that in a pedantic way, yes, kevlar is strong enough to be a Mars elevator going by yield strength.  But that's only if it is literally stressed to its yield strength.  Even then, you're at a taper ratio of 43.  Add in some margin, and this explodes to factors which are a good fraction of a million.
I didn't include the 3x ratio for seatbelt material, because I took the value which is the actual "working load".  It's a good sample for an "everyday" material, even if depressing.
But still, I'll have to concede that it is possible, since Zylon is a real material, even if I am skeptical the industrial production capability and quality control.  If you'll just accept the ratio of 1,929 then we can agree it is possible.  It might be promptly broken by a meteorite, but that's not the question.  Since this is an area ratio, the diameter ratio will only be about 43.  That is, if the diameter on the surface is 1 mm, then the diameter at GEO will be 4.3 cm.  You are free to interpret the consequences of that result as you see fit.

The sci-fi book Ouroboros Wave entertains this exact idea.  In that book, they used engineered systems to flex a Martian space elevator made of carbon nanotubes to avoid Phobos when it passed by, which is an important point.
If you were going to build a Martian space elevator, you would either have to do something like this to avoid Phobos, or just crash it into the planet before you start.  There is a distinct proposal to put a space elevator on the dark side of Phobos, since it is tidally locked.  Phobos orbits almost 3 times every Martian day.  That means that $\omega$ is larger for that system, which means that it will be much easier to build.
Comment: Thanks for the quantitative analysis.   why does the gravity of mars not enter into the solution?   Seems to me g=9.8ms/sec^2 has been assumed somewhere.
Answer: Alan Rominger gave some good information in his answer. Not only some numbers but how to get the numbers. I would like to add to it.
The approach I use is different from Rominger's. I try to explain it here.  To get acceleration at elevator foot the model subtracts $\omega^2r$ from $GM_{planet}/r^2$ to get net acceleration. If a moon is the tether anchor, $GM_{moon}/r_{moon}^2$ is also included, whether this acceleration is added or subtracted depends if the tether is above or below the moon.
This net acceleration times kilograms gives the newtons payload exerts. This sets the thickness of the first length of zylon. The next length of tether is thicker as it supports the first length as well as payload. The model chops the tether into a 1000 lengths.
Here is a screen capture from my look at a Mars elevator:

It is reassuring to me that my numbers aren't much different from Rominger's. For a safety factor of one, Rominger gives a Zylon taper ratio of 12.449 (vs 13 for my model). For a safety factor of three he gives a Zylon taper ratio of 1929.560 (vs 2016 for my model).
My model based on Wolfe's spreadsheet also gives ratio of Zylon tether to payload mass. For a safety factor of 1, you'd need 154 times the mass in Zylon as the payload being lifted. By "payload" I mean the elevator car and contents. The elevator car would need its own power source and engines. So the actual cargo would be even less.
With a safety factor of 1, the slightest nick or scrape will cause a break. Given the large length of this elevator, I'd expect breaks to be frequent. I would not risk valuable cargo on such an elevator, much less human lives.
Given a sensible safety factor of three, tether to payload ratio would be 51,824.
And this wouldn't be the entire elevator. There must be tether and a counterweight above Mars synchronous orbit to balance the downward newtons exerted by the lower elevator.
A Zylon Clarke tower for Mars is implausible.
However I don't write off the notion of Mars elevators. Mars equator isn't the only place to anchor an elevator. There are a number of scenarios I look at:
Lower Phobos Elevator
Upper Phobos Elevator
Deimos Elevator
I am excited about elevators allowing a Zero Relative Velocity Transfer Orbit (ZRVTO) between Phobos and Deimos:

Taper ratios and tether to payload ratios for these two elevators are quite modest:

Extend the upper Phobos elevator and you can fling payloads to the Main Asteroid Belt as well as towards earth. And without prohibitive tether to payload mass ratios.
Extend the lower Phobos elevator 1400 kilometers and you can drop payloads into orbits where periapsis passes through Mars' upper atmosphere. A few periapsis drag passes can circularize at low Mars orbit with a velocity of about 3.4 km/s. EDL would be easier than the 5.5 km/s atmospheric entry a payload incoming from an earth to Mars Hohmann would experience. Especially if the descent vehicle had some propellent and reaction mass from Phobos. Mars EDL could be considerably easier. Given a safety factor of three, tether to payload mass ratio would be .33.
Can a Zylon Phobos elevator descend all the way to Mars upper atmosphere? If so, tether foot velocity with regard to Mars would only be .6 km/s. That's only about mach 2, the Concorde did that. But alas, given a safety factor of three, tether to payload mass ratio would be 638. I don't think a lower Phobos Zylon elevator 5,800 km long is practical.
Answer: It is actually an old ladies myth that the space elevator cannot be built with current technology. It would just be extraordinarily more expensive with current materials.
The elevator needs to be built from geostationary orbit downward. This means that all the material needs to be pulled up by conventional propulsion, this is the principal factor affecting cost. The conventional approach to build an elevator without materials satisfying the strong tensile requirements that are required for the single-tether design would have to be an exponential structure; a single tether connected to earth, supported by two tether, supported themselves by 4 tethers,.. until reaching above geo orbit, where we'll have to attach $2^n$ tethers to the counterweight, where $n$ is given by the tensile properties of the chosen material.
If you have already one space elevator, then it is easier/cheaper to build a second one, because the expensive step of moving the mass up has already been bootstrapped. In the case of mars, it would make more economical sense to actually send the building materials from earth than to uplift them from mars surface, assuming of course we already have a working elevator on earth
Comment: Surely you'd start by putting a mass-driver on some suitable asteroid to get it into orbit, and then use the remaining mass of it as material for both the tether and counterbalance. Much cheaper than lifting billions of tons by rocket. We don't yet have the technology for the mass driver, but neither can we build all the rockets...
Comment: @hdhondt i doubt the tradeoff of extracting the raw materials from an asteroid and processing them (say, into graphene nanotubes) will make it significantly more economically viable, but there is a lot of room for improvement in the next decades in that area


Make eclipse debug my android PROJECT

Question: I am writing an Android application using Eclipse. When I click on the project in the left tree view and then click debug, the IDE builds an APK and installs in the emulator / device as expected.
However, if I'm editing a file and forget to first click on the project before attempting to debug, the IDE thinks I want to debug that specific Java file. This is NOT what I want to do, I would like it to build and emulate / install on device as usual.
Is there any way to change this behavior in Eclipse?
Answer: In eclipse, you can set in workspace preferences / run-debug / launching to always launch the previously launched application (until you explicitly choose an other application: then it will be the last that will be launched).
This way, no matter where you press (ctrl)F11 or click the debug/run button, the launch configuration you used the last time will be called again.
You will still be able to launch different applications of course, by explicitly calling their launchers (the way you debug now).
Comment: this is exactly what I needed! I personally like this approach better (having the IDE launch the same project until you tell it otherwise... even if you are working in a Library etc.) Eclipse should come setup like this out of the box IMO
Answer: The procedure you are using (clicking on the project and selecting Debug as => Android Application is OK, for the first debug session (resp. Run as, non debug).
If you want to debug the app again (regardless of what is selected in the left hand side navigator), you should just click on the Green Run circular icon (or rather on the small > sign on its right side if you want to select a different run configuration) or the little bug on its left (for debug).
If you click on one of the > you will select on of the 8 last run/debugged app.  If you are sure that the last one is the one you want to run again, then just press one of these two icons (bug for debug, green arrow for run) instead of the arrows.
When you click on the project and select Debug as what you actually do is configure a default run configuration for this app or class that can be later tweaked through the Run/debug Configurations... to better suit your customisation needs.  If you click again, eclipse will detect that it has already generated a default configuration (and will not create a new identical one).  Alternately you can directly create your new Run/Debug config directly through the Run/debug Configurations... sub menu.
Since the ADT plugin shipped by Google does not include a Run as... Android Application submenu when you click a java class under an android project, the default launch configuration is the java application or the server application (static main method absent).
Update
To clarify things a bit.  What you ask (running your android app whilst having the java class selected in the package explorer is possible).  What happens when you press the 'small bug' icon does not depend on what is selected in any navigator.
The "default launch configuration" is poorly phrased.
Let me describe what happens in more detail. When you right-click on a java class say in the package explorer (or the project explorer for Java EE version) eclipse (the navigator) calls all contributions (plugins) having registered a handler for that event and lists possible candidates in a sub menu.
In a standard Java EE eclipse installation you will see at least the run on server option and if the class has a main static method with string array arguments, you will also have a the runs as ... java application option.  In both cases, eclipse will generate for you a "launch configuration".  These launch configurations (both debug and non debug) are all available in the launcher dialog boxes (accessible via the icons described above).  They have a lot of different configuration options depending on their nature (for instance whether you debug on a server or a simple java app or an applet).  What I termed the "default configuration" is that for each of this launch configuration categories, eclipse will leave these options empty.
So the first time, you will select the Android project and select the run as... Android application option.  This will create a default configuration. In ADT's case, the default configuration will also probably select a default ADV and launch it (if it's not already launched).  And on subsequent occasions, it will be enough to press the run or debug icon to redeploy your app back to your ADV and this will happen regardless of what is selected in the navigator.
Comment: I would like to be able to have a Java class selected in the left hand nav, and still debug the project itself when I click the bug icon. Your answer implies that this is possible in paragraph 2. But then later, with the talk of the default launch configuration for Java classes, seems to contradicts that idea?

Make eclipse debug my android PROJECT


How do I install Google Chrome?

Question: When I go to download Google Chrome from http://www.google.com/chrome in Midori on the Raspberry Pi , I am presented with a modal dialogue box,

Please select your download package:

32 bit .deb (For Debian/Ubuntu)
64 bit .deb (For Debian/Ubuntu)
32 bit .rpm (For Fedora/openSUSE)
64 bit .rpm (For Fedora/openSUSE)

Not Debian/Ubuntu or Fedora/openSUSE? There may be a community-supported version for your distribution here.

Is it possible to install Google Chrome on the Raspberry Pi?  How would I go about it?
Comment: Chromium binaries are [now available](http://hexxeh.net/?p=328117859).
Comment: I downloaded Noob today and it had Chromium installed built in.
Answer: You can't install Google Chrome, but you can install Chromium.  As other people have posted, Chromium is the code base out of which Google Chrome is compiled.  Chromium is an open-source version of this browser.  Simply type the following.
Debian
$ sudo apt-get install chromium-browser

If you receive any errors running this command, try running
$ sudo apt-get update

and then rerun the first command again.
Arch
$ sudo pacman -S chromium

Comment: Please Chromium does not support HTML5 video DRM and so cannot be used for netflix etc. Just use Chromium is not necessarily a solution for people.
Comment: `sudo apt-get install chromium` doesn't work anymore; you must use `sudo apt-get install chromium-browser` instead.
Comment: @Scoop "chromium-browser" is the old name for the package. Since Wheezy, it is a dummy package to install `chromium`. See http://packages.debian.org/search?keywords=chromium
Comment: This "just worked".  Tested on Debian.  Shortcut appears in the "Internet" folder in the programs menu.
Comment: As of today, this is not working on my Pi 3. I get the following error: Package chromium is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  chromium-inspector chromium-bsu
Comment: @McKAMEY sounds like the Raspbian people need to have a look at that so it can be integrated in the main repos.
Comment: what is the difference between `sudo apt-get install chromium-browser` and `sudo apt-get install chromium`?
Comment: Doesn't seem to work for raspbian jessie - I get the message "E: Package 'chromium' has no installation candidate"
Comment: It tells me "E: package 'chromium' has no installation candidate"
Comment: @Tass I am also receiving the no installation candidate error. Does this method no longer work?
Comment: doesn't work on arch.
Comment: Anonymous user says: "If you going to install chromium I recommend doing it on the Raspberry Pi 2 B as the Pi 2 is powerful enough for it to be a smooth experience but if you going to do it on the Pi B+, B, A or A+ Overclock your Pi so it is more smooth but not as smooth as you what it to be."
Comment: followed these instructions, and it worked like a charm - http://conoroneill.net/running-the-latest-chromium-45-on-debian-jessie-on-your-raspberry-pi-2/
Answer: As far as I know Google does not (yet) distribute Chrome binaries for Linux/ARM. (The only ARM binaries are for Android and these will not be compatible.)
You might be able to cross-compile Chromium for Linux/armel (I have not tried but I am willing to bet that the RasPi itself is not powerful enough to compile it.)
Also keep in mind that if you were able to install it, you may be disappointed with its performance as it is designed for somewhat more powerful machines.
Comment: I'm going to try X-compiling this evening. I shall let you know.
Comment: The Chromium available through apt-get is quite usable.  Note it does not support Youtube video.
Comment: @ThorbjørnRavnAndersen is there any way to get video support for just mp4 or webm in chrome?
Comment: I do not know.  Note that the Chromium build is not the full Chrome browser as distributed by Google.  Given the amount of attention to the Pi I would say that you just need to wait a while longer.
Answer: Note that apt-get gives you a very old version of Chromium (v6). Hexxeh has a much newer build (v22):

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=11800
http://hexxeh.net/?p=328117859
Comment: v22 Now installs from api-get and works well
Answer: After finding out that Chromium is stuck at version 22 (current version is 31) I decided to switch to Firefox ie Iceweasel browser on Raspbian because it is kept updated.
Comment: If you have Raspberry Pi 2 and want latest version of Chromium you can update Raspbian from Wheezy (Debian 7.0) to Jessie (Debian 8.0) and then have all upto date packages, including Chromium and Iceweasel (Firefox).
Comment: As of February 2015, Chromium is still stuck at 22. Iceweasel is probably your best option.
Comment: Alright found the answer [HERE](http://linuxconfig.org/raspbian-gnu-linux-upgrade-from-wheezy-to-raspbian-jessie-8)
Comment: How did you switch to Jessie (Debian 8)?
Comment: 'sudo apt-get install iceweasel '
Answer: Chromium is working fine and get reasonable performance on my Raspberry Pi. Better than Midori.
sudo apt-get install chromium

Comment: Chromium is really faster than Midori? Chrome was often a huge memory-hog that bogs down the system in my experience.
Answer: Open Source Chromium is really good alternative for Google Chrome. But sometimes it's needed original Google Chrome. For example, you can't watch video with Netflix or Amazon prime with Chromium because it lack a couple of libraries.
You can install original x86 Google Chrome with help of ExaGear Desktop.

Install ExaGear Desktop (note that ExaGear isn't free and you have to obtain the license)
tar -xvzpf exagear-desktop-rpi2.tar.gz
sudo ./install-exagear.sh

Run ExaGear Desktop
exagear

Download Google Chrome
wget http://mirror.retrosnub.co.uk/apt/google/pool/main/g/google-chrome-stable/google-chrome-stable_48.0.2564.116-1_i386.deb

Install Google Chrome
sudo dpkg -i google-chrome-stable_48.0.2564.116-1_i386.deb

Now you can run Google Chrome from Start Menu

Based on this post.
Answer: This works great.
sudo apt-get install chromium

Comment: This doesn't work on RPi2 - Jessie
Answer: Because the question is already answered, I will tell you something else.
If you dont use the new Pi2, I really recommend you using a different browser, like midori. Simply because things will run smoother in midori/every other lightweight browser that with chrome/-ium.
Comment: In fact if you don't use the new Pi2 you can no longer run a **recent** version of Chromium AT ALL - the older posts here refer to version 22 or so, and at the time of writing the current version is in the mid 40's - and does not IIRC have any GPU hardware acceleration.
Answer: Install Chromium on your Raspberry Pi with apt-get
At first, we have to update our packages. Open a terminal and type in:
sudo apt-get update

Then, you can install it also by using the packet manager:
sudo apt-get install chromium --yes

Alternatively you can install the package chromium-browser instead of chromium.
That's all! If you are connected through SSH or not using the graphical user interface, you should start (startx). Otherwise you can also establish a remote desktop connection. Now click the start button and navigate to "Internet" where you will find the Chromium shortcut.

Install Chromium on Raspberry Pi's by using git
If you want to compile the Raspberry Pi Chrome (Chromium) Browser yourself, visit their Google Source repository where you can also check the code. The code is not available on GitHub, but that makes no difference for cloning and compiling the repository. But you should know that the files to download are about 15 gigabyte (after installing in fact 22 GB). This is why I recommend the first option, if you only want to install it quickly. If the installation above failed (for any reason) or you want to inspect / change the code, this is how you can do it (you must have a Raspberry Pi Model 2B / 3, because the models before have not 4 kernels):
If you haven't already installed git, you have to install it first:
sudo apt-get install git

Next, we clone the whole repository to a specific folder, which we create and then go into this directory.
sudo mkdir /opt/chromium
cd /opt/chromium
sudo git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git

Now you can check out the needed files (about 15 GB). Make sure that your micro SD card (32GB or more) has enough empty disk space.
export PATH=$PATH:/opt/chromium/depot_tools
nice fetch --nohooks --no-history chromium

Depending on your internet speed this step can take a while. After finished downloading all files, you can compile the project.
./build/install-build-deps.sh
gclient runhooks
./build/gyp_chromium -Dcomponent=shared_library -Dfastbuild=1
nice ninja -C out/Release chrome

Based off here

Google Chrome installation instruction
Note: Exagear, which is needed is not free it does cost a few bucks for a license!
Configure Raspbian

Google Chrome is CPU intensive application, therefore, we recommend to increase swap space. Open configuration file in Terminal (command line) using the following command:

$ sudo nano /etc/dphys-swapfile
Raspbian has 100MB of swap by default. You should change it to 2000MB in the configuration file. So you will have to find this line:
CONF_SWAPSIZE=100
And then change it into:
CONF_SWAPSIZE=2048
Press F3 key to save changes and F2 to close the file. Then restart dphys-swapfile to apply changes:
$ sudo /etc/init.d/dphys-swapfile stop
$ sudo /etc/init.d/dphys-swapfile start
Install ExaGear Desktop

Download ExaGear Desktop archive with installation packages and license key. Unpack the downloaded archive by entering the following command in Terminal:

$ tar -xvzpf exagear-desktop-rpi3.tar.gz

Install and activate ExaGear on your RPi by running install-exagear.sh script in a directory with deb packages and one license key:

$ sudo ./install-exagear.sh
Launch guest x86 system

Enter the guest x86 system by using the following command:

$ exagear
Starting the shell in the guest image  /opt/exagear/images/debian-8

Now you are in the x86 environment that can be checked by running the arch command:
 $ arch
i686
It is recommended to update apt-get repositories on the first launch of the guest system:

$ sudo apt-get update
Install Chrome

Download Google Chrome:
   $ wget http://mirror.retrosnub.co.uk/apt/google/pool/main/g/google- chrome-stable/google-chrome-stable_48.0.2564.116-1_i386.deb
Install Chrome:
  $ sudo dpkg -i google-chrome-stable_48.0.2564.116-1_i386.deb
  $ sudo apt-get install -f
  $ sudo rm -f /etc/apt/sources.list.d/google-chrome.list

Run Chrome
Based off here

How do I install Google Chrome?


Android 3.0 - what are the advantages of using LoaderManager instances exactly?

Question: With 3.0 we got the fancy LoaderManager, which handles data loading using the AsyncTaskLoader, the CursorLoader, and other custom Loader instances. But reading through the docs for these I just couldn't get the point: how are these better than just using the good old AsyncTask for data loading?
Comment: [**Understanding the `LoaderManager`**](http://www.androiddesignpatterns.com/2012/07/understanding-loadermanager.html) is a great post to learn from.
Comment: Check out [**this post**](http://www.androiddesignpatterns.com/2012/06/app-force-close-honeycomb-ics.html)... the first part lists the advantages of using the `LoaderManager` over the deprecated `startManagingCursor`...
Answer: Well they are a lot simpler to implement, and take care of everything about lifecycle management so are much less error prone.
Just look at the sample code, for showing the result of a cursor query which lets the user interactively filter the result set through a query input field in the action bar:
public static class CursorLoaderListFragment extends ListFragment
        implements OnQueryTextListener, LoaderManager.LoaderCallbacks<Cursor> {

    // This is the Adapter being used to display the list's data.
    SimpleCursorAdapter mAdapter;

    // If non-null, this is the current filter the user has provided.
    String mCurFilter;

    @Override public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        // Give some text to display if there is no data.  In a real
        // application this would come from a resource.
        setEmptyText("No phone numbers");

        // We have a menu item to show in action bar.
        setHasOptionsMenu(true);

        // Create an empty adapter we will use to display the loaded data.
        mAdapter = new SimpleCursorAdapter(getActivity(),
                android.R.layout.simple_list_item_2, null,
                new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
                new int[] { android.R.id.text1, android.R.id.text2 }, 0);
        setListAdapter(mAdapter);

        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);
    }

    @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        // Place an action bar item for searching.
        MenuItem item = menu.add("Search");
        item.setIcon(android.R.drawable.ic_menu_search);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        SearchView sv = new SearchView(getActivity());
        sv.setOnQueryTextListener(this);
        item.setActionView(sv);
    }

    public boolean onQueryTextChange(String newText) {
        // Called when the action bar search text has changed.  Update
        // the search filter, and restart the loader to do a new query
        // with this filter.
        mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
        getLoaderManager().restartLoader(0, null, this);
        return true;
    }

    @Override public boolean onQueryTextSubmit(String query) {
        // Don't care about this.
        return true;
    }

    @Override public void onListItemClick(ListView l, View v, int position, long id) {
        // Insert desired behavior here.
        Log.i("FragmentComplexList", "Item clicked: " + id);
    }

    // These are the Contacts rows that we will retrieve.
    static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
        Contacts._ID,
        Contacts.DISPLAY_NAME,
        Contacts.CONTACT_STATUS,
        Contacts.CONTACT_PRESENCE,
        Contacts.PHOTO_ID,
        Contacts.LOOKUP_KEY,
    };

    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        // This is called when a new Loader needs to be created.  This
        // sample only has one Loader, so we don't care about the ID.
        // First, pick the base URI to use depending on whether we are
        // currently filtering.
        Uri baseUri;
        if (mCurFilter != null) {
            baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
                    Uri.encode(mCurFilter));
        } else {
            baseUri = Contacts.CONTENT_URI;
        }

        // Now create and return a CursorLoader that will take care of
        // creating a Cursor for the data being displayed.
        String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
                + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
                + Contacts.DISPLAY_NAME + " != '' ))";
        return new CursorLoader(getActivity(), baseUri,
                CONTACTS_SUMMARY_PROJECTION, select, null,
                Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
    }

    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        // Swap the new cursor in.  (The framework will take care of closing the
        // old cursor once we return.)
        mAdapter.swapCursor(data);
    }

    public void onLoaderReset(Loader<Cursor> loader) {
        // This is called when the last Cursor provided to onLoadFinished()
        // above is about to be closed.  We need to make sure we are no
        // longer using it.
        mAdapter.swapCursor(null);
    }
}

Correctly implementing this full example yourself with AsyncTask is going to involve a lot more code...  and even then, are you going to implement something as complete and well working?  For example, will your implementation retain the loaded Cursor across activity configuration changes so it doesn't need to be re-queried when the new instances is created?  LoaderManager/Loader will do that automatically for you, as well as taking care of correctly creating and closing the Cursor based on the activity lifecycle.
Also notice that using this code doesn't require that you think at all about making sure long running work is performed off the main UI thread.  LoaderManager and CursorLoader take care of all of that for you, ensuring you will never block the main thread while interacting with the cursor.  To do this correctly you actually need to have two Cursor objects active at the same time at points, so you can continue to display an interactive UI with your current Cursor while the next one to show is being loaded.  LoaderManager does all of that for you.
This is just a much simpler API -- no need to know about AsyncTask and think about what needs to run in the background, no need to think about activity lifecycle or how to use the old "managed cursor" APIs in Activity (which didn't work as well as LoaderManager anyway).
(Btw don't forget the new "support" static library that let you use the full LoaderManager API on older versions of Android down to 1.6!)
Comment: Maybe it's me, but this seems far from easy!
Comment: I know this is an old question, but even though a `Loader` seems easier to implement and handle config changes, it doesn't seem the best to use if you need to update the UI as it doesn't have an equivalent of `AsyncTask's` `onProgressUpdate`.  It's hard to know as there's little documentation on it and what are the best practices.  It seems to me that `Loaders` and `AsyncTasks` are similar but each have their own tradeoffs.
Comment: Great answer! Yes it was still far too easy for beginners to misuse AsyncTask -- it failed to handle configuration changes easily and you had to be careful if you needed anything with a Context in `onProgressUpdate` etc in order to ensure you didn't cause memory leaks.
Comment: @hackbod I've tried both Android 4.0 and support library, and it looks like cursor _is not_ retained across configuration changes. I even found a related bug on this: http://code.google.com/p/android/issues/detail?id=25112
Comment: They definitely do normally retain across configuration changes.  At this point most of the UI in stock Android uses them, and rely on this to not reload when you change orientation.  As far as progress updates, it is trivial to implement this yourself -- just post a message to the main thread.
Comment: @hackbod please with regard to your last comment about posting a message to the main thread from a CursorLoader, please do you have any examples on that? I am having troubles related to that expercially as i using a CursorLoader within a fragment. Thank you
Comment: @hackbod or a guideline on how to implement that correctly? Thank you
Comment: Hi manuel, see my answer here: http://stackoverflow.com/questions/10168171/update-ui-from-an-asynctaskloader/10370973#10370973


Efficient sparse access to large memory-mapped file

Question: We have image data in a large (e.g. 700 MB) files. The files are memory mapped on Windows 7 64-bit.
Some operations on the image data involve us reading a few bytes from each line of the image. This can be slow - no line is larger than a page so we get a page fault for every line even though we are only reading a few bytes. There's no way we can see of getting round this in our current implementation, however we would like to make sure we can squeeze the most out of the disk system.
To get the best possible performance, we are hoping that we can hint to the VM system to fetch the next image line (possibly causing a page fault) while we are processing data in the current one. This would parallelise our processing and the page faults. There does not seem to be an obvious way to do this on Windows!
So the questions:

Is there any equivalent on Windows 7 to madvise( MADV_WILLNEED )?
Is there a way of asynchronously touching a page, triggering a page
fault without waiting for the page to become available?

The right long-term solution is to store our data a different way (e.g. in tiles), however we can't do that right now. We need to keep the memory-mapped approach as well at the moment.
Answer: I do not think you can hint VM system but you can pre-fetch data just by loading next line data while you process previous. You can make this parallel to processing. You should probably fetch more than 1 ahead since processing is most likely much faster then reading from file.
This actually quite nicely fits into producer-consumer pattern. Make image reader and data processor run on separate threads and use some sort of blocking collection (like C# BlockingCollection) with capacity limit to pass data from reader to processor.
Comment: Hmm, was hoping to avoid spinning off a thread to do this and do the synchronisation to make it work. That's possibly unavoidable though.
Answer: Even though this is somewhat oldish topic already, I give a practical example of one implementation, which should be used as a design reference only if you understand the big picture well enough.
We had a challenge in one "big data" telco -application, where we new better than virtual memory manager what pages should be paged in from sparse "huge files". What we did was that we  had a dedicated thread ("inmemadvisor") to receive "need" requests, which each had a priority. This thread maintains the prioritized list of requests and submits the memory read "hints" to pool of threads, where largest number of threads handles high priority requests and smallest part of the pool handles lowest priority (you probably get the idea).
Then we have parameters to control the number of threads in the pool and some other nifty details.
Pros of this implementation are:

we outperform 10x the VM's default paging model (in Windoze Server 2008/2012)
as long as the paging goes "soft" and we can forget the data we don't need again (no immediate need to page in with hard fault) the performance is better than good
we can utilize the whole available free physical RAM memory to speed up the computation
every new MB of memory you add can boost the performance

Cons:

if you run out of RAM (locality broken), the performance will be a pig ... well, that would be same even without this implementation
this requires some careful design and good implementation to be worth of doing it
in some applications you may need to add additional monitoring and control logic to control "inmemadvisor" to be a good citizen

So, in short: This is something that one rather would not do, but on the other hand, these are the things wich make programming a positive challenge ;-) Btw: Our implementation beats Linux madvice() in performance with our application, but is not as generic as it is.
Cheers, //Jari


Do I need to write a bibliography?

Question: I made a program and wrote a paper on how it works. I do not quote anything, I just talk about my program. Do I still need to write a bibliography?
Comment: A bibliography is for listing sources that were cited or consulted in the course of your writing.
Answer: I don't understand the question.  How COULD you write a bibliography if you didn't read anything?  Or...did you read something, and just not quote it?
If you consulted a resource but didn't quote from it, you need to be sure whether you're working in a field that requires a 'Works Cited' page, or a field that requires a 'Bibliography'.  Generally, as the names suggest, a Works Cited page only lists those works you actually cite, while a bibliography traditionally lists all the works you consulted.  So...
If you didn't do any reading for this assignment, obviously you don't need either;
If you did some reading but didn't include anything that requires a citation, then you should check whether you're expected to create a full bibliography (list whatever you read) or just a Works Cited (don't list anything, since you didn't cite anything).
Answer: If it's useful to the reader, you might refer to written descriptions of:

data structures or algorithms you used (if they're unusual or important)
the overall structure or architecture of your system
the problem your system helps users to solve
your development process and practices

And if you refer to such descriptions, you might make a bibliography of them.
If there aren't any written descriptions of those things, or you don't think it would be helpful to cite them, you don't need a bibliography.
Answer: Your paper is a description of the program that you wrote. The program is your production. If an algorithm you chose to implement is controversial, you might want to cite an article or two. If you realized a process in a new, efficient way, then it would be good to mention some of the background in a citation.
And if you decided to implement one algorithm over another, and the reasons for your choice aren't obvious, then I think it's an excellent idea to justify your choice with citations.

Do I need to write a bibliography?


Why does a strong base completely neutralize a weak acid?

Question: For the longest time, weak acid-strong base titration curves completely baffled me.  I understood that the equivalence point of a strong acid-strong base titration is reached when equal numbers of moles of base titrant are added as there are acid analyte, but I didn't realize why the same is true for a weak acid-strong base titration; I incorrectly assumed that a strong base will not completely neutralize a weak acid when a stoichiometrically equal amount of base is added to acid - I thought that since a weak acid only partially deprotonates in solution, it is also only partially neutralized by strong base.  Now that I realize that is an inherently incorrect assumption, my question is why does a strong base fully neutralize a weak acid if only a small percentage of the acid is deprotonated in solution?  Is it an effect of Le Chatelier's principle?
Comment: Very short version: a weak acid does a very good job of protecting its acidic protons against removal by water molecules. But hydroxide ions are *vastly* better at stealing those protons. Look around this site: there are numerous relevant detailed answers or discussions.
Comment: See the neutralization equilibrium of acetic acid and hydroxide ion, as per my second comment: https://chemistry.stackexchange.com/a/32781/79678 . But note that the k value is $10^{-4.75}$/$10^{-14}$ = $10^{9.25}$, not what the answer mistakenly gave. Still, a value above a billion, so the weak acid almost entirely gets converted to conjugate base.
Comment: A little more. Write the dissociation equilibrium for acetic acid and note that its dissociation constant is much less than one. Next write the auto-ionization equilibrium of water, with hydrogen and hydroxide ions on the left and water on the right. So the k for that is the reciprocal of water's auto-ionization constant. Finally, add the two equilibria, cancel common species and then you see that the equilibrium constant is acetic acid's k divided by water's autoionization constant. Thus it is 100 trillion times larger and much greater than zero.
Comment: Equivalence point and neutral point are *not* the same thing. I think you know the difference but are mixing up the terms.
Answer: The simple (high-school chemistry level) answer is that you are correct and it is indeed Le Chatelier's Principle. Consider ethanoic acid, $\ce{CH3COOH}$, which dissociates according to the equation $\ce{CH3COOH + H2O-> CH3COOH + H3O+}$. (If you haven't previously encountered hydronium ions, $\ce{H3O+}$, it's essentially just a somewhat more accurate way to represent $\ce{H+}$ ions in solution.)
As a strong base like $\ce{NaOH}$ is added, it will react with the $\ce{H3O+}$ ions in solution, so equilibrium for the dissociation of the weak acid will move to the right, forming more $\ce{H3O+}$ ions, which react with the strong base. This continues until the weak acid has entirely dissociated.
(Ed V's comment sets out a more quantitative explanation; depending on what level you're currently studying chemistry at, it may be more appropriate.)


push button controlled PMOS high side switch circuit review

Question: I have been working on a project and one of the ideas was to control the power supply by push button. In a normal case, the SW1 is open, the 5v_POWER supplies the 5V_IN; when the SW1 is closed, the 5V_IN is cut off. My solution is to use a PMOS SSM3J328R and a normal-off-momentary-on push buttonPMS9P1B10M2QE to implement the manual temporaray power-off feature. The rated current is 2A. I have googled for a high side switch circuit but so far I haven't found a proper solution for this scenario. Is this going to work or do I need something else to make this work? Thanks in advance.
Comment: You need to fully explain how you expect everything to work. As is, closing SW1 will force Q2 to be off. Releasing SW1 will allow Q2 to turn on. That is all. So SW1 will be like a temporary power cut switch. Cuts power while you hold it down. I would suggest that to avoid blowing up Q2's gate you move C4 so it is from gate to source. Also add a zener protection diode from gate to source. Also make R8 bigger. Like 47k or 100k.
Comment: @user_1818839 That means there will be a constant current running through the push-button all the time. Personally, I don't want to let the power of the whole system rely on the current over a pushbutton, especially when the system running in a harsh environment(dusty, hot..). Compared to the push button, I trust MOSFET more.
Comment: This will be a reset button. Releasing it returns power.
Comment: @mkeith Thanks for your comment. I will add a Zener diode and increase R8 as well. However, I don't quite understand why C4 may blow up Q2's gate in this circuit?
Comment: I could be wrong but depending on how far the switch is from the cap and FET, the parasitic inductance could lead to voltage overshoot at the gate. That MOSFET has an absolute maximum gate voltage of 8V. Putting a cap from gate to source will help prevent high peak voltages. And the zener will help clamp them off if they somehow occur in spite of the cap.
Comment: Looks like it will work. But what does it give you over a NC pushbutton?
Answer: R7-C4 have a time constant of only 18 us.  This is not nearly long enough to act as a debounce network, so what is the purpose of these components?
I would place C4 in parallel with R8, and delete R7.  That increases the debounce time constant to 1 ms.  If this still is too short, increase C4 up to 1 uF, then start increasing R8 until you get the performance you want.
Comment: The R7 is simply used to make Vgs adjustable for more flexibility. During the debugging, we will increase the R8 and C4 values to match the switch debounce requirement as you suggested.
Answer: It will work, but you need to protect the switch from high initial current when shorting C4. Move the 180Ω resistor into the path of the switch:

simulate this circuit – Schematic created using CircuitLab


Could a computer program be used to automate testing for trapdoors?

Question: Could a computer program given the source or object version of another program be used to automate testing for trapdoors/backdoors?
Answer: It depends on what your requirements are.
A sufficiently complex and well-designed system could be used to identify the most simple backdoors or trapdoors in most programming languages. However, if a language is Turing complete, any single expression or function can be expressed in an infinite number of ways, which makes such analysis equal to the halting problem.
A quick example of this is adding a and b together, to produce c.
c = a + b
c = (-a) - (-b)
c = (a - 1) + (b + 1)
c = ((a * 2) + (b * 2)) / 2

All of these are equal, and there are an infinite number of other ways to perform the same calculation. This gets even more complex when there are different instructions that can be used to do (almost) the same thing.
Most current vulnerability analysis that focuses on static analysis of executables works by identifying compiler artefacts, i.e. oddities and idiosyncrasies of individual compilers that allow for signature-based matching of potentially vulnerable code fragments. However, the automated tools spit out a large number of false positives, so a skilled person still has to sift through the results.
Since a backdoor is an is not a defined artefact, i.e. a backdoor may exist in a whole variety of different forms (e.g. backdoor account, reverse shell, hidden files, etc.), it is even more difficult to identify such problems. If the backdoor is something like an intentional buffer misuse to allow for easy buffer overflow exploitation, then it may well be possible to detect such a problem. If it's something more complex, like a particular secret command used to disable file access control, then it's nearly impossible.
Comment: True -  oddly enough, if you dig deep enough into the theory behind this, the issue with the specific example you give is because equality is not commutative (not that I would recommend that it should be  :-)  )  And I agree there are plenty of other examples   - and old prof of mine used to point out that with respect to boundary conditions, the operant logic of a system was a lower transfinite # than the number of boundary and error conditions
Comment: @D.W. My point being that a sufficiently complex and well-designed system could identify things like buffer overflow holes, use-after-free, etc. for most cases, albeit with a pretty terrible signal-to-noise ratio. We can and do already do this. We can also use pattern-based detection to identify calls to common APIs that might signify a particular type of routine, e.g. a reverse shell. We *can* identify the most common and simple types of backdoor, with sufficiently complex tools, but more complex or context-sensitive backdoors are nearly impossible to identify.
Comment: @Mok-KongShen It's not designed to be a rigorous proof, it's just an example of an alternate way to express the halting problem, in a way that's relevant to this topic. The rigorous proof for my example is equally as complex as (and completely analogous to) that given on the Wiki article for the formal definition of the halting problem. I don't pretend to fully understand that proof, but it's trivial (at least in my eyes) to derive a logical inference.
Comment: @Mok-KongShen Just hop into [the DMZ](http://chat.stackexchange.com/rooms/151/the-dmz) and we can talk there.
Comment: @Mok-KongShen The halting problem essentially states that, given any program written in a Turing complete language, it is impossible to write any algorithm that identifies whether that program will run forever or not. The problem stems from the fact that any single expression may be implemented in a Turing complete language in an infinite number of ways. Turing completeness is essentially judged based on the potential for a programming language to re-implement its own compiler or interpreter, which immediately results in a potential infinite recursion scenario.
Comment: @Polynomial: Perhaps I should express my point this way: I haven't seen elsewhere in literature any proof concerning the halting problem in the line of your argumentation. Yours seems to be very much simpler, thus I have some doubt, being a layman in that field.
Comment: @D.W. I missed a word out of that sentence that gives it the all-important context. I meant to say "identify *the* most simple backdoors".
Comment: @Mok-KongShen The halting problem is a specific case to describe a larger pattern. Identifying whether a program runs forever or finitely is a single example, but there are many more such operations with similar or identical problems. This becomes more prevalent when discussing real-time compilation (e.g. Intellisense in Visual Studio), where the halting problem is often used as an analogous term to describe any situation where the result of an operation cannot be determined without actually compiling and running the program.
Comment: @Mok-KongShen My assertion is based on the fact that a Turing complete language exhibits the halting problem by definition, and that any expression in a Turing complete language may be expressed in an infinite number of ways. If you're struggling with the latter part, consider the fact that Turing completeness is loosely tested by being able to write a compiler for the language, in that language. At such a point, there are an infinite number of syntaxes that an invented language might use, which provides the logical inference that an expression can be described in an infinite number of ways.
Comment: @Mok-KongShen It's not a direct proof, but rather an alternate example of the underlying problem. The halting problem in itself *is* an example of a wider computational problem - algorithmically identifying the behaviour of a program without running it. The actual halting question (i.e. "does this program have a finite runtime?") just happens to be a really good demonstration of that problem. The halting problem expresses a general case via example.
Answer: No.  It is beyond the state of the art to automatically detect malicious backdoors in your code.
Sure, you could write a code-scanning tool to look for some specific known backdoor.  But the problem is that there are too many ways an attacker could introduce a backdoor, and it is not feasible to identify all such patterns.  In fact, if you think about it a little bit, you will quickly see that -- in the general case -- verifying the absence of backdoors is as difficult as verifying the correctness of the code, which is beyond the state of the art for most software systems we build today.
There are deep reasons to believe that finding malicious backdoors automatically is difficult, based upon a reduction to the halting problem.  However, the practical barriers are even more serious.  As a result, at the moment, there is no good, reliable way to automatically scan a program and determine whether it contains a malicious backdoor or not.
Therefore, the standard approach today is to rely upon your trust in the folks who wrote the program.  If the program comes from someone who you trust won't attack you (e.g., Microsoft, Apple, assuming you trust them), then you can run it and rely upon your trust in the source of the program.  This approach leads to relying upon branding or individuals who you have a relationship with.  Alternatively, if you don't trust the source of the program, then your choices are to either run it and take a risk, or else run it in a sandbox that restricts what the program can do.  The latter leads to sandboxed execution platforms, like web browsers provide for running Javascript (since in general there's no reason to trust the web site that sent you the Javascript, the only safe option is to run the Javascript in a sandbox that sharply limits what it can do, so that malicious backdoors are limited in the harm they can cause).  These approaches have their own limitations, but given the state of the art, they're the most realistic defense today.
Answer: What can theoretically be done is to provide, for a given application, a formal definition of its exact functionality, and then a formal proof (verifiable by a computer) that the application really fulfills that definition. This cannot be slapped on an existing program in all generality (see the Halting Problem: even when the functionality is "ultimately halts", it cannot be proven true or proven false for all programs). However, this can be done with the help of the programmer or his compiler.
Very reduced versions of that exist, e.g. bytecode for a Java Virtual Machine. The functionality is there "does not write outside a buffer, does not call an inexistent method on an object" (that's a gross simplification, of course). When the JVM loads the code, it "proves" that this functionality is respected. This works with a conceptually simple flow analysis and it works because the Java compiler took care to produce code for which the flow analysis works (in recent versions, the compiler even includes hints which the JVM just has to check rather than recompute).
Ideally, we would want a formal specification which captures more user-level semantics. This leads to three issues:

It is difficult to distinguish between malicious and non-malicious code. Is deleting a file a malicious action ? Yes, except if that's what the user wanted. Translating the user whims into a formal specification looks like a quite daunting task.
The specification should follow a mathematical structure which is amenable to automatic verification. The Halting Problem looms nearby.
The programmer should be able to efficiently turn the specification into some code which is provable and still runs at reasonable speed.

If we can do all three, then we can write applications which are provably non-malicious. As a side effect, we also prove that the applications are bug-free. This alone shows that it is not easy.
Some people are working on it. Don't hold your breath, though.
Comment: To have a good proof system is certainly extremely desirable. However the proper practical application of it is likely to require expertise and resources that only very few people could have and there remains thus ultimately the issue of trusting trust IMHO.
Answer: TL;DR: Yes, but it depends on what you mean by computer program, source or object version,  automate, testing and backdoors.

I will start by proposing specific definitions to some of the above terms, partly because the previous answers referred to different meanings, and partly to make it easier to follow the discussion.

Computer program: In order to remain completely vendor-agnostic, let us assume that there is such a product that would allow us to program our rules, and have that applied to the target code. This would need to function in a specific form, see below, but let's assume such a product exists.
Source or object version: I will discuss source code analysis here; in theory, it should be possible to decompile the binary object format into source code, and continue from there. However, I have never tested this part, nor am I familiar with any product that would do this cleanly. So, source code is a requirement for this answer.
Automated: While I would expect such a program to scan man thousands and millions of lines of code automatically, without manual intervention, I am not requiring this to be 100% automated straight out of the box, nor do I expect the program to have a generic answer for ALL target programs. Rather, I will allow manual configuration / tweaking / scripting, before running the full scan.
Testing: The purpose here is to find existing backdoors - not necessarily 100%, and not to mathematically prove there are no others, but to find as many as possible, such that it provides a high level of confidence. Just like XSS scanners attempt to find most such flaws, but with no mathematical guarantee it is complete. Moreover, the level of confidence is directly correlated to the threat model - treat each class of backdoor as a threat, then we can scan for those (regardless of the implementation). If you haven't modeled it - it won't be found.
Backdoor: From OWASP's definition: Malicious code inserted into a program for the purposes of providing the author covert access to... the program.
Specifically, I am NOT including in this any form of "backdoor software", i.e. trojan horses or any other malware, such as BackOrifice; I am NOT including system-level backdoors, such as a hidden OS user; I am NOT including anything framework-level or compiler-based, such as Ken Thompson's classic Unix compiler rootkit; and I am NOT including cryptographic trapdoors such as the Debian flaw. I am only talking about code level backdoors (otherwise scanning code for them is irrelevant, anyway).
I am also very specifically NOT including general security vulnerabilities; as @D.W. put it in a comment: backdoors (deliberately introduced by a developer) vs. vulnerabilities (inadvertently introduced by developers). Or even simpler: Unauthorized functionality.
For the sake of my explanation, I will also not be referring to untrusted client apps; it will be simpler to discuss only the case of large, enterprise server systems, wherein the threat is that one of the many developers of the system, inserted unwanted functionality, to allow himself "covert access". However, this can be easily transferred later to client and/or 3rd party apps, too.

Before I continue, it is important to note that according to this definition of "Backdoor", testing for backdoors is nearly meaningless, without some additional definition. (It would be akin to saying "test for all bugs" - you need to scope which forms of bugs you expect to find. Or as the PHB said to Dilbert: I need to know all the unexpected things that can go wrong.) Now, I am not claiming merely that we should explicitly describe the backdoor, and then we can find it; but I mean that there are a certain number of classes of backdoors, and we will be able to scan for any defined class of backdoor (for which there is an infinite number of possible implementations, of course).
For example, here are a few classes of backdoors, classified by (mis-)functionality:

Authentication bypass (via special user / "magic number" or parameter / hidden URL)
Authorization bypass (via special user / hidden parameter)
Data access via backend leakage (i.e. sending the data outside of the protected database, e.g. emailing credit card numbers).

Of course there are others, though not infinite; if the (mis)functionality can be designed, it can be analyzed, but let's start with these, for now.

Now, once we've defined the functionality (irrelevant of the implementation) that we'd like to find, let's describe what a possible program+ruleset would look like, to find such (mis)functionality.
Obviously, such a scanner could not work by scanning the code for specific patterns and signatures, since there is an infinite number of ways to implement a given functionality.
Rather, for a scanner to succeed in this, it would have to perform a form of compilation, analyzing both the data flow (between inputs, variables, parameters, outputs, etc) and the control flow (e.g. what influences when to branch, what other functions to call, how to loop, etc.), and also correlations between them (e.g. branching depending on the result of a calculation based on input).
Additionally, it must be possible for us to define, tailored for each target program we're scanning, how to find certain global, well-defined elements of the application. For example, What object or method represents authentication checks? This could be as simple as an object/method name, or more complex to even heuristics; but for now, let's say we can specify the authentication mechanism's name. Same thing for how the application accesses the database (in the designed, legitimate fashion).
Now, if we could script our own ruleset, it would be possible to find any flow, that succeeds in passing the authentication mechanism, without a valid comparison between the username which came from the userinput and a value from the database, AND a valid comparison between the password which came from userinput and a value from the database.
In other words, what we're looking for is a flow that matches these conditions: ( (pass-authentication) && !( (input.username == database.username) && (input.password == database.password) ) ) (in very pathetic pseudocode...) Of course, the values might be checked in SQL, or first pulled from the database and checked in application code...
(We also need to adjust for password encryption, which can be solved the same as before, and hey while we're at it let's check that passwords ARE encrypted, otherwise throw a vulnerability...)
Basically, we just found all cases where it is possible to "authenticate" without sending a valid username and password. Problem solved.
In a similar manner, we can do the same for authorization bypass: declare the authorization mechanism, then find places where this is subverted or bypassed by the username or identity (which is actually also influenced by the username...). Also, we would need to find places where there is NO access check, but sensitive / suspicious actions are performed.
Backend data stealing: define the sensitive data (e.g. passwords; credit card numbers, etc.); find any place that data flows to an external target (e.g. via email, network access, files, etc) besides the database. Note that we may need to finetune this, according to the application - perhaps there is an MQ server to copy everything to a mainframe... But we can simply exclude those too, just as we excluded the database. Also note that these should be known to the architect.
Thus, given the existance of such a scanning platform, and the effort to script our ruleset, we can absolutely find any unauthorized functionality (my definition of the problem).

FOOTNOTE:
However, you might now raise the objection: "Well, sure, but you only defined a small subset of the possible backdoors".
Actually, while this might be true in a strict sense, it is not in a practical manner, at least according to our previous definitions.
At a very high level, there are a very limited ways of achieving access to the program - and while I did not mention all of them, the list is not long. Remember, we're not looking for any hidden functionality, only those that provide access at a code level.
Furthermore, if any other form of backdoor is deemed relevant, according to the application's threat model / risk profile, that form can similarly be analyzed and scripted for.
For example, if we now want to check that the programmer did not embed some code which includes a block of encrypted instructions whose key is derived from various system parameters, such that the actual backdoor is hidden - we could easily script a rule that finds any place that the code decrypts a block, then dynamically executes this. Sure, it might be possible that there will be a false positive - perhaps if there is some strange, unique functional requirement to actually do this (really?) - but these can be adjusted for, and then scan the original code pre-encryption.

So, bottom line - Is it possible to scan source code for a given class of backdoor?
Yes.
The problematic part is in defining the classes of backdoors which are relevant.
Will this typically provide a 100% guarantee, with mathematical proof?
No.  Then again, the same applies for any other type of vulnerability scanner (e.g. scanning source code for XSS), but depending on the amount of effort we can get incrementally and xenomorphically closer to 100%, such that it is good enough.
Comment: I disagree: your analysis glosses over many points such as complete source code availability ([can you trust the compiler?](http://cm.bell-labs.com/who/ken/trust.html)), the amount of [I have no idea whether this is within spec, if I rejected all such dodgy-looking code I'd have to rewrite 90% of my code base](http://underhanded.xcott.com/), and [there's no (nearly sufficiently precise) spec anyway](http://lwn.net/Articles/57135/), and what about backdoors in the spec (what's a famous example for that?). So really, even with a lot of testing and verification, you will only find a small subset.
Comment: Compiler backdoors are a seperate issue, and I explicitly excluded them - if you're using a standard compiler, there might be backdoor issues, but then again what we're worried about now is the specific code developed by our programmers. As DW said in his answer, there is an element of trust here. As for dodgy code and lack of spec, well then backdoors are probably not the biggest problem... But anyway, at worst the results would need to be manually confirmed/discarded. Still, getting a handful of potential results over a several 100KLoC codebase, is still a good deal.
Answer: If one examines a blackbox (non-opensource) software, treating it only as a blackbox, i.e. providing some input data and analysing the outputs, then IMHO it is intuitively evident that there is barely chance that any sufficiently intelligently implanted backdoors could ever be detected. For instance the software may contain a "timed bomb", i.e. it does something particular when a certain praticular time comes but otherwise behaves entirely normally as one expects. Several decades ago I happened to know of such a timed bomb: The computer (mainframe) of a firm crashed almost every other day during the night time and an employee who was the system specialist had to come and work hard to bring up the system again. After sometime the management noticed the importance of this guy for the firm and promoted him to the chief of the computing centre. After that the usual crash at night "mysteriously" disappeared.
Comment: Addendum: The well-known paper of Ken Thompson http://cm.bell-labs.com/who/ken/trust.html entitled "Reflections on Trusting Trust" shows that even an open-source examined by a huge number of people could have a backdoor not noticed for decades. Now consider the current time where cyberwars are looming with Stuxnet, Flame and Gauss already discovered. How could one be sure that the many proprietary blackbox software generally employed for IT security purposes don't in fact contain "dormant" backdoors implanted by agencies of foreign countries to be exploited at critical moments of their choice?
Comment: Addendum: There could be very subtle backdoors that are not simple to find even with source codes to examine by humans. It is conceivable that e.g. the keys generated for RSA are such that they are susceptible to particular kinds of attacks planned by the autors of backdoors.
Answer: There are commercial analyzers that work on compiled binaries, e.g Veracode and Fortify.
Of course, because of the halting problem, if they do not find anything, it does not mean there are no trapdoors.
Comment: Those tools mostly focus on finding vulnerabilities (inadvertently introduced by developers), not backdoors (deliberately introduced by a developer).


Operator precedence in Scala

Question: I like Scala's propose of operator precedence but in some rare cases, unmodified rules may be inconvenient, because you have restrictions in naming your methods. Are there ways to define another rules for a class/file, etc. in Scala? If not, would it be resolved in the future?
Comment: Related mailing list thread: http://scala-programming-language.1934581.n4.nabble.com/More-unicode-alternatives-for-ASCII-operators-td2008146.html
Answer: Operator precedence is fixed in the Scala Reference - 6.12.3 Infix Operations by the first character in the operator. Listed in increasing order of precedence:
<code>(all letters)
|
^
&
= !
< >
:
+ -
* / %
(all other special characters)
</code>
And it's not very probable that it will change. It will probably create more problems than it fixes. If you're used the normal operator precedence changing it for one class will be quite confusing.
Comment: @Luigi Plinge, `===` is not an assignment operator because there in an exception: an operator ending in `=` is an assignment operator *unless  the operator also starts with an equals character*. Look at the gmane thread and the other link, Martin himself indicated that the SLS needed an update. I cannot see an update yet.
Comment: @huynhjl from the cited reference: "There's one exception to this rule, which concerns assignment operators(§6.12.4). The precedence of an assigment operator is the same as the one of simple assignment (=). That is, it is lower than the precedence of any other operator." §6.12.4 describes an assignment operator as one ending in "=". So the list above is incomplete, rather than incorrect.
Comment: I think the decision to make `(all letters)` the "weakest" one is weird: `a contains b || c contains d`, which I think is a frequent construct, needs parentheses...
Comment: @ErikAllik indeed, I agree fully, really makes for pointless noise when working with a DSL that _could_ look like: if(a is b && c is d && ...), but requires if(a === b && c === d && ...) due to precedance rules.
Answer:
Are there ways to define another rules for a class/file, etc. in Scala? If not, would it be resolved in the future?

There is no such ability and there is little likelihood of it being added in the forseeable future.
Answer: There was a feature request raised in the typelevel fork of the scala compiler, a version of the compiler which 'previews' experimental features. The developers suggested that if somebody were to write a SIP for this, it may be considered for implementation.
But in it's current state, there is no way to override precedence. It's rules are formally defined in the language specification.
Answer:
unmodified rules may be inconvenient, because you have restrictions in naming your methods

you do not have any restrictions in naming your methods. For example, you can define methods +, -, * and etc. for a class.
we must also follow de-facto "unmodified rules" (enforced by Scala operator precedence rules) mentioned in previous answer (https://stackoverflow.com/a/2922456) by Thomas Jung - it is common for many if not all programming languages, and abstract algebra; we need not redefine operator precedence for a+b*c.

See Chapter 6 of the book http://www.scala-lang.org/docu/files/ScalaByExample.pdf for "Rational" class example.
Comment: Not all programming languages have unmodifiable operator precedence. Look at haskell's infix/infixr/infixl commands.
Comment: by "restrictions in naming your methods" I mean that if, for example,  you think that '+' is a perfect name for your method, there can be situations that you whould be forced to choose another name because of unmodifiable precedence.

Operator precedence in Scala


Does the Xbox One controller support DirectInput on PC?

Question: I know it supports XInput on PC. But is it possible to play old games which only have DirectInput with the controller?
Answer: Yes, the Xbox One controller can be used with DirectInput.

So, I've installed Jade Empire to play it with my Xbox One controller. The game is rather old (and the port is rather terrible) but Steam says it has partial controller support (and who are we to question the word of Gaben?). The controls are actually okay-ish, except the little fact that JE apparently uses DirectInput and because of that it doesn't recognizes triggers as a separate buttons and instead they act like a single button. According to MSDN it's not a bug, it's a feature. Which is sad.

You can read more about the limitations of the Xbox 360 controllers when using DirectInput here. I believe the very same limitations aply to the Xbox One controller as well.


How is it possible that CEWP shows up with IE but nothing in FF, Chrome and Safari?

Question: On my machine I can get CEWP to show (image and data) on IE and FF. Chrome and Safari still show nothing (just blank screen). CEWP is linking to a txt file that has javascript stuff. Here is the code if you want to see it in details (http://www.codeupload.com/4063).
Answer: If the code you show in the link is what you've put into your CEWP, I'd expect problems. What you show is a full HTML page, including a BODY tag.  You should only include the markup you want. I think that will probably solve the issue.
So remove:
2.    <!DOCTYPE html>
3.
4.
5.        <meta charset="utf-8">
6.        <title>Slides, A Slideshow Plugin for jQuery</title>

this
44.
45.

and the closing
105.
106.

Comment: Actually I have taken those tags out from the text file that I am feeding to CEWP.
Comment: Well, then it sort of hard to make an informed suggestion! I looked at what you had posted and that was my observation. If you could post what you actually have in your CEWP, I might have other ideas.


How to redirect old permalinks to ones generated by [WP-Hashed-ID] plugin?

Question: I've changed the permalink for WordPress post. Old permalink structure was using the 'post_id' and new one is hashed post id using the plugin WP-Hashed-ID. How can I enable redirection from links generated by old permalinks to ones generated by [WP-Hashed-ID] plugin?
Answer: Depending on the number of posts that you have, you might just use a plugin like Redirection. It's easy and straightforward, if time consuming.
Good luck!
Comment: So you are saying, if I enabled WP-Hashed-ID, Redirection plugin will auto redirect old post links to new ones? I was afraid of trying to be honest as the website is huge. There is also Yoast SEO premium, does it do the trick as well?
Comment: "...will auto redirect old post links to new ones?"

No, it won't auto, it's manual and time consuming. And, to my understanding, Yoast won't auto re-direct, but I haven't used it for that outcome, so I can't say whether it'll be helpful or not.
Comment: Is there any RewriteRule which can help with redirecting from %post_id% to %hashed_id& ?
Comment: There may be, but I don't know it. That's why I use Redirection :D


Potential energy between attracting molecules

Question: I read in fluid dynamics  that the potential energy stored in the molecule of water due to the attraction by the other molecules is negative. Can energy be negative and what does it mean to have negative energy??
Comment: Why attractive forces cause negative energy?? why not repulsive one ??
Comment: Attractive forces in case of attracting molecules do positive Work that's why the change in potential energy of the system is negative
Answer: Potential energy is taken with respect to a reference. What we can define about potential energy isn't it's absolute value, but the difference of potential energy of two points.
$U_2-U_1=-\int_{1}^{2} \vec{F}.d\vec{r}$.
For convenience and simplicity we take the the potential at $\infty$ to be $0$. And that's why for attractive forces potential is negative.
Answer: Definition: The change in potential energy of a system is defined as the negative of work done by the internal conservative forces of the system.
Absolute potential energy is undefined.Relative potential energy is defined.You are free to choose reference anywhere.
Negative potential energy is just a mathematical consequence after choosing the reference level.
Attractive forces in case of attracting molecules do positive Work that's why the change in potential energy of the system is negative.


Using storeValue and echo in Katalon Recorder

Question: I have been automating a web application regression test using Katalon Automation Recorder.
There is a part where I want to use a unique application ID that's generated by the system to search for the application again to verify its existence.
For this, I am trying to use the storeValue command like this:
<code>(Command | Target | Value)

storeValue | id=_application_enquiry_portlet_WAR_morcmsportlet_custId | customerID |
</code>
When I run this, the test log does return this message after that line is run:
<code>[info] Store 'AA12345' into 'customerID'
</code>
But when I try to call the saved value again on a different test case (but the same test suite) in a search engine like this:
<code> echo | ${customerID} | |
</code>
the value doesn't enter.
For the record, I also tried this:
<code> echo | id=s2id_autogen1_search | ${customerID} |
</code>
because I felt that, the echo still needed a target specified when entering a saved value. The line turned green which usually means it works, but the value doesn't appear in the search box and the log doesn't show the value being called either.
I am afraid that I could be using the wrong syntax, but I have been following what my research has brought me to believe is right. I am not sure what to do or where I am going wrong.
Comment: Try asking in Katalon [forum](https://forum.katalon.com).
Answer: echo will output the value of the variable in the Log. It can be used for debugging purposes.
Try using the command type to enter the value into the search box
<code>type | id=s2id_autogen1_search | ${customerID} |
</code>


Is it possible to interact with Active Directory without a domain user account?

Question: Can someone without a domain user account interact with Active Directory to obtain, e.g. password policy, list of domain users, list of domain controllers etc.? - or is it impossible to interact with Active Directory without domain user credentials?
Answer: If you are a Domain Administrator, it is possible to enable anonymous (unauthenticated) logins to the AD LDAP service via the dSHeuristics parameter. The search term for that is "anonymous bind". Once that's enabled, you'll probably have to grant access to individual LDAP entries via ACLs.
Is it wise to do so? IMHO, not at all. At the very least, it would easily become a major privacy issue for your employees – and attract security problems as well. (Hence no links to documentation.)
If you are writing a script for domains managed by someone else – the general answer is "no". Even things such as services or batch jobs should have their own credentials.
Answer: I'm not sure what you mean by windows specific. Active Directory provides a LDAP interface to work with it. Most of the information AD provides can be queried using that interface.
Microsoft has various articles that go into detail as to how it works and what's important. For instance:

Serverless Binding and RootDSE which has some information about how to connect to AD.
RootDSE Schema Information which details what information is available within RootDSE.
How Active Directory Searches Work which also has some information about anonymous access.
Anonymous LDAP operations to Active Directory are disabled on Windows Server 2003 domain controllers

By default AD wouldn't/shouldn't accept anonymous connections which can be changed. If they are enabled ACLs might limit what you're able to query for. In order to test this you migth be able to use ADSI edit or another LDAP tool. Access to RootDSE should be possible.
Comment: Most of the information OP asks for isn't part of the RootDSE though.
Comment: @grawity you're right that a lot of the information he likely wants won't be accessible, if nobody changed the AD configuration, but his initial question is whenever you can interact with the AD without having an account. The answer to that question is yes. How valuable the obtainable information is depends on the specific AD configuration (which is also being pointed out).


Good Game Dev Engine?

Question: I'm new to game dev, and would like to know a good engine/program to code games with. I tried C#, and generally enjoyed the experience, but found that without something like MonoGame or XNA Studio, it was too slow and CPU-reliant for game dev. i also tried Unity, but found that I don't enjoy using a graphical interface, and prefer just coding with only a bit of graphical interface, like with Visual Studio. I have also tried Java, and quite enjoyed the experience, so that might work. My question is: what is a good way to make a game with mostly writing code? Any help would be appreciated! :D
Comment: This question is very much opinion based and if I recall correctly they don't like that on these websites and might lock out the question from comments soon. That said you sound a lot like me in your pursuit of gamedev. I'd say MonoGame, XNA (frameworks for C#) and LibGDX (framework for Java) are essential tools to start out creating games. Without them as you have said, it takes much longer and you are basically spending weeks re-creating something that is already in libgdx etc. It depends on what your target platforms are and the language you most comfortable.You seem to be on the right path
Comment: If you like scene graph based engines jmonkey engine is excellent and based on java which is probably the fastest you'll get without going to c++ (and it'll be faster than c++ done poorly)
Answer: For Java you could uses LWJGL, libgdx, or SFML (with java bindings)
but as for C#, MonoGame/XNA are kinda your best options for premade engines.
You can always get OpenGL/GLEW in either Java or C# and write your own engine from scratch. If you're not familiar with certain design concepts and theory it may take (a lot) longer, but you'll know your engine inside out.
Best of luck on your game!
Comment: Thanks! I'l try Monogame, I've heard it's like an open-source XNA, so it sounds like my thing. :D
Answer: Normally would comment this but app won't let me so I'll provide as an answer.
There is absolutely nothing in unity that says you have to use their GUI beyond browsing your files and importing assets. You can work almost exclusively in Visual Studio in C# and still take advantage of all short cuts and pre-built functionality of Unity, not to mention the built in support for cross platform deployment.
I personally do not use Unity so this is not the Pov of a fanboy, but in the past I have used it as described. My personal choice is UE4 but if you don't like gui and don't want to work in C++ (mostly managed by engine) it's probably not for you.

Good Game Dev Engine?


The use of Pure Korean words like 가람 [river]?

Question: Are pure Korean words like 가람 still used in speech or writing instead of Chinese borrowings like  강 ?
Comment: "가람" is a dated and obscure word. By "pure Korean words like 가람," do you mean native ("plain") Korean words in general, or specifically dated, old-fashioned ones?
Comment: 가람 is no more used to mean 'river, lake'. It is sometimes used as names. If you want any example of pure Korean still used until today despite the existence of Chinese borrowings, some color names are pure Korean, like '빨강 - 적색', '노랑 - 황색', '파랑 - 청색', '검정 - 흑색', '하양 - 백색'. 날 (day-일), 달 (month-월, moon-월), 해 (year-년, sun-일) are also pure Korean,
Answer: As others answered above, 가람 is not used in daily conversation. Sometimes it is used in names of organizations or people, as in the attached photo below (한가람고등학교).
Answer: Short answer: No.
There used to be popular TV shows that created a trend of re-discovering pure Korean words like in 2000s, and some have become popular since then.
However, many others are still obsolete, and 가람 is one among them.
It's just that some people know 가람 means rivers, but it is rarely used for daily usages. I wouldn't expect people to understand what I mean when I say 가람.
I've seen 가람 being used for names for people or businesses though.
I think you should consider these old pure Korean words somewhat like jargons. When you say it, people may or may not understand you.
Answer: No.
In Korea, No one uses 가람. The historical fact that 가람 means 강, is being considered like an interesting knowledge among Koreans. So there are Koreans who don't even know the word 가람. You can just understand that everyone uses 강, instead of 가람.


He's worried himself sick about his daughter

Question: He's worried himself sick about his daughter.
In this sentence, Is either He's [He is] or [He has] ?
Comment: You can say **He is worried sick** but if you're describing a process which has ended in that result, it is as the answers say, **He has worried himself sick**.
Comment: There is a difference between saying **He is in this state** and **He has done things to get himself into this state**.
Answer: It is He has.  This sentence is an example of the present perfect tense.  The present perfect is formed with to have (here, He has) and a past participle (here, worried).
You're probably asking "Why can't it be is?" because "He is worried" is also a perfectly good sentence.  The answer is that if it were is, then "worried himself sick" doesn't make sense, so it must be has.
Answer: The answer can only be "He has". "He is worried himself sick about his daughter" is ungrammatical and makes no sense. To worry oneself sick means to become ill through worry.
https://en.oxforddictionaries.com/definition/%E2%80%94_oneself_sick


What engine is more durable? 3 or 4 cylinder ?

Question: I would like to know what engine would last longer and with less problems?
A 3 or a 4 cylinder engine?
Thanks.
 Alik.
Comment: Please explain why you voted the question down
Comment: Is miles per cylinder a major or minor factor in durability? Consider a 6 cylinder SUV versus an 8 cylinder SUV. assume the same work load for both engines.
Answer: The number of cylinders is completely irrelevant when determining the durability of an engine. Workload, used materials, building process, maintainance, etc. are far more important.
Comment: If all the factors are the same (Workload, used materials, building process, maintainance, etc), is there still a difference? For example, perhaps the 3 cylinders need to work faster to give the same output, I would expect it to ware out faster.
Answer: 4-cylinder, cycles are more balanced, and load is distributed across 4 instead of 3 cylinders, all other things being the same.
Answer: I've seen this question before. The debate is
Smaller engines have less moving parts to break, bigger engines have more parts to distribute load. Choose your side.
Really though, what are you going to be doing? Drag racing with spray or huge boost? Probably not gonna want a smaller engine (at least, a smaller block that is...)
Comment: It's not a question about big or small engines. I wanted to buy a small (engine) car for private genral use. I had 2 general options: 3 or 4 cylinder engine. I wanted to know which one is more durable.


MiKTeX 2.9's tex4ht not working

Question: According to this document and my own experience. MiKTeX 2.9's version of tex4ht is not working. Using MiKTeX 2.8's tex4ht does work, but is obviously not prefered. Does anybody know how to fix MiKTeX 2.9's version of tex4ht?
Answer: Did you install it using the 'user' package manager?
I've had a similar problem myself and did a clean and re-install, this time making sure I added tex4ht-base with the 'admin' package manager.
Answer: On the current MiKTeX 2.9 (December 2012) tex4ht works nicely with several example documents. What is slightly misleading that the extra scripts, e.g. mzlatex and others are not installed. Instead it is recommend to use the wrapper mk4ht.
Have you tried mk4ht mzlatex example.tex? This calls tex4ht and should create the correct output.
Answer: TeX4ht does work under MiKTeX 2.9 for Windows 7, although equations are often converted into bitmap pictures rather than MathML, unless the option "html,mathml" is used with the htlatex command.
Here's what I did:

Installed MiKTeX 2.9 with both miktex-tex4ht-bin-2.9 and miktex-tex4ht-base-2.9 installed with the package manager in administrator mode, on Windows 7.
Created a test.tex file in E:\downloads, as follows:
\documentclass{report}
\begin{document}
Hello there. This is a test of $x_i^2=3$, where
$$\int_0^\infty f(x) = 1.$$
\end{document}
Converted the TeX file into an HTML file with the following MS DOS commands. It is important to note that as htlatex accepts filenames but not pathnames, it is important to set the current directory to where the tex file resides. If a pathname were given for the test file, e.g., e:\downloads\test.tex, the error "undefined command sequence" would be produced.
e:
cd Downloads
"C:\Program Files (x86)\MiKTeX 2.9\scripts\tex4ht\htlatex.bat" test.tex "html,mathml"

Incidentally, this summarizes a more general question I asked in TeX4ht (htlatex) on MiKTeX 2.9 to convert LaTeX into MathML, and then into Office MathML with Word 2010.
Note that the linked solution calls TeX4ht via htlatex with the option "html,mathml". Calling it via mk4ht requires that a Perl interpreter be installed on Windows.
There's a problem with a second conversion into OMML but you might not be affected by that if an HTML file with or without MML is all you want.

MiKTeX 2.9's tex4ht not working


Subtracting an integer in my db by 1. SQL

Question: I want to subtract the follower count of a user by 1, or increase it by but I don't want to do this:
   $sql = $conn->prepare('SELECT folllower_num FROM users WHERE user_id = ?');
   $sql->execute($user_id));
   //then grab the follower_num value, save it to a variable, and subtract 1
   //from it and then:
   $sql = $conn->prepare('UPDATE users SET follower_num = ? WHERE user_id =
   ?;');
   $sql->execute($newfollowercount, $user_id));

or something like that. To me this seems bad to do because while the value is saved into this code and then changed and put back into the database, someone else could have followed or unfollowed and then the number becomes incorrect. Is there another way I can do this?
Answer: SQL allows to update the number of rows at once:
UPDATE users
   SET follower_num = follower_num + 1
 WHERE user_id IN (1,2,3,4...)

WHERE clause can contain any conditions you want. All users that satisfy that conditions will be updated.
Comment: Remove excess `value` words.
Answer: UPDATE users SET follower_ct = follower_ct + 1 WHERE user_id = ?

(or - 1)
Answer: In addition to Kondybas's answer.
You may increase and decrease the field values in one statement:
UPDATE users
SET follower_num = follower_num + CASE WHEN user_id IN (1,3,5...)
                                       THEN 1
                                       ELSE -1
                                       END
WHERE user_id IN (1,2,3,4,5,...)

The ids list in WHERE defines what records must be updated (with any type of update).
The ids list in CASE defines what records must be increased. The rest of records to be updated (not included in this list but present in the list in WHERE) will be decreased.
Of course, the CASE statement (and assignment expression at all) may be more complex and it may include more than 2 conditions and updating alternatives.


Why are the dynamic content options limited when initializing a variable

Question: I would like to make a variable in a workflow to specific content in a column I call Parent List ID. However, when I try, the only dynamic content options I get are for the item ID. Why do I only get that one option? Do I have to use an expression to get the information from the right column? I tried using the item function, but that doesn't work.
Answer: Is your ParentID column on that list set up as a number type field?
I set mine up as a number type field with zero decimal places, and you can see that it is available in the dynamic content selection box:

I'm fairly sure what's happening is that when you specify the type of the variable, SharePoint/Flow is filtering out the available choices in the dynamic content to only ones of that same type, so you don't mismatch and throw errors.
Answer: Agree with Dylan, per my test if you set the variable as integer, it only accepts numbers column. Have a check on your Parent ID column type and the advanced settings of your trigger, make sure you are using a correct view including the parent ID column.


Tinymce editor text alignment in noneditable contet

Question: I've created a custom tinymce plugin to Add Headers,

(this plugin used to add readonly text into the editor)
these headers are inserted into a div with attribute
contenteditable="false"
Like
Marks

(headerDiv is used to set the div as inline)

I havn't use the tinymce noneditable plugin regex , for me it's not working on inserting from a listbox. (please check the images)

The problem arises when i try to align the selected content with noneditable headers,
the headers will displayed on next line. (please check the image)

I've checked the tinymce_src.js, from that i understand how alignment works,
they get the content from the editor and wrap a div around it,
and align that div using text-align property.
In wrapping section they check the selected content has a html tag,
if the tag was found then they split the content into 3
i.e

content before the tag
content with html tag
content after the tag

and wrap this 3 part with a div
Example for tinymce selected content : raw tepmlate Marks

part 1 :
raw tepmlate

part 2 :

Marks

part 3 :

Any guidance and help is appreciated..!
Comment: hmm, what is your question?
Comment: I want to align the editor content with noneditable header, after alignment the content must be in same line
Answer: style="display: inline-block;"

?