TT-TDB with SPICE from ephemerides kernels as 'de440t.bsp'

Question: I am a new SPICE user. I would like to ask a question: does anyone know if it is possible with some SPICE function to get the TT-TDB value
directly from kernels as 'de440t.bsp', body id '1000000001'?
Comment: Not sure what you mean by "directly".  This article shows how to use the data files yourself, without SPICE: https://www.celestialprogramming.com/jpl-ephemeris-format/jpl-ephemeris-format.html
Answer: The data to compute the TDT-TT value is stored in the leap seconds file. The latest version as of now is naif00012.tls.
The description should help in that computation but I must admit never having fully understood it and rely on ESA's definition instead: https://gssc.esa.int/navipedia/index.php/Transformations_between_Time_Systems#TDT_-_TDB.2C_TCB .
Answer: I know that the TT-TDB difference can be obtained with the SPICELIB DELTET function:
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/deltet.html
But the goal would be to read it directly from the DE440/LE440 ephemeris, not this way as from 'naif00012.tls:
https://gssc.esa.int/navipedia/index.php/Transformations_between_Time_Systems#TDT_-_TDB.2C_TCB
I also know that the TT-TDB difference can be obtained from the JPL Ephemeris Files by looking up the Chebyshev coefficients of triplet 15 and interpolating from ASCII files such as the
ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/de440t/ascp01950.440t
EPHEMERIS FILES, INTERNAL FORMAT OF THE EPHEMERIS FILES:
The 15 triplets give information about the location, order and time-coverage of the chebychev polynomials corresponding to the following 15 items:
<code>   01.- Mercury
   02.- Venus
   03.- Earth-Moon barycenter
   ...
   12.- Earth Nutations in longitude and obliquity (IAU 1980 model)
   13.- Lunar mantle libration
   14.- Lunar mantle angular velocity
   15.- TT-TDB (at geocenter)
</code>
What I was looking for is to be able to do the equivalent of the latter directly from the kernel:
ftp://ssd.jpl.nasa.gov/pub/eph/planets/bsp/de440t.bsp
with some SPICE routine, using fortran code, for example. some of:
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/index.html
I've tried with SPKPOS, TARGET = '1000000001', but it didn't work.
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/spkpos.html
What I was looking for was how to obtain the interpolated value of the naf_id = '1000000001' from kernels like 'de440t.bsp', which would be the equivalence to obtain and interpolate from the 15 triplet of the ASCII "ascp01950.440t".


How to find address of function in memory?

Question: I am currently completing a CTF exercise where i must attempt to overwrite a function pointer on the stack through a buffer overflow here is the code:
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

char *gets(char *);

void complete_level() {
  printf("Congratulations, you've finished :-) Well done!\n");
  exit(0);
}

int main(int argc, char **argv) {
  struct {
    char buffer[64];
    volatile int (*fp)();
  } locals;

  locals.fp = NULL;
  gets(locals.buffer);

  if (locals.fp) {
    printf("calling function pointer @ %p\n", locals.fp);
    fflush(stdout);
    locals.fp();
  } else {
    printf("function pointer remains unmodified :~( better luck next time!\n");
  }

  exit(0);
}

The code will get input using the vulnerable gets() function and store it inside the buffer called buffer.
Since buffer is the largest variable in the struct it will allow me to overwrite variables below it on the stack. The next variable is the function pointer called fp.
In order to overwrite fp (and make it point to complete_level) i will need to find the address of the complete_level function in memory. Then write "A" 64 times, then write the functions address.
The problem i have is that i cannot find the address of the function.
So far i have tried objdump however that gives me a offset and not the full address:
objdump -M intel -d 3 | grep complete_level
    1184:   80 3d 8d 2e 00 00 00    cmp    BYTE PTR [rip+0x2e8d],0x0        # 4018 <completed.0>
    11ac:   c6 05 65 2e 00 00 01    mov    BYTE PTR [rip+0x2e65],0x1        # 4018 <completed.0>
00000000000011c9 <complete_level>:

Here is an output of the executable under the file command:
3: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=11a5f76e0d40b7f4fdc53d4dd60faac9f9e405be, for GNU/Linux 3.2.0, not stripped

Why is it not showing the full address? Also how can i get the full address of the function complete_level?
Comment: There's no reason for the linker to include `complete_level` in the executable, because it's not used.
Comment: Forget the [silly] `gets` call and the struct. Just call `__builtin_frame_address`
Answer: just use gdb and crack it like i did here.
look at registers closely and see what moves where, when calls happen, etc...


ASP.NET web app development: hiding sensitive information from contractors/freelencers

Question: I am developing a web application that uses Amazon Web Services. I am using ASP.NET MVC. I also use several Amazon Web Serivces including S3, EC2 and SQS. I am planning to hire freelancers to help the development. Now I put the Amazon Web Service key and secret in the web.config file and it is connected to my credit card. I am using hosted SVN source control, and TeamCity for automatic build and testing.
The question is, is there a way the freelancer can checkout the code and do testing, without knowing the sensitive information like the AWS key and secret? Should I put it in a different file? Should I put it in the database and encrypt it?
Answer:
have a test account for your
development and give that to your
freelancers
you can encrypt the    sections of
web.config following the    steps
mentioned here
you can    move the key into the
code and    compile the layer as a
dll and give    that to the
developers
Answer: The problem with freelancers is that they generally have access to the keys to the kingdom.  In .net you can toss all the stuff you want to keep secret into a separate assembly...but that can be reversed and opened up.  You can keep the data in an encrypted format but at some point in time you have to give them access to the decryption algorithm so that they can work with the decrypted data when speaking with those services.  If you have a shop with developers you can always create a wrapper that interacts between the freelancers code and your service layer thereby somewhat protecting your code and sensitive data from the un-trusted freelancers.
The easiest way for you to do this is with traditional abstraction layers.  Don't give your freelancers deep access into your code base and you should be good.  In your statement you said that you were using a public SVN which means you may need more than one repository.
Comment: I think both answered my question but I can only mark one as an answer.
Answer: Don't be sold on easily solving this problem -- you cannot hide your key from developers without going to greater lengths.  If it's stored in a DLL, they can decompile the DLL with a tool like Reflector.  If it's encrypted in web.config, but decrypted somewhere else where it needs to be used, they can monitor the network traffic with a proxy tool, or attach a debugger.  While the methods suggested are useful for preventing casual theft of the key, such as by a typical user, somebody skilled who is determined to find it out and has access to run your code can generally find a way to get what they want.
Try to hire people you can trust.  Do background checks if you must.
If you really need to hide your key, keep the code that uses it on a separate system the developers won't have access to except through a well-designed secure interface.  Basically, you'll end up proxying access to AWS through another web service.
Answer: Legal protections are your friend here. Get a lawyer to draw up a contract for you, including protective clauses and penalties for violations. Also, if you need enough freelance help, it might make sense to look at a company to provide the services which could be a bit more secure than the freelance angle.
Failing that, Rony's first point is good--get a second, non production account. You honestly should have one anyhow for staging and testing as you probably don't want untested code playing with production data. The real expense with AWS is in bandwidth rather than purely in storage, so it shouldn't cost too much.
Another angle, depending on how much of the service's API you are using and your skills as a coder, would be to abstract the S3 bits behind your own storage interface. Provide the developers with a non-S3 backed implementation while keeping your s3-backed implementation in a separate repository they don't have access to, then switch to the s3-backed option when appropriate. This has long-term advantages like making it easy to switch storage providers should the need arise.


is the natural numbers can be a valid subspace over some field?

Question: if i choose the real numbers as vector space over SOME field,
and i look on the subset of the natural numbers group including zero.
so according to subspaces:
1) 0 included 2) closed under addition of vectors.
so, is there a Field that can make the natural numbers as a valid subspaces? (field that multipication from natural numbers with scalar is closed) or it doesnt exist
Comment: The only thing that comes to mind is that, since natural numbers form a monoid, one can talk about some monoid containing naturals as a submonoid; or the natural numbers can act by multiplication on some other monoid (the last written additively).
Answer: The natural numbers, with the operation of addition, do not have a vector space structure over any field. To be a vector space, you first have to be a group, and most natural numbers do not have additive inverses.
The integers (again with addition) resolve this issue, since they include the negatives, but they still do not have a vector space structure over any field. The reason is that the integers are "non-torsion", i.e. $1+1+1+1+\dots$ never equals zero. Thus the field cannot have torsion either - it must be "characteristic zero." But every characteristic zero field contains the rational numbers, and there will be no way to define multiplication of the integers by rational numbers since, e.g. there is no integer $x$ such that $5\cdot x = 2$, so there will be no good definition for $(1/5)\cdot 2$.
Comment: It looks like the OP asked about the natural numbers, not the integers.
Comment: @KevinCarlson - good point; I will edit. I was thrown by the word "group."


Trying to use openH264 as an alternative to libX264 in FFMPEG C project

Question: I have an application that transcodes a video frame by frame using FFMPEG and x264 encoder. I am looking to release this application but the licensing of x264 made me switch to using openh264 instead.
I managed to compile everything smoothly (openh264 then FFMPEG with enable-openh264). I am now trying to correct the encoder setup in my C code as what worked for libx264 doesn't work anymore. Unfortunately I found very limited C/C++ examples of FFMPEG/openh264, i would appreciate any link/hint.
I am using the following code (dec_ctx is the AVCodecContext of the video I am decoding)
<code>            enc_ctx->height = dec_ctx->height;
            enc_ctx->width = dec_ctx->width;
            enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
            /* take first format from list of supported formats */
            enc_ctx->pix_fmt = encoder->pix_fmts[0];
            /* video time_base can be set to whatever is handy and supported by encoder */
            enc_ctx->time_base = dec_ctx->time_base;

            enc_ctx->gop_size      = 120; /* emit one intra frame every twelve frames at most */
            enc_ctx->max_b_frames = 16;
            enc_ctx->scenechange_threshold = 0;
            enc_ctx->rc_buffer_size = 0;
            enc_ctx->me_method = ME_ZERO;

            enc_ctx->ticks_per_frame = dec_ctx->ticks_per_frame * ifmt_ctx->streams[i]->time_base.den * ifmt_ctx->streams[i]->r_frame_rate.num/ifmt_ctx->streams[i]->r_frame_rate.den;
            // Set Ultrafast profile. internal name for this preset is baseline
            av_opt_set(enc_ctx->priv_data, "preset", "placebo", AV_OPT_SEARCH_CHILDREN);
</code>
I get the following errors in the output with the [OpenH264] tag:
<code>[OpenH264] this = 0x0000000019C126C0, Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.
Output #0, mp4, to 'C:\Dev\temp\geoVid.mp4':
Stream #0:0: Video: h264 (libopenh264), yuv420p, 720x480, q=2-31, 200 kb/s, 90k tbn, 180k tbc
Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp, 96 kb/s
[OpenH264] this = 0x0000000019C126C0, Warning:Actual input framerate fAverageFrameRate = 0.000000 is quite different from framerate in setting 60.000000, please check setting or timestamp unit (ms), start_Ts = 0
[OpenH264] this = 0x0000000019C126C0, Warning:Actual input framerate fAverageFrameRate = 0.000000 is quite different from framerate in setting 60.000000, please check setting or timestamp unit (ms), start_Ts = 0
</code>
The output video file just plays black frames. Any hint or link to some doc would be appreciated. I have been trying to understand these errors but not too sure how to enable "skip frame" or why it is complaining about my input framerate (this is the same input as when I encode successfully with libx264)
Answer: The warnings suggest that you have to set a framedrop mode before setting the bitrate, and because of that it is setting the bitrate to 0.


Miner quit working this morning

Question: CPU mining for Quark coins for the last few days, (just doing it for fun, I know they're practically worthless) been working with no issues. This morning I wake up and look at my wallet and the last transaction shows as completed at 7:26 AM 22 DEC 13 and nothing follows that transaction. I've tried stopping and restarting everything, viewed my logs, reviewed my settings, checked with the pool to make sure they're still up.... everything seems to be in order. I'm still relatively new to all of this so if anyone could help me think of some troubleshooting tasks I haven't taken, it'd be appreciated.
Answer: A bit more of info would have been helpful...
Let's see, if you mention your wallet, I understand that you're mining by having your wallet mining for you (solo-mining) and not via a pool. In case this were to be true, you'd have to make sure that your wallet is up to date and that you have at least one or two nodes listed in your conf file.
In case you were mining via a pool, I'd make sure the pool is still up. The fact you don't see any new transactions could be for two reasons:
1) The power you put to solo-mine is not enough anymore, difficulty has risen too much and your computer can't mine efficiently anymore.
2) Check that you're still really synchronised with the blockchain.
Hope it helps.

Miner quit working this morning


Can a cheap RF module be used for two way communication

Question: Can a cheap RF(transmitter and receiver) module be used for two way communication, not at the same time of course but for example arduino A sends string to be printed on lcd the arduino B receives it and prints it on lcd, then after some time arduino B sends a temperature data back to arduino A, then arduino prints the temperature data on the serial monitor. All of this while arduino A is connected to a transmitter and arduino B is connected a receiver.
Comment: Yes you can, but you'd need both modules on both Arduinos. So two sending modules, and two receiving modules.
Answer: Each device that will ever transmit anything will need a transmitter. Each device that will ever receive anything, needs a receiver. The devices you show in your question are separate receivers and transmitters, so on Arduino A and Arduino B, you will need both a receiver and a transmitter in order to have real, two-way communication between them.
Some RF devices are "Transceivers" which have both a receiver and a transmitter in the same module. Some of these can operate "full-duplex", meaning they can receive at the same time they are transmitting other data (Typically each direction is on a different frequency, but not necessarily.) Most cheap ones are half-duplex, meaning the module can only receive or transmit at any one time.
ADDITIONAL INFORMATION ABOUT RADIOHEAD
Your comment mentioned the RadioHead library. I was able to find the documentation on the library and see that it supports a wide range of radio chipsets and modules. The cheap ones you note are simple ones that use OOK (on-off-keying) or ASK (amplitude-shift-keying) and don't actually have a protocol. The receiver simply provide a HIGH or LOW output if it detects a signal on it's designated receive frequency. The transmitter simply oscillates at the transmit frequency when it's input pin sees a HIGH value, and stops when it sees a LOW value.
The RadioHead RH_ASK class deals with these simple transmitters. The documentation is at http://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK.html#details
This page notes the way to connect both a transmitter and receiver thus:
Connecting to Arduino

Most transmitters can be connected to Arduino like this:

Arduino                         Transmitter
 GND------------------------------GND
 D12------------------------------Data
 5V-------------------------------VCC

Most receivers can be connected to Arduino like this:

Arduino                         Receiver
 GND------------------------------GND
 D11------------------------------Data
 5V-------------------------------VCC
                                  SHUT (not connected)
                                  WAKEB (not connected)
                                  GND |
                                  ANT |- connect to your antenna syetem

Comment: i have searched everywhere for a diagram of some sort of how to connect both transmitter and receiver to one arduino, i cant find any, do you have some advise? i am asking this because the "RadioHead" library expects data from pin 12, and i don't know if any other pin would work? thanks.
Comment: This sounds different enough to become a new question itself. That is, the RadioHead library and dealing with separate transmitter and receiver modules.
Answer: Sure it can.  A transmitter is only a transmitter while it's actively transmitting.  And you can have as many receivers as you like.
Comment: wait... so does this mean when a receiver is not receiving it can transmit? and when a transmitter is not transmitting it can receive?
Comment: No, it means you can have two people in a room. Each has a mouth, and each has ears. Only one should talk at once, but both people's ears are working all the time. The person talking knows he's talking though so ignores whatever comes in through his ears.
Comment: not those ones, those look to be separate transmitter and receiver modules.  But something like the nrf24 is a transceiver, meaning it can do both   like this   https://www.amazon.com/dp/B00O9O868G/ref=sspa_dk_detail_1?psc=1
Comment: I'll second Chad G's recommendation of the NRF24L01 unit, cheep/readily available(Ebay) and very effective. I am using these to remote control my projects, range depends on who you talk to but have seen statements ranging from 100 to 1000mts. This item is well supported in the Arduino community.


What's the name of this Connect 4 variant?

Question: I'm being trying to find this variant.
It's a variant where, when you have a full column, you can place a disk into that column and push downwards, causing all the disks to go down one row except for the bottom disk with then falls out of the bottom?
Comment: It's not using a normal rack, pushing down only effects the column the disk is placed in, and only when it's full.
Comment: Due to the way the reset mechanism works in Connect 4, this variant could easily cause the entire game to be reset when you attempt to push 1 column down through the bottom.
Answer: This is not a well-known variant.
But it sounds like an interesting House rule
If it was a common variant it would be mentioned in one of the Connect4 variant lists which appear on BGG, Wiki, ultraboardgames, Hasbro-rules.
Searching through lists of Connect4 variants, I spotted two variants with some similarity to the push-down rule you are looking for:

"Popout" allows to drop a disk from the bottom:

The game play is like the original Connect4 except on your turn you
can do:

Drop a checker, or
Pop one of your own checkers out of the bottom row.

In "Power Up" each player have several special disks, one of them is the Anvil, which when placed immediately pops out all the checkers below it, leaving only the anvil on the bottom row.

Sources:

BGG: Variations on four-in-a-row
BGG: the Tic Tac Toe Family Reunion
Wiki: Connect_Four #Rule_variations
ultraboardgames: variations
Hasbro rules archives
Comment: Chat GPT should not be used for answers.
Comment: GPT answers are considered bad practice on most of the sites that I have seen. Even if it is a supplemental part it should be avoided.
Comment: @JoeW, ok I deleted GPT's answer
Comment: I remember when I was younger playong the game with a physical rack that coul actually have the bottom disks fall out.
Comment: @blademan9999, yes I also had a physical rack that could actually have the bottom disks fall out.  It was used to initialize the board after a game ends. Removing all the disks.
Comment: I meant when you placed a disk in a full row.
Comment: @JoeW, My answer is "I made a thorough search and did not find."  GPT is only the 5th source after searching at the most important sources.
Comment: The revised edition (where the variants listed in the answer come from) has an altered mechanism for disk retention and allows for individual disks from a single column to be popped out: https://boardgamegeek.com/image/4037436/connect-4-revised-edition
Comment: An AI generated answer would be equivalent to making up an answer about something you have heard about for the first time because you've played hundreds of other games like it. It might be right but there's 0 actual confidence in the response.
Comment: I looked at it as another search tool like google-search.  My statement was: This variant isn't shown at the known variant-lists, not in Wiki, not shown in google-search and even GPT do not know about it. Anyway, I get it, I will not mention GPT again.
Answer: This is not an official variant of the game.  It's similar to the "PopOut" variant by Hasbro, and seems like a totally viable house-rule variant if you have a Connect 4 Revised Edition board.
Hasbro released a new version of Connect 4 in 2008, the Connect 4 Revised Edition, that has the ability to remove the bottom checker from just a single column without messing up the rest of the board.  The intention of this was to support two new game variants (PopOut and Pop 10).  The one most similar to the rules you describe is PopOut:

Play PopOut just like the Original Connect 4. However, on your turn, you can choose either to drop a counter in OR pop one out of the bottom row.
Note: You can only drop in or pop out counters of your own colour.

There is also Connect 4 Revised Second Edition, which adds two more official variants (Five in a Row and Power Up), but neither of these are relevant.
The rules you describe are unlikely to show up as on official variant for the game without a hardware update.  On the classic Connect 4 board, trying to push a checker into a full column could very easily reset the whole board by accident.  Meanwhile, the Revised Connect 4 boards are designed to allow for removal of the bottom checker, but you do so by popping it out of the column, not by pushing a new checker in at the top.  While the Revised boards fully support this style of play, you would need to pop out the checker first and then add the new checker second.
Don't let any of this stop you!  House rules can be great.  It seems like a cool rule, and if you have a Connect 4 board that supports it, go for it.
Comment: I think that's the one, maybe.


Converting pdf's to images with Imagemagick + RMagic

Question: I'm using paperclip at the moment to convert pdf files to images.
My code looks something like this
  def convert_keynote_to_slides
    system('convert -size 640x300 ' +  keynote.queued_for_write[:original].path + ' ' + KEYNOTE_PATH + '/' + File.basename( self.keynote_file_name )+"%02d.png")

    slide_basename = File.basename( self.keynote_file_name )

    files = Dir.entries(KEYNOTE_PATH).sort
    for file in files
      #puts file if file.include?(slide_basename +'-')
      self.slides.build("slide" => "#{file}") if file.include?(slide_basename)
    end

  end

I'm sure this can be re-factored to work better.
My questions are:
Is there a way to figure out the progress of ImageMagick if not how would I put this into a delayed job as im worried this wont scale very well.
Can anyone point me in the direction as to how to make this code better / more efficient. The KEYNOTE_PATH points to a directory in public where all of the images are held in a single folder im not sure if I like this or not. What would probably be better is to assign a random name to each file.
Answer: I hope you're doing extensive filtering of keynote.queued_for_write[:original].path and File.basename( self.keynote_file_name ) input variables, so you're not susceptible to shell meta-character injection attacks.
Comment: I'm pretty sure that its done my Paperclip I could be wrong however. I validate to make sure that the file is only a PDF.The path to the file is after it has been uploaded.


Label Blocking in QGIS?

Question: Does anyone know how the 'Blocking' label style in QGIS 2.16 works? I've got a polygon boundary layer and would like to keep any labels from overlapping the outline. I've turned blocking on for the polygon, but none of the labels seem to change.
Comment: Yeah...I don't think there's a lot of information out there regarding this except for this [tweet](https://twitter.com/underdarkgis/status/759487799678599168)
Comment: Yes I'm not getting this to work either...
Answer: I tested the blocking option, using QGIS 2.16.2, to block labels that are located at the edge of the polygon boundary. Actually it works, but it seems it works if the labels are located close to the edge of the polygon layer.
To illustrate the difference of using the blocking option and not using the blocking option, I will use two shapefiles: the world boundary shapefile and the major city shapefile.
First, we need to show the labels of major city shapefile and use the world boundary polygon to block the labels.
Here is the difference:

Without using blocking option, the labels will look like this:

With using blocking option, the labels will look like this, especially those marked with red rectangles:

If the labels of major city shapefile are located very close to the edge of the polygon boundary shapefile (world boundary), the labels will be blocked from covering the edge of the polygon boundary, but if the labels of major city are located a little bit far from the edge of the polygon boundary, the influence of blocking will have a minimum effect or no influence at all.
Another point is, blocking option was available in the previous version of 2.14, but with different name "Discourage other labels from covering features in this layer". I think the developer team changed the name to make it shorter and to give more descriptive meaning to its function.
Comment: Thanks for checking it out. I'm noticing what you describe. Would love to have a feature comparable to arcmap's label weights where you can completely prevent labels from overlapping polygon edges or interiors.
Comment: "Blocking" is more absolute than "discourage", I think the name should not have been changed given the functionality that it enables.
Answer: It seems to me that this feature is buggy. I noticed that the result depends on the 'placement' settings for the labels:

offset from centroid / around centroid: blocking areas are ignored
horizontal / free / using perimeter: blocking areas are respected

My test setup:

a polygon layer containing one polygon, labels set to 'blocking'
another polygon layer with a few polygons, labels enabled & then using different 'placement' options

I filed a bug report: https://hub.qgis.org/issues/15718

Label Blocking in QGIS?


CMD my program (it must be 15 charcters long)

Question: Hello everyone I am just finished writting a 1800+ lined code batch file... What it does is it blocks website and unblocks them. Now the features are the you can enter a website and block it and the you can block a whole bunch aswell. Now you can tyoe in the websites name and it will unblock or you can unblock them all uy deleting to file. Now there is a new feature... Redirection, I successfully made that prossible with you guys :). Now what this does it , you have 2 options make a website redirect to another website or redirect to the "Unable to connect page". Yes that is why I asked you guys about how to extract the IP address when you ping a website and then my progrm stores the IP address in a varible. SO you would type a website in e.g. www.facebook.com and it would ping the website and get the IP addess and store it in a varible. But this is a problem when entering a website to unblock. So I use the findstr command to look for the blocked website and remove it but this is a multiuniverse hasale. It would unblock the website the have to redirected IP address in it.
188.8.131.52 www.facebook.com www.google.co.za
220.127.116.11 www.facebook.com www.youtube.com

and when it redirects to the "Unable to connect page" (localhost) it would be like this...
127.0.0.1 www.miniclip.com.

Now this is my problem CMD doesnt know which is the blocked website and which is to redirect website. So I need someone to help me with a little code and yes once this is done I promise to give you a link so you can download this program that took me about 173 hours to make because I had to do alot and alot of brainstorming and thinking not just typeing code from the top of my head. Now here is the code I'm stuck with...
if %directstate% == uilocalhost (
findstr /i %IPaddress% %%A >>%hosts%
)

if %directstate% == uiwebsite (
findstr /i %IPaddress% %directmode% %%A >>%hosts%
)

directstate varible is the varible that is the option to redirect to a website or localhost
and if the directstate varible is set on a website the Ipaddress varible is set on the extracted ping IP address and if the directstate is on localhost the IP address is set on 127.0.0.1 and the hosts varible is where the dir of the hosts file is setting.
Here is the entire code to unblock a website...
::Uninstall Selected Bocked Website START
:unblockselectedloadmenu
echo [%time%] [UNBLOCK SELECTED MENU STATUS: LOADED MENU] >>%logdir%\WEBMATRIXLOG.log
:unblockselected
set unblockURL=unblockURL
mode 52,22
echo -UNBLOCK SELECTED
echo                  ----MY PROGRAM----
echo.
echo Listing Blocked Addresses...
type %hosts%
echo.
echo b/back
echo Enter the website to unblock:
set /p unblockURL=www.
if %unblockURL% == unblockURL (goto unblockselected ) else if %unblockURL% == b (
echo [%time%] [UNINSTALL SELECTED MENU STATUS: USER BACKED OUT FROM UNINSTALL SELECTED MENU] >>%logdir%\WEBMATRIXLOG.log
goto mainmenu ) else (
echo [%time%] [UNINSTALL SELECTED MENU STATUS: INPUT WEBSITE ADDRESS: www.%unblockURL%] >>%logdir%\WEBMATRIXLOG.log )
echo.
echo Processing...
findstr /i "%unblockURL%" %hosts% >nul
IF %ERRORLEVEL% NEQ 0 (
echo Address is already uninstalled...
ping localhost -n 3 >nul
echo [%time%] [UNINSTALL SELECTED MENU STATUS: ADDRESS IS ALREADY UNINSTALLED] >>%logdir%\WEBMATRIXLOG.log
goto mainmenu )
attrib -r %hosts%
FOR %%A IN (
www.%unblockURL%
) DO (
MOVE %hosts% hosts.bak >NUL
FINDSTR /V /C:"%%A" hosts.bak > %hosts%
DEL /F /Q hosts.bak )
attrib +r %hosts%
echo DONE! - Cleared Selected Blocked Address!
ping localhost -n 2 >nul
echo You may need to restart browser
ping localhost -n 3 >nul
echo [%time%] [UNINSTALL SELECTED MENU STATUS: REMOVED WEBSITE ADDRESS: www.%unblockURL%] >>%logdir%\WEBMATRIXLOG.log
cls
goto mainmenu
::Uninstall Selected Bocked Website END

Please help me if you understand what I am talking about. Thanks you everyone to make this possible. Remember you will get a copy of this program once it's done. Probably in a few days :)
Comment: Your question is all over the place; please distill it down to a single, coherent question. What exactly is the problem you are having, what error are you getting, and where in the code do you think the problem is?
Comment: Your question is too long, I can't read it before Easter ...
Comment: When I enter a website to unblock i.e... 188.8.131.52 www.facebook.com www.google.co.za
220.127.116.11 www.youtube.com www.facebook.com. And when I unblock it with the unblock feature it will remove all the redirect url address not just the ones on the left hand side. I'm sorry it is realy hard to explain :)
Answer: I suspect this line:
findstr /i %IPaddress% %directmode% %%A >>%hosts%

This will find any lines containing %IPaddress% OR %directmode%. From your comment not just the ones on the left hand side I'd conclude you want to find the line(s) containing literally "%IPaddress% %directmode%" - with the space between them.
Try
findstr /i /c:"%IPaddress% %directmode%" %%A >>%hosts%


3D surface plots in TikZ

Question: I need to plot a surface plot using TikZ. I have the (x,y) coordinate and the corresponding function value in a table form. I have not done 3D plots before in TikZ and hence I would appreciate any help. I would want a surf plot like this, but I do not have a closed form expression for my function. Instead, I have a table of values as shown below.The (X,Y) values are a two dimensional uniform grid on the domain [0,4] * [0,4].
Comment: Please provide the data in a plain text rather than an image.
Answer: TikZ cannot do this with builtin methods. pgfplots can do it - in your case with \addplot3[surf, mesh/ordering=x varies] table {myfile.dat}; .
It supports custom colormaps, color bars, draws an appropriate axis, chooses suitable scales, ticks, and ticklabels etc.
See http://pgfplots.sourceforge.net/pgfplots.pdf for details and examples.

By default, pgfplots assumes numerical input (i.e. 0.29 instead of 29/10). If your data file really looks like
X Y Z
0 0 29/10
...

you need to write \addplot3.... table[z expr=\thisrow{Z}] {myfile.dat}; in order to activate math expression parsing for that column.
Comment: Thanks for the update. In fact, `file` and `table` are almost the same and both do the job. `\addplot3 table` is more powerful and allows a huge degree of customization; but its default is actually the same as `\addplot3 file`.
Comment: Thanks for the clarification! For some reason, this does not seem to work for me - using `table` instead of `file` with a `.dat`-file as source for the plotting data throws an error. I may very well have done something wrong here, but at least `file` works like a charm.

I must add that `pgfplots` in general is amazing; thanks for that! :)
Comment: As far as I can tell, if the data supplied is in a file (.dat here), the command `file`should be used instead of `table`- at least that did the trick for me. I suspect that this is syntax that may have changed since the post was written, and just wanted to add this in case it is helpful to someone else coming across this post. Otherwise, great answer! :)

3D surface plots in TikZ


Can I use the Ubuntu logo on t-shirts produced non-comercially?

Question:
Possible Duplicate:
Is it possible to create Ubuntu Shirts ( Merchandise )

Is it permited to use(print) Ubuntu logo on a "Ubuntu users group" T-shirt which is not sold public but to the group members ?
(I read this question.)
Answer: Your usage will be fine. Per the Trademark & copyright policy.

Ubuntu is built by and largely for its community. We share access to
  the Trademarks with the entire community for the purposes of
  discussion, development and advocacy. We recognise that most of the
  open source discussion and development areas are for non-commercial
  purposes. We therefore allow the use of the Trademarks in this
  context, provided the Trademark is used in a manner consistent with
  the guidelines below:

there is no commercial intent behind the use
what you are referring to is in fact Ubuntu. If someone is confused into thinking that what isn't Ubuntu is in fact Ubuntu, you are
  probably doing something wrong
there is no suggestion (through words or appearance) that your project is approved, sponsored, or affiliated with Ubuntu or its
  related projects unless it actually has been approved by and is
  accountable to the Ubuntu Community Council
Comment: this needs updating, I believe the wording has changed
Answer: It's a big planet with a lot of different rules. You could probably do this legally in North Korea or a small Pacific island nation.
If you are in a country that observes and enforces international trade and copyright treaties, you need to read Canonical's Trademark and Copyright policies page. You can't use the Ubuntu name or logo without Canonical's permission for commercial use, according to the Community Advocacy paragraphs. Generally, this means that you can pass along the costs to produce the shirts, but you can't take a profit.
You should talk to a lawyer if you have a legal question. A cheaper alternative would be to just contact Canonical and ask. I've done it before and they were friendly and replied promptly. If your goal is to promote Ubuntu and just cover any costs, they can confirm that this is acceptable for you.
Answer: You can use the Ubuntu logo freely, as long as it isn't used to create a bad brand identity.
Use the Ubuntu Brand Guidelines as a guide - though make sure you don't misuse the logo as pointed out in the 'Incorrect Use' section.
Source: Ubuntu Brand Guidelines.


Open Web Crawling Dumps

Question: I am currently using the Common Crawl dump of web crawl data. Are their any other good providers of free web crawling data that I can blend with my Common Crawl data?
Comment: Are you looking for any specific kind of data? Or, in other words, why are you looking to extend the Common Crawl dump with data from other sources?
Comment: Yes, there are URLs in my training set of data that are not found in Common Crawl, so I would like to supplement common crawl data with any other sources.
Answer: If the crawled data doesn't need to be very recent, the Internet Archive provides 80 terabytes of archived web crawl data from 2011 for research. Unfortunately, they don't say under which license they release the data, so it might not be Open Data as defined by the Open Definition.
Comment: I would prefer recent and one that is kept up to date like common crawl.
Answer: I'm pretty sure there aren't, but your best bet would probably be to ask on the Common Crawl mailing list.  That's a place where people who are interested in this kind of stuff hang out and it's low enough traffic that a polite request wouldn't be out of line -- the answer would probably be of interest to the entire community there.

Open Web Crawling Dumps


OpenCV and Blender for use in Broadcast

Question: We are a high school broadcasting team looking to up our productions for all of our shows. We are looking to specifically improve our american football productions, as those are some of our big shows. One common element in an American football game is the yellow first down marker. As you can imagine, this is an extremely difficult thing to accomplish for two main reasons:

Keeping the line in the same place as the camera moves is difficult to achieve.
Getting the line to go under the players and not on top of them is difficult.

We have figured out how to place the line under the players using chroma keying on our switcher, so no problem there. There problem is keeping the line in place. We are looking into motion tracking to achieve this, and stumbled upon something called OpenCV. It is essentially an open source video tracking/interpretation software. It has enough power and acceleration to run in real time.
We are looking to do something like this:

Take live video feed from a Decklink card into Blender
Place a 3D model of the football field over it, and use OpenCV to track it to the field.
In the 3D model layer, or with a layer parented to it, have our graphics play.
Send ONLY these graphics back out to our switcher for use in broadcast.

Everything having an SDK (The video card) or being open source (Blender, OpenCV), does this sound like something that could happen? What issues could arise with it?
Thank you
Comment: afaik Blender doesn't handle live footage...
Comment: I am looking to incorporate this as the intake from the grabber card, does this sound like something that can be done?
Comment: i've been looking for the same thing for some time, the only plosable way to do it is to duplicate a window with clean UI have teh background set to green and mirror that window to OBS so you can source it out as a video output.
Comment: This question was one I asked very early on. This paper details how we ended up completing the project.
Comment: https://drive.google.com/open?id=1deBHSbWQEG0gIO_ZPd8jKtOnZp0k2a_F
Answer: This paper details the solutions and challenges, as well as some technical information to how we completed the project.
https://drive.google.com/open?id=1deBHSbWQEG0gIO_ZPd8jKtOnZp0k2a_F

OpenCV and Blender for use in Broadcast


O-Rings vs. Washers for Garden Hoses?

Question: Hose sealers seem to be typically sold in a combo pack  with two types.  When are garden-hose washers used and when are the O-rings appropriate?  I've been kind of winging it with my own hoses, depending upon which seems to fit better.  Is there more to the logic than that?  Pictures would be particularly helpful.
Answer: Actually there is an o-ring that works far better than those typical flat or squared edge washers - it has a larger diameter (fatter) and seals better than anything I've ever used.
Walmart has them as well as many other retailers.
Part # 853814-1001 50381
Answer: There are better washers than those large, flat, stiff rubber ones. The better ones are softer, a little smaller, and have three or so "ears" on them. I have never used an O-ring to connect garden hoses.
See these vinyl hose sealing washers with ears  The washers are a little smaller than the large stiff rubber ones so they fit in the hose end easily, but the ears hold them in place. The old style may work for older extra heavy duty hoses which people don't buy anymore, but they are over-sized for modern "consumer grade" hoses.
Answer: Hose rings are flat to accommodate various types of male end connections. Some are cast brass, some are stamped from steel tubing. O-rings don't provide enough surface for the edges to press against. They're likely to slip past and be damaged or leak.
The two types aren't typically sold together because they're useful together.  That's just another cheapskate ploy by retailers to save shelf space and sell you more than you need.
Comment: I rarely say never, but unless you have special connectors that came with o-rings, washers are a better bet.
Comment: I have had great luck luck with o rings and my high end hoses nice heavy fittings, I find the flat washers work better on the cheaper "stamped" hose fittings. In both cases I like the softer rubber or neoprene, buna it is easier to seal and remove but they don't last as long as the harder materials.
Comment: So are you saying the o rings are never appropriate for garden hoses?
Answer: No garden hose uses an O-ring for the junction between it and a threaded connection to something else.  O-rings are only used with quick-connects that snap in and out.
Undersized cheap vinyl washers with ears are meant for cheap undersized hoses, are inferior to rubber and just save the manufacturer a few cents to make them.  Before I bought any of those I would check the condition of the hose because it may not be in good enough shape to bother buying washers for.
Always get the correct size rubber washer when it is available.
The odd thing is that this question is asked at all.  All hoses come with a washer so you should be replacing it with the same type it originally had in it.
Answer: We have one of the newer very flexible and light-weight garden hoses called "Zero-G" from "Teknor Apex" that will not work with the typical 1" diameter hose washer.
Oddly enough, the inner diameter of the female connector is 1 1/16 inches. If a normal 1" washer is used, it will leak.
To work properly, first a 1 1/16 O-ring has to be placed into the connector followed by a normal 1" diameter hose washer. The combination of the two work together to prevent leaking.
Amazing how foreign manufacturers can take something simple & easy that has worked for years and years and make it complicated with additional cost.

O-Rings vs. Washers for Garden Hoses?


Can a Brownian motion be fast at its extrema?

Question: After pondering this MO question > Location of maximum of Brownian motion with rough drift <, I wonder whether a Brownian motion can be fast (i.e. beats the law of the iterated logarithm) at its extrema?  Is it necessarily fast?
Comment: Can you ask the question in a more precise way?
Answer: Heuristically, a point $(t,B_t)$ being a extremum is antithetical to fast oscillation, since there is no oscillation on one side of (above/below) $B_t$.
However,

This is only a heuristic, and
One may wonder whether there are so many fast times and so many maxima as to force an overlap.

At least we can rule out (2) as follows:
Theorem. If $W$ and $B$ are two independent Brownian motions then the set of maxima of $W$ is disjoint from the set of fast times of $B$.
Proof: Let $M$ be the set of local maxima of $W$ on a given closed interval.
Then $M$ is a union of finite discrete, hence closed, sets $M_n$, where $M_n$ consists of those $t$ such that $B_s\le B_t$ for all $s$ with $|s-t|\le 1/n$.
Since $M_n$ is countable, the packing dimension $d_P(M_n)=0$.
So by Theorem 10.22 of http://research.microsoft.com/en-us/um/people/peres/brbook.pdf
we have almost surely that
$$\sup_{t\in M_n} \limsup_{h\downarrow 0} \frac{|B_{t+h}-B_t|}{\sqrt{2h\log(1/h)}}=\sqrt{d_P(M_n)}=0.$$
Given $a>0$ we call a time $t\in [0,1]$ an $a$-fast time if
$$\limsup_{h\downarrow 0} \frac{|B_{t+h}-B_t|}{\sqrt{2h\log(1/h)}}\ge a.$$
And a time is fast if it is $a$-fast for some $a>0$.
Thus, a.s. no fast time of $B$ is a local maximum of $W$.
Comment: Thanks for the update. I did consider that heuristic but on the other hand also thought that the Brownian motion has to get away from the local minimum, and it might even be the fast movement that lead to the local extrema.  My intuition for these things isn't great!


Shoulder press machine vs dumbells

Question: I've heard, and through my own experiences discovered, that for bodybuilding/hypertrophy purposes machine exercises are superior because they provide more stability they have a more even resistance profile throughout the range of motion. This holds true for me with most muscle groups except for shoulders. I've always felt a better pump and felt like my shoulders had been worked more through a dumbell press than a shoulder press machine. Is this because my shoulders respond better to dumbell movements or is it just that feeling a pump is a good indicator better hypertrophy?
Answer: The biggest thing about exercise selection is preference. If you enjoy doing DB shoulder press, you feel soreness, and get a pump, there is no reason to stop them if you are responding well. There are general exercises that are good, but everyone is different so stick to what works with you.
Every so often you can swap a movement out so you can target the same muscles,
but the same joints are not strained as much.

Shoulder press machine vs dumbells


Is the quantum analogue of electrostatic field photon? What will be its wavelength then?

Question: When two charges are separated there is an electrostatic field between two. Quantum mechanically, is it actually the discrete energy packet or photons that's travelling from one charge to another? If yes, what is its wavelength? How can I better understand the interaction between two charges with the perspective of quantum theory?
Comment: Duplicate of [Photons in coulomb field](https://physics.stackexchange.com/q/383507/140996)?
Answer: The interaction of two charges quantum mechanically are described by Feynman diagrams of many orders, where the dominant in the calculation are the first order ones.  The diagrams depend on the quantum field theoretical framework .
Here is a first order diagram of electron electron interaction:

No matter how far away the two electrons are , this is the quantum mechanical interaction. The internal line is called a virtual particle, because it is off mass shell. It has the quantum numbers of a photon but the mass under the integration depends on the bounds on the integral, the specific interaction. Thus one cannot talk of "frequency" for this virtual photon. The integral will reproduce the coulomb potential forces between the two charges. See this for a general view of exchanged virtual particles for static potentials.


Using MAMP and Xip.io to view a WordPress Multisite on a local network

Question: I am trying to use MAMP's built in Xip.io functionality to view a WordPress multisite installation on a local network. I have this working no problem with a WordPress single installation but am struggling with multisite. Just wondered if anyone knew what needed changing in the wp-config file to get this working using multisite as changing database entries isn't really the way forward here.
Answer: I have not used MAMP and Xip.io for my local installation, but rather I used XAMPP.
I will explain to you the idea that I did to enable multi-site setup on my computer, and hopefully this would direct you in the right way allowing you an implementation using MAMP.  Note that I am using Windows.
Before doing anything, I was planning to have my sub-domain setup for my network, not a sub-directory. Therefore my plan was to have domain.dev, www.domain.dev, sub1.domain.dev, sub2.domain.dev ...etc.
Therefore, I had to add in my hosts file the following entries:
127.0.0.1       domain.dev
127.0.0.1       www.domain.dev
127.0.0.1       sub1.domain.dev
127.0.0.1       sub2.domain.dev

Then I updated my virtual hosts file httpd-vhosts.conf to include the following:
<VirtualHost domain.dev:80>
    ServerAdmin admin@domaindev
    DocumentRoot "C:/path/to/wordpress"
    ServerName domain.dev
    ServerAlias www.domain.dev

    <Directory "C:/path/to/wordpress">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

</VirtualHost>

<VirtualHost sub1.domain.dev:80>
    ServerAdmin firstname.lastname@example.com
    DocumentRoot "C:/path/to/wordpress"
    ServerName sub1.domain.dev

    <Directory "C:/path/to/wordpress">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

</VirtualHost>

<VirtualHost sub2.domain.dev:80>
    ServerAdmin firstname.lastname@example.com
    DocumentRoot "C:/path/to/wordpress"
    ServerName sub2.domain.dev

    <Directory "C:/path/to/wordpress">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

</VirtualHost>

Then I, I installed WordPress as usual, single installation.
Then I enabled multi-site with sub-domain as described here and everything worked perfectly.
Answer: I got xip.io/nip.io working with WordPress multisite on Laragon (basically equivalent to MAMP, but for Windows).
My basic steps were:

Create a normal new WordPress site. Let's say your new site's name is "mysite.test"
Install WP CLI
From the command line (terminal) run wp search-replace "mysite.test" "mysite.127.0.0.1.nip.io" --all-tables (or you could set it to xip.io, I haven't seen any difference).
In the Apache configuration file for your site, change the ServerName to be mysite.127.0.0.1.nip.io and ServerAlias to be *.mysite.127.0.0.1.nip.io) instead of mysite.test.
Restart Apache.
Visit mysite.127.0.0.1.nip.io. It should be your site.
Enable WordPress multisite, choosing the "sub-domain" option.

It's a bit barbaric having to enter such a long URL, but at least I don't have to worry about adding a new DNS entry anymore.
Answer: I have had similar issues and contacted Appsolute about it (I have  been a user of MAMP PRO for years). The answer I received 'It doesn't work with Wordpress'. But they mentioned that this is an issue they aware of and their own MAMP Viewer for iOS (android?) should work. Which it doesn't. Since reporting this back and answering questions I have not heard from them. I simply switched to Local by Flywheel for Wordpress development. However, I would think that the  above answers should help.  I have also used a plugin to make all paths relative (Relative Paths). Still doesn't resolve the MAMP xip.io / Mamp Viewer issue, but makes moving/testing a site a little easier. And Wordpress serialized some field where the url is used so any URL change should also accommodate the correct number of letter in the string. Hope this helps


My new iMac connects to my router, but not to the internet. How to fix?

Question: I have a 3 week old 2012 27-inch iMac and this morning I turned it on and it wouldn't connect to the internet. It connected to my home network just fine, just not the internet. I assumed it was my router's fault, but every other device in the house connected to the internet just fine. I have already tried turning it off and on again, many times, as with my router. I have also tried turning the Wi-Fi off and on in System Preferences. Any help?
Comment: Is your router set up with the default settings, or have you made modifications such as enabling port-forwarding, static IP's, etc.
Comment: What's the iMac's IP address? Does it start with 169? To check, go to Apple Icon in top left corner > System Preferences > Network > Make sure Wifi is elected on the left pane > It should say "Connected" and the IP below that.
Comment: Could you open a Terminal, type within `Terminal` the command: `ifconfig en1` and insert the oupput within your original question. This will help network engineers to help you.
Answer: You are connecting your Mac to the router via WiFi.
The first thing to check is that your Mac is asking for an IP address and your router is giving it one.
Open System Preferences > Network and select "Wi-Fi" in the left hand pane. On the right is should say "Wi-Fi is connected to [router name] and has the IP address [IP address]"
If it does you have a deeper problem, if it doesn't say that but instead says it has a self-assigned address that start with 169 then you have a DHCP problem.
Click on the "Advanced…" button at bottom right and in the Advanced pane click on "TCP/IP". Make sure that "Configure IPv4" is set to "Using DHCP" and then click on "Renew DHCP Lease" and see if you now get a good address.
if you are getting a good address from your router then try something simple, run "ping -c 5 google.com" on the command line and you should see ping send and receive 5 packets.
If neither of those work then please run ifconfig at the command line and you will see a number of blocks starting with an interface name of "en" followed by a number. Your wireless is probably "en1" or "en0". Paste this output into your question and we will have a look at it.
Answer: By "turn it on/ off," do you mean you rebooted the computer? Apple sign in the top left corner > Restart. Sorry if this seems obvious. Just have to start simplest first.
If you have tried rebooting, try the following:
1. Unplug your modem and router
2. Wait a full minute
3. Plug in your modem
4. Wait a full minute
5. Plug in your router
6. Wait a full minute
7. Check internet connections now
Comment: Elliot wrote:
    …Wi-Fi off and on in **System Preferences**.
And this is sufficient to fire a DHCP renewal, without going through the waste of time of a reboot. A reboot is the rule of thumb rule to fix anything when you are running an OS of really poor quality.


Is Rylai's slow affected if I use Tiamat as well?

Question: If I'm using a single target spell (e.g. Annie's Disintegrate) with both Rylai's scepter and Tiamat equipped, does it cause the full 35% slow for ST abilities or 15% counting it as AoE?
Answer: Tiamat only modifies basic attacks, not champion abilities. To this end, having Tiamat would do nothing to Annie's Disintegrate, which would still apply the full 35% Rylai's slow. Additionally, the splash from Tiamat is considered part of the basic attack, and does not apply a slow from Rylai's Crystal Scepter at all.
Comment: Thanks - I didn't know Tiamat doesn't work for skills :(
Answer: As answered above, Tiamat only applies on Autoattacks, but if you buy a Frozen Mallet and a Tiamat and Autoattack someone, you get the full slow, cause the Tiamat splash dmg and the Frozen Mallett slow apply simultaneously.
Comment: Are you completely sure? As far as i know, it only applies the actual damage, and not the on hit effects (AOE Madred's Bloodrazor much)?
Comment: As I said, Frozen Mallett applys the full slow on the Target you hit. That has nothing to do with the Tiamat Dmg.
Comment: Ok. I misunderstood you then. (Tho explaining that on-hit effects dont interract with each other directly was kind of odd)


C windows _popen on command that request input: avoid freeze

Question: I have this problem;
I'm writing a C-coded server that have to execute cmd command. The main() has to create a new thread and this thread has to create a new process that have to start this cmd command and send back the results.
This works fine if the command sends back only output (i.e. dir, netstat, ls etc). But when I try to use a command that has ro wait for an input as "date" (that wait for a new date) the new process freeze. This is not possible to solve because I can use WaitForSingleObject on the new process' handle and use a timeout so if the process doesn't finish for a while, I can terminate it using TerminateProcess().
But using process cmd.exe will continue running because it was started by the process of my server and never closed.
I don't care about command that requires input, I just want to ignore them so that if the _popen wait for something I simply close the cmd and return.
Is there are some way to avoid this situation where _popen freeze on a command that require inputs?
Here the code of the process that runs _popen
<code>char readBuff[8096];
DWORD readed;
ReadFile(pipe,readBuff,8096,&readed,NULL);
FILE * out=_popen(commandToExec,"r"); //assume commandToExec contains "date"
char buffer[128];
char output[8096];
output[0]='\0';
while(fgets(buffer, 128, out)){
    snprintf(output,8096,"%s%s\n",outputComando,buffer);
}
DWORD writed;
WriteFile(pipe,outputComando,8096,&scritti,NULL); //it writes the output to a pipe
</code>
This works fine on an output-only command but it never reaches the "while" on a command that requires an input (I debugged it)
Answer: According to the msdn page on popen, you need extra work to redirect both stdin and stout
http://msdn.microsoft.com/en-us/library/ms682499.aspx


Attack in bitcoin network

Question: I am new to blockchain and quite curious about some attack in bitcoin network. So, assume there is already an existing block which has content A and address B. Let's say if an attacker changes the block's content to A' and changes the address to B'. Just curious what should the attacker do to get the reward form the current? Does he need to manually create a hash collision? Or he may need to steal the pub key and signature?
Answer: From Bitcoin's actual rules, you would have to do several things:

Solve the nonce for that block (simple mining problem) with a fake timestamp.
Intelligently calculate the rest of the nonces until you have enough chainwork to overtake the current canonical chain, without the timestamping going into the future (a byproduct of attempts to artificially lower the 2048 block difficulty calculation)
Successfully partition enough of the network to cause a reorg that causes the consensus to latch onto your fork. This requires several eclipse attacks.

Each one of these steps' difficulty increases astronomically, but is still technically possible.

Attack in bitcoin network


Agreed upon domain of inverse trig functions

Question: Why do we choose $[-\pi/2,\pi/2]$ as the domain restriction for $\sin(x)$ when determining $\arcsin(x)$, clearly other restrictions are possible, which also yield a 1-1 function (like $[\pi/2,3\pi/2]$). No pre-calculus book I have seen goes beyond saying that this choice is completely arbitrary. However, I have noticed that every domain restriction for inverse trig functions contains the whole first quadrant in its entirety (with the exception of x values where there are vertical asymptopes). I think these domain restrictions we choose are the only possible choices to get a 1-1 function on a domain that includes "effectively" the whole first quadrant. Is this the reason why we choose these domain restrictions? Are there other reasons why these domain restrictions are more natural than others that would yield a 1-1 function?
Comment: Well, the interval is symmetric. Also $[3\pi / 2, 5\pi / 2]$ yields the same arguments as $[-\pi/2, \pi/2]$.
Comment: I'm not sure what you mean Alex; is an interval being symmetric a standard term? I've never heard this word used in this way. You could also make similar types of statements when adding $2\pi$ to the endpoints of any interval.
Comment: The domain should include the "normal" angles between $0$ and $90^\circ$, and be *connected*. Doesn't leave much choice for $\arcsin$!
Comment: "Symmetric", when applied to an interval in $\mathbb{R}$, or more generally a region in $\mathbb{R}^n$, means that for every point $x$ in the region, the point $-x$ is also in the region.
Comment: Oh I see, I thought Alex's second sentence was some how related to his definition of symmetry now I see that these were two separate statements. Thanks for the clarification.
Answer: It's nice to have a domain that includes $0$. The domain of a trig function is the range of the corresponding inverse function, and it's nice to have $0$ in the range.
Think of applications. If I'm building something, and I want to set two pieces at some angle, I want an angle between $0$ and $\pi$, because that's what I can measure with my tools. That's one reason that it's nice to use intervals either centered on $0$, or with $0$ as an endpoint.
Also, in calculus, we like to represent functions as power series, and these things are a lot easier to write down if we can center them at $x=0$. Of course, this isn't an explanation that would have much place in one of those Precalculus books that you mention, but it would seem strange to define the ranges of inverse trig functions to be one thing in Precal and something else in Calculus.
There may be other reasons, but I think these two are compelling.
Comment: This is a great point, but for say cos(x) $[-\pi,0]$ would also satisfy your condition that 0 should be included, although it would be an odd choice to have a completely non positive interval. I just pulled out my old calculus text book and there is also no explanation in there for the domain restriction (besides the standard 1-1 statements). I would up-vote this post, but unfortunately I am a newbie who doesn't have enough rep to do that.
Comment: Yeah, values of $\cos^{-1}$ are angles, and insofar as angles are physical quantities, it's natural for them to be non-negative. I don't know why they don't explain this in more textbooks.
Comment: I have the same doubt about the domains of inverse trigonometric functions. Unfortunatelly I would like a more objective answer but it seems that it is a conveniente convention.


Use of propensity score in a case-control study

Question: The theory of propensity score (PS) suggests that it should only be used for the cohort study because PS matches the "treated/exposed" to the "un-treated/un-exposed" groups. However, cases and controls are the outcomes (not the exposures) in a case-control study. What are the pitfalls if PS is used in a case-control study?
Answer: A propensity score isn't just a way of matching groups. There are other ways to use propensity scores - at its heart, its a way to characterize the probability of being exposed given covariates. When this is adjusted for in any one of a number of ways (including matching) you theoretically break one of the conditions necessary for confounding.
The problem with a case-control study is its very hard to calculate a true probability of exposure for the same reason its hard to calculate a true probability of disease: you don't have a whole cohort to work off of, just an unbalanced sample. That being said, there are some articles discussing the use of propensity-score methods in case-control studies. This one might be a good place to start. The main thrust is that they're much less straightforward to use, so unless you have a credible reason to adjust using propensity scores instead of outcome-oriented approaches like including covariates in a model, it might not be worthwhile.
04/03 edit for your comment:
It's not a matter of matching to the exposure or the outcome. In all matching, you're matching on covariates. The propensity score is just a way to roll all your covariates into one composite covariate - the propensity score itself. What you're doing by matching is trying to find cases and controls who had ~equal probability of being exposed for all covariates save for your exposure of interest. Observe that in the SUGI paper you linked, the actual code to generate the propensity score used in the matching is the following:
<code>PROC LOGISTIC DATA= study.contra descend;
MODEL revasc = ptage sex white mlrphecg rwmisxhr mhsmoke ... / SELECTION = STEPWISE...;
OUTPUT OUT = study.ALLPropen prob=prob;
RUN;
</code>
That code is modeling your predicted probability of having the exposure (revasc). See Page 2 of that paper.
Comment: @ EpiGrad: Stratification score (a retrospective balancing score) is the probability of disease (outcome or "case-control status") as described in a recent paper [1]. Is stratification score better than propensity score in a case-control study? [1]: http://www.ncbi.nlm.nih.gov/pubmed/21402731
Comment: Thank you for pointing me to the paper which also mathches exposures. However, some papers use propensity scores to match the outcomes (i.e. the case and the control group) [1] [2]. Is this use correct? [1]: http://www2.sas.com/proceedings/sugi29/165-29.pdf [2]: http://www.ncbi.nlm.nih.gov/pubmed/20861628
Comment: @Jinn-YuhGuh See my edit.
Comment: @Jinn-YuhGuh And here we reach the limits of my knowledge. I'm a cohort guy myself ;) But I suspect for anything but the most esoteric purposes, propensity matching, traditional matching or a stratification score will yield similar results.
Answer: You can implement a PS in a case-cohort design, but not in a traditional case-control design; due in part to the reverse logic (relative to the cohort design) of the case-control design.


Does Windows 2008 R2 windows backup requires changes in registry to allow backup of Hyper-V?

Question: There's a lot of information on web that to enable Hyper-V backup in Windows Backup Tool you need to do changes in registry before it will allow you to. But are those settings applicable only to Windows 2008 with Hyper-V or does Windows 2008 R2 too requires the changes? Also does Windows Backup support snapshots and everything else related to Hyper-V backup?
Answer: Yes, if you want to use VSS-aware applications, and no it does not support snapshots!


How to highlight a cell if there is a specific word inside?

Question: I'm looking for something that can highlight all cells/strings that contains a specific string. I'm using Calc on LibreOffice.
Comment: You can use [filters](https://help.libreoffice.org/Calc/Filter:_Applying_Advanced_Filters) to filter the cells with a specific string (you can use a simple find or even regex) and then highlight it.
Comment: I managed to get it to work on a little part, but I have many rows, that's not quite easy..
Answer: You can use conditional formatting with a simple equal to criteria.
The trick is to use quotation marks around the search string.
Step-by-step:

Select a range of cells,
In the menu, select the Format > Conditional Formatting > Condition entry,
Enter the string you want to match surrounded with quotation marks,
Select the style to use for highlighting, of create a new one for that purpose,
Click OK.
Comment: It seems that it has to be double quotes, as shown in this answer. For some reason I encountered behavior in OpenOffice where the software was putting in single quotes, which fails.
Comment: I would like asked if in conditional statement can be the cell format. For example: If the background color of this cell is red, type "red" in this cell. Thx for info.
Answer: My solution would be to use conditional formatting, but it's based on the assumption that the formatting you have at the moment can be affected.
I created a small spreadsheet with the following values in column A, starting from row 1 (i.e. there's no heading for the values):
fred
george
barney
george fred
fred barney
barney george
fred barney george
In my example I want to highlight all the cells that contain the string "fred". To do this, select only one cell (e.g. A1 containing "fred" in my example) and then choose Format...Conditional Formatting... from the menu.
In an empty row change the values to "Formula is IF(SEARCH("fred",A1)>0,1,0)". This will look for the string "fred" in cell A1, and if it's found then applies the conditional format (btw, SEARCH isn't case sensitive). Next, change the formatting to whatever highlighting you want to use.
To future-proof your formatting I'd recommend using a cell reference instead of the literal string "fred". For example, store "fred" in cell Z1 or as a named cell somewhere else, and for the search function use "SEARCH(Z1,A1)". That way if you need to find a different string you can simply update cell Z1, rather than updating all of the conditional formatting again.
Once you've applied the conditional formatting to one cell, use the Format Painter to apply it to the others.
Hope this helps,
Bob.


Main cause of self-charging of unshorted capacitors?

Question: In the lab, we keep all of the high voltage capacitors shorted when not in use, and rightfully so. They tend to spontaneously charge when left for some time and become extremely dangerous. while the self charge rate is not really of any practical use that i know of, I'm not sure what the main mechanism of this charging is.  I have a strong background in EM, the cause is just not evident to me.  A good qualitative explanation would be just fine.
Comment: As a practical matter: always either short HV capacitors, when not in use (even/especially in a circuit!) or solder/screw a high voltage, high impedance discharge resistor to them so that it can't be easily removed.
Comment: Any chance the magnetic field of the Earth moving through the conductive plates generate a charge, although small, over time?
Answer: The phenomenon you are talking about is called dielectric absorption. The way it works is this:
Let's say you've just discharged a capacitor. An ideal capacitor would remain at zero volts after this. However, in real life, the capacitor will develop a small voltage from time-delayed dipole discharging (also known as dielectric relaxation). Dielectric relaxation is a momentary lag in the dielectric constant of a material. The dielectric constant is the same as the relative permittivity of a material, which is the factor by which the electric field between two points in a material is decreased relative to the permittivity of a vacuum.
A simpler explanation is that since no capacitor is perfect, some of the electrons store energy chemically, and don't move all the way through the dialectric in the capacitor.
This voltage that is developed is can be less than 1-2% of the original voltage, but it can be as much as 15% of the original voltage. This is why you have to keep the capacitors shorted when not in use.
I hope this helps! Here are two websites that might also help:

https://en.wikipedia.org/wiki/Dielectric_absorption
http://slot-tech.com/interesting_stuff/sencore/LC103/TT105%20-%203759.pdf
Comment: just a further observation: If I make a brand new capacitor, (say a glass bottle with tinfoil wrapped on the inside and outside), my understanding is that self charging can still be an issue, yet this shouldn't be from the dielectric absorption mechanism described above as it's never been polarized.
Answer: Capacitors that have been discharged and shorted for a very long time, will still self charge once the short is removed. The energy is coming from an external source, I do believe this is related to the casimir effect, Low voltage capacitors do not exhibit the same effect as high voltage capacitors, probably due to a more leaky di electric being used. There is an idea that Zero point energy is being extracted, due to virtual particles coming into existence on either side of the plates, exerting a force thus creating a charge. Read into the casimir effect for a true answer to this phenomenon , It truly could be the answer to extracting unlimited energy.


Why is work defined as force dot displacement?

Question: Why is work defined as force dot displacement? I know that it is defined like that based on the observational fact - we do more work when we apply greater force or move to a greater distance. But I wanted to know if there was a more physical reason to back this fundamental relation.
Answer: $dW = F \cdot ds$
Where $dW$ is an infinitesimal amount of Work, and $ds$ is an infinitesimal displacement. With this,
$dW = m\left(\frac{dv}{dt}\right) \cdot ds $
since $F = ma = m\left(\frac{dv}{dt}\right)$. Therefore,
$dW = m\left(\frac{ds}{dt}\right)dv = m \cdot vdv$
Now from the chain rule it follows that
$vdv = \frac12 d(v^2)$
where $d(v^2)$ means a small change in $v^2$. Therefore
$dW = m\left(\frac{ds}{dt}\right)dv = m \cdot \frac12 d(v^2)$
Integrating over $W$ for constant acceleration yields
$W = \frac12 m(v^2 - u^2)$
where $v$ is the final velocity and $u$ is the initial velocity. Therefore,
$W = \frac12 mv^2 - \frac12 mu^2 = $ final KE - initial KE.
So work being defined as Force $\cdot$ Displacement makes work equivalent to the change in kinetic energy.
Comment: Actually KE came first.  The origin of KE = 0.5mv^2 came from experiments where different weights were dropped into clay.  It was found that penetration depth was proportional the square of the impact velocity, and mass.
Comment: +1 Nice, but not yet a complete answer. For example, pushing a large mass over a rough surface will require a lot of work, but will not necessarily change the kinetic energy of the mass.
Comment: But  kinetic energy itself is defined on the concept of work. It is like proving something with a thing, which itself has been proved by the former thing.
Comment: What about the 1/2?
Comment: @AndresSalas
1/2 came from the fact that in the 18's when the concept of work was introduced , the only mathemetically described  (in relative sense) was gravity and from the tempetation of d = at^2/2 , mv^2 was made mv^2/2
Answer: Actually work as you mentioned has meaning only in classical mechanics, in this physics there are classical (vector) forces and meaning for displacement, but in modern Quantum Physics there are no more such things, or at least their meaning is totally different, there are no more force as this simple vectors or meaning to say that our particle has been displaced 5 meters.
So what I want to say, is that actually energy is much more fundamental that "work" , while other answers explained the relation between work and energy in classical sense, they didn't mention why energy is more fundamental, and that because energy is a concept that deeply related with the structure of our space & time, more precisely because our space & time are homogeneous and isotropic (this means that rotating or displacing a box and applying on it the same experiment will not change the results, rather you will do experiment now or after 100 years), this nature according to "First Noeather theorem" makes energy & momentum conserved.


Are there any special words or phrases for people that were emigrating in history?

Question: Are there any special words or phrases for people that were emigrating in history (18th, 19th, 20th centuries)? Or maybe the words which were used in that time and how were people calling the emigrants? Anything related to that would be very helpful.
Comment: Have a look at _diaspora_. http://en.wikipedia.org/wiki/Diaspora
Comment: Exiles, expatriates, refugees, itinerants, migrants.  And various exonyms: Gypsies, nomads, etc.
Comment: Settlers comes to mind
Answer: The earliest reference in the OED (Oxford English Dictionary) to the verb emigrate is from 1782.

1782   T. Pownall Treat. Study Antiq. 60 (T.)   The surplus parts of
  this plethorick [printed phletorick] body must emigrate.

The OED's Historical Thesaurus, which is a wonderful new tool for historians of the language, published in 2009, suggests the following synonyms, with dates:

remove 1388; flit 1504; shift 1530; to pull up stakes (US) 1703; move
  1707; emigrate 1841; uproot 1961; pick up stakes (US) 1974.
Answer:
The settlers had come to America to look for land

Etymonline says that the term settler, meaning a person who moves to a different land or country is dated from the 1690s, which makes it older than the verb emigrate

settler (n.)
  1590s, "a thing that settles" (a debate, etc.); agent noun from settle (v.). Meaning "a person who moves into a new country" is from 1690s.


Utilizing a current web site's assets in a new mobile version

Question: I recently joined a friend of mine in developing his web app. He built it from scratch using the MVC pattern.
Now I'm trying to make a new (and separated in a sub domain) mobile site that's based on CodeIgniter, but I have no idea how to utilize the models my friend made, especially considering they don't follow CodeIgniter's rules, plus they have includes and dependencies on other files in them.
Any suggestions on how I could approach this?
Your help is much appreciated :)
Answer: Since your friend used the MVC pattern to develop the initial site, why not re-use his controller/model to serve up different views.
That way you're not re-writing code, messing with new frameworks, worrying about incompatibilities, etc. You just have to make the new views handle the data and look pretty on a mobile device.
Comment: but the mobile site is going to be in a sub-domain. How would that work?


How to mute one side of an mp3?

Question: I have some mp3s that have earbud-specific audio. I want to edit the mp3s by muting one ear's audio (wind sounds) but I don't know much about sound editing and this is such an unusual or specific goal that I haven't been able to find out how to accomplish this. I havent tried anything yet but I assume I need to somehow separate the audio "sides" (left ear and right ear) then select and delete the one I don't want. How do I do this?
Answer: I would use Audacity. It is a free sound editing app, relatively straightforward and easy to use, and has the capability of opening and saving as mp3.
Two recommendations:

Save as ogg/vorbis, not mp3. The quality will be just as good, if not slightly better, and using the format does not require any licensing. MP3 is a proprietary format and if you make any real money with your app, expect Fraunhofer corp or whatever their name is, to come knocking.
Be careful when you download Audacity. There are several sites which include viruses and adware in the downloads. I think you can find the original site by checking wikipedia reference section at the end of the article on Audacity.
Comment: You say it opens and saves mp3s but does it let you separate and delete earbud-specific audio (left side or right side)? If not I won't get any use out of it.
Comment: Looks like you got your answer from Connor before I got back online. Hope you are good to go now. This is a good forum for getting "how to's" on using Audacity.
Answer: I agree with Phil Freihofner. Download audacity, as it will allow you to open the pre-existing mp3 file.
In audacity, you will see two tracks like this when you open your mp3:
From here, you can click the arrow next to the track title, circled in red:

Then select split stereo track. Then you will be able to edit, mute, or even delete each side of the track independently from one another.To get the tracks back to stereo, go to the Tracks dropdown menu at the top, select both tracks using shift click, and select Mix and Render.
Comment: Thank you for confirming the software can do this and thanks for the detailed answer. You guys are awesome.

How to mute one side of an mp3?


Python inspect.stack is slow

Question: I was just profiling my Python program to see why it seemed to be rather slow. I discovered that the majority of its running time was spent in the inspect.stack() method (for outputting debug messages with modules and line numbers), at 0.005 seconds per call. This seems rather high; is inspect.stack really this slow, or could something be wrong with my program?
Answer: inspect.stack() does two things:

collect the stack by asking the interpreter for the stack frame from the caller (sys._getframe(1)) then following all the .f_back references. This is cheap.
per frame, collect the filename, linenumber, and source file context (the source file line plus some extra lines around it if requested). The latter requires reading the source file for each stack frame. This is the expensive step.

To switch off the file context loading, set the context parameter to 0:
inspect.stack(0)

Even with context set to 0, you still incur some filesystem access per frame as the filename is determined and verified to exist for each frame.
Comment: That cut down the time spent in the inspect.stack method by a factor of about 5. From there I think I'll just work to reduce the number of debug messages logged (or combine them). Thanks for the info.
Answer: inspect.stack(0) can be faster than inspect.stack(). Even so, it is fastest to avoid calling it altogether, and perhaps use a pattern such as this instead:
frame = inspect.currentframe()
while frame:
    if has_what_i_want(frame):  # customize
        return what_i_want(frame)  # customize
    frame = frame.f_back

Note that the last frame.f_back is None, and the loop will then end.
sys._getframe(1) should obviously not be used because it is an internal method.
As an alternative, inspect.getouterframes(inspect.currentframe()) can be looped over, but this is expected to be slower than the above approach.
Answer: Here's a concrete example building on the other answers, showing how to efficiently walk back up the stack to find the typical caller information (filename, line number, function name) incorporated into debug messages.
import sys
from collections import namedtuple

FrameInfo = namedtuple('FrameInfo', ['filename', 'lineno', 'function'])

def frame_info(walkback=0):
    # NOTE: sys._getframe() is a tiny bit faster than inspect.currentframe()
    #   Although the function name is prefixed with an underscore, it is
    #   documented and fine to use assuming we are running under CPython:
    #
    #   https://docs.python.org/3/library/sys.html#sys._getframe
    #
    frame = sys._getframe().f_back

    for __ in range(walkback):
        f_back = frame.f_back
        if not f_back:
            break

        frame = f_back

    return FrameInfo(frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name)

Python inspect.stack is slow


What would Resolve first?

Question: If my opponent has one Timberwatch Elf tapped, and I use Yamabushi Flame on it, can my opponent respond with a Wirewood Lodge and then use Timberwatch Elf to protect it?
Answer: Yes. Wirewood Lodge's ability will go on the stack. Once it resolves, Timberwatch Elf will be untapped and the active player will get priority. Yamabushi's Flame won't resolve until all players pass priority, so your opponent has a chance to activate Timberwatch Elf's ability targeting itself.
Of course, there will need to be at least one other elf in play in order for the ability to actually save it from the 3 damage Yamabushi's Flame will deal.
Answer: Yes. The full sequence of events goes:

You cast Yamabushi's Flame
Your opponent activates Wirewood Lodge
Your opponent taps Timberwatch Elf targeting itself
Timberwatch Elf gets pumped
Yamabushi's Flame deals 3 damage to Timberwatch Elf

Now, between literally every step there is an implicit "both players pass priority"; you can both still respond at every juncture. So, for instance, if you want to respond to his Wirewood Lodge activation with another burn spell, you could do so and probably kill it (causing all the other steps to be countered for illegal targets)
Comment: Wouldn't, between numbers 2 and 3, the opponent not pass priority and activate all his abilities in a row? I might be confused on priority though, since I am not well versed in it.
Comment: @MiloGertjejansen Villain has to pass priority to let the Wirewood Lodge effect resolve. Nonmana abilities of lands still use the stack and you still have to let your opponent respond to them. If the Timberwatch Elf were untapped, villain could activate both in a row without passing, but in this case it's tapped so villain needs the lodge to resolve before using its tap ability.
Comment: Ah, but of course. Didn't even think of that. Thanks for the clarification!

What would Resolve first?


2 thermostats week on week off

Question: I work week on and week of so my house requires completely different heating on these weeks.
What I want to do is have 2 thermostats set to the different setting and turn one on and one off depending on if I'm work or at home.
This way it allows me to actually program a 14 day cycle. For the week that I'm working this should save a lot.
That is the plan just wondering if it would work.
Comment: You might check out nest instead.  It can be set up to detect if your phone is home (on the home network) or away (not on the home network). Your schedule would only apply if home, otherwise the eco away temp applies.
Comment: Yeah, the days of complex algorithms are behind us. Go with a smart unit.
Answer: A thermostat is basically a few contact closures that are controlled by a temperature switch and a schedule (on programmable models).  You can split the wires going to your single thermostat and run them in parallel to more than one thermostat.  Your plan will work and with the cost of 7-day programmable thermostats, it's probably the cheapest option.
However, as others have noted, WiFi thermostats are the future, and if you have a C-wire available (search this site for tons of info on C-wires), they can be great.  Nest is not the only "smart" thermostat available, and I for one do not like the way it claims to "learn" my schedule.  I use a cheaper WiFi thermostat that can be programmed just like traditional models to very specific times and temperatures without any guesswork.
Comment: I agree that Nest's "learning" is quirky, but it handles home/away states and odd departures from routine far better than something you have to manually manage. The human is usually the weak link in something as mundane as temperature management.
Answer: Not sure if this is what you are looking for, but there are several programmable thermostats out there which have apps for mobile devices which can be used to control them.
I know for a fact that the NEST thermostat does this, and I'm sure there are others.
Perhaps this could be your solution?

2 thermostats week on week off


How does the nose of a plane self adjust down

Question: I am not a Flat Earther. I understand that the plane's trim, speed and atmospheric pressure determine the plane's altitude. As the plane moves forward the Earth does indeed curve out from under it and the plane does indeed try to fly off into outer space and fails to do so as the air pressure becomes too thin for the trim and speed and so the plane constantly settles back to the correct altitude, the altitude that has enough atmospheric density for the trim and speed to stop the downward settling. Thus we have level flight.
Just one problem, even though the plane stays at one altitude, the nose seems as if it should gain small upward tilts that slowly accumulate into a serious problem. How is the nose, not the plane, following the curvature of the Earth?
Comment: How does the bow of a boat adjust when sailing across the ocean?  Why aren't boats that left San Francisco pointed up in the air when they reach Japan?   Same idea.
Comment: Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange network, you've granted a non-revocable right, under the [CC BY-SA 3.0 license](//creativecommons.org/licenses/by-sa/3.0/), for Stack Exchange to distribute that content (i.e. regardless of your future choices). By Stack Exchange policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: [How does deleting work?](//meta.stackexchange.com/q/5221)
Comment: Rather than look at it as trim, speed and atmospheric pressure, you should consider the _four forces_ acting on the aircraft  https://en.wikipedia.org/wiki/Aerodynamics#Fundamental_concepts
Comment: We know the earth is round, but because of the sheer scale, for all practical purposes you might as well consider it flat.  The curvature really only comes into play on truly straight line applications like radio waves and lasers.  Airplanes and pilots perceive it to be just as flat as any pedestrian or car driver would.
Answer: Good question! First practical detail to note would be that I doubt there is any airplane with such stability (without electronic aids etc) that you could left flying hands-off for long enough period to perceive effects of Earth curvature without other disturbances affecting flight path and attitude much more.
But lets take this as a theoretical problem: absolutely calm air, no disturbances, only curved Earth. The fact is that air density or pressure change is not the reason for curved path around the Earth. It would work even with constant air density (or pressure) all the way up. It is on the contrary the "automatic" pitch adjustment which goes first and as the pitch adjusts, flightpath follows it round around the Earth.
It is important to remember that actual pitch (or angle of attack) is result of balance of acting forces (gravity, lift of the wings and tailplane), it is in no way "conserved" due to inertia or whatever.
All starts with the mechanism how the pitch-wise stability of airplane works. For really nice and detailed explanation see "See How It Flies" by John S. Denker (whole text is only to recommend reading for more technical understanding of flight). The trim mechanism (balance between tail and wing forces) works such that it rotates airframe towards one fixed value of angle of attack and keeps it balanced there.
So what happens ... let's do the differentiation of motion in small steps:

the plane flew perfectly straight a short bit in tangential direction to the surface;
so the direction of the gravity force has changed by an infinitesimal angle and has a component pointing backwards relative to the airplane now;
this new component of gravity force starts slowing down the flight (we have not adjusted any control or engine power);
slower flight means less lift, so the airplane starts to fall down a little;
falling down means that relative airflow will come more from underside increasing the angle of attack perceived by airfoils;
now the trim mechanism comes into the play correcting the angle of attack to its original value.

So this small amount of falling down is corrected to forward flight (with respect to the airplane), but now the trajectory follows Earth curvature. Flying the circle means, that you are all the time falling down as seen relative to the previous direction of motion, so it is exactly what you need.
Comment: … and once the aircraft has stabilized on that west-east course, it has gained a miniscule pitch and yaw speed which will tilt it horizontally and along the right latitude all along the way, without any stability coming into play.
Comment: Thank you for answering this! It is frustrating that others didn't understand the question and I'm glad that you did. You answered it well, so I now understand. Thank you again.
Answer: I'll try a very short answer:
While the physics are not exactly the same, it's similar to why the noses of ships or cars don't point up after travelling a while - the equilibrium state (trimmed level flight for an aircraft, trimmed level float for a ship and supported by all wheels for a car) follows the surface of the earth so as to be locally horizontal at each point.
Comment: Yeah I was using a ball and computer mouse trying to visualize this and was probably creating a situation where my mouse-plane was gaining 3,000 miles at a time, greatly exaggerating the tilt problem. A car going over a hill too fast will do what I was envisioning,: launching into the air as the hill (earth) curves away under neath and there is a ton of video showing cars going nose up or even flipping backwards and crashing. Of course the angle of curvature of a hill proportionate to a car and its speed is greatly exaggerated as well.